Hello Guest

[BUG] DisplayMode madness

  • 4 Replies
  • 7940 Views
[BUG] DisplayMode madness
« on: December 09, 2010, 15:51:45 »
Hello LWJGLians.

I am developing a game with JME on Ubuntu 10.04 64 bit. I have an ATI e4690 graphics card and two 1680x1050 TFT screens.

Now,
 - I can start my application with 1680x1050 in fullscreen mode -> that just uses the first screen
 - I can start my app with 3360x1050 without fullscreen -> works too but is not FS
 - When I start my app in 3360x1050 with fullscreen, JME tells me "Bad display mode".

To avoid this really demotivatonal statement, the following alteration to JME code has been made so when JME cant find a close match for the DisplayMode I desire it would have just returned null, now it tries to force the DisplayMode I want (yes, I know its a mean hack):
Code: [Select]
       if (best_match == -1) {
            final DisplayMode mode = new DisplayMode(width, height);
            logger.warning("No valid display mode found. Trying to force it");
            try {
                final Class<?> c = mode.getClass();
                Field f = c.getDeclaredField("fullscreen");
                f.setAccessible(true);
                f.setBoolean(mode, Boolean.TRUE);
                f = c.getDeclaredField("bpp");
                f.setAccessible(true);
                f.setInt(mode, bpp);
                f = c.getDeclaredField("freq");
                f.setAccessible(true);
                f.setInt(mode, freq);
            } catch (final NoSuchFieldException x) {
                x.printStackTrace();
            } catch (final IllegalArgumentException x) {
                x.printStackTrace();
            } catch (final IllegalAccessException x) {
                x.printStackTrace();
            }
            return mode;
        } // if
        logger.log(Level.INFO, "Selected DisplayMode: {0}", modes[best_match]);
        return modes[best_match];

That producest this log output and stacktrace:
Code: [Select]
Xrandr extension not available
XF86VidMode extension version 2.2
Using XF86VidMode for display mode switching
XF86VidMode extension version 2.2
Initial mode: 1680 x 1050 x 24 @60Hz
Removed 11 duplicate displaymodes
Dec 9, 2010 4:22:53 PM com.jme.system.lwjgl.LWJGLDisplaySystem getValidDisplayMode
WARNING: No valid display mode found. Trying to force it
Mode 0: 1680x1050 @60
Mode 1: 1440x900 @60
Mode 2: 1280x800 @60
Mode 3: 1152x648 @60
Mode 4: 1280x1024 @60
Mode 5: 1280x1024 @60
Mode 6: 1280x960 @60
Mode 7: 1280x800 @60
Mode 8: 1152x864 @60
Mode 9: 1152x864 @60
Mode 10: 1280x768 @60
Mode 11: 1280x720 @60
Mode 12: 1024x768 @60
Mode 13: 1024x768 @60
Mode 14: 1024x768 @60
Mode 15: 1024x600 @60
Mode 16: 800x600 @60
Mode 17: 800x600 @60
Mode 18: 800x600 @60
Mode 19: 800x600 @60
Mode 20: 800x600 @60
Mode 21: 800x480 @60
Mode 22: 720x480 @60
Mode 23: 640x480 @60
Mode 24: 640x480 @60
Mode 25: 640x480 @60
Dec 9, 2010 4:22:53 PM com.jme.system.lwjgl.LWJGLDisplaySystem initDisplay
SEVERE: Cannot create window
Dec 9, 2010 4:22:53 PM class com.jme.system.lwjgl.LWJGLDisplaySystem initDisplay()
SEVERE: Exception
org.lwjgl.LWJGLException: Could not switch mode.
at org.lwjgl.opengl.LinuxDisplay.nSwitchDisplayMode(Native Method)
at org.lwjgl.opengl.LinuxDisplay.switchDisplayModeOnTmpDisplay(LinuxDisplay.java:524)
at org.lwjgl.opengl.LinuxDisplay.switchDisplayMode(LinuxDisplay.java:514)
at org.lwjgl.opengl.Display.switchDisplayMode(Display.java:367)
at org.lwjgl.opengl.Display.create(Display.java:853)
at org.lwjgl.opengl.Display.create(Display.java:785)
at com.jme.system.lwjgl.LWJGLDisplaySystem.initDisplay(LWJGLDisplaySystem.java:476)
at com.jme.system.lwjgl.LWJGLDisplaySystem.createWindow(LWJGLDisplaySystem.java:148)
at com.jmex.game.StandardGame.initSystem(StandardGame.java:302)
at com.jmex.game.StandardGame.run(StandardGame.java:213)
at java.lang.Thread.run(Thread.java:662)
Dec 9, 2010 4:22:53 PM com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException
SEVERE: Main game loop broken by uncaught exception
com.jme.system.JmeException: Cannot create window: Could not switch mode.
at com.jme.system.lwjgl.LWJGLDisplaySystem.initDisplay(LWJGLDisplaySystem.java:495)
at com.jme.system.lwjgl.LWJGLDisplaySystem.createWindow(LWJGLDisplaySystem.java:148)
at com.jmex.game.StandardGame.initSystem(StandardGame.java:302)
at com.jmex.game.StandardGame.run(StandardGame.java:213)
at java.lang.Thread.run(Thread.java:662)


So, to make this short, I would like to have a fullscreen game accross two identical monitors, which is not possible it seems.

I have tried it with XRANDR and XF86VidMode as DisplayMode switching thingys
I have tried it with Xinerama ON and OFF
I have tried with various resolutions, frequencies and color depths
I have tried screen setups with AMDCCLE, XRANDR and manual xorg.conf hacking
 ... nothing will work

