Java2D not OpenGL'ed on Win

The first thing I want you to know is that I don’t know OpenGL (temporary situation ;D), so the things I’m writing may be incorrect.

I did some experiments with Java3D and OpenGL (JOGL) on win. Just simple things. I ever wanted to draw something on a buffer and then grab the resulting pixels and save them as TGA with transparent background.
No way. I always got a fully opaque black background.

I did some investigation in order to get a transparent background. I posted almost everywhere without getting any convincing solution. Someone told me that I was initializing OpenGL in the wrong way. Some other suggested to chroma-key the background (UGLY! say goodbye to speed and antialiasing).

Now I am almost certain that the reason is the implementation of OpenGL on windows: ChoosePixelFormat does not give any background transparence, even if requested. Maybe It’s a fault of the Microsoft OpenGL implementation. I don’t know.

Now, talking about Java2D on win, I suspect it will be unlikely it will be implemented on top of OpenGL for the reasons above, at least without breaking backwards compatibility with the existing Java2D graphics software.

There is no such thing as a transparent background in a window, if that’s what you’re trying to do.

Cas :slight_smile:

[quote]There is no such thing as a transparent background in a window, if that’s what you’re trying to do.

Cas :slight_smile:
[/quote]
…unless you use Xwindows / linux. Most of the WM’s support transparent backgrounds (although I’ve not yet seen an app that makes sensible use of this feature…)

[quote]There is no such thing as a transparent background in a window, if that’s what you’re trying to do.

Cas :slight_smile:
[/quote]
Windows does support bitmask transparency for windows. Most media players use this to implement their non rectangular appearance. Currently you have to use JNI to get this effect in Java.

2K and XP also support full alpha.
Winamp has an option for it… though its completely useless :slight_smile:

I meant in Java.

Cas :slight_smile:

Bitmask transparency is not needed here.

We need full alpha support in order to get high quality and speed from OpenGL.

Bu the question still remains an maybe some officials here can answer: is the lack of full alpha support the cause of the absence of Java2D OpenGL acceleration on win ?

OpenGL on Windows has full destination alpha channel support on most drivers these days.

Cas :slight_smile:

[quote]Bitmask transparency is not needed here.

We need full alpha support in order to get high quality and speed from OpenGL.

Bu the question still remains an maybe some officials here can answer: is the lack of full alpha support the cause of the absence of Java2D OpenGL acceleration on win ?
[/quote]
Could you please explain further why you expect a full hardware alpha channel will give you:

  • high quality, and
  • speed

As Cas mentioned, most modern OpenGL drivers support a full (“stored alpha”) channel in hardware on some visuals/pixfmts. This means that your destination surface is RGBA instead of RGB. Note that this issue is completely separate from the discussion of whether you can have bitmask or translucent heavyweight windows. Even if you have an OGL stored alpha channel, it does not mean that you will be able to “see through” the window when the alpha values are not 1.0.

Now, I should mention how this all relates to the OGL-based Java 2D pipeline. In theory, the OGL pipeline could implement translucent VolatileImages (a new feature in 1.5) in hardware, using the concepts mentioned above (i.e. pbuffer with stored alpha). However, this is not currently implemented, so if you ask for a translucent VolatileImage with OGL enabled, you will get back a system memory surface. As I mentioned, it’s just a Small Matter Of Programming, so I will file an RFE today and hopefully we’ll get to it in an upcoming release.

With that implementation in place, I think javazoid will get the desired effect (hardware accelerated rendering to a translucent offscreen surface).

All that said, it should be clear now that this issue has nothing to do with the fact that the OGL-based Java 2D pipeline is not available on Windows in 1.5. That issue has already been addressed countless times on this forum, but I can say for sure that we have a prototype working in-house, and we’d like to include it (as an alternate pipeline) in an upcoming release.

Chris

Thanks Chris… getting accelerated translucent images in the OGL pipeline would be great.

On the other issue - is there anything happening in terms of supporting translucent or irregularly shaped windows? I know there is an existing RFE for these, and all the major platforms support them now.

[quote]Thanks Chris… getting accelerated translucent images in the OGL pipeline would be great.

On the other issue - is there anything happening in terms of supporting translucent or irregularly shaped windows? I know there is an existing RFE for these, and all the major platforms support them now.
[/quote]
I just filed a new RFE:
5002129: OGL: translucent VolatileImages should be hardware accelerated

Should show up here eventually:
http://developer.java.sun.com/developer/bugParade/bugs/5002129.html

(Yes, that’s right, we’ve entered a brave new world where bugid’s start with the number 5… My eyes haven’t yet adjusted.)

As for the non-rectangular window issue, the RFE is:
http://developer.java.sun.com/developer/bugParade/bugs/4479178.html

The AWT team explored adding this feature, but I believe it was too risky for Tiger (difficult to spec and implement consistently across all platforms). Hopefully they’ll get to it in a future release.

Chris

[quote] Could you please explain further why you expect a full hardware alpha channel will give you:

  • high quality, and
  • speed
    [/quote]
    Nice to hear from you, Chris.

I was referring to the “bitmask” solution. Using a bitmask gives poor quality as you can only have 1 bit alpha channel.

Even more computing the bitmask through a chroma key is not the way to achieve speed because you have to build it by analyzing the grabbed image buffer.

I suppose that OpenGL can give you both aspects when it renders to a “stored alpha” RGBA surface, even with a certain degree of antialiasing and bilinear interpolation.

[quote] With that implementation in place, I think javazoid will get the desired effect (hardware accelerated rendering to a translucent offscreen surface).
[/quote]
At long last :wink: That’s exactly what I expected to hear from you. When you say “hardware accelerated rendering” do you also mean transforms and bilinear/bicubic interpolation ?

Thanks for the RFE and for your reply.

Or you could use SWT which offers this features on “selected” platforms :slight_smile: See an example, should work on Windows and Linux.