Login  Register

Transparent Texture?

Posted by Lathanda on Aug 03, 2010; 8:52pm
URL: https://forum.jogamp.org/Transparent-Texture-tp1020455.html

atm I use jogl2 for 2D graphics.
I try to create moving sprit. As long as the sprit does not contain transparency everything works fine.
But atm i use transparent images the transparent parts are rendered in black.
I use the sequence
new Texture(new AWTTextureData(
                        GLProfile.get(GLProfile.GL2),
                        GL.GL_RGBA,
                        GL.GL_RGBA,
                        false,
                        img)
                );
which is stored for further use. img is a Bufferedimage containing a png image with transparency.
I inspected img, and the data looks fine.

For drawing i use... ( t is the previous created Texture.)
                t.enable();
                t.bind();
                gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
                gl.glBegin(GL2.GL_QUADS);
                        gl.glTexCoord2d(0.0,0.0); gl.glVertex2d(x, y);
                        gl.glTexCoord2d(1.0,0.0); gl.glVertex2d(x+width, y);
                        gl.glTexCoord2d(1.0,1.0); gl.glVertex2d(x+width, y+height);
                        gl.glTexCoord2d(0.0,1.0); gl.glVertex2d(x, y+height);
                gl.glEnd();
                t.disable();

I also tried using a TextureRenderer, but the effect is the same i don't get transparency to work.

I believe I miss something really trivial, but I have no idea what it could be.