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 primary surface is the surface currently visible on the monitor and is identified by the DDSCAPS_PRIMARYSURFACE flag. You can only have one primary surface for each DirectDraw object.

When you create a primary surface, remember that the dimensions and pixel format implicitly match the current display mode. Therefore, this is the one time you do not need to declare a surface's dimensions or pixel format. If you do specify them, the call will fail and return DDERR_INVALIDPARAMS— even if the information you used matches the current display mode.

Code Example

The following code example demonstrates how to prepare the DDSURFACEDESCstructure members relevant for creating the primary surface.

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; 
ddsd.dwSize = sizeof(ddsd); 
 
// Tell DirectDraw which members are valid. 
ddsd.dwFlags = DDSD_CAPS; 
 
// Request a primary surface. 
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 

After creating the primary surface, you can retrieve information about its dimensions and pixel format by calling its IDirectDrawSurface::GetSurfaceDescmethod.

See Also

Concepts

Display Modes