The Java2D implementation in Mustang (JDK 6) build 51 and JOGL now have a powerful new interoperability capability.
In the JOGL library, when 100% correct Swing integration is required, the GLJPanel widget must be used. This is a pure lightweight widget which overlaps correctly with other Swing widgets. Previously, the best-case code path for the GLJPanel performed OpenGL rendering into a pbuffer, read back the frame buffer into an AWT BufferedImage, and drew the resulting pixels via Graphics.drawImage(). While the results were repeatable across platforms, the frame buffer readback and BufferedImage draw made this solution significantly slower than the heavyweight widget case and therefore unusable for many applications.
With Mustang build 51 and the current JOGL sources, interoperability between Java2D’s new Single-Threaded Rendering OpenGL pipeline and JOGL’s GLJPanel has been introduced. (See Chris Campbell’s blog entry for some more details.) JOGL can now render directly into the OpenGL drawable used by the Java2D OpenGL pipeline, providing full hardware acceleration for the GLJPanel and eliminating the readback of the frame buffer. The result is that the GLJPanel is almost as fast as the heavyweight GLCanvas and provides complete integration with Java2D. With this capability, you can:
 Overlay Swing components (lightweight menus, tooltips, and other widgets) on top of OpenGL rendering.
 Use 3D graphics anywhere you would ordinarily use a Swing widget. (Inside a JTable, JTree, …)
 Draw 3D OpenGL graphics on top of Java2D rendering. The JOGL JGears demo (also in the JRefract demo menu as “Gears”) provides an example of this where the background is drawn with a Java2D GradientPaint and a translucent GLJPanel with a zero-alpha background draws the gears on top.
 Draw Java2D graphics on top of 3D OpenGL rendering. The JGears demo again provides an example of this: the icons and frames-per-second counter are drawn on top of the gears using Java2D.
The best part is that no changes to the JOGL application are necessary due to JOGL’s GLEventListener rendering model. Simply add your GLEventListener to a GLJPanel instead of a GLCanvas.
Try it out! A demo is available on line via Java Web Start. There are still some remaining issues (it looks like the InfiniteShadowVolumes demo crashes the JVM on X11, for one) but most demos are working perfectly. To run the demo:
 Download Mustang build 51 or later from java.net.
 Install either the JRE or JDK bundle.
 Check to make sure the Mustang version of Java Web Start is registered as the helper application for MIME type “application/x-java-jnlp-file”.
 Click the launch links below!
Notice in particular the huge speed increase in the Gears demo. These demos are fully accelerated on Windows and X11 OSs and have been tested with NVidia and ATI hardware. We plan to work with Apple Computer to be able to achieve these speedups on Mac OS X as well.
There are some known issues that should be mentioned:
 There is significant lag of delivery of mouse events on some Windows machines with some of the more computationally intensive demos. We will try to diagnose and fix this soon.
 With NVidia graphics cards on Windows, there is a significant slowdown when dragging the JInternalFrames around the JDesktopPane. This is due to a bug in NVidia’s drivers which we have heard will be fixed in their next driver update. (Note that resizing operations are very fast.)
The new code has been checked in to the JOGL source tree under the JSR-231 branch. If you would like to experiment with it, please check out and build the source tree:
cvs co -r JSR-231 -P jogl jogl-demos
Adding -Dsun.java2d.opengl=true (specify “True” instead to get debugging information from Java2D) to your command line will enable the Java2D OpenGL pipeline; JOGL will automatically take advantage of it in its GLJPanel implementation. You can get debugging information from the JOGL side by specifying -Djogl.debug.Java2D -Djogl.debug.GLJPanel. The JOGL/Java2D integration can be disabled with -Djogl.gljpanel.noogl.
We are excited about the new visual effects this integration will enable. Please post here with any comments, questions or suggestions. The new JOGL APIs this support is built on top of are planned to be in the public API of JSR-231, which should be out for public review soon.