The list in the log output doesnt show my fullscreen resolution. The actual desktop area is 3360x1050 but doesn't show up in the LWJGL list of compatible display modes, because it just returns the resolutions for one monitor and not for the whole screen.

Can someone help me out here?

Thanks already for even trying.
« Last Edit: December 14, 2010, 09:00:22 by dhdd »

Re: DisplayMode madness
« Reply #1 on: December 09, 2010, 17:52:11 »
In order to use both screens, you might have to create 2 different AWT windows and threads using Canvas, if this is possible.

Alternatively, you could set the location to negative coords so that the start is on the other monitor, but I don't know how your monitors are setup and this would only be possible in windowed mode -- if it even is possible.

Display.setDisplayMode(new DisplayMode(3360,1050));
Display.setFullscreen(false);
Display.setLocation(-1680,0);
Display.create();
Display.setLocation(-1680,0); //try again in case LWJGL centered our X
cool story, bro

Re: DisplayMode madness
« Reply #2 on: December 14, 2010, 06:17:34 »
Hi jediTofu.

Thanks for the answer, even though your second suggestion would work for me I have two questions:
 1. Do I have performance loss in fake-fullscreen windowed mode compared to fullscreen mode?
 2. The Ubuntu Taskbar is on top of the window , how can I get rid of that?

Thanks

UPDATE:
 2. -Dorg.lwjgl.opengl.Window.undecorated=true will remove the decorations of the window and in the gnome context menu "Always on Top" will move the window to the front. This is fix enough for me.

I'd still like an answer to 1. plz
« Last Edit: December 14, 2010, 07:50:23 by dhdd »

Re: DisplayMode madness
« Reply #3 on: December 14, 2010, 08:21:05 »
It could be a small performance hit, but nothing to write home about, I would think.

If you had wanted to go fullscreen to a smaller resolution, the performance hit would be more noticeable.  For example, a game running in 800x600 will run better than a game in 1024x768, especially if the game was designed for 800x600.  But, you had wanted to be in the same large resolution, so the only small performance hit will be in not being able to get fullscreen exclusive access.

You'll need to make sure that your users have both monitors as the same resolution.  In this case, 2 awt windows would be better.  That way you could make the window in the primary monitor fullscreen and set to the same resolution as the secondary monitor.

Out of curiosity, did you print out all of the possible fullscreen resolutions that LWJGL returned?  There might have been one for dual monitors.  There still might be a way to change the resolution of the secondary display; I haven't looked through the LWJGL javadoc for this, but I'm not even sure if all platforms can do this.
cool story, bro

Re: DisplayMode madness
« Reply #4 on: December 14, 2010, 08:49:06 »
Thanks for the info about the performance. Luckily I will deploy to one hardware platform only, so I know the exact hardware of the PC running the app and the monitors it'll use  ;)

Out of curiosity, did you print out all of the possible fullscreen resolutions that LWJGL returned?  There might have been one for dual monitors.  There still might be a way to change the resolution of the secondary display; I haven't looked through the LWJGL javadoc for this, but I'm not even sure if all platforms can do this.

Yes the list above contains the full log output of LWJGL. But this might interest you:
Code: [Select]
andgra@andgra01:~$ xrandr -q
Screen 0: minimum 320 x 200, current 3360 x 1050, maximum 3360 x 3360
DFP1 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 474mm x 296mm
   1680x1050      60.0*+   59.9 
   1400x1050      60.0 +
   1440x900       59.9 +
   1280x800       60.0 +   75.0 
   1152x648       60.0 +
   1280x1024      75.0     60.0 
   1280x960       60.0 
   1152x864       75.0     60.0 
   1280x768       59.9 
   1280x720       60.0 
   1024x768       75.0     70.1     60.0 
   1024x600       60.0 
   800x600        72.2     75.0     70.0     60.3     56.2 
   800x480        60.0 
   720x480        60.0 
   640x480        75.0     72.8     60.0 
DFP2 disconnected (normal left inverted right x axis y axis)
DFP3 disconnected (normal left inverted right x axis y axis)
DFP4 connected 1680x1050+1680+0 (normal left inverted right x axis y axis) 474mm x 296mm
   1680x1050      60.0*+   59.9 
   1400x1050      60.0 +
   1440x900       59.9 +
   1280x800       60.0 +   75.0 
   1152x648       60.0 +
   1280x1024      75.0     60.0 
   1280x960       60.0 
   1152x864       75.0     60.0 
   1280x768       59.9 
   1280x720       60.0 
   1024x768       75.0     70.1     60.0 
   1024x600       60.0 
   800x600        72.2     75.0     70.0     60.3     56.2 
   800x480        60.0 
   720x480        60.0 
   640x480        75.0     72.8     60.0 
CRT1 disconnected (normal left inverted right x axis y axis)
CRT2 disconnected (normal left inverted right x axis y axis)
TV disconnected (normal left inverted right x axis y axis)

As you can see the screen "Screen 0" has the resolution that I want and its listed in XRANDR ... However LWJGL just returns the exact same list as XRANDR lists under the monitor "DFP1".

Basically, under Ubuntu 8.04 I had an ATI BigDesktop running and LWJGL returned 3360x1050 as my single valid fullscreen resolution(!) Strangely now that I run 10.04 I cannot get BigDesktop to work and LWJGL returns all the resolutions BUT the one I need.

If we can still fix this so I can run my app in fullscreen it would be awesome.  ;)