Problems setting AppSettings in JME3.1.0-beta1

Hi,
Yesterday I started (again) with JME, but now with fancy version 3.1.0-beta1. I started playing around with Lemur and thought about creating a native settings screen. But I soon ran into trouble applying the settings…
When I update some AppSettings, set them on the SimpleApplication object and calling restart(), strange stuff starts to happen. Rendering is broken, some settings are just not taken into account etc…
I created a test case to try out and added some screenshots.

Am I doing something wrong?

Applying settings before calling start(): OK

Applying settings later and called restart(): NOK Lemur gui is broken, StatsAppState is not visible anymore, …

Test case:

public class AppSettingsProblem extends SimpleApplication {

    public static void main(String[] args) {
        AppSettingsProblem appSettingsProblem = new AppSettingsProblem();
        // this will work ok
        AppSettings settings = new AppSettings(true);
        settings.setSamples(8);
        appSettingsProblem.setSettings(settings);
        appSettingsProblem.setShowSettings(false);
        appSettingsProblem.start();
    }

    @Override
    public void simpleInitApp() {
        GuiGlobals.initialize(this);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");

        drawBox();
        someLemur();

        // this will not work
//        AppSettings settings = getContext().getSettings();
//        settings.setSamples(2);
//        this.setSettings(settings);
//        this.restart();
    }

    private void drawBox() {
        Geometry geometry = new Geometry("box", new Box(1, 1, 1));
        Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        material.setColor("Color", ColorRGBA.Blue);
        Texture texture = assetManager.loadTexture("Textures/Monkey.png");
        material.setTexture("ColorMap", texture);
        geometry.setMaterial(material);
        rootNode.attachChild(geometry);
    }

    private void someLemur() {
        Container container = new Container();
        container.addChild(new Label("Placeholder"));
        container.addChild(new Button("Button"));
        container.setLocalTranslation(new Vector3f(0, getContext().getSettings().getHeight(), 0));
        getGuiNode().attachChild(container);
    }
}

In the test case I just use Anti Aliasing as a sample, but other settings also cause this behaviour…

This is a case where I set gamma correction enabled before calling start().


Here I set gamma correction later on and call restart(). You can clearly see at the Lemur gui that this is not turned on.

Same issue when setting BitsPerPixel etc… (yes the resolution/refresh rate/bpp is supported by my gfx card)

simpleInitApp() is special… pretty sure that’s a bad place to try to restart the app since it hasn’t even fully started yet.

Since you have a button… maybe try hooking the change on the button click. It would at least eliminate simpleInitApp() as being the issue.

I’ve changed settings at runtime before but I don’t remember what version of JME it was.

It’s just in this test case I apply the settings in the simleInitApp() method. On my actual ‘project’ it’s in an AppState when the app is already running. So initialisation etc is already long done…

I’ll update the test case… I also used to do this frequently in 3.0, this is the first time I ran into trouble.
Maybe it’s mac related, it will certainly not be the first time :slight_smile:

edit: updated test case. The settings will apply when you push the button.

public class AppSettingsProblem extends SimpleApplication {

    public static void main(String[] args) {
        AppSettingsProblem appSettingsProblem = new AppSettingsProblem();
        AppSettings settings = new AppSettings(true);
        settings.setSamples(8);
        settings.setGammaCorrection(false);
        appSettingsProblem.setSettings(settings);
        appSettingsProblem.setShowSettings(false);
        appSettingsProblem.start();
    }

    public AppSettingsProblem() {
        super(new StatsAppState());
    }

    @Override
    public void simpleInitApp() {
        GuiGlobals.initialize(this);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");

        drawBox();
        someLemur();
    }

    private void drawBox() {
        Geometry geometry = new Geometry("box", new Box(1, 1, 1));
        Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        material.setColor("Color", ColorRGBA.Blue);
        Texture texture = assetManager.loadTexture("Textures/Monkey.png");
        material.setTexture("ColorMap", texture);
        geometry.setMaterial(material);
        rootNode.attachChild(geometry);
    }

    private void someLemur() {
        Container container = new Container();
        container.addChild(new Label("Placeholder"));
        Button button = container.addChild(new Button("Button"));
        button.addClickCommands((Command<Button>) source -> updateSettings());
        container.setLocalTranslation(new Vector3f(0, getContext().getSettings().getHeight(), 0));
        getGuiNode().attachChild(container);
    }

    private void updateSettings() {
        AppSettings settings = getContext().getSettings();
        settings.setSamples(2);
        settings.setGammaCorrection(true);
        this.setSettings(settings);
        this.restart();
    }
}

before click:

after click:

edit2: same problem on a Dell running Windows 10. When setting the renderer to use LWJGL3, the screen goes completely black when pushing the button :confused:

Hi! I have exactly same issue. Using JME 3.1 and lwjgl3 on Win7. Is anyone have sometrouble like it? Any solutions?