I have just noticed that when I run my program with the DX Control Panel set to use the debug mode, I get an error every draw call.
Direct3D9: (ERROR) :Vertex buffer must be unlocked during DrawPrimitive call
Direct3D9: (ERROR) :DrawPrimitive failed.
This is the code I am using to render a single quad. Nothing else is happening in the draw call that reports any errors (i.e. If I comment out this source the program doesnt report any errors)
if(!FAILED(pVertexSpriteObject->Lock(0,(nNumVerts)*sizeof(D3DVERTEX),&pVertexBuffer,D3DLOCK_DISCARD)))
{
pVertexSpriteObject->Lock(0,(nNumVerts)*sizeof(D3DVERTEX),&pVertexBuffer,D3DLOCK_DISCARD);
memcpy(pVertexBuffer,vertices,(nNumVerts)*sizeof(D3DVERTEX));
Renderer->DeviceHandle()->SetStreamSource(0,pVertexSpriteObject,0,sizeof(D3DVERTEX));
Renderer->DeviceHandle()->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
pVertexSpriteObject->Unlock();
Renderer->DeviceHandle()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,nNumVerts-2);
}
As far as I can see, I am unlocking the vertex buffer with pVertexSpriteObject->Unlock();.I have tried moving that line below DrawPrimative() but get the same error.
Any chance anyone could advise on what I am doing wrong?
Thanks in advance