Problem show up when I use debug in DX9 control panel

Started by
2 comments, last by cozzie 9 years, 11 months ago
Hi Guys,

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 smile.png
Advertisement
Damn, what a stupid mistake. I saw what is wrong straight after I posted this (must be the different font - LOL)

I am locking the vertex buffer twice in a row.

Damn, what a stupid mistake. I saw what is wrong straight after I posted this (must be the different font - LOL)


It happens. I know a number of developers who keep a stuffed animal or somesuch around just so they can go up to it and explain out loud the problem they're stuck on in detail (without distracting any teammates) and then often figure out the problem as they're explaining it.

Sean Middleditch – Game Systems Engineer – Join my team!

If you want you can also mark/ enable that the application stops when a d3d error occurs, that way you don't have to constantly check and rely on checking the output debug window always

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement