Skip to content

changing BitsPerPixel in AppSettings interferes with StatsAppState  #801

@stephengold

Description

@stephengold

In windowed mode, my attempts to change the display's bits per pixel cause the StatsAppState bitmap text to disappear. But some geometries (such as the blue cube and the darkeners) are unaffected. I see this issue both with JME 3.1 and 3.2 . Interestingly, I don't see it in full-screen mode.

Here is my test app:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        AppSettings initialSettings = new AppSettings(true);
        initialSettings.setBitsPerPixel(24);

        Main app = new Main();
        app.setSettings(initialSettings);
        app.start();
    }

    @Override
    public void simpleInitApp() {
        viewPort.setBackgroundColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1f));

        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
        inputManager.addMapping("changeBpp", new KeyTrigger(KeyInput.KEY_P));
        ActionListener listener = new ActionListener() {
            @Override
            public void onAction(String name, boolean keyPressed, float tpf) {
                if (name.equals("changeBpp") && keyPressed) {
                    goWindowed();
                }
            }
        };
        inputManager.addListener(listener, "changeBpp");
    }

    void goWindowed() {
        AppSettings newSettings = new AppSettings(false);
        newSettings.copyFrom(settings);
        newSettings.setBitsPerPixel(16);

        setSettings(newSettings);
        restart();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions