Hello everyone. In my scene I am displaying a jpeg image on a quad (I am completely aware that jpeg do not support an alpha component natively). The quad with the applied texture are faded in until the alpha component is 1 but the rest of the scene is still visible through the texture. What I’m trying to accomplish is to have a solid texture with only the black components completely transparent. The following code is how I set up my texture and how i am rendering the texture. Any help would be greatly appreciated!
Jon
glGenTextures(1, &littlepic);
glBindTexture(GL_TEXTURE_2D, littlepic);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_ADD);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, littleImg->getWidth(), littleImg->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, littleImg->getPixels());
The rendering portion.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindTexture(GL_TEXTURE_2D, littlepic);
glPushMatrix();
glTranslatef(1.0,1.0,1.0);
glBegin(GL_TRIANGLE_FAN);
glColor4f(1.0,1.0,1.0, logoAlpha2);
glTexCoord2f(0.0, 1.0); glVertex3f(150.0,220.0,0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(150.0,370.0,0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(650.0,370.0,0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(650.0,220.0,0.0);
glEnd();
glPopMatrix();
if((seconds >= 29000.0001) && (seconds <= 34000.0001))
{
logoAlpha2 += (t*1000.0)/5500.00;
}
else if(seconds >= 37000.0001)
{
logoAlpha2 -= (t*1000.0)/4000.00;
}