Platform SDK: DirectX |
The information in this section pertains only to applications written in C and C++. See DirectDraw Visual Basic Tutorials.
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 DDSURFACEDESC2 structure it will use. It then sets the flags appropriate to create a primary surface and creates it by calling the IDirectDraw7::CreateSurface method. For the call, the first parameter is a pointer to a DDSURFACEDESC2 structure that describes the surface to be created. The second parameter is a pointer to a variable that will receive an IDirectDrawSurface7 interface pointer if the call succeeds. The last parameter is set to NULL to indicate that no COM aggregation is taking place.