Struggling with Fullscreen mode

Theres lots of games, heck, even the OS monitor settings where you can specify parameters that will make your setup not work. The display settings in the jME settings screen are taken from AWT/Swing.

Your graphics adapter specifies 25 Hz as a valid refresh rate for the display, which is why it is listed as one of the refresh rates in the combo box. This is common for e.g. PAL televisions which use a 25 Hz progressive refresh rate.

I think a more interesting discussion is what value should jME3 prefer to select by default. For example, I’ve seen displays that support 75 Hz, 70 Hz, 59 Hz, 50 Hz (PAL interlaced), and 40 Hz (power save on laptop). Clearly choosing the largest or the lowest value is not preferable, perhaps jME3 should choose the closest frequency to 60 Hz?

1 Like

This sounds good to me :ok_hand:

I’m not sure it is. There is no default “best setting” - and JME simply offers you everything that has been reported as viable for your system. Your game would generally query the user if no settings file has been created, or if the previously chosen setting no longer matches any reported configuration.

I believe windows holds the current desktop refresh rate in the registry, but I have no idea how nix or mac store it. That could be one way to guarantee a working resolution/refresh rate - and then allowing the user to change it via in-game settings.

EDIT: It seems that windows changes it’s storage location from within the registry in XP, Vista/7 and Windows 8/8.1 so that kinda makes native collection a pain.

I generally agree with @jayfella; however please note that we are talking about how to avoid an issue that shows with the code in the wiki… when no other information is known, is probably better to avoid to set as default a configuration that is more likely than others to cause a crash.

setFrequency(0);

Oh, sorry. Thanks for the info, I will try this.

The issue happens to me since I upgraded to 3.1.
Is it LWJGL related?

Source:

package mygame;

import com.jme3.app.SimpleApplication;

public class Test extends SimpleApplication {

    public static void main(String[] args) {
        Test app = new Test();
        app.start();
    }

    @Override
    public void simpleInitApp() {
    }
}

On the settings screen:

Fullscreen: Yes
VSync: No
Gamma correction: No
Screen Resolution: 1280 x 1024 (this is the max resolution for my display monitor)
Color Depth: 24 bpp (no other option available)
Refresh Rate: 50 Hz (no other option available)
Anti-Aliasing: Disabled

And the error message:

run:
sep 26, 2016 1:32:02 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.1-beta1
 * Branch: HEAD
 * Git Hash: 310f4db
 * Build Date: 2016-04-25
sep 26, 2016 1:32:03 AM com.jme3.app.LegacyApplication handleError
SEVERE: Failed to create display
java.lang.RuntimeException: Unable to find fullscreen display mode matching settings
	at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:79)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
	at java.lang.Thread.run(Thread.java:745)

sep 26, 2016 1:32:03 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run
SEVERE: Display initialization failed. Cannot continue.

I didn’t have the issue on 3.0.

On 3.0 are your options the same?

Yes, it was before I upgrade it. And it worked in fullscreen mode perfectly.

Edit: I’m on Ubuntu 16.04 LTS 64-Bit with OpenJDK 1.8.0_91.

So all of those options were exactly the same including the “no other option available” part and the odd 50 hz setting, etc.? And note: “I’m pretty sure” is not the same as “definitely sure”… and it matters.

Trying to decide if it’s the settings dialog screwing up on what options it gives you or something else that changed.

OK, I re-installed jME 3.0 and tried to run the code again. It worked with the same options as follows:

Fullscreen: Yes
VSync: No
Screen Resolution: 1280 x 1024
Color Depth: 24 bpp (only option available)
Refresh Rate: 50 Hz (only option available)
Anti-Aliasing: Disabled

Messages:

run:
sep 26, 2016 2:47:44 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.10
sep 26, 2016 2:47:44 AM com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: /home/fba/Projetos/jme3/BasicGameTest
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: null
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: null
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: NVIDIA Corporation
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.5.0 NVIDIA 361.42
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: GeForce GTX 550 Ti/PCIe/SSE2
sep 26, 2016 2:47:45 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.50 NVIDIA
sep 26, 2016 2:47:45 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
sep 26, 2016 2:47:45 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4

