Tutorial 2: Loading Bitmaps on the Back Buffer

The sample discussed in this tutorial (DDEX2) expands on the DDEX1 sample that was discussed in Tutorial 1. DDEX2 includes functionality to load a bitmap file on the back buffer. This new functionality is demonstrated in the following steps:

·Step 1: Creating the Palette

·Step 2: Setting the Palette

·Step 3: Loading a Bitmap on the Back Buffer

·Step 4: Flipping the Surfaces

As in DDEX1, doInit is the initialization function for the DDEX2 application. Although the code for the DirectDraw initialization does not look quite the same in DDEX2 as it did in DDEX1, it is essentially the same, except for the following section:

lpDDPal = DDLoadPalette(lpDD, szBackground);

if (lpDDPal == NULL)

goto error;

ddrval = lpDDSPrimary->SetPalette(lpDDPal);

if(ddrval != DD_OK)

goto error;

// Load a bitmap into the back buffer.

ddrval = DDReLoadBitmap(lpDDSBack, szBackground);

if(ddrval != DD_OK)

goto error;