Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Display.getDepth fix  (Read 1987 times)
0 Members and 1 Guest are viewing this topic.
Offline aldacron

Senior Devvie

Medals: 10
Exp: 17 years

Java games rock!

« Posted 2004-01-26 16:27:22 »

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:

Actual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.

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.
Offline elias

Senior Devvie

« Reply #1 - Posted 2004-01-26 16:58:30 »

Seems reasonable, fixed in CVS.

- elias

Offline aldacron

Senior Devvie

Medals: 10
Exp: 17 years

Java games rock!

« Reply #2 - Posted 2004-01-26 17:05:14 »

I forgot to mention that I tested it locally and it does fix the issue.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Matzon

JGO Knight

Medals: 19
Projects: 1

I'm gonna wring your pants!

« Reply #3 - Posted 2004-01-26 18:58:50 »

Seems reasonable, fixed in CVS.

- elias

Huh Huh Huh How Huh Huh Huh
Last time I played with SF CVS I got a
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)


Offline Matzon

JGO Knight

Medals: 19
Projects: 1

I'm gonna wring your pants!

« Reply #4 - Posted 2004-01-26 20:29:28 »

back online - w00t  Shocked

Offline princec

« JGO Spiffy Duke »

Medals: 545
Projects: 3
Exp: 16 years

Eh? Who? What? ... Me?

« Reply #5 - Posted 2004-01-27 06:35:59 »

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 :/

<edit>There, activated you directly.

Cas Smiley

Offline aldacron

Senior Devvie

Medals: 10
Exp: 17 years

Java games rock!

« Reply #6 - Posted 2004-01-27 09:21:56 »

thanks Smiley
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (11 views)
2015-07-03 11:22:16

deepthought (41 views)
2015-06-30 15:39:44

deepthought (45 views)
2015-06-30 15:39:09

deepthought (55 views)
2015-06-30 15:36:52

Za\'Anzabar (24 views)
2015-06-29 05:44:54

TritonDreyja (41 views)
2015-06-24 17:10:40

CopyableCougar4 (40 views)
2015-06-23 00:34:45

BurntPizza (44 views)
2015-06-21 20:36:46

cookiecompiler (86 views)
2015-06-11 15:42:53

cookiecompiler (49 views)
2015-06-11 15:41:14
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!