Skip navigation
And so then Java2D says to JOGL: "Ni hao, wode pengyou" 

In Mustang b51, we made some minor enhancements to Java2D that allow JOGL's GLJPanel implementation to render directly into the Swing backbuffer when the OpenGL-based Java2D pipeline is enabled (see 6309763). While it was certainly possible before to use JOGL in a Swing application, it required a number of intermediate steps to get the proper rendering on the screen in the correct order. With these minor changes in place, JOGL is now able to use an optimized codepath so that rendering goes directly into the OpenGL-enabled Swing backbuffer, effectively bypassing all those slow intermediate steps.

Let's just say this makes for some wicked fast 3D rendering in Swing applications! If you've ever tried to integrate a JOGL (or other heavyweight) component into your Swing application, you're probably aware of the horrors of lightweight/heavyweight mixing. The above changes represent a novel solution to the dreaded lw/hw problem because it's now possible to achieve nearly the same framerates as you would in the heavyweight GLCanvas case, instead now all the rendering is respecting the lightweight clipping boundaries and therefore plays nicely with Swing. In addition, this new JOGL codepath takes advantage of the single-threaded architecture of the OpenGL-based Java2D pipeline, so both implementations benefit from improved stability.

I'd like to reiterate that this is simply a new optimized codepath in the existing GLJPanel implementation, which means if you're currently using GLJPanel there are no code changes required in your application to take advanatage of this new, fast codepath! So if the OpenGL-based Java2D pipeline is disabled, or you're running your JOGL app on a pre-b51 build of Mustang, or you're running on another vendor's VM that does not include the OpenGL-based Java2D pipeline, then fear not, your app will still run correctly, albeit not as fast as the ideal described above.

This postby Ken Russell on the forums has all the details, including links to some cool WebStarted demos. Here are some pretty screenshots of the application running a number of JOGL and Java2D demos in overlapping internal frames. I never thought I'd see the day... [Is that a tear in Ken's eye, or just the sweat from making this happen? Hmm...]

Running on Windows XP:

The same demo running unmodified on Solaris 10 (x64, with CDE for some reason, ick!):

The whizzy 3D demos shown here are really impressive, but in my opinion, the real potential here is in the "gears" demo. "But the gears demo is as old as the hills!", I'm hearing you say? Sure, but take a closer look at the screenshots. Note that in this version of the gears demo, the background is filled with a GradientPaint using Java2D (this is accelerated by the OGL pipeline, by the way). Then on top of that we do our 3D rendering of the animated gears using JOGL. And finally we render a simple "heads-up" style overlay, containing a couple images using Java2D.

Just think, this is really powerful stuff! Finally we have made it easier (and more performant) for developers to use 3D effects in their Swing and Java2D applications. Often developers run into the limitations of Swing/2D and then go off and try to rewrite their entire app in terms of JOGL, or they find OpenGL way too complex and go back to the simplicity of Swing and Java2D. Well, it's no longer a black-and-white issue; you should be able to use the best of both worlds as you see fit. Want to use fragment shaders to achieve cool effects in your Swing app? Well now's your chance... (As mentioned in the above bug report, this is really only one part of the overall Java2D/JOGL interop story. Watch this RFE for info on more official interop work between the two APIs.)

This work has opened the floodgates so to speak, so I'm really looking forward to seeing more developers mixing Swing, Java2D, and JOGL in their applications. (Romain: wink wink, nudge nudge...) Anyone want to try their hand at creating a Swing L&F (or extending the Ocean L&F) with some 3D effects?

FBO support: hao chi... 

Also in Mustang b51, we added support for the GL_EXT_framebuffer_object extension (or FBO for short) in the OpenGL-based Java2D pipeline (see 6255507for more details). In a nutshell, this means improved performance for VolatileImages when the OGL pipeline is enabled, and they use up less VRAM too (than pbuffer-based images)... This translates into a performance improvement of up to 15% in internal Swing benchmarks.

This extension is very new and the driver teams are still working out the kinks, so for now we're disabling this support by default, but it can be enabled by a system property if you want to experiment (-Dsun.java2d.opengl.fbobject=true). I expect the driver bugs to be worked out in the next couple months, so there's still a chance we could turn this on by default in Mustang. (Note: Unfortunately the JOGL interoperability stuff I mentioned above does not currently work with our FBO codepath; this is something we hope to correct in the near future.)

This FBO codepath has made it much easier to accelerate translucent VolatileImages with the OGL pipeline, so we've finally added support for this, and it will be available in next week's Mustang b53 snapshot (see 5002129for more info).

Xie xie, Zhongguo! 

I just returned from a fantastic (albeit short) trip to Beijing for the JavaChina 2005 conference. It was great to interact with so many attendees, and I was amazed to learn how many were relatively new to Java. Some of the young audience members I chatted with have been learning Java for only one month, but already they seemed very engaged and were taking the various sessions to heart.

The demos in the "Extreme GUI Makeover" session I presented were greeted with lots of oohing, aahing, and even some spontaneous applause, so I hope to see some "extreme" rich client applications coming out of China in the near future. I was also fortunate to co-present a session on SwingX and JDIC with my colleague George Zhang from the Java SE team in Beijing. Based on the crowd that surrounded us (well, mostly George) asking for more information after the session, I'd say it went very well.

I've heard there were around 9000 attendees between the hub in Beijing and the other satellite cities, so it should be interesting to see how many attend JavaChina 2006... Thanks to all the attendees and event staff for what appeared to be a very successful conference. Hopefully I can return next year with improved Mandarin skills!

In my ears: PINE*am, "Pull The Rabbit Ears"
In my eyes: Jhumpa Lahiri, "The Namesake"