Different uses of display calls

Hi all

Suppose I have a GLAutoDrawable (drawable) and a GLEventListener(gllistener) attached to it.

Does the result of a call to a display method of the drawable, is the same with the following code:


drawable.getContext().makeCurrent();
gllistener.display(drawable);

Is this thread safe; What about if the drawable shares context with other drawables?

Thanks in advance

At some level it’s approximately the same thing but there are several things to consider. First, the JOGL implementation tries to internally do all of its OpenGL work on one thread (the Event Dispatch Thread) due to multithreading-related problems seen with OpenGL drivers on all platforms. Second, you should check the return code from makeCurrent() and decide whether or not to call init(), display(), etc. based on that return code. You should look inside the JOGL implementation (in particular at the com.sun.opengl.impl.GLDrawableHelper class) to see how this is done internally.