I encountered a similar problem when I started learning Opengl (JOGL) for the "GL2 gl" months ago.... and then I discovered how to solve (everything having something to do with "gl" should be called from within the display/init method).
After some time I also needed to use the "GLU glu" (for the gluOrtho2D). Therefore this problem arose again. But lets say that it wasn't such a big problem, because the program was running fine despite this error.
Unfortunately, it seems that now this problem has some annoying effects.. so I really would like to solve it.
Here some code:
...
GLU glu = new GLU();
public void display(GLAutoDrawable gLAutoDrawable) {
...
// map a 2D bild width*height on OpenGL
glu.gluOrtho2D(-width/2, (width+1)/2, -(height+1)/2, height/2);
}
The funny thing is that:
I have other glu calls in the display, like "glu.gluLookAt(0, 0, 1, 0, 0, 0, 0, -1, 0);" and I never got a problem there
It takes place only when I call a refresh from another thread ("glcanvas.display")
I already did many attempts like initialize it everytime in the display, or forcing the context with:
glu = new GLU();
gLContext = gLCanvas.getContext();
gLContext.makeCurrent();
but nothing so far worked:
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: No OpenGL context current on this thread at javax.media.opengl.glu.GLU.getCurrentGL(GLU.java:175) at javax.media.opengl.glu.GLU.gluOrtho2D(GLU.java:1344)
I tried to move the getContext and the makeCurrent just before the glu.gluOrtho2D and it worked..