I just noticed in sun’s most recent java release that it optionally supports using opengl for Graphics2D drawings. Is the any relationships btw jogl and what sun’s done? Could there be a merging in the future?
No relationship and it don’t make sense to merge.
Actually, better interoperability between the OpenGL pipeline for Java2D and JOGL is a goal. At last year’s JavaOne we showed a demo of proper overlapping of Swing widgets with 3D graphics drawn via JOGL, all with full hardware acceleration. This was done by allowing JOGL to share the Swing back buffer with the OpenGL Java2D pipeline. The demo was a hack, but we’re hoping to make this interoperability a supported feature in either Java2D or the JAWT in the next J2SE release.
That would rock. Currently I’m forced to look at SWT for a utility project due to lightweight / heavy weight issues with Swing and JOGL
How was that sharing accomplished? Is it something done via JNI?
The prototype worked by exposing a couple of Sun-private APIs to fetch the OpenGL context associated with the pbuffer that is used by Java2D as its Swing back buffer. JOGL could then render directly into that context. There was a lot of trickiness associated with figuring out the rectangle into which JOGL rendering could occur without blowing away the Swing rendering, as well as saving and restoring OpenGL state elements used by the Java2D pipeline. We didn’t get the prototype to the point where it was completely transparent to an application using JOGL.
The plan as I understand it is to expose the OpenGL context through the JAWT (AWT native interface) so that a lightweight widget can be locked and a DrawingSurfaceInfo fetched for it in similar fashion to a heavyweight widget.
Interesting. Thanks!
…making it just as feasible (easy?) for other OGL bindings to do the same sharing? Perhaps would make a convincing case to many non-experts to say “Java2D is OGL accelerated. You can even render to the OGL surface with any OGL binding of your choice”…[show examples]?
Certainly, it would make an excellent piece of ammo for dealing with the thick-skulled publishers and devs who chant “java is slow; Java graphics is even slower”. It’s much harder to argue with something as transparent as that…
[quote]The plan as I understand it is to expose the OpenGL context through the JAWT (AWT native interface) so that a lightweight widget can be locked and a DrawingSurfaceInfo fetched for it in similar fashion to a heavyweight widget.
[/quote]
I think this will be a very important thing for Swing and Java2D, to be able to integrate with JOGL. I’ve been working on real-time 2D/3D media apps in Java and for countless times I find myself wishing for the ability to render high-level graphics thru Java2D -and- low-level graphics with OpenGL, on the same surface. It just makes the whole thing so much richer with possibilities.
I’ve posted something related to this on Chet Hasse’s weblog at java.net: http://weblogs.java.net/blog/chet/archive/2004/09/tiger_on_the_de_1.html#comments
With the source snapshot release of Mustang (JDK1.6) today, I’m even more excited since people like us may be able to help out afterall.
For somebody new to the JDK codebase, can you point me quickly to where this ‘integration’ is being worked on? Many thanks!
.rex