Hi… try this:
/------------ Code -------------/
int pf, maxpf, psize, perror;
PIXELFORMATDESCRIPTOR pfd;
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;
found:
// 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.