Hello
Here’s my problem. I’m developing a 3d application with gui, which downloads through internet models and textures. Downloading takes 30 seconds and during that time GUI is obviously frozen. So I decided to move the loading procedure to another thread and display progress bar but unfortunately I got stuck
Here’s pseudocode snippet:
GLContext glContext;
boolean contextLost = false;
class Loader implements Runnable {
public void run()
{
contextLost=true;
glContext.makeCurrent();
LoadModel(); // create texture objects, VBOs and so on...
glContext.release();
}
}
public void init(GLAutoDrawable drawable)
{
initopengl();
glContext = drawable.getContext();
glContext.release();
StartLoaderThread();
}
public void display(GLAutoDrawable drawable)
{
if(stillLoadingModel)
return;
if(contextLost==true)
{
contextLost=false;
glContext.makeCurrent();
}
RenderScene();
}
It doesn’t work. Application throws an exception.
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: No OpenGL context is current on this thread
I tried also to create second context (which would share all data with the main one) with GLCanvas createContext(GLContext shareWith) method but it throws exception
Exception in thread "Thread-4" javax.media.opengl.GLException: Surface already locked
I’m no expert in multithreading jogl apps so if someone helped me with that issue I would be grateful
EDIT:
After having changed GLCanvas to GLJPanel createContext(GLContext shareWith) works but another error occurs. I create second context in the main thread and then call on that context makeCurrent from another thread. Although it works on Mac OS X without a glitch, on Windows Vista app throws an exception: (inside 2nd thread) wglShareLists failed :(. Any ideas ?