385
(.bmp) or Targa (.tga). The details of how to capture a screen shot vary from
platform to platform, but they typically involve making a call to the graphics
API that allows the contents of the frame buff er to be transferred from video
RAM to main RAM, where it can be scanned and converted into the image
fi le format of your choice. The image fi les are typically writt en to a predefi ned
folder on disk and named using a date and time stamp to guarantee unique
fi le names.
You may want to provide your users with various options controlling
how screen shots are to be captured. Some common examples include:
z Whether or not to include debug lines and text in the screen shot.
z Whether or not to include heads-up display (HUD) elements in the
screen shot.
z The resolution at which to capture. Some engines allow high resolution
screen shots to be captured, perhaps by modifying the projection matrix
so that separate screen shots can be taken of the four quadrants of the
screen at normal resolution and then combined into the fi nal high-res
image.
z Simple camera animations. For example, you could allow the user to
mark the starting and ending positions and orientations of the camera.
A sequence of screen shots could then be taken while gradually interpo-
lating the camera from the start location to the ending location.
Some engines also provide a full-fl edged movie capture mode. Such a sys-
tem captures a sequence of screen shots at the target frame rate of the game,
which are typically processed offl ine to generate a movie fi le in a suitable
format such as AVI or MP4.
Capturing a screen shot is usually a relatively slow operation, due in
part to the time required to transfer the frame buff er data from video RAM
to main RAM (an operation for which the graphics hardware is usually not
optimized), and in larger part to the time required to write image fi les to disk.
If you want to capture movies in real time (or at least close to real time), you’ll
almost certainly need to store the captured images to a buff er in main RAM,
only writing them out to disk when the buff er has been fi lled (during which
the game will typically be frozen).
9.8 In-Game Profi ling
Games are real-time systems, so achieving and maintaining a high frame rate
(usually 30 FPS or 60 FPS) is important. Therefore, part of any game program-
9.8. In-Game Profi ling