I saw a thread over at the puppygames forums realted to a problem with Display.getDepth. The poster stated he was getting odd return values. I’ve been bitten by this as well and I believe I’ve found the problem. It seems to be taking forever and a day to receive my account activation email from the forums there, so I’m posting here before I forget.
Line 253 of win32/org_lwjgl_Display.cpp:
bpp = GetDeviceCaps(screenDC, COLORRES);
The value returned from this call is used to initialize the initial display mode (desktop). Later, if a call to Display.getDepth is made, it is this value that is returned. Unfortunately, the call as it is does not retrieve the actual color depth of the desktop. Instead, it is getting the ‘color resolution’ of the device, which may not always be valid.
MSDN defines COLORRES as:
When my desktop is set to 16 bpp, this call repeatedly returns 24 on a Geforce2MX 400. If I use this value in Window.create then LWJGL happily throws an Exception telling me that my application requires a greater color depth since pixelformat selection is, assumedly, returning 16 in the colorbits field. The original poster has the same problem on one machine, but was getting 16 on another. Obviously, this is not the intended behavior.
The correct thing to do would be to change COLORRES to BITSPIXEL. This will return the current desktop color depth correctly, and is the value one would want to use when describing the pixel format in windowed mode.


