DDraw Off-Screen Surfaces

Windows Mobile SupportedWindows Embedded CE Not Supported


This code sample is named DDEx3. It demonstrates how to use off-screen surfaces, how to initialize DirectDraw, and how to create a DirectDraw surface. It creates a "back surface," and uses Page Flipping and Back Buffering to alternately display the contents of the front and back surfaces. Other techniques demonstrated include Color Fills, and how to use GDI Functions on a DirectDraw surface.

Feature Area

Relevant APIs


To run the code sample

  1. Navigate to the solution file (*.sln), and double-click it. By default, the solution file is copied to the following folder:

    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\directx\DDraw\DDex3

    Microsoft Visual Studio 2005 launches and loads the solution.

  2. Build the solution (Ctrl+Shift+B).

  3. Deploy the solution (F5).

To use the application

  1. DDEx3 needs no user input.

  2. Press the ACTION button to quit the program.


The DDEx3 code sample is an extension of code sample DDEx2, from DDraw and Bitmaps.

In addition to the front and back surfaces, the program creates two DDraw Off-Screen Surfaces, and loads bitmaps into them. It calls the IDirectDrawSurface::Blt method to copy the contents of an off-screen surface to the back surface, alternating the source surface on each frame. After it blits the bitmap to the back surface, DDEx3 flips the front and back surfaces.

To run this code sample, your mobile device must support hardware flipping. If the display driver doesn't support page flipping the sample will exit during initialization.

To run this code sample, your mobile device needs at least 1.2 MB of video RAM.

Development Environments

Pocket PC SDK: Windows Mobile 6 Professional SDK 

Development Environment: Visual Studio 2005.

ActiveSync: Version 4.5.

See Also


Code Samples for Windows Mobile
DDraw and Animation
DDraw and Audio
DDraw and Bitmaps
DDraw Initialization

Other Resources

Working with DirectDraw Surfaces
Creating an Off-Screen Surface