TextureStates across Threads

I found that if I pass a reference of a Spatial to another thread and , in this other thread, I try to set a TextureState to the Spatial,

JVM crashes because of  some kind of sigsev in the monitors . Is it normal?

p.s. The same code in works perfectly if executed in the same thread.

Thank you very much!

I will try! :slight_smile:

Good afternoon,

I'm suffering from the same problem as Al3TT0.

Me and four classmates are developing a paragliding simulation as a project for school. We thought it might be nice to build a loading screen to display some interactivity while a lot of loading is done (paraglider, world, hud, terrain, physics… etc).

The idea was to create a user thread to which a spatial was passed, and execute some of the methods in that spatial (the loading), while the JME thread would continue and show a loading screen. This was to go on until the user thread set a boolean indicating that the loading was complete, after which the JME thread would continue handling the game.

This caused me to run into the same problem as the topicstarter. When the user thread tried to create a texture state, an EXCEPTION_ACCESS_VIOLATION occured. After implementing llama's hack the user thread no longer ran into this violation, but now the next line of code is causing us trouble, and we can't seem to fix this on our own. This is the line of code causing trouble:


Here the texture being loaded is a 256*256 22KB JPEG picture, and this is the trouble it's causing:

Exception in thread "LoadingManager" java.lang.ArrayIndexOutOfBoundsException: 0

The real big reason (besides your normal thread joys) behind thread difficulties with jME is that OpenGL is really single threaded in nature…

Thanks for your reply :).

I don't think we'll be going through such a lot of fuss for a loading screen then, since we've got a lot of things which priorities are somewhat higher than of a loading screen ;)… but thanks anyway. Such a class in the future would be a nice thing though.

I've been away for a while; I completely agree with renanse and I was thinkin' about organizing GL calls in a blackboard architecture.

A component contains all data(Spatials etc.) and  the other threads read and write data from that component(just like if it was a blackboard).

Only a control thread(the one that instantiates the blackboard component)makes calls to GL.

Give a look to the Blackboard pattern If u find it interesting.

Bye  :slight_smile: