PDA

View Full Version : Transparent texture mapping???



xpnctoc
11-28-2003, 08:19 AM
Hello! I need to do some partially transparent texture mapping for billboarding. I cannot get this thing to work for the life of me. I have a sample program from a book which runs just FINE. But I can't get my own program to work. I used my debugger to check the bit values of the RGBA-modified BYTE array to make sure the alpha bit is set correctly. When I initialize OpenGL, I do use PFD_TYPE_RGBA. My sequence for the transparent texture mapping is:

glEnable(GL_BLEND) ;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
glEnable(GL_ALPHA_TEST) ;
glAlphaFunc(GL_GREATER, 0) ;
glBindTexture(...) ;
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE) ;
...and then do the drawing.

Yet when the drawing occurs, the black "transparent" shows up in full color, creating a black rectangular edge.

Interestingly, if I switch the alpha test to (GL_LESS, 1), the ENTIRE quad becomes invisible, even though I have checked the bytes of the texture, and the alpha values vary correctly between 0 and 255 where I want transparency or not.

Any suggestions at this point would be greatly appreciated. I've been working on this for 3 days now. Maybe I'm overlooking something stupidly obvious. Thanks a bunch.

jwatte
11-28-2003, 02:45 PM
Sounds a lot like your calls to TexImage2D() or TexSubImage2D() are not correct, or you're feeding them incorrect data.

xpnctoc
11-29-2003, 07:30 AM
YES! That was the problem. I forgot to change the internal format field on TexImage2D when I switched over from BGR format. DUH! Thanks much. http://www.opengl.org/discussion_boards/ubb/smile.gif