Locking surfaces
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
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement