more complex transparency with .pngs

I’ve just been trying to get some transparency to work with pngs as textures but when the pngs have transparency they look…odd. Attached is the png image and a screenie of ingame.

blend code:

gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

texture loading:


                gl.glBindTexture(GL.GL_TEXTURE_2D, textures[textureIndex]);
                gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
                gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
                gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, texturesT[textureIndex].getWidth(), texturesT[textureIndex].getHeight(), 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, texturesD[textureIndex].getBuffer());

It’s probably just some stupid little mistake… but I can’t seem to find it.

Er, which bit is supposed to be transparent in your first picture? I can’t see any blending other than possibly the text, which looks fine.

Also, whats up with that crazy moire pattern on the white squares? Is that deliberate or have you accidentally used pixel units rather than normalised texture coords?

The GL_RGB in your glTexImage2D call should be GL_RGBA. I would recommend you look into the TextureIO classes in com.sun.opengl.util which should do things like proper loading of transparent textures for you.

GAH, sorry about this, I forgot to change that GL_RGB back to GL_RGBA becuase I was having buffer problems before.

Just changed the buffer and it is working now, posted my problem up here too soon :-X