Why does my program have a stupid bug in it?

Started by
1 comment, last by SpazBoy 24 years, 9 months ago
The problem is that when you Alt-TAB out of a program and back into it, your DD surfaces are lost, so then when you try to use them, you get NULL pointer problems.

The solution is to have a way to restore surfaces. The best way I have found to handle this is to have a global variable to keep track of whether your app has the focus (i.e., for a non-Windowed mode game, it is not minimized). This flag can be set by handling the WM_ACTIVATEAPP message if (wparam will be TRUE if the app is gaining the focus, false if it is being minimized). When your app is inactive, you want to skip the game loop. When it switches to active from inactive, you want to call a routine to restore your surfaces. This routine will check every surface you have to see if the surface has been lost (use IsLost() to check and Restore() to restore). You will then have to reload the images you had in those surfaces; modularization of your image loading makes this a lot easier.

Advertisement
Ok, I've done a tetris game like that article
says, but one little thing. I've done it in
Windows using Direct-X, and I am neither a
Direct-X programmer nor a Windows programmer.

For some reason, when you ALT-TAB out of the
program, then ALT-TAB back in, it freezes the
whole damn computer. Why could this be?

Any help would be appreciated.

The views expressed in this post do not represent those of the human race in any way.
Ahh, I was restoring my primary suface & the
back buffer, but not my sprites. Thanks for
that. I can use the WM_ACTIVATEAPP to set
my paused flag, just like in those dodgy Microsoft games.

This topic is closed to new replies.

Advertisement