//----------Set up DirectDraw--------------------- |
// Create the DirectDraw object |
hr = DirectDrawCreate( NULL, &lpdd, NULL ); |
if( hr != DD_OK ) |
return FALSE; |
// Decide the application's behaviour |
hr = lpdd->SetCooperativeLevel( hwndApp, DDSCL_EXCLUSIVE | |
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX ); |
if( hr != DD_OK ) |
return FALSE; |
// Set the display mode |
hr = lpdd->SetDisplayMode( window_width, window_height, bits_per_pixel ); |
if( hr != DD_OK ) |
return FALSE; |
ddsd.dwSize = sizeof( ddsd ); |
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; |
ddsd.dwBackBufferCount = 1; //We are using one back buffer |
//Specify surface capabilities |
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
hr = lpdd->CreateSurface( &ddsd, &lpFrontBuffer, NULL ); |
if( hr != DD_OK ) |
return FALSE; |
// get pointer to back buffer |
ddscaps.dwCaps = DDSCAPS_BACKBUFFER; |
hr = lpFrontBuffer->GetAttachedSurface(&ddscaps, &lpBackBuffer ); |
if( hr != DD_OK ) |
return FALSE; |
/* Initial screen layout & rendering can be done here if needed */ |
return TRUE; |
} |
Setting up |
DirectDraw |
640 X 480 X 8 |