代码拉取完成,页面将自动刷新
#include "dut/TextureCube.h"
#include "dut/Image.h"
HRESULT Dut::TextureCube::Create(ID3D11Device* device, const std::string& path)
{
HRESULT hr;
const char* faces[6] = {
"right.jpg",
"left.jpg",
"top.jpg",
"bottom.jpg",
"front.jpg",
"back.jpg"
};
Dut::Image images[6];
m_TexDesc.Width = images[0].m_Width;
m_TexDesc.Height = images[0].m_Height;
m_TexDesc.MipLevels = 1;
m_TexDesc.ArraySize = 6;
m_TexDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_TexDesc.Usage = D3D11_USAGE_DEFAULT;
m_TexDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
m_TexDesc.CPUAccessFlags = 0;
m_TexDesc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
m_TexDesc.SampleDesc.Count = 1;
m_TexDesc.SampleDesc.Quality = 0;
D3D11_SUBRESOURCE_DATA pData[6];
for (int i = 0; i < ARRAYSIZE(faces); i++)
{
images[i].Load(path + "/" + faces[i]);
m_TexDesc.Width = images[0].m_Width;
m_TexDesc.Height = images[0].m_Height;
pData[i].pSysMem = images[i].m_Data;
pData[i].SysMemPitch = static_cast<UINT>(m_TexDesc.Width * 4);
pData[i].SysMemSlicePitch = static_cast<UINT>(m_TexDesc.Width * m_TexDesc.Height * 4);
}
HR(device->CreateTexture2D(&m_TexDesc, pData, m_Texture.ReleaseAndGetAddressOf()));
m_SrvDesc.Format = m_TexDesc.Format;
m_SrvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
m_SrvDesc.TextureCube.MipLevels = m_TexDesc.MipLevels;
m_SrvDesc.TextureCube.MostDetailedMip = 0;
HR(device->CreateShaderResourceView(m_Texture.Get(), &m_SrvDesc, m_ShaderResourceView.ReleaseAndGetAddressOf()));
return S_OK;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。