LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Morgrog on January 23, 2004, 13:45:56

Title: Display.getDepth() question
Post by: Morgrog on January 23, 2004, 13:45:56
Display.getDepth returns the current value of the bpp eh?

I mean if you're running windowed it should return the resolution of the desktop right?

Well, what happens is this.
At home I'm running at 32 bpp, if I do a System.out.println(Display.getDepth()); it prints out 24 (dunno why it doesn't print 32 :oops:) the app runs
If I switch to 16, it prints out 16 (which is good) and the app runs

At work, if I run my desktop at 32bpp it prints out 24, the app loads wonderfully
if I switch to 16, it still prints out 24 but the app can't run it says

Java Web Start 1.4.2_03 Console, démarrée Fri Jan 23 08:49:57 EST 2004
Environnement d'exécution Java 2 : version 1.4.2_03 par Sun Microsystems Inc.
Consignation dans le fichier : C:\Documents and Settings\stamoun\Bureau\j.log
24
java.lang.Exception: This application requires a greater colour depth
at org.lwjgl.opengl.Window.nCreate(Native Method)
at org.lwjgl.opengl.Window.createWindow(Unknown Source)
at org.lwjgl.opengl.Window.create(Unknown Source)
at com.stamoun.games.missilecommand.MCMain.init_lwjgl(MCMain.java:75)
at com.stamoun.games.missilecommand.MCMain.<init>(MCMain.java:46)
at com.stamoun.games.missilecommand.MCMain.main(MCMain.java:289)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Here's my init code

/** Init lwjgl (display and input if needed)
*/

public void init_lwjgl( int width, int height, int bpp )
{
// Find the display mode
DisplayMode[] modes = Display.getAvailableDisplayModes();

// Useful for fullscreen
for(int i = 0; i < modes.length; i++)
{
if( modes[i].width == width
  && modes[i].height == height
  && modes[i].bpp >= bpp )
{
mode = modes[i];
}
}

try
{
System.out.println(Display.getDepth());
// Start in windowed mode
Window.create("Missile Command", 50, 50, width, height, Display.getDepth(), 0, 8, 0);

init_gl();
} catch(Exception e)
{
e.printStackTrace();
}
}

(I use the modes variable later on when switching to full screen)

What am I not understanding here? :cry:
Title: Display.getDepth() question
Post by: Morgrog on January 23, 2004, 22:07:07
*smacks his head*

window creation should check for color depth, not the depth buffer :(

so uh, how do I get the desktop's color depth?
Title: Display.getDepth() question
Post by: princec on January 24, 2004, 11:26:29
getDepth() is the bpp depth.
Let me guess... you're using a Matrox card, or running Linux...? <edit>Aha, obviously not Linux ;)
As far as I know, Matrox are the only cards under Win32 that support 24-bit colour depth (as opposed to 32).

Cas :)
Title: Display.getDepth() question
Post by: Morgrog on January 24, 2004, 20:11:21
ATI 9600xt at home :O

But the one that fails (getting the 16bpp when running Display.getDepth()) is at work and its a huh geforce 2 MX

So that's kinda weird :(

maybe I'll just force my windowed app creation at 16bpp (will it get automagically upped to 32 if my card support is?)