Animating Graphics

Send Feedback

To provide fast, animated graphics, the Game API (GAPI) allows direct access to your display's video frame buffer (VFB) memory. Every device is different, so GAPI defines each device.

Note   GAPI is deprecated. Use DirectDraw and Direct3D Mobile APIs instead.

To determine whether a device has support for direct frame buffer access, use the GetFBAddress function. A NULL return value indicates that the device does not support frame buffer access.

Many devices have 8-bit or 16-bit color but have a frame buffer memory bandwidth that is similar to a 2-bit monochrome device. You cannot clear the screen 30 times a second on many devices. This may change as Windows Mobile-based device manufacturers improve hardware in this area.

GAPI includes the GXDisplayProperties structure, which provides information about the VFB. Use the values in the GXDisplayProperties structure to draw correctly. A typical program should support 16 bits per pixel (bpp) and, if written to use cbxStride and cbyStride, should not have any problems. A robust program should support 4-bpp grayscale, 8-bpp indexed color, and 16-bpp direct color. The 4-bpp mode is more complicated because some devices have a rotated VFB, which means that 1 byte in display memory encompasses two vertically stacked pixels — not horizontally adjacent ones. In this case, custom code needs to be written and the cbxStride and cbyStride values need to be used carefully because they cannot contain fractional byte widths. Take into consideration that some of the most popular hardware has the rotated frame buffer with a 4-bit pixel depth.

Note   If you want to support different rotations, you need to factor that into your draw code and your button code.

To continue drawing more data on the screen, call GXBeginDraw to get a pointer to the VFB. Immediately after drawing is complete, call GXEndDraw.

Consider the performance cost of these calls when implementing them in your application because they are typically called 20 or 30 times per second. It is acceptable to draw several frames between the GXBeginDraw and GXEndDraw calls, but you must remember to call GXEndDraw in WM_KILLFOCUS if necessary.

See Also

Detecting Key Presses

GAPI Overview

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.