Okay, here is what I am doing:
To save the png, I am using Photoshop. I have a transparent area in the image in photoshop, so I am not creating a seperate alpha channel, then I am using the save for web feature to save it as a png-24 with transparency checked (which should store an alpha channel then for the transparency, correct?) Because the transparent area does appear transparent inside my app, so I’m assuming there’s nothing wrong with the way I am handling the image. The texture is 64x64, btw.
Here is how I am initing OpenGL:
gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable (GL.GL_BLEND);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
gl.glColor3f( 0.0f, 0.0f, 0.0f );
gl.glPointSize(4.0f);
I also tried turning off blending, and enabling alpha testing in this way:
gl.glAlphaFunc(gl.GL_LESS, 1);
gl.glEnable(gl.GL_ALPHA_TEST);
However, when I did that, only the outside edge of the non-transparent part of the image was showing up (but it was still fading in and out)
This is how I setup the texture:
gl.glBindTexture(GL.GL_TEXTURE_2D, texture[0]);
gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, imageWidth,
imageHeight, 0, GL.GL_RGBA,
GL.GL_UNSIGNED_BYTE, imageRGBA);
Notice the use of GL_RGBA here. imageRGBA is the data from the image loaded using the same method used by the “Jumping into JOGL” tutorial, using the Image toolkit.
And finally, here is how I attempt to draw a sprite:
gl.glPushMatrix();
gl.glTranslatef(x_loc,y_loc,0.0f);
gl.glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
gl.glBindTexture(GL.GL_TEXTURE_2D, texture[0]);
gl.glBegin (GL.GL_POLYGON);
gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex2i (0, 0);
gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex2i (63, 0);
gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex2i (63, 63);
gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex2i (0, 63);
gl.glEnd();
gl.glPopMatrix();
That having been said, does that give anyone any more clues as to what I may be doing wrong to get this fading in and out business around the edge?
I appreciate all your help!
-veediot!