Am I overwriting the vertex buffer

Started by
0 comments, last by Hodgman 11 years, 8 months ago

#define D3DFVF_MESHVERTEX (D3DFVF_XYZ| D3DFVF_NORMAL| D3DFVF_DIFFUSE)
struct MESHVERTEX
{
D3DXVECTOR3 Pos;
D3DXVECTOR3 Normal;
DWORD rgba;
};
MESHVERTEX* SphereVerts = new MESHVERTEX[iVQuantity];
/*Doing something here*/
BYTE* lpVertices;
m_pDevice->CreateVertexBuffer(iVQuantity * sizeof(MESHVERTEX), D3DUSAGE_WRITEONLY,D3DFVF_MESHVERTEX,D3DPOOL_MANAGED,&m_pVB,0);
m_pVB->Lock( 0, iVQuantity*sizeof(MESHVERTEX), (void**)&lpVertices, 0 );
memcpy( lpVertices, SphereVerts, iVQuantity*sizeof(MESHVERTEX) );
m_pVB->Unlock();


Am I overwriting the buffer? I have an assertion says _BLOCK_TYPE_IS_VAlID(pHead->nBlockUse),when I try to delete m_pVB.
Advertisement
when I try to delete m_pVB
Do you mean with [font=courier new,courier,monospace]delete m_pVB;[/font]?
Your VB wasn't created with new (but [font=courier new,courier,monospace]SphereVerts[/font] was), so you should use:
[font=courier new,courier,monospace]delete SphereVerts;[/font]
and
[font=courier new,courier,monospace]m_pVB->Release();[/font]

This topic is closed to new replies.

Advertisement