Skip to main content
gamedev.net
🔒 Locked

Surface Locking Problem

Started by JonW Aug 6, 2002 at 6:13 PM 1 replies 250+ views
Original Post
JonW
JonW
I''ve got a screwy locking problem with DirectDraw that has been giving me headaches for two days. I have a class called CSurface that manages a single LPDIRECTDRAWSURFACE7 object. One of the functions does something like this: CSurface::Squeeze () { if (!bLocked) Lock (); // Do stuff to surface... CSurface *pTemp = new CSurface (); pTemp->Create (); pTemp->Fill (0); } As you can see, it locks itself, messes with its color data, and then creates a new surface and fills it with black. But the problem is the fill function fails with DDERR_SURFACEBUSY. I know I''m not unlocking the surface, but I''ve never locked the temporary one so I don''t think it should matter. I only lock each surface once every frame. Does DD only allow one surface to be locked at a time? This is the only logic thing I can come up with... Thanks!
JonW
JonW
Side question - is there any benefit of only locking once per frame? Has anyone ever done this before?
JonW
JonW
Hi again,

I''ve looked in a DirectX book I have and it seems that multiple surfaces can be locked at the same time. So that isn''t the problem then. I noticed that the backbuffer fill function only fails when I call Squeeze () during initialization - it works fine in the gameloop. I also tried drawing a line during initialization and that lock caused the fill to fail also. I think this is because I unlock all surfaces before blitting them in the gameloop.

Maybe I can make a class called CSurfaceMgr that will only allow one surface to be locked at a time. This seems to be what is causing everything to act up. Thoughts?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.