setAutoSwapBufferMode error with JOGL/Java2D interoperability enable

Hello,

I have just enabled the JOGL/Java2D interoperabilty mode in my program. JOGL seems to run quite faster with it, but I have an issue with the setAutoSwapBufferMode.
When I try to disable the swap buffer mode I’ve got an NULL pointer exception in GLJPanel.java.

I first tried to set the swap buffer mode from my own thread and got error message:
Exception in thread “main” java.lang.NullPointerException
at javax.media.opengl.GLJPanel.setAutoSwapBufferMode(GLJPanel.java:812)

I then tried to use it from the display method and got:
Exception in thread “Java2D Queue Flusher” java.lang.NullPointerException
at javax.media.opengl.GLJPanel.setAutoSwapBufferMode(GLJPanel.java:812)

Is it a know bug? Or is there any palliative for it?

Thank you for your great job with JOGL,
Jean-Baptiste

This is a known issue which has a workaround (call it in your GLEventListener.init() method).

I’m not sure this method will have the effect you want with the GLJPanel, however. It disables calls to the platform-dependent buffer swapping routine for the heavyweight GLCanvas (if it’s double-buffered), but for the lightweight GLJPanel it’s less clear how it can or should work, especially if the Java 2D / JOGL bridge is active and it’s drawing directly to the Swing back buffer.

Thank you for your answer. I will have a try in the init method.

I’ve got an other question about the init method. Why is it called so frequently when using a GLJPanel and only once with a GLCanvas?

Jean-Baptiste.

For the GLJPanel it needs to be called during resize operations since the backing store (pbuffer, typically) needs to be destroyed and re-created with a larger size. We support a little slack to avoid calling init() during each resize operation. If you’re using the Java 2D / JOGL bridge, it’s up to the Java 2D rendering pipeline when the FBO corresponding to the top-level frame’s backing store is re-created. Whenever this happens, init() is called for the GLJPanel’s listeners.