1 | //----------Set up DirectDraw--------------------- |
2 | // Create the DirectDraw object |
3 | hr = DirectDrawCreate( NULL, &lpdd, NULL ); |
4 | if( hr != DD_OK ) |
5 | return FALSE; |
6 | // Decide the application's behaviour |
7 | hr = lpdd->SetCooperativeLevel( hwndApp, DDSCL_EXCLUSIVE | |
8 | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX ); |
9 | if( hr != DD_OK ) |
10 | return FALSE; |
11 | // Set the display mode |
12 | hr = lpdd->SetDisplayMode( window_width, window_height, bits_per_pixel ); |
13 | if( hr != DD_OK ) |
14 | return FALSE; |
15 | ddsd.dwSize = sizeof( ddsd ); |
16 | ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; |
17 | ddsd.dwBackBufferCount = 1; //We are using one back buffer |
18 | //Specify surface capabilities |
19 | ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; |
20 | hr = lpdd->CreateSurface( &ddsd, &lpFrontBuffer, NULL ); |
21 | if( hr != DD_OK ) |
22 | return FALSE; |
23 | // get pointer to back buffer |
24 | ddscaps.dwCaps = DDSCAPS_BACKBUFFER; |
25 | hr = lpFrontBuffer->GetAttachedSurface(&ddscaps, &lpBackBuffer ); |
26 | if( hr != DD_OK ) |
27 | return FALSE; |
28 | /* Initial screen layout & rendering can be done here if needed */ |
29 | return TRUE; |
30 | } |
31 | Setting up |
32 | DirectDraw |
33 | 640 X 480 X 8 |