Share via


Creating Surfaces

Send Feedback

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::CreateSurface method 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 DDSURFACEDESC structure, 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 DDSCAPS structure when calling IDirectDraw::CreateSurface.

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.