Waiting for GL Thread


I'm usding a slightly outdated version of JME (the one compatible with the physics2 library from April 06) and would like to know if it is possible to wait for the GL thread to have finished rendering. My problem is I'm using a JMEcanvas to render a physics simulation. The simulation and rendering updates are perfomed from the same thread. Everything works pretty well as long as I include a pause after the rendering. The code looks like this:

for(int i=0; i<simulationSteps;i++){





If I don't pause, I get an Error saying: "Invalid operation for locked space." followed by a native

JVM crash.

I guess I have understood  that it's not a good idea to change the simulation while it is rendered, but how could I find out when it is save to update the simulation again? Unforunately I don't have the source code of the old JME version I'm using (I downloaded it from the physics2 webside, and they don't offer the source for this version). But I found out that I don't have classes like GameTaskQueueManager or StandardGame?

Is there a way to wait for the GL thread? Or am I completely wrong in my understanding of the problem?



If you want one thread to wait on the OpenGL thread before doing your work StandardGame has this feature built-in with the lock() / unlock() methods, but they are pretty simple to reproduce in your own code, the concept is just basic locking.

Thank's I will have a look into StandardGame. I additionally have manged download and compile the cvs versions from physics2 and jme  :slight_smile: