Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Why does my program have a stupid bug in it?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 SpazBoy   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 July 1999 - 01:35 PM

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.


Sponsor:

#2 Dave Astle   Senior Staff   -  Reputation: 2307

Like
Likes
Like

Posted 21 July 1999 - 08:22 AM

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.


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 21 July 1999 - 01:35 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS