NullPointerException in LWJGLRenderer.draw

Hi everyone,

I get this exception not every time I start my application but about every second to third time.

Due to that erratic behaviour I assume it is a threading problem but I have been unable to debug into it.

As you can see I use an extention of StandardGame. I use several GameStates one of which is a JMEDesktopState.

Any help or hints is appreciated.


18:12:41 [12] com.jmex.game.DefaultUncaughtExceptionHandler->uncaughtException() - SCHWERWIEGEND: Main game loop broken by uncaught exception
java.lang.NullPointerException
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(LWJGLRenderer.java:945)
   at com.jme.scene.batch.TriangleBatch.draw(TriangleBatch.java:255)
   at com.jme.renderer.RenderQueue.renderOrthoBucket(RenderQueue.java:301)
   at com.jme.renderer.RenderQueue.renderBuckets(RenderQueue.java:240)
   at com.jme.renderer.Renderer.renderQueue(Renderer.java:452)
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(LWJGLRenderer.java:509)
   at com.jmex.game.StandardGame.run(StandardGame.java:200)
   at java.lang.Thread.run(Thread.java:619)

Don't modify the scenegraph while it is being updated or rendered (your case). In StandardGame you need to use locking. I never used StandardGame myself, so maybe someone else can tell you the exact code lines required for locking if you do not know them.

Check the wiki:



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



You need to either call game.lock(); game.unlock(); or use the GameQueue to insert code into the GL-thread

Thanks a lot that should have fixed my problem!