Wallpaper screws up after leaving my game

Started by
4 comments, last by SpaceRook 22 years, 3 months ago
Hi all. I am working on a modest Tetris clone using DirectX under Win2000. I have a bit of a problem, though. When I exit from my game, the desktop wallpaper is centered on the desktop, with the width & height of the wallpaper equal to the resolution of my game. For example, my desktop resolution is 1024x768, and I have a wallpaper image stretched over the desktop. When I quit out of my 800x600 game, the wallpaper image is now 800x600 pixels wide and centered. Any way of fixing this? BTW, when my game''s color depth was 8 bits, the desktop wallpaper was also getting reduced to 8 bits when I left the game. I am released all my directX objects before the program ends.
Advertisement
It sounds like the main ddraw object isn''t being released correctly. Check the return value when you release it and make sure it was successfuly released.
quote:Original post by Anonymous Poster
It sounds like the main ddraw object isn''t being released correctly. Check the return value when you release it and make sure it was successfuly released.


It seems like the ddraw object is being release OK. My shutdown code contains the following block:

if(lpdd != NULL)
{
fprintf(file, "\nReleasing DD object");
if(FAILED(lpdd->Release()))
{
fprintf(file, "DD release failed");
}
}
fprintf(file, "\nLeaving shutdown");

The output reads:
Releasing DD object
Leaving shutdown


Make sure you release all DD-created things before releasing the DD itself.
quote:Original post by siaspete
Make sure you release all DD-created things before releasing the DD itself.


I have isolated my problem down to the line that seems to be causing the problem (where lpddsprimary is a LPDIRECTDRAWSURFACE7):

if(lpddsprimary)
{
fprintf(file, "\n****lpdds primary not null****\n");
if(FAILED(lpddsprimary->Release()))
fprintf(file, "\nlpdds primary release failed");
}

My program seems to hang on that call to Release(). NO OUTPUT AT ALL will get written if I leave that if... statement in. However, when I comment it out, my program outputs "****lpdds primary not null****". It seems like some kind of null pointer exception, yet if the program gets into the loop, lpddsprimary obviously can''t be null!

OK, I finally got it!!!! The order I was releasing things was screwed up. Like you suggested, I released the DD object last. But I still had to reorder the other release() calls. I could have sworn I tried that before and it didn''t work, but I guess I didn''t. Thanks for the help, everyone!

This topic is closed to new replies.

Advertisement