I’m using the NVIDIA binary driver version 361.42 from the Ubuntu repositories.
Maybe a bug in LWJGL since jME 3.0 uses version 2.9 and jME 3.1 uses version 3.0?

Nope, 3.1 uses lwjgl 2.9. or am i wrong @Momoko_Fan?

Anything is possible… but at least we know the app settings dialog’s detection changes didn’t break this.

Oh, yeah… what he said.

You have to do something special to get 3.1 to use lwjgl 3 I think.

That’s right, jME3.0 uses LWJGL 2.9.0 and jME3.1 uses LWJGL 2.9.3.

There are differences though on the method runloop() of the class LwjglAbstractDisplay, which seems to be to cause of the issue. Unfortunately I can’t debug it right now since I’m not at home at this moment. I’ll try to check it later tonight when I’m home from work. Hopefully some of you guys can see it in the mean time?

Edit: the class is actually in the com.jme3.system.lwjgl package.

The display modes shown in the settings dialog are coming from AWT, so they might not match exactly with LWJGL’s modes. I looked at the display mode matching code and I don’t see any changes on the jME side that would cause this.

If you’re feeling adventurous, you can run this small test program to print what LWJGL thinks the display modes are and see if the 1280x1024@50Hz mode is listed:

import com.jme3.system.NativeLibraryLoader;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class PrintDisplayModes {
    public static void main(String[] args) throws LWJGLException {
        NativeLibraryLoader.loadNativeLibrary("lwjgl", true);
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (DisplayMode mode : modes) {
            System.out.println(mode);
        }
    }
}

Try with jME 3.0 and jME 3.1 and see if makes a difference.

Just tested locally and compared the results from LWJGL 2 and 3… Apparently the ones coming from LWJGL 2 correspond to another monitor I have connected but not actually enabled. The ones from Java and LWJGL 3 do correspond with the enabled monitor. So I think once we switch to LWJGL 3 this issue should be fixed.

Then I wonder if you know why it worked on 3.0 and not on 3.1 with the exact same settings, etc… That’s what I was doing: eliminating the settings as the issue.

Thank you, @Momoko_Fan. I hope the issue will be fixed with LWJGL 3.

Anyway, I tried your code on jME 3.0 and jME 3.1 as you asked, though there is no NativeLibraryLoader on jME 3.0. I just commented that line and the results are as follows:

jME 3.0 (without NativeLibraryLoader)

run:
640 x 480 x 24 @56Hz
1280 x 800 x 24 @57Hz
1280 x 720 x 24 @58Hz
800 x 600 x 24 @53Hz
800 x 600 x 24 @54Hz
1280 x 1024 x 24 @50Hz
1024 x 768 x 24 @51Hz
1024 x 768 x 24 @52Hz
640 x 480 x 24 @55Hz

jME 3.1 (with NativeLibraryLoader)

run:
1024 x 768 x 24 @75Hz
640 x 480 x 24 @75Hz
640 x 480 x 24 @59Hz
1280 x 1024 x 24 @60Hz
1024 x 768 x 24 @60Hz
800 x 600 x 24 @75Hz
800 x 600 x 24 @60Hz

The lowest value for Hertz on 3.1 is 59Hz. I commented the NativeLibraryLoader line and the results are just the same.

OK, found a workaround.

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;

public class ScreenTest extends SimpleApplication {

	public static void main(String[] args) {
		AppSettings settings = new AppSettings(true);
		settings.setResolution(1280, 1024);
		settings.setFrequency(60); // <--- that does the trick
		settings.setFullscreen(true);

		ScreenTest screenTest = new ScreenTest();
		screenTest.setSettings(settings);
		screenTest.setShowSettings(false);
		screenTest.start();
	}

	@Override
	public void simpleInitApp() {
	}
}

Something is not right with the settings window. Why it doesn’t show the correct refresh rate for full screen mode?