Game Development Reference
In-Depth Information
Deal with DirectX Lost Devices and Resources
Most of the bugs in full-screen mode happen as a result of switching from full-
screen to windowed mode or vice versa. This happens because DirectX features
are lost and need to be restored after the switch, something that is easily
forgotten by coders. Another problem that happens as a result of the switch is
that surfaces can have the wrong pixel format. There
s no guarantee that the
full-screen pixel depth and format are identical to that of windowed mode.
When the switch happens, lost or invalid surfaces refuse to draw and return
errors. Your program might handle these errors by exiting or attempting to
restore all the surfaces again. Of course, since the surface in question won
'
'
t
get
restored in the first place, your game might get caught
in a weird
obsessive and repetitive attempt to fix something that can
'
t be fixed.
It would be nice if you could simulate this problem entirely in windowed mode. To a
large extent, you can. If you ' ve followed the advice of the DirectX SDK, you always
should check your display surfaces to see if they have been lost before you perform
any action on them. It turns out that if you change your display settings while your
game is running in windowed mode, you will essentially simulate the event of switch-
ing between windowed mode and full-screen mode. There are a few windows mes-
sages your game should handle to make this a little easier. You can see how to do
this in the GameCode4 source code. Just look for WM_ and you
'
ll see how all these
messages are handled. You ' ll need to handle WM_DISPLAYCHANGE , the message that
is sent when the display changes, and WM_ACTIVATE , the message that signifies gain
and loss of focus.
Got Full-Screen Display Bugs?
About 90 percent of all full-screen display bugs can be found and solved with a
single monitor setup using windowed mode. Just start your game, change the
bit depth, and see what happens. The other 10 percent can only be solved with
a multimonitor setup or via remote debugging. It
s much easier to debug these
problems on a multimonitor rig, so make sure that at least one programmer
has two monitors.
'
Remote Debugging
One solution for debugging full-screen-only games is remote debugging. The game
runs on one computer and communicates to your development box via your net-
work. One interesting thing about this setup is that it is as close to a pristine runtime
environment as you can get. (Another way of saying it
s very close to the environ-
ment people have when actually playing the game.) I don
'
'
t know about you, but peo-
ple like my Mom don
'
t have a copy of Visual Studio lying around. The presence of a
 
 
Search WWH ::




Custom Search