The vertex decl is:
D3DVERTEXELEMENT9 decl[MAX_VERTEXDECL];
size_t uDeclCount = 1;
// Position declaration
decl[0].Stream = 0;
decl[0].Offset = 0;
decl[0].Type = D3DDECLTYPE_FLOAT3;
decl[0].Method = D3DDECLMETHOD_DEFAULT;
decl[0].Usage = D3DDECLUSAGE_POSITION;
decl[0].UsageIndex = 0;
// Normal declaration
if ((FVF & D3DFVF_NORMAL) != 0) {
decl[uDeclCount].Stream = 0;
decl[uDeclCount].Offset = sizeof(float) * 3;
decl[uDeclCount].Type = D3DDECLTYPE_FLOAT3;
decl[uDeclCount].Method = D3DDECLMETHOD_DEFAULT;
decl[uDeclCount].Usage = D3DDECLUSAGE_NORMAL;
decl[uDeclCount].UsageIndex = 0;
uDeclCount++;
}
// Texture declaration
if ((FVF & D3DFVF_TEX1) != 0) {
decl[uDeclCount].Stream = 0;
decl[uDeclCount].Offset = sizeof(float) * 3 * uDeclCount;
decl[uDeclCount].Type = D3DDECLTYPE_FLOAT2;
decl[uDeclCount].Method = D3DDECLMETHOD_DEFAULT;
decl[uDeclCount].Usage = D3DDECLUSAGE_TEXCOORD;
decl[uDeclCount].UsageIndex = 0;
uDeclCount++;
}
// End of declarations
decl[uDeclCount].Stream = 0xFF;
decl[uDeclCount].Offset = 0;
decl[uDeclCount].Type = D3DDECLTYPE_UNUSED;
decl[uDeclCount].Method = 0;
decl[uDeclCount].Usage = 0;
decl[uDeclCount].UsageIndex = 0;
The values for the vertex buffer are procedurally generated, so posting those exactly would just be noisy. But, you can imagine a cuboid:
v4 v5
+---+
/| /|
/ | / |
/ |/ |
/ / |
/ /| |
v2 +---+v3 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | +---+v7
| |/v6 /
| | /
| /| /
| / | /
|/ |/
+---+
v0 v1
With indices:
4, 2, 0
0, 6, 4
1, 3, 7
5, 7, 3
1, 2, 0
1, 3, 2
5, 6, 4
5, 7, 6
3, 2, 4
3, 4, 5
The shaders are extremely simple:
struct VS_INPUT {
float4 position : POSITION;
float3 normal : NORMAL;
float2 Texture : TEXCOORD0;
};
struct VS_OUTPUT {
float4 position : POSITION;
float2 Texture : TEXCOORD0;
float3 normal : TEXCOORD1;
float4 color : COLOR;
};
float4x4 matWVP;
float4x4 matWorld;
bool bIsSelected;
VS_OUTPUT vs_main(in VS_INPUT input)
{
VS_OUTPUT output;
output.position = mul(float4(input.position.xyz, 1.0f), matWVP);
output.Texture = input.Texture;
output.normal = normalize(mul(input.normal, matWorld));
output.color = float4(1.0f, 1.0f, 1.0f, 1.0f);
return output;
}
struct PS_INPUT {
float4 position : VPOS;
float2 Texture : TEXCOORD0;
float3 normal : TEXCOORD1;
float4 color : COLOR0;
};
struct PS_OUTPUT {
float4 color : COLOR0;
};
sampler2D Tex0;
PS_OUTPUT ps_main(in PS_INPUT input)
{
PS_OUTPUT output;
output.color = tex2D(Tex0, input.Texture);
return output;
}