Hello all
I try to create a simple square using mesh. The square has 2 triangles and 4 vertex points. Bellow is my function that must create this mesh. However after executing it I don't receive what I expected. Can someone tell where is my mistake:
[source]
void CD3DSimulationView::CreateMeshes()
{
unsigned short nNumFaces = 2;
unsigned short nNumVertices = 4;
//setup mesh
if(SUCCESS(D3DXCreateMeshFVF(nNumFaces, nNumVertices, D3DXMESH_VB_MANAGED, D3DFVF_XYZ,
m_pd3dDevice, &m_pMesh))
{
//allocate vertex buffer
CUSTOMVERTEX* pVertices;
m_pMesh->LockVertexBuffer(D3DLOCK_DISCARD, (void**)&pVertices);
//initialize vertex buffer // X Y Z
pVertices[0].m_pVertices = D3DXVECTOR3( 2, -2, 0);
pVertices[1].m_pVertices = D3DXVECTOR3(-2, -2, 0);
pVertices[2].m_pVertices = D3DXVECTOR3(-2, 2, 0);
pVertices[3].m_pVertices = D3DXVECTOR3( 2, 2, 0);
m_pMesh->UnlockVertexBuffer();
//allocate and initialize index buffer
UINT16 *pIB = NULL;
m_pMesh->LockIndexBuffer(0, (void**)&pIB);
pIB[0] = 0;
pIB[1] = 1;
pIB[2] = 2;
pIB[3] = 0;
pIB[4] = 3;
pIB[5] = 2;
m_pMesh->UnlockIndexBuffer();
}
}
[source]
best regards
Kamen
initialize index buffer of mesh
Started by f1engineer, Aug 21 2007 10:40 AM
3 replies to this topic
#1
Posted 21 August 2007 - 10:40 AM
#2
Posted 21 August 2007 - 12:55 PM
Concreteness my question is:
Do I initialize index buffer correctly? I think my mistake is of initializing the index buffer.
regards
Kamen
Do I initialize index buffer correctly? I think my mistake is of initializing the index buffer.
regards
Kamen
#3
Posted 21 August 2007 - 04:22 PM
f1engineer said:
Do I initialize index buffer correctly?
#4
Posted 22 August 2007 - 06:30 AM
Thank You
I shall try immediately.
I shall try immediately.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












