Problem loading GL object from canvas object.

Hi,

Using JOGL to create a display list. This is initalized in the .init() function. The display list is then written in the .display() function.

Occasionally, an event occurs that requires the display list to be updated. The function to update the display list works just fine when it takes a GL object passed from the .display() or .init() functions (obtained by GL gl = GLAutoDrawable_object.getGL()).

When calling it from a different that does not have direct access to the GLAutoDrawable object, I’ve tried to obtain the GL object form the Canvas object using Canvas_object.getGL(); my understanding is that this should work in the same way. However, I am getting the following exception:

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:234)
at com.sun.opengl.util.GLUT.glutBitmapString(GLUT.java:297)
at DrawPromoter.Legend(DrawPromoter.java:295)
at DrawPromoter.initPromoters(DrawPromoter.java:323)
at DrawPromoter.mouseWheelMoved(DrawPromoter.java:517)
at java.awt.Component.processMouseWheelEvent(Component.java:5576)
at java.awt.Component.processEvent(Component.java:5260)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

I’ve tried several things. Using the following code redraws the display list once, but subsequently the program crashes (no exception, but the program just freezes, and I have to kill the process):

GLContext context = canvas.getContext();
context.makeCurrent();
GL gl = context.getGL();

I am working in Open SuSe 10.1; and using software rendering (Mesa-6.4.2-19@i586).

Am I doing something wrong? Is this a bug in JOGL or Mesa? If so, is this something I should report to the appropriate project?

Tried to keep the message short as possible, if you need more of my code to help find the problem, let me know.

Thanks very much for your responses,
Charles

You probably didn’t call context.release() which is why the program deadlocked.

In general we recommend that you put these events on a queue and process them in your GLEventListener.display() method. Manually manipulating the GLContext is recommended only for advanced users and in general only as a last resort, as doing so will interact with JOGL’s attempts to do all OpenGL work on a single thread for best robustness and portability.

Hi,

Thanks very much for the response!

I won’t try messing with Context any further. I’ve written a workaround that works quite well … boolean variable that forces the .draw() function to re-create the display lists.

If I can, though, I would rather do this properly. Any idea what I am getting the GLException when calling GLCanvas_OBJECT.getGL()?

Thanks again!
Charles

You’re attempting to perform OpenGL work outside of your GLEventListener’s callbacks. Those callbacks are the only time when JOGL guarantees that the OpenGL context is current.