Jump to content
  • Advertisement

Archived

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

SpazBoy

Why does my program have a stupid bug in it?

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

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!