1 Star 0 Fork 0

2144/dut

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TextureCube.cpp 1.65 KB
一键复制 编辑 原始数据 按行查看 历史
2144 提交于 2024-07-09 01:49 . s
#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;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iamherer/dut.git
git@gitee.com:iamherer/dut.git
iamherer
dut
dut
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385