StandardGame With GLSLShaderObjectsState throw NPException

   public static void main(String[] args) throws Exception {
      // Instantiate StandardGame
      StandardGame game = new StandardGame("A Simple Test");
      // Show settings screen
      if (GameSettingsPanel.prompt(game.getSettings())) {
         // Start StandardGame, it will block until it has initialized successfully, then return
         game.start();
         
         /* Just try to create GLSLShaderObjectsState */
         game.getDisplay().getRenderer().createGLSLShaderObjectsState();

         // Create a DebugGameState - has all the built-in features that SimpleGame provides
         // NOTE: for a distributable game implementation you'll want to use something like
         // BasicGameState instead and provide control features yourself.
         DebugGameState state = new DebugGameState();
         // Put our box in it
         Box box = new Box("my box", new Vector3f(0, 0, 0), 2, 2, 2);
          box.setModelBound(new BoundingSphere());
          box.updateModelBound();
          // We had to add the following line because the render thread is already running
          // Anytime we add content we need to updateRenderState or we get funky effects
          box.updateRenderState();
          state.getRootNode().attachChild(box);
         // Add it to the manager
         GameStateManager.getInstance().attachChild(state);
         // Activate the game state
         state.setActive(true);
      }
   }



This is the TestStandardGame class, with this line: "game.getDisplay().getRenderer().createGLSLShaderObjectsState();" throw this NullPointerException:


Exception in thread "main" java.lang.NullPointerException
   at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.isSupported(LWJGLShaderObjectsState.java:125)
   at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.<init>(LWJGLShaderObjectsState.java:91)
   at com.jme.renderer.lwjgl.LWJGLRenderer.createGLSLShaderObjectsState(LWJGLRenderer.java:379)
   at jmetest.game.TestStandardGame.main(TestStandardGame.java:60)



:?

I don't think the renderer is ready in this call, maybe you need to throw it in a queue first?

Actually, game.start() blocks until it is actually running the main game loop successfully before returning, but the latter statement was probably the cause of his problems.



anykeyh, if you put it in the GameTaskQueue it should resolve your issue as my assumption is that is doing something directly to OpenGL so it must be run in the OpenGL thread.