# Problem show up when I use debug in DX9 control panel

This topic is 1330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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)))
{

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?

##### Share on other sites

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.

##### Share on other sites
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

• 11
• 11
• 9
• 12
• 10