I’ve been using bmp files for texture images, but now need to have a transparent background on a texture, so I’m trying to get that working. I’ve stepped through the code and can’t find anything wrong. The problem is that nothing displays. Here is a summary of the code. I streamlined the code and removed error checking to make it easier to read.
The loadPNGTexture creates an unsigned char array that is width * height * 4 (rgba) and creates the texture from that data. Can anyone tell me why it is not displaying anything?
thanks,
William
// initialization:
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtex);
glFlush();
//----------------------------------------------------------
texid = loadPNGTexture (“texture.png”);
glEnable( GL_BLEND );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texid );
glBegin(GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (lr.left, lr.bottom, z);
glTexCoord2f (1.0, 0.0);
glVertex3f (lr.right, lr.bottom, z);
glTexCoord2f (1.0, 1.0);
glVertex3f (lr.right, lr.top, z);
glTexCoord2f (0.0, 1.0);
glVertex3f (lr.left, lr.top, z);
glEnd();
glDisable( GL_TEXTURE_2D );
glDisable( GL_BLEND );