Problem with StandardGame

I have the following problem:



I create a StandardGame and in the first dialog I only show some FengGUI buttons!

The FengGUI extends GameState.

Now, if you clicked at one button , I want to show a

new display with an 3D graphic and some FengGUI elements like in the

following example:

http://www.jmonkeyengine.com/wiki/doku.php?id=fenggui_jme_appl_using_standardgame



Therefore, I cleanup my standardgame:


GameStateManager.getInstance().cleanup();
         
if ( DisplaySystem.getDisplaySystem() != null && DisplaySystem.getDisplaySystem().getRenderer() != null)
{
   DisplaySystem.getDisplaySystem().getRenderer().cleanup();
   DisplaySystem.getDisplaySystem().getRenderer().clearZBuffer();
}
TextureManager.clearCache();
TextureManager.doTextureCleanup();
DisplaySystem.getDisplaySystem().getCurrentContext().invalidateStates();
KeyInput.destroyIfInitalized();
MouseInput.destroyIfInitalized();
JoystickInput.destroyIfInitalized();
          
DisplaySystem.getDisplaySystem().reset();
DisplaySystem.getDisplaySystem().close();
standardGame.finish();



And now I want to create a new StandardGame:

StandardGame game = new StandardGame( "New game" );
   
game.getSettings().setVerticalSync( true );
game.getSettings().setFullscreen( false );
game.getSettings().setWidth( PropertiesIO.DEFAULT_WIDTH + 160 );
game.getSettings().setHeight( PropertiesIO.DEFAULT_HEIGHT + 120 );
game.start();
         
CreateJME3d app3d = new CreateJME3d();
app3d.setActive( true );
      
// add 3d graphic to game
GameStateManager.getInstance().attachChild( app3d );
      
try
{
   GameTaskQueueManager.getManager().render( new Callable<Object>()
   {
      public Object call() throws Exception
      {
         // add Fenggui elements to game
         FengGuiState feng = new FengGuiState();
         feng.setActive( true );
         GameStateManager.getInstance().attachChild( feng );
         return null;
      }
   }).get();
}catch(Exception e)
{
   e.printStackTrace();
}



When I start it, I can the 3D elements for a short moment and then I get
a black screen and I get the following error:

java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glDisable(GL11.java:995)
at com.jme.scene.state.lwjgl.LWJGLZBufferState.enableDepthTest(Unknown Source)
at com.jme.scene.state.lwjgl.LWJGLZBufferState.apply(Unknown Source)
at com.jme.renderer.lwjgl.LWJGLRenderer.clearBuffers(Unknown Source)
at com.jmex.game.StandardGame.render(Unknown Source)
at com.jmex.game.StandardGame.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Did I forget something when cleanup? Or how can I restart my StandardGame?

Hmm, that looks like an openGL error to me; something that should have been done in the openGL thread wasn't…