Login  Register

Re: Rendering transparent triangles with opengl...

Posted by Xerxes Rånby on May 22, 2015; 2:34pm
URL: https://forum.jogamp.org/Rendering-transparent-triangles-with-opengl-tp4034507p4034512.html

ManuelBrotz wrote
...
My triangles are 2D only and will never have a z-coordinate. Nor does it matter to me, that the transparency is order-dependent.

All i want to do, is to blend a number of transparent triangles over each other and get a similar effect like i get it with the BufferedBitmap and Graphics2D...

By the way, the colors seem to blend fine, it's the alpha-channel, which makes problems...

I will try to give some better examples later, when i have more time.

M. Brotz
I think i have the solution for you:

Brandon Borkholder has made a really cool project called GLG2D that implements a working Graphics2D using JogAmp JOGL.

http://brandonborkholder.github.io/glg2d/

You may use glg2d as is or be inspired by it.

If you look inside Brandons implementation you find his AbstractColorHelper class that implements the color precomutation required for OpenGL to implement Alpha blending the same way as Java2D, have a look for the SRC_ATOP implementation in this file:

https://github.com/brandonborkholder/glg2d/blob/master/src/main/java/org/jogamp/glg2d/impl/AbstractColorHelper.java

Cheers
Xerxes