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.
*/
@Override
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();
defaultTextureState.setTexture(defTex);
defaultTextureState.apply();
// render the GUI
disp.display();
}
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.
display.getRenderer().clearBuffers();
// We could draw the GUI here, but I find it cleaner to just do
// all the jME engine calls together.
display.getRenderer().draw(rootNode);
// Then we display the GUI
disp.display();
}
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?