JOGL Java2D/OpenGL bridge - does it actually work?

I ask because I have never actually seen it working and both of the JOGL demos that use this technology bring up a blank white window and nothing else when I run them on 3 separate machines under various flavours of Windows.

So, is this just an experimental technology or is there a way to get it to work? We are very interested in this feature and hope that it can be made to work.

In case there is any confusion, I am referring to what is more commonly known as the “Java2D/JOGL interoperability” technology.

If anything, steer clear of it. Sun ditched JOGL, and so don’t expect much (any?) support.

Yes, Sun ditched JOGL but surely it has just as much support now as say LWJGL

The main reason I am interested in JOGL and the Java2D/JOGL interoperability is because our game relies heavily on text and we need the text to be clear and crisp. LWJGL is an alternative but doesn’t offer much (anything?) in the way of good text rendering.

I won’t recommend using it esp. if you want to distribute your app via webstart/applets - it was never stable enough to be used on unknown hardware (IMO of course).

There are many other ways of implementing interop between java2d and jogl.

e.g
-google for swogl (swing for jogl)
-wonderland has also at least one working implementation (beside the JME one)

i’ve written one for my engine for debugging purposes but it isn’t open source (screenshot)

use the TextRenderer. Renders any java font you like in your gl scene. (but thats not the full interop i referred to in the last post)

Just to be clear, are you referring to the Java2D/JOGL interoperability or JOGL itself when you say “don’t use it” and that it’s unstable?

Also, there are other reasons why we would like to fully investigate the viability of Java2D/JOGL interoperability so I would appreciate someone close to the JOGL project commenting on its status.

LWJGL differs from JOGL in that it is, for the most part, only an OpenGL binding. It doesn’t include a bunch of other stuff. I see this as a good thing.

I wrote Unicode font support for Slick, which is based on LWJGL:
https://bob.newdawnsoftware.com/repos/slick/trunk/Slick/src/org/newdawn/slick/UnicodeFont.java
It wouldn’t be too hard to pull this out of Slick. There is also a tool for designing your fonts:
http://slick.cokeandcode.com/demos/hiero.jnlp
(Blame Kevin, Slick’s author, for the Hiero tool not closing properly. :P) This tool saves a “.hiero” file that UnicodeFont can open which describes font size, spacing, and effects (colors, borders, etc). UnicodeFont then renders (at startup or on the fly) glyphs from TrueType fonts to OpenGL atlas textures using Java2D. Because UnicodeFont can render glyphs on the fly, apps can support allowing the user to type Unicode characters.

The Hiero tool can also alternatively output the BMFont format and any number of packed glyph images. This is a fine solution if you know all the glyphs up front. Quality is the same, including kerning. The AngelCodeFont class in Slick renders fonts with these. The BMFont format is easy to render, eg I have written a renderer for both the iPhone and Android.

Java2D/JOGL interoperability

i am one of the main contributors of the community version of JOGL2, its probably close enough :wink:

If I say Java2D/JOGL interoperability i mean:

  1. Enable swing opengl rendering with sun.java2d.opengl=true property
  2. and use GLJPanel which will render directly into swings gl backbuffer.
    (now you can do everything you like with swing or gl)

problem is 1.) is already unstable. Try it.

Thanks for the info. Do I need (1) to do (2)?

And thanks for confirming that (1) is unstable. Is anything being done to address this? Is it a Java issue or a JOGL issue?

So we know Java2D is a Sun API, and JOGL was. Now knowing Sun ditched JOGL, and Java2D is constantly changing its implementation do you expect the JOGL developers to keep up?? There is little gain in Java2D/OpenGL interoperability anyway, the alternatives (also mentioned in this thread) are way better.

Currently I use Java2D/OpenGL bridge under Linux and Windows, it works quite fine when I don’t try to force the Java2D OpenGL pipeline. I use it to display transparent Swing components into a control part (Eclipse RCP application) including a JOGL GLJPanel.

Thanks for the info but I don’t really know what you mean by this. Could you please elaborate?

And how do you get it to work? Even in my simplest program using a GLJPanel, if I set sun.java2d.opengl=true then I just end up with a blank white window. If I don’t set that property then the performance with multisampling is terrible!

Don’t set sun.java2d.opengl to true, only set sun.java2d.noddraw to true. I use multisampling and it works fine.