[SOLVED] Fullscreen failing on laptop, why?

Started by wondersonic, June 30, 2010, 09:07:31

Previous topic - Next topic

wondersonic

Hi all,
From time to time, my game won't run in fullscreen. I get some exception from this code fragment:

           Display.setFullscreen(true);
            try {
                final DisplayMode[] availableDisplayModes = org.lwjgl.util.Display.getAvailableDisplayModes(
                        SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 32, 75, 75);
                org.lwjgl.util.Display.setDisplayMode(availableDisplayModes, new String[]{
                        "width=" + SCREEN_WIDTH,
                        "height=" + SCREEN_HEIGHT,
                        "freq=" + FRAME_RATE,
                        "bpp=" + 32
                });
            }
            catch (Exception e) {
                System.err.println("ERROR: could not start full screen mode, switching to windowed mode!");
                try {
                    Thread.sleep(3000L);
                }
                catch (InterruptedException ignored) {
                }
                Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT));
            }


Do you have any idea why?

I'm running this game with last LWJGL version on a laptop under Windows XP, would it be related to energy saving configuration?

Please, advise  ;D

Regards,
WS

S.

Matthias

If you get an exception it would help if you post the exception too (including stack trace).

princec

And when you say "time to time", do you mean randomly and intermittently on one machine, or just doesn't work randomly on some machines?

Cas :)

wondersonic

Quote from: Matthias on June 30, 2010, 09:49:52
If you get an exception it would help if you post the exception too (including stack trace).

Ok, I guess, I mask the exception to the user. I'll try to reproduce it asap and copy/paste it here.
S.

wondersonic

Quote from: princec on June 30, 2010, 10:51:05
And when you say "time to time", do you mean randomly and intermittently on one machine, or just doesn't work randomly on some machines?

Cas :)

I had the case on 1 laptop on which the fullscreen mode worked previously but now it seems to fail. I'll try to reproduce.
S.

wondersonic

The exception is:
java.lang.Exception: Failed to set display mode.
	at org.lwjgl.util.Display.setDisplayMode(Display.java:243)
	at tf4r.game.Game.createWindow(Game.java:829)
	at tf4r.game.Game.initialize(Game.java:329)
	at tf4r.game.Game.<init>(Game.java:284)
	at tf4r.Stub.run(Stub.java:57)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at tf4r.Main.main(Main.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
S.

wondersonic

Ok, I found the problem!

I'm too restrictive when asking for the video mode to set in fullscreen:

minimum frequency=75Hz
maximum frequency=75Hz

when decreasing minimum frequency down to 60Hz, this works!

                final DisplayMode[] availableDisplayModes = org.lwjgl.util.Display.getAvailableDisplayModes(
                        SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 32, 60, 75);


S.

Ciardhubh

Quote from: wondersonic on July 01, 2010, 06:28:08
when decreasing minimum frequency down to 60Hz, this works!

Keep in mind that frequency on Linux (at least some) is somewhat weird and doesn't necessarily correspond to the actual frequency. That is, if you want your apps to run on Linux. There are a lot of modes with unusual frequencies in the range of 50-60. The frequency attribute appears to be "abused" as some kind of ID for display modes.

For example on my Ubuntu desktop computer I get these modes:
1280 x 960 x 24 @50Hz
1280 x 960 x 24 @51Hz
1152 x 864 x 24 @52Hz
1152 x 864 x 24 @53Hz
1152 x 864 x 24 @54Hz
1152 x 864 x 24 @55Hz
1152 x 864 x 24 @56Hz
1152 x 864 x 24 @57Hz
1152 x 864 x 24 @58Hz
1024 x 768 x 24 @59Hz
1024 x 768 x 24 @60Hz
1024 x 768 x 24 @61Hz
1024 x 768 x 24 @62Hz
1024 x 768 x 24 @63Hz
960 x 600 x 24 @64Hz
960 x 540 x 24 @65Hz
840 x 525 x 24 @66Hz
840 x 525 x 24 @67Hz
840 x 525 x 24 @68Hz
840 x 525 x 24 @69Hz
840 x 525 x 24 @70Hz
832 x 624 x 24 @71Hz
800 x 600 x 24 @72Hz
800 x 600 x 24 @73Hz
800 x 600 x 24 @74Hz
800 x 600 x 24 @75Hz
800 x 600 x 24 @76Hz
720 x 450 x 24 @77Hz
720 x 400 x 24 @78Hz
700 x 525 x 24 @79Hz
700 x 525 x 24 @80Hz
680 x 384 x 24 @81Hz
680 x 384 x 24 @82Hz
640 x 480 x 24 @83Hz
640 x 480 x 24 @84Hz
640 x 480 x 24 @85Hz
640 x 480 x 24 @86Hz
640 x 480 x 24 @87Hz
640 x 480 x 24 @88Hz
640 x 400 x 24 @89Hz
640 x 350 x 24 @90Hz
512 x 384 x 24 @91Hz
512 x 384 x 24 @92Hz
512 x 384 x 24 @93Hz
400 x 300 x 24 @94Hz
320 x 240 x 24 @95Hz
320 x 240 x 24 @96Hz
320 x 175 x 24 @97Hz

Matthias

The best way to get reliable full screen mode is to just use the desktop resolution & settings - eg the initial DisplayMode. You can use Display.setParent and Display.setFullscreen easily together without the need to set a DisplayMode.

wondersonic

Quote from: Matthias on July 01, 2010, 10:37:30
The best way to get reliable full screen mode is to just use the desktop resolution & settings - eg the initial DisplayMode. You can use Display.setParent and Display.setFullscreen easily together without the need to set a DisplayMode.

Quote from: Ciardhubh on July 01, 2010, 10:04:37
Quote from: wondersonic on July 01, 2010, 06:28:08
when decreasing minimum frequency down to 60Hz, this works!

Keep in mind that frequency on Linux (at least some) is somewhat weird and doesn't necessarily correspond to the actual frequency. That is, if you want your apps to run on Linux. There are a lot of modes with unusual frequencies in the range of 50-60. The frequency attribute appears to be "abused" as some kind of ID for display modes.
...

Thank you both!

Indeed, weird frequencies!  :o
S.