Holding on to gl context in JSR-231

I’m using JSR-231 and mustang b60 (all those after 60 have an issue with using webstart and jogl jar files) and vaughly remember reading somewhere that issuing calls on a gl context outside of the event listener methods would be handled by the library. I’m looking now to verify this but I can’t find it again (maybe its alzimers setting in).

My question is, with JSR-231 and mustang can I issue calls to a gl context in a separate thread from the event listener thread and it will handle the threading issues, or must I continue to setup things and then issue a request for a refresh during which I update the gl context.

To be more explicit, if I wish to stream data to vertex buffer objects via another thread, can I call GLU().getCurrentGL() from inside that thread and use the gl object to stream the data to the card.

JOGL will handle the correct multithreading only if you use the GLEventListener mechanism. If you get the GLContext and make it current on the current thread explicitly then there is nothing the library can do. You can invoke a Runnable on the “OpenGL” thread using the Threading class, but I would suggest you just set up state and hand the data back to your GLEventListener for processing.

I was looking in the TextureIO class and saw where they have some methods:

glGetInteger(int pname), and glGetTexLevelParameteri(…)

which used the GLU().getCurrentGL(). So this means that these should only be used during one of the GLEventListener calls. So my next question is then how do I asynchronously load textures and then get a signal when it is loaded so I can use it.

Yes, these methods must only be called when an OpenGL context is active. Note that the methods which load a TextureData rather than a Texture do not require an OpenGL context to be current; only the conversion of a TextureData to a Texture (also done by TextureIO) requires a current context. You can write a simple asynchronous loader which produces TextureData objects for your main thread. We don’t provide one at the moment, though if you have suggestions about how to write a general one please feel free to offer them or help contribute some code.

In your initial implementation I would suggest just loading the textures synchronously in your main loop and only switching to an asynchronous model if you find that you see unacceptable pauses during rendering or similar.