Platform SDK: DirectX

Creating Surfaces

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.

[C++]

Use the IDirectDraw7::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 won't be using an indexed palette). All these characteristics are contained in a DDSURFACEDESC2 structure, whose address you send with the call. If the hardware can't support the requested capabilities or if it previously allocated those resources to another DirectDrawSurface object, the call will fail.

[Visual Basic]

Use the DirectDraw7.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 won't be using an indexed palette). All these characteristics are contained in a DDSURFACEDESC2 type, whose address you send with the call. If the hardware can't 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.

[C++]

By default, for all surfaces except client memory surfaces, DirectDraw attempts to create a surface in local video memory. If there isn't 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 DDSCAPS2 structure when calling IDirectDraw7::CreateSurface.

[Visual Basic]

By default, for all surfaces except client memory surfaces, DirectDraw attempts to create a surface in local video memory. If there isn't 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 DDSCAPS2 type when calling DirectDraw7.CreateSurface.