• Advertisement
Sign in to follow this  

Usage of D3D Index Buffers

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.position.x = x;
      Vx.position.z = z;
      Vx.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
Advertisement
Sign in to follow this  

  • Advertisement