JOGL & J2D Combined Superpower!

Greetings,

I’m currently working on a prototype for a graphical Java application.
The application involves drawing high level elements like text, arbitrary shapes, but also drawing a high res deformed texture in the background.

After profiling and testing my conclusions are that for the high level elements Java2D would be excelent, it keeps up a good framerate and offers a stable api that does most of the work for you.
The only way to draw the distorted texture is in contrast tho a api which lets me draw textured triangle strips, which obviously points to JOGL (in fact it’s a round sonar display that has to map a rectangular texture in a circle, way cool :slight_smile: Trying to do this in Java2D is tedious and slow and very pretty.

So I’m stuck now with the problem that I would like to use Java2D and JOGL in one and the same window. J2D for it’s high level API, JOGL for it’s fast textured triangle drawing.

I’ve tried to do this by drawing with J2D to a BuffereImage, and then using this image as a texture in JOGL.
This means having to copy the content of the image twice for each drawn frame tho (once from the byte[] array in the bufferedImage to a byteBuffer, and once when you call the jogl function to set up a texture) Which I’m affraid to say degrades the performance just a bit too much.

On a 1024*1024 BufferedImage I only get about 8 fps on my target platform, I’m aiming for 20 :slight_smile:

That’s with a BufferedImage set up in the same color model as opengl btw., so it’s straight copying without having to translate.

So my question is if someone has any ideas on:

  • Speeding up the copying process I use.
  • Other methods to intergrate J2D and JOGL that are might achieve a higher framerate
  • Other ways to quickly draw textured triangles in J2D, using J2D primitives or other opengl bindings, or anything ^-^
  • Intergrate JOGL and J2D the other way round, render opengl to a pbuffer and draw that in J2D? would be just as slow ? can’t be done platform independent yet ?

Any help would be greatly appreciated, I think this is a rather interesting topic for JOGL in general too, Being able to combine JOGL and J2D in such a fashion would be rather usefull :slight_smile:

Since I’m building the thing now I’m mostly interested in solutions that can be done with the current JOGL btw. ^.^

Many thanks in advance! :slight_smile:

Hello,

I encountered similar issues during my work on a project that uses a scenegraph implementation which can be displayed using Java2D, Java3D or OpenGL via GL4Java (and soon JOGL). Because the focus is now mainly on displaying compex 2D scenes (geographical data as raster images and vector data and overlayed meteorological data in all kind of flavours) Java2D is the renderer used by default. The OpenGL path currently has only rudimentary text functionality and has bad performance if complex polygons have to be triangulated prior to their use.
To speed things up I experimented with drawing the Java2D path into a BufferedImage which I used then as a texture. I haven’t measured performance yet, but I guess it would be in the area you mentioned (BTW: what is your target platform?) Until now I haven’t found a perfect solution to integrate the best features of J2D and OpenGL, but if I figure something out I’ll let you know.

Greetings,

Greg