Hi,
I'm adding streaming instancing support to my graphics engine and I have a couple of problems. I'm basing my code on the DirectX Hardware instancing demo from the SDK. The first problem is my vertex buffer, my buffer has vertex position, normals, colour, specular and texture coorinates.
struct MYVERTEX
{
float x, y, z;
float nx,ny,nz;
DWORD Col;
DWORD Spec;
float tu, tv;
} ;
the example from the sdk has Position, normal and texture coordinates.
I'm trying to create the vertex declaration for my vertex buffer..
D3DVERTEXELEMENT9 g_VertexElemHardware[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },// Size 12
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },// Size 12
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },// Size 4
{ 0, 28, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1 },// Size 4
{ 0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },// Size 12
{ 1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },// Size 4
{ 1, 4, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1 },// Size 4
D3DDECL_END()
};
hr = m_pD3DDevice->CreateVertexDeclaration( g_VertexElemHardware, &g_pVertexDeclHardware );
if (hr == S_OK)
Instancing = true;
else
Instancing = false;
my first problem is that CreateVertexDeclaration fails and I don't know why, the second problem is with the .fx file.
void VS_HWInstancing( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float4 difCol : COLOR0,
float4 SpecCol : COLOR0,
float2 vTex0 : TEXCOORD0,
float4 vColor : COLOR0,
float4 vBoxInstance : COLOR1,
out float4 oPos : POSITION,
out float4 oColor : COLOR0,
out float2 oTex0 : TEXCOORD0 )
this also fails to compile? what am I doing wrong?
[Edited by - darrenmarklines on October 11, 2007 7:03:13 AM]