Fenggui problem and question

This is a copy of a post from the Fenggui forums

problem: FengGui is displayed under all jME content.  I read this post: http://www.fenggui.org/forum/index.php?topic=13.60  and am wondering if this is still the proper workaround?

     * Reset RenderStates before rendering FengGUI,
     * especially the TextureState.
    public void render(float tpf) {
        // set a default TextureState, tis is needed to not let FengGUI inherit
        // wrong Texture coordinates and stuff.
        Texture defTex = TextureState.getDefaultTexture().createSimpleClone();
        defTex.setScale(new Vector3f(1, 1, 1));
        TextureState defaultTextureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        // render the GUI

Here is the render method that core-dump has posted at the jME tutorials.

   protected void render(float interpolation)
      // First we draw our jME scene.  This must be called before
      //   anything will even show up.
      //   FIXME: This throws a NullPointerException when the app exits.
      //          Must investigate why.
      // We could draw the GUI here, but I find it cleaner to just do
      //    all the jME engine calls together.
      // Then we display the GUI

Here is the render method from a simple_fenggui_jme_app; which is very close to what I am doing now, rendering the GUI as the very last thing in my scene.

Where I am confused is which is the correct approach?  the one discussed in the forum post?  or just call disp.display() as the last thing to render?
I have tried setting disp.setDepthTestEnabled( true ); but to no avail.

My next question is about a custom GUI object: basically its one large area which listens for mouse clicks and two smaller circles that also listen for mouse clicks, one of which also listens for dragged mouse.  My question is how to go about implementing this?  I read the post that gave a brief tutorial about creating custom widgets, but was left with more questions.  Is there a quick example showing the creation of such a custom widget?

I didn't have any problems yet when using separate GameStates, but you need to attach the FengGuiGamestates as the last State. (which could be problematic if you want to dynamically create GameStates while the Game is running.

Maybe using a RenderPass for FengGUI would be the best way to separate FengGUI from the rest of jME.

Actually this line was the problem (in my main graphics gamestate not the GUI)

rootNode.setRenderQueueMode( DisplaySystem.getDisplaySystem().getRenderer().QUEUE_OPAQUE );

Weird, since I thought it was the transparent bucket that was causing the problems…

At which point the gui was on top, but all garbled which was fixed by using your default texture fix :D, thanks

Wouldn't it be better to use a single pre-constructed defaultTextureState as a pose to creating a new one each render loop?

oh yeah, just re-read my first post (copy from fengGui forum) this is the post I was referring to http://www.fenggui.org/forum/index.php?topic=13.60

basixs said:

Wouldn't it be better to use a single pre-constructed defaultTextureState as a pose to creating a new one each render loop?

Probably yes,  creating a new TextureState and Texture each loop is far from optimal  hehe.
There is actually the Renderer.defaultStateList[].
But i remember, only calling apply() on the defaultTextureState did not keep FengGUI from inheriting the wrong Texture coordinates or something.

Gotcha, thanks :smiley: