Hello,
I am trying to texture a simple quad. My 'engine' can currently create a quad and I would like to expand it to be able to load textures.
My current attempt is as follows:
Vertex vtx[] =
{
Vertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Vertex(1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f),
Vertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Vertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
};
createVertexBuffer(ARRAYSIZE(vtx), vtx, &vertexBuffer);
createShaders();
D3DX11CreateShaderResourceViewFromFile(d3d11Device, "textures\\t1.bmp", NULL, NULL, &texture, NULL);
d3d11DevCon->PSSetShaderResources(0, 1, &texture);
d3d11DevCon->Draw(4, 0);
where texture is of type ID3D11ShaderResourceView
The problem is I am reusing the same.fx file which is as follows:
cbuffer cbPerObject
{
float4x4 WVP;
};
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
};
VS_OUTPUT VS(float4 inPos : POSITION, float4 inColor : COLOR)
{
VS_OUTPUT output;
output.Pos = mul(inPos, WVP);
output.Color = inColor;
return output;
}
float4 PS(VS_OUTPUT input) : SV_TARGET
{
return input.Color;
}
I am stuck understanding how to edit the .fx file to allow for textures. And if I have correctly laid out code that will draw my textured quad.
Thank for your yout time