Display.getDepth fix

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.

Seems reasonable, fixed in CVS.

  • elias

I forgot to mention that I tested it locally and it does fix the issue.

[quote]Seems reasonable, fixed in CVS.

  • elias
    [/quote]
    ??? ??? ??? How ??? ??? ???
    Last time I played with SF CVS I got a

[quote]cvs update: warning: unrecognized response `FATAL ERROR: Network error: Connection refused
’ from cvs server
cvs [update aborted]: end of file from server (consult above messages if any)
[/quote]

:frowning:

back online - w00t :o

The account activation from our forums is probably because SpamAssassin or somesuch has blacklisted our server. We got hacked for a few hours last year and the result is the whole internet treats puppygames mail as spam forever more and there’s nothing we can do about it :confused:

There, activated you directly.

Cas :slight_smile:

thanks :slight_smile: