[SOLVED] Nifty Interface rendered behind everything else

I’m using the following code to display a simple “hello world” message in the center of the screen. It does display, but only behind my scene.

NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(
    assets, inputs, app.getAudioRenderer(), viewPort);
Nifty nifty = niftyDisplay.getNifty();
try {
    nifty.validateXml("Interface/game interface.xml");
} catch (Exception ex) {
nifty.fromXml("Interface/game interface.xml", "start");

How do I fix this?

1 Like

Not an answer to your question but as it looks like you’re just starting out with Nifty, be aware that its not really well liked any more and Lemur is probably a better bet for a new project.


In your code fragment, you appear to be adding the NiftyJmeDisplay scene processor to the main viewport. However, it’s possible to change the order in which the main scene and Nifty are rendered.

Viewports are generally rendered back-to-front. To render Nifty after the main scene, you’ll want to add its scene processor to a “post” viewport — one that’s rendered after the main scene.

In the jme3-examples project, this is usually done by adding to the GUI viewport, like so:


Here’s a code fragment that I use to create a custom “post” viewport and add the scene processor to it:

            int height = cam.getHeight();
            int width = cam.getWidth();
            Camera niftyCam = new Camera(width, height);
            ViewPort niftyView = renderManager.createPostView("NiftyGUI", niftyCam);
1 Like

That worked. Thank you! :grinning:

1 Like