overlay layer with color index mode

Thanks for help in advance.

Hi. I am using msvc++ 6.0 on win2k. My code uses a pixelformat with one overlay layer that requires a palette (PFD_NEED_PALETTE is true) and has cColorBits=8 so I should be able to give it 256 colors when I call wglSetLayerPaletteEntries. When I try that, the call is
successful, but it returns a value of 1 (not 256) and my palette does indeed consist of only one color. It ends up that I can draw to the overlay OK, but only in the one color. Any ideas would be greatly appreciated.


Which graphics hardware?

My hardware is a 3dlabs Oxygen VX1.

Hi… try this:

/------------ Code -------------/
int pf, maxpf, psize, perror;
LAYERPLANEDESCRIPTOR lpd; // layer plane descriptor
int crCount = 14; // number of entries in palette
COLORREF crEntries[14] = // entries in custom palette
0x00000000, // Black
0x00808080, // Gray
0x000000FF, // Red
0x0000FFFF, // Yellow
0x00A6F2A6, // Green
0x00FFFF00, // Cyan
0x00FF0000, // Blue
0x00FF00FF, // Magenta
0x00FFFFFF, // White
0x00404040, // Light Gray glColor3f( 0.250980f, 0.250980f, 0.250980f )
0x00202020, // Dark Gray
0x00FEFFFE, // Other_1 glColor3f( 0.996078f, 1.000000f, 0.996078f )
0x00F3F3F3, // Other_2 glColor3f( 0.952941f, 0.952941f, 0.952941f )
0x00F1F145, // Other_3 glColor3f( 0.270588f, 0.949020f, 0.949020f );

// get the maximum number of pixel formats
maxpf = DescribePixelFormat(hDC, 0, 0, NULL);

// find an overlay layer descriptor
for(pf = 0; pf < maxpf; pf++)
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

// the bReserved field of the PIXELFORMATDESCRIPTOR contains the
//   number of overlay/underlay planes

if (pfd.bReserved > 0)
// This format has overlays/underlays
wglDescribeLayerPlane(hDC, pf, 1, sizeof(LAYERPLANEDESCRIPTOR), &lpd);
if (lpd.dwFlags & LPD_SUPPORT_OPENGL && lpd.dwFlags & flags)
goto found;
// couldn’t find any overlay/underlay planes
MessageBox(NULL, “Fatal Error: Hardware does not support overlay planes.”, “Error”, MB_OK);
return 0;

// now get the “normal” pixel format descriptor for the layer
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

// set the pixel format
if(SetPixelFormat(hDC, pf, &pfd) == FALSE)
MessageBox(NULL, “SetPixelFormat() failed: Cannot set format specified.”, “Error”, MB_OK);
return 0;

// set up the layer palette
psize = wglSetLayerPaletteEntries(hDC, 1, 0, crCount, &crEntries[0]);
perror = GetLastError();

// realize the palette
wglRealizeLayerPalette(hDC, 1, TRUE);

// announce what we’ve got
printf("Number of overlays = %d
", pfd.bReserved);
printf("Color bits in the overlay = %d
", lpd.cColorBits);

With this you should be able to specify 256 different colors in a single palette and get more than just the white color to display. My problem is that I can’t figure out how to enable antialiasing on the overlay buffer. I hope that helped.