Code:
bool CGfxEntityCube::Initialise()
{
gD3dDevice->CreateVertexBuffer(8*sizeof(CUBEVERTEX), D3DUSAGE_WRITEONLY, D3DFVF_CUBEVERTEX, D3DPOOL_MANAGED, &m_vb, NULL);
CUBEVERTEX pVertices[]={{ 0.0, 0.0, 0.0,},
{ 0.0, 1.0, 0.0,},
{ 1.0, 0.0, 0.0,},
{ 1.0, 1.0, 0.0,},
{ 1.0, 0.0, 1.0,},
{ 1.0, 1.0, 1.0,},
{ 0.0, 0.0, 1.0,},
{ 0.0, 1.0, 1.0,}};
VOID *vertices;
m_vb->Lock(0, sizeof(pVertices), (void**)&vertices, 0);
memcpy(vertices, pVertices, sizeof(pVertices));
m_vb->Unlock();
gD3dDevice->CreateIndexBuffer(36*3*2, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ib, NULL);
WORD pIndices[]={0, 1, 2,
2, 1, 3,
2, 3, 4,
4, 3, 5,
4, 5, 6,
6, 5, 7,
6, 7, 0,
0, 7, 1,
1, 7, 3,
3, 7, 5,
0, 2, 6,
2, 4, 6};
VOID *indices;
m_ib->Lock(0, sizeof(pIndices), (void**)&indices, 0);
memcpy(indices, pIndices, sizeof(pIndices));
m_ib->Unlock();
return TRUE;
}
Is that ok? any other ideas where im going wrong?