Sign in to follow this  

Am I overwriting the vertex buffer

This topic is 1986 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

[CODE]
#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();
[/CODE]

Am I overwriting the buffer? I have an assertion says _BLOCK_TYPE_IS_VAlID(pHead->nBlockUse),when I try to delete m_pVB.

Share this post


Link to post
Share on other sites
[quote name='monkeyboi' timestamp='1344639204' post='4968232']when I try to delete m_pVB[/quote]Do you mean with [font=courier new,courier,monospace]delete m_pVB;[/font]?
Your VB wasn't created with new ([i]but [font=courier new,courier,monospace]SphereVerts[/font] was[/i]), so you should use:
[font=courier new,courier,monospace]delete SphereVerts;[/font]
and
[font=courier new,courier,monospace]m_pVB->Release();[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this