Sorry guys i am fairly new to d3d, i currently use OpenGL and i am jsut trying to learn a bit of D3D just to see how the other side lives :-)
i am trying to render a small mesh with the size of 64x64 (basically like a brute force terrain minus the y value)
data:
struct Vertex3f
{
float x,y,z;
};
Vertex3f *Vertices;
here is my init function
vertexcount = (m_iSize-1)*(m_iSize-1)*6;
Vertices = new Vertex3f[vertexcount];
//Build our vertex array
for(int z=0,int i=0; z<m_iSize-1; z++ )
{
for( int x=0; x<m_iSize-1; x++ )
{
//Triangle 1
Vertices.x = x;
Vertices.y = 0;
Vertices.z = z;
i++;
Vertices.x = x;
Vertices.y = 0;
Vertices.z = z+1;
i++;
Vertices.x = x+1;
Vertices.y = 0;
Vertices.z = z+1;
i++;
//triangle 2
Vertices.x = x+1;
Vertices.y = 0;
Vertices.z = z+1;
i++;
Vertices.x = x+1;
Vertices.y = 0;
Vertices.z = z;
i++;
Vertices.x = x;
Vertices.y = 0;
Vertices.z = z;
i++;
primitivecount+=2;
}
}
if( FAILED( m_d3D9dev->CreateVertexBuffer( vertexcount*sizeof(Vertex3f),
0, D3DFVF_XYZ,
D3DPOOL_DEFAULT, &g_pVertexBuffer, NULL ) ) )
{
return E_FAIL;
}
VOID* pVertices;
if( FAILED( g_pVertexBuffer->Lock( 0, sizeof(Vertices), (void**)&pVertices, 0 ) ) )
return E_FAIL;
memcpy( pVertices, Vertices, sizeof(Vertices) );
g_pVertexBuffer->Unlock();
Render source:
m_d3D9dev->SetStreamSource( 0, g_pVertexBuffer, 0, sizeof(Vertex3f) );
m_d3D9dev->SetFVF(D3DFVF_XYZ);
m_d3D9dev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, primitivecount );
I am using the april 05 SDK with .net2003 ..i am running it with direct3d debugging and it is not spitting out any error's at all but i can not see the mesh.
If i try to render say a simple triangle i can see that on screen perfectly, i am using my own camera class and it appears to move around correctly too (just judging by the way i can fly around the triangle)
any idea's what i have stuffed up?? i have tried to follow Microsoft's samples as close as i could but obviouslly i am doing something wrong