### Step 1: Creating a Primary Surface

To prepare for using overlay surfaces, you must first initialize DirectDraw and create a primary surface over which the overlay surface will be displayed. Mosquito creates a primary surface with the following code:

// Zero-out the structure and set the dwSize member.

ZeroMemory(&ddsd, sizeof(ddsd));

ddsd.dwSize = sizeof(ddsd);

// Set flags and create a primary surface.

ddsd.dwFlags = DDSD_CAPS;

ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

ddrval = g_lpdd->CreateSurface(&ddsd, &g_lpddsPrimary, NULL );

The preceding example begins by initializing the DDSURFACEDESC structure it will use. It then sets the flags appropriate to create a primary surface and creates it by calling the IDirectDraw2::CreateSurface method. For the call, the first parameter is a pointer to a DDSURFACEDESC structure that describes the surface to be created. The second parameter is a pointer to a variable that will receive an IDirectDrawSurface interface pointer if the call succeeds. The last parameter is set to NULL to indicate that no COM aggregation is taking place.