Article ID: 139096
Article Last Modified on 8/18/2005
LPDIRECTDRAW lpDD; // DirectDraw object
LPDIRECTDRAWSURFACE lpDDSPrimary; // DirectDraw primary surface
LPDIRECTDRAWSURFACE lpDDSBack; // DirectDraw back surface
DDSCAPS ddscaps;
DDSURFACEDESC ddsd;
HRESULT hResult;
// Create the main DirectDraw object
hResult = DirectDrawCreate( NULL, &lpDD, NULL );
if (DD_OK != hResult)
{
// Handle error
}
// Get exclusive mode
hResult = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX);
if (DD_OK != hResult)
{
// Handle error
}
// Use mode 13
hResult = lpDD->SetDisplayMode( 320, 200, 8 );
if (DD_OK != hResult)
{
// handle error
}
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
// Create a primary surface with one back buffer
hResult = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );
if (DD_OK != hResult)
{
// Handle error
}
// Get a pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
hResult = lpDDSPrimary->GetAttachedSurface(&ddscaps, &lpDDSBack);
if (DD_OK != hResult)
{
// Handle error
}
Additional query words: 1.00
Keywords: kbhowto kbcode KB139096