Quote:Original post by Evil Steve
Quote:Original post by wswqwps
In the SetFVF() function it used a [D3DFVF_TEX2] flag, but I do not know what I should use to identify the D3DDECLUSAGE_TEXCOORD : [0] or [1]???
It should be 0. That number means that it's the first set of texture coordinates. If you had two sets of texture corodinates, you'd put that line in twice, and change the last parameter.
Actually, he
has 2 sets. D3DFVF_TEX2 means he has two sets of texture coordinates. Their sizes would be specified with D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1), for instance. But since he left those out, it default to two floats per set.
Also, he uses transformed vertices (D3DFVF_XYZRHW), so IMO, including the D3DFVF_DIFFUSE, the vertex declaration should be:
const D3DVERTEXELEMENT9 FVF_POS_T_TEX1[] = { { 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0}, { 0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, { 0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, { 0, 28, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, D3DDECL_END()};
And then of course use TEXCOORD0 and TEXCOORD1 in the shader.
(Also, I prefer using offsetof() instead of hard-coding the byte offsets in the vertex)