I'm having a problem with some code I'm trying to move from the BaseSimpleGame framework to the StandardGame framework. The problem appears to be something missing from the setup of the DisplaySystem or its Renderer, but I can't quite figure out what it is. In the StandardGame version, GLContext.getCapabilities() is returning null, which causes null pointer exceptions in a few functions like the following:
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:1960)
at com.jme.scene.state.lwjgl.records.RendererRecord.switchMode(RendererRecord.java:25)
at com.jme.renderer.lwjgl.LWJGLCamera.doFrustumChange(LWJGLCamera.java:172)
at com.jme.renderer.lwjgl.LWJGLCamera.apply(LWJGLCamera.java:134)
at com.jme.renderer.lwjgl.LWJGLCamera.<init>(LWJGLCamera.java:75)
at com.jme.renderer.lwjgl.LWJGLRenderer.createCamera(LWJGLRenderer.java:239)
or:
Exception in thread "main" java.lang.NullPointerException
com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.isSupported(LWJGLShaderObjectsState.java:122)
at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.<init>(LWJGLShaderObjectsState.java:88)
at com.jme.renderer.lwjgl.LWJGLRenderer.createGLSLShaderObjectsState(LWJGLRenderer.java:380)
Does anyone have any idea what's missing that would be causing these errors? Both of these functions work just fine when called in a subclass of BaseSimpleGame.
Update: It appears that the problem is not that something is missing from StandardGame, but that it's doing something which causes these functions to break.
Certain methods who access the GL Context need to be called from inside the openGL Thread.
Use the GameTaskQueueManager to call the methods who throw NPE's.
Search the wiki for StandardGame or GameTaskQueue Manager, there are a few good articles describing the problem.
Thanks, Core-Dump. That helped a lot; it's working now that I moved the functions into the right thread.