I'm relatively new C++/DX11- although I've been researching a lot on the subject to get myself up to speed. Anyway, my issue is that with the default DX11 XAML UWP Template (I'm using VS 2017)- I'm having trouble applying a texture onto the mesh. I've done some digging and found really useful resources on the official MS documentation, however I'm not terribly sure how to implement my texture loading code in my Sample3DSceneRenderer.cpp.
// After the vertex shader file is loaded, create the shader and input layout.
auto createVSTask = loadVSTask.then([this](const std::vector<byte>& fileData) {
DX::ThrowIfFailed(
m_deviceResources->GetD3DDevice()->CreateVertexShader(
&fileData[0],
fileData.size(),
nullptr,
&m_vertexShader
)
);
static const D3D11_INPUT_ELEMENT_DESC vertexDesc [] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_AYUV, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
DX::ThrowIfFailed(
m_deviceResources->GetD3DDevice()->CreateInputLayout(
vertexDesc,
ARRAYSIZE(vertexDesc),
&fileData[0],
fileData.size(),
&m_inputLayout
)
);
});
I figured out by choosing certain values from the specific enum list (The value here is set to "DXGI_FORMAT_AYUV") I can change the colours of the cube, but I am aware usually the process of UV mapping is needed for this kind of thing, but I'm not sure if I have to define the process, or if it's already taken care of in the shader code. (Apologies for any mis-information, I'm still learning DX11)
Here is the documentation that I'm getting the logic from: https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-textures-how-to
I'm specifically trying to Create WIC Texture From File.
Hopefully anyone familiar with the default DX11 UWP template can see where I'm coming from, all contributions welcome! Thanks.