ah… the eternal question, transparency in jogl…
I’ve posted endless questions on this and after numerous (and numerous more) tries finally implemented it correctly. It’s easy in theory but often requires alot of cover-up functions. Basically, you do this:
(pseudocode)
BufferedImage img = readPNG(filename); //filename is a String, get the readPNG method off NeHe if you don’t already have it, same with some other methods I call here
if(img == null) complain
turn image transparent however you want here:
the easiest way is to make a new BufferedImage of type 4BYTE_ABGR and draw in your old image pixel by pixel, with getRGB() and setRGB() methods. If getRGB() returns an int with the same number as the RGB value as the color you want transparent, setRGB() in the new image with 0x00000000 (fully transparent black, in case for some reason you don’t know RGB encoding numbers) instead of the same color as the old image.
The new image is now the one you’re using.
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, some number which will refer to this texture, in int form);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_FILTER, GL.GL_NEAREST);
ByteBuffer dest = a ByteBuffer filled with data from your image, if you don’t know how to get this check one of my posts in this forum or ask me to paste the code that finally worked, sry im not pasting it right now bc its on a different computer
if(you want it mipmapped)
glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, GL.GL_RGBA, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, dest);
else
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, dest);
then disable blending and textures until you need to use them; when you do:
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
//this is the line you were wondering about, this is what you want bc src alpha is the color of your image, which you want to depend on alpha value, and destination color is the color already in the frame buffer.
gl.glEnable(GL.GL_BLEND);
//i think you need those lines in that order
gl.glBindTexture(GL.GL_TEXTURE_2D, the id number you gave that texture);
whew, and thats only the very basics… I suggest you make some sort of TextureHandler class as I did to hide all that gunk
hope this helped, if it didnt i have actual (non-pseudo) code if you want it