24-bit is just shorthand for "really 32 but 8 of those are unused". If you don't have 24-bit available in hardware (and trust me, you don't) no OS is going to make it magically appear.
You can check this on Windows by sticking these lines in your bSetupPixelFormat function just before returning TRUE:
Code: Select all
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
DescribePixelFormat (hDC, pixelformat, sizeof (PIXELFORMATDESCRIPTOR), &pfd);
(Or doing the equivalent on Linux, I'm sure there's a glx function to tell you what format you actually got.)
Set a breakpoint on the return, run, and examine the contents of "pfd" - it will tell whether or not you
really got that 32-bit depth and 24-bit colour you asked for. Quite an eye-opener.
It will also give you shift-bits for each of R, G, B and A which will tell you whether your PFD_TYPE_RGBA is actually laid out in BGRA, ABGR, ARGB or whatever order.
Read the documentation on ChoosePixelFormat again - there is no contract to give you
exactly what you ask for. The sample code given should look familiar and raise a chuckle as well.