Archived

This topic is now archived and is closed to further replies.

Locking surfaces

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

I have weird problem. When i try to lock a surface my whole game crashes. This is the code: LPDIRECTDRAWSURFACE7 Surface = 0; HRESULT r = 0; // Create the surface CreateSurface(Surface, Colorkey here, width, height); LoadBitmap into surface(); DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // Now lock the surface r = Surface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); Everytime i try to do this, the game crashs... Edited by - Devu on November 5, 2001 1:24:52 PM

Share this post


Link to post
Share on other sites
By the looks of it, you''re passing an empty surface description. I think you need to provide proper surface dimensions for this to work. Set the width and height of ddsd to the size of your bitmap and see if that works.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you sure the surface is created properly?
As you''re having problems locking the surface, I assume you use some library function to load the bitmap?

You shouldnt need to fill the ddsd structure with the surface dimensions as the Lock method actually uses this structure to pass information back to you (in your case in the ddsd.lpSurface member).

Check the return code of CreateSurface and LoadBitmap for errors, and you will probably see that you actually attempt to lock an invalid surface

/ Tooon

Share this post


Link to post
Share on other sites