Skybox problem's in PhysicsGameState

Hi guys!



I'm trying to create a skybox in my class that extends PhysicsGameState and i get the error:


java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1348)
   at com.jme.scene.state.lwjgl.LWJGLTextureState.load(LWJGLTextureState.java:303)
   at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(LWJGLTextureState.java:881)
   at com.jme.scene.Skybox.preloadTextures(Skybox.java:264)



My skybox code is correct because i used it in a classe extended from SimplePassGame and worked fine.

What is the problem? I can only use skybox in simplepassgame??

Don't use the Skybox.preloadTextures() method inside the gamestate's constructor. This is a known problem and darkfrog has refused to fix it when I asked him about it 2 years ago.

refused to fix it ?  :roll:



The problem is that it some Methods need to be called inside the opengl thread.

You need to use a GameTaskQueue to execute those methods in the correct thread.

The Wiki has a lot of info about StandardGame / Threads / GameTaskQueue

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



There is also a incomplete list of Methods which need to be called inside the opengl thread.

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

Thank's guys!



Like Core-Dump said, i needed to create a GameTaskQueueManager so i put my preloadTextures method inside it.



        Callable<Object> preload = new Callable<Object>() {
            public Object call() throws Exception {
                preloadTextures();
                return null;
            }
        };
        GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER)
                .enqueue(preload);



Now it work's fine!! Thanks again!