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

The DirectDrawSurface object represents a surface that usually resides in the display memory, but can exist in system memory if display memory is exhausted or if it is explicitly requested.

Use the IDirectDraw::CreateSurfacemethod to create one surface or to simultaneously create multiple surfaces (a complex surface).

When calling CreateSurface, you specify the dimensions of the surface, whether it is a single surface or a complex surface, and the pixel format (if the surface will not be using an indexed palette).

All of these characteristics are contained in a DDSURFACEDESCstructure, whose address you send with the call.

If the hardware cannot support the requested capabilities or if it previously allocated those resources to another DirectDrawSurface object, the call will fail.

Creating single surfaces or multiple surfaces is a simple matter that requires only a few lines of code. There are a few common situations (and some less common ones) in which you will need to create surfaces.

The following situations are discussed:

By default, for all surfaces except client memory surfaces, DirectDraw attempts to create a surface in local video memory.

If there is not enough local video memory available to hold the surface, DirectDraw will try to use non-local video memory (on some Accelerated Graphics Port-equipped systems), and fall back on system memory if all other types of memory are unavailable.

You can explicitly request that a surface be created in a certain type of memory by including the appropriate flags in the associated DDSCAPSstructure when calling IDirectDraw::CreateSurface.