Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

You can also create complex surfaces. A complex surface is a set of surfaces created with a single call to the IDirectDraw::CreateSurfacemethod.

If the DDSCAPS_FLIP flag is set when you call CreateSurfacecall, DirectDraw implicitly creates one or more surfaces in addition to the surface explicitly specified.

You manage complex surfaces just like a single surface — a single call to the IDirectDrawSurface::ReleaseDCmethod releases all surfaces, and a single call to the IDirectDrawSurface::Restoremethod restores them all.

Complex surfaces are used in flipping chains. Usually, a flipping chain is made of a primary surface and one or more back buffers. The DDSCAPS_FLIP flag indicates that a surface is part of a flipping chain.

Code Example

The following code example demonstrates how to prepare for creating a primary surface flipping chain.

Note:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
Copy Code
DDSURFACEDESC ddsd; 
ddsd2.dwSize = sizeof(ddsd); 
 
// Tell DirectDraw which members are valid. 
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 
 
// Request a primary surface with a single 
// back buffer 
ddsd.ddsCaps.dwCaps = DDSCAPS_FLIP | 
DDSCAPS_PRIMARYSURFACE; 
ddsd.dwBackBufferCount = 1; 

The previous example constructs a double-buffered flipping environment — a single call to the IDirectDrawSurface::Flipmethod exchanges the surface memory of the primary surface and the back buffer.

If you specify 2 for the value of the dwBackBufferCountmember of the DDSURFACEDESCstructure, two back buffers are created, and each call to Fliprotates the surfaces in a circular pattern, providing a triple-buffered flipping environment.

For more information, see Flipping Surfaces.