Original Post
Hi everyone. I'm having problems with transparency using textures and I'd appreciate some help. The thing is I'm making this assignment for class in which there are fishes swimming around and when a prey gets eaten by a predator I simulate the "eating" by making the prey progressively turn transparent. This worked just fine when I wasn't using textures, but I can't seem to make it work when there are textures applied, and I can't figure out why. I think this is all the transparency- or texture-related code I have: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ..... glEnable(GL_TEXTURE_2D); Vertex4f white(1, 1, 1, 1); //Vertex4f has format RGBA. glMaterialfv(GL_FRONT, GL_AMBIENT, (GLfloat *) &white); glMaterialfv(GL_FRONT, GL_DIFFUSE, (GLfloat *) &white); glMaterialfv(GL_FRONT, GL_SPECULAR, (GLfloat *) &white); glMaterialf(GL_FRONT, GL_SHININESS, shininess); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D(GL_TEXTURE_2D, 0, 4, texture.width(), texture.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, &(texture.pixels()[0])); ..... //here I draw my triangles glDisable(GL_TEXTURE_2D); I think that's it. Another thing: I'm using my textures with the alpha value 255 (ie, 1). And this is the code that executes when I'm not using textures, which *does* work transparency-wise: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ..... glMaterialfv(GL_FRONT, GL_AMBIENT, (GLfloat *) &colors[AMBIENT_COLOR]); glMaterialfv(GL_FRONT, GL_DIFFUSE, (GLfloat *) &colors[DIFFUSE_COLOR]); glMaterialfv(GL_FRONT, GL_SPECULAR, (GLfloat *) &colors[SPECULAR_COLOR]); glMaterialf(GL_FRONT, GL_SHININESS, shininess); ..... //here I draw my triangles Any input? Thanks a lot.