Sign in to follow this  
kevlur

Usage of D3D Index Buffers

Recommended Posts

kevlur    124
Hi, i want to create a mesh of triangles that extends on the z/x plane( all the vertex have the same y = 0), so i create a vertex buffer:
struct VERTEX
{
  D3DXVECTOR3 pos;
  DWORD       col;
};

LPDIRECT3DVERTEXBUFFER9  *g_pVB = NULL;

d3dDevice->CreateVertexBuffer(....., &g_pVB,......);
I lock the buffer and fill it with my vertices:
VERTEX *Vx;
int i = 0;

g_pVB->Lock(0,0,(void)&Vx,0);

for(int z = 0; z <= 1000; z += 100)
{
   for(int x = 0; x <= 1000; x += 100)
   {
      Vx[i].position.x = x;
      Vx[i].position.z = z;
      Vx[i].position.y = 0;

      i++;
   }
}

g_pVB->Unlock();
Now, how can i create an index buffer to set up the trangle order? and how can i render the the indexed triangles? Thank you very much for reading this and for the help :) Kev

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this