# ID3DXMesh indexbuffer.

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

## Recommended Posts

Hello, When you create an index buffer without a mesh, you need to specify the size of the buffer. However, since there is no CreateIndexBuffer function in ID3DXMesh, how does the Mesh know how much space to allocate for the indices? I know you specify the number of vertices and faces when you create the mesh, but how does it know whether you are reusing vertices via the index buffer?

##### Share on other sites
I do it like this:

D3DXCreateMeshFVF( m_iNumFaces, m_iNumVertices,                   D3DXMESH_MANAGED | D3DXMESH_WRITEONLY | D3DXMESH_32BIT,                    CUSTOMFVF,                   pD3DDevice,                   &m_pMesh );    DWORD *pIndices = NULL;m_pMesh->LockIndexBuffer( 0, (void**)&pIndices );// Loop*pIndices++ == index;m_pMesh->UnlockIndexBuffer();

I'm using an indexed triangle strip to create a big grid for a height map, but I don't think it renders the last row of triangles all the way.

##### Share on other sites
D3DXMesh uses triangle lists, so the index buffer has 3 entries per face.

When you create the D3DXMesh you tell it how many faces.

• 21
• 13
• 9
• 17
• 13