Transparency insanity

I have been struggling to draw a quad/polygon with transparency.

I am loading a PNG image with transparent pixels in it, and use it as a texture. Such a simple task, but no luck. The transparent parts of the texture are rendered all solid.

Is transparent textures supported by JOGL at all??

I have failed to find a way to do this after countless of hours working on the problem and checking all kinds of OpenGL documentation. I have failed to reconstruct them in JOGL.

Please help before I go insane! :’(

Where’s your code?

do you have gl.glEnable(GL.GL_BLEND) and a proper blending function enabled, such as: gl.glBlendFUnc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);? You will also want to remove writing to the depth buffer with gl.glDepthMask(false)…

Are you doing the nehe tutorial on transparent textures? See nehe.gamedev.net if you havn’t… they have a JOGL port for it.

NeHe Lesson 8? I downloaded and ran the JOGL bytecode. It rendered a solid cube here, no transparency in sight…

I doubt it is my openGL driver, it is working perfectly with every other openGL program. I am using a Geforce 6800 gt, with the newest drivers.

My code is extremely simple:

init:

int maskTextureID=readtexture… //read png texture with alpha channel
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glEnable ( GL.GL_BLEND );
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D,maskTextureID);

display:

    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    gl.glBegin(GL.GL_QUADS);
        gl.glTexCoord2f(0,0);
        gl.glVertex3f(-100.0f, -100.0f, 0.0f);
        gl.glTexCoord2f(1,0);
        gl.glVertex3f( 100.0f, -100.0f, 0.0f);
        gl.glTexCoord2f(1,1);
        gl.glVertex3f( 100.0f,100.0f, 0.0f);
        gl.glTexCoord2f(0,1);
        gl.glVertex3f(-100.0f,100.0f, 0.0f);
    gl.glEnd();

If you have any examples proven to work in JOGL, I would be grateful if you can post them…

Did you see transparency in JOGL yourself?

I just re-ran the lesson 8, and by pressing the secret “b” key blending was enabled, so it works. It is not the type of transparency I need though…

So, nobody knows how to draw a quad with transparent pixels in it?? Is it impossible??

I got it working now. Turns out it was a bug in the texture loader I copied from the NeHe site. It did not properly assign the texture alpha’s to the texture like it was supposed to.

if you use the one taking an argument with “storeAlphaChannel”, make sure it is in fact used to set the number of bytes when the texture is created using “glTexImage2D”

Phew, so much work for this bug… :frowning: