I didn’t post any code because I figured this was a common and known problem. It seemed like a bit much to just throw this up here, but I suppose it may be the only way to get the help needed. As mentioned, the two quads draw fine, and show transparency, but the transparency is not influenced by the values of GL_COLOR4f() as the tutorial describes. A possibly related problem is that some random texel from the bound texture is becoming the current color, so any text ends up that color as does any quad NOT textured. I had to remove a good deal of code for this to fit in the post, so many unrelated methods are simply missing and quite a bit of seemingly unrelated code was removed from inside of the methods that ARE shown. If it turns out that no answer is available from this, I will be happy to put the whole thing up.
Any help appreciated!
public class GL_Game_Core extends JFrame implements GLEventListener
{
public void init(GLAutoDrawable drawable)
{
// Get current GL and GLU
GL gl = drawable.getGL();
// Create the GLUT object
glut = new GLUT();
glu = new GLU();
// Get TextureManager instance
textureManager = TextureManager.getInstance(gl, glu);
// Enable basic OpenGL functions
gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_CULL_FACE);
// Set state variables
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glClearDepth(1.0f);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glCullFace(GL.GL_BACK);
}
public void display(GLAutoDrawable drawable)
{
// Get current GL and GLU
GL gl = drawable.getGL();
// Clear drawing surface and the z buffer
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Clear the modelview matrix giving all transformations a fresh start
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// Force all remaining operations through the pipeline.
gl.glFlush();
}
private void initGameSpecificCode(GL gl, GLU glu)
{
// Create textures
try
{
textureManager.createManagedTexture("translucentTexture",
"green.png",
GL.GL_TEXTURE_2D,
GL.GL_RGB,
GL.GL_RGB,
GL.GL_LINEAR,
GL.GL_LINEAR,
false,
true);
}
catch(IOException ioe)
{
}
}
// Extending class places additional 3D drawing code here
private void draw3D(GL gl, GLU glu)
{
gl.glEnable(GL.GL_TEXTURE_2D);
textureManager.bindTexture("translucentTexture");
// Draw translucent objects
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
gl.glDepthMask(false);
gl.glColor4f(1f, 1f, 1f, .8f);
gl.glBegin(GL.GL_QUADS);
gl.glNormal3f( 0f, 1f, 0f);
gl.glTexCoord2f(0f, 1f); gl.glVertex3f(-1f, 1f, 1f);
gl.glTexCoord2f(0f, 0f); gl.glVertex3f(-1f, -1f, 1f);
gl.glTexCoord2f(1f, 0f); gl.glVertex3f( 1f, -1f, 1f);
gl.glTexCoord2f(1f, 1f); gl.glVertex3f( 1f, 1f, 1f);
gl.glNormal3f( 0f, 1f, 0f);
gl.glTexCoord2f(0f, 1f); gl.glVertex3f(-1f, 1f, 2f);
gl.glTexCoord2f(0f, 0f); gl.glVertex3f(-1f, -1f, 2f);
gl.glTexCoord2f(1f, 0f); gl.glVertex3f( 1f, -1f, 2f);
gl.glTexCoord2f(1f, 1f); gl.glVertex3f( 1f, 1f, 2f);
gl.glEnd();
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glDepthMask(true);
gl.glDisable(GL.GL_BLEND);
}
}