When and Where Lock Nodes?

Hi,

Im trying to lock my scenary because it doesnt change at all but im getting exception:


Exception in thread "main" java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glGenLists(GL11.java:1359)
   at com.jme.renderer.lwjgl.LWJGLRenderer.createDisplayList(LWJGLRenderer.java:1480)
   at com.jme.scene.batch.GeomBatch.lockMeshes(GeomBatch.java:537)
   at com.jme.scene.Geometry.lockMeshes(Geometry.java:750)
   at com.jme.scene.SharedMesh.lockMeshes(SharedMesh.java:526)
   at com.jme.scene.Node.lockMeshes(Node.java:439)
   at com.jme.scene.Node.lockMeshes(Node.java:439)
   at com.jme.scene.Node.lockMeshes(Node.java:439)
   at com.jme.scene.Node.lockMeshes(Node.java:439)
   at com.jme.scene.Node.lockMeshes(Node.java:439)
   at com.jme.scene.SceneElement.lockMeshes(SceneElement.java:336)
   at com.jme.scene.SceneElement.lock(SceneElement.java:367)
   at br.com.foihcorp.v8gt.objects.Pista.initialize(Pista.java:106)
   at br.com.foihcorp.v8gt.objects.Pista.<init>(Pista.java:23)
   at br.com.foihcorp.v8gt.objects.World.<init>(World.java:17)
   at br.com.foihcorp.v8gt.factories.WorldFactory.getWorldInstance(WorldFactory.java:17)
   at br.com.foihcorp.v8gt.gamestates.V8GameState.initGameplay(V8GameState.java:170)
   at br.com.foihcorp.v8gt.gamestates.V8GameState.init(V8GameState.java:163)
   at br.com.foihcorp.v8gt.gamestates.V8GameState.<init>(V8GameState.java:92)
   at br.com.foihcorp.v8gt.gamestates.V8GameState.<init>(V8GameState.java:87)
   at br.com.foihcorp.v8gt.managers.V8Manager.getV8GameState(V8Manager.java:18)
   at br.com.foihcorp.v8gt.managers.V8Manager.getV8GameState(V8Manager.java:23)
   at br.com.foihcorp.v8gt.V8StreetDragGT.<init>(V8StreetDragGT.java:45)
   at br.com.foihcorp.v8gt.V8StreetDragGT.main(V8StreetDragGT.java:68)



Where do i have to call lock?

Im using SharedNodes.

if (gameIsMultiThreaded) {
  makeSureToCallLockInsideOpenGLThread();
}



<a href="http://www.jmonkeyengine.com/wiki/doku.php?id=some_standardgame_frequently_asked_questions#can_you_give_me_an_example_how_to_inject_game_tasks_into_the_opengl_thread">;-)

the Smiley points to an example

Its being called in the OGLThread

Im calling my method from the init of the GameState.

Its not on the OGLThread?

It will, then, depend on which object/method is calling your init on the GameState… From your stack trace I can see that this is coming from the main of your application. This might just not be right… check that you are really using GameStateManager and the like (done automatically for you if you use StandardGame)

here is the line on the gameState init:



at br.com.foihcorp.v8gt.gamestates.V8GameState.init(V8GameState.java:163)

This init is called on the V8GameState constructor.



Im using GameStateManager.


GameStateManager.getInstance().attachChild(gameManager.getV8GameState());


this getV8GameState instanciate the My custom GameState.
clovis said:

Im calling my method from the init of the GameState.
Its not on the OGLThread?

no, only the update and render methods are executed inside the OpenGL thread, if you use StandardGame that is.

If you look at JMEDesktopState, it also makes use of the GameTaskQueueManager in its constructor, when the OpenGL thread is needed.

Thanks!!! It worked now!

Now i understand a little more! Thanks for all replies!