I’m trying to make black (0,0,0) be the transparent color (yes, i know it’s all just alpha). In my code that loads bitmaps, it checks if the RGB of the pixel it just read in is all black. If so, it sets the alpha component of the texture data (a standard GLubyte *data) to 0. It it is a normal pixel, it sets it to 255. Later in my code when I go to draw it, i have the following:
GLfloat rgba[] = {.0f, .0f, .0f, 1.0f};
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
glPushMatrix();
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba);
glBindTexture(GL_TEXTURE_2D, textureID);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
<draw just a plain square using GL_QUADS>
glPopMatrix();
glDisable(GL_BLEND);
But I get some weird corrupted looking image. If I don’t do any transparency setting (i.e. my texture data array only allocates memory for RGB and not RGBA info) then something weird happens. Now, all of a sudden none of the black pixels show up. This is good. BUT, the rest of the bitmap that is showing looks as if it’s being alpha blended with the rest of the data on the screen. Can anyone tell me what I’m seriously screwing up??? Thanks for your help =)