View Full Version : Transparent texture color
LongJumper
2003.10.11, 05:54 PM
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0);
Is supposedly the code that will "make sure the transparent part of the texture isn't drawn", according to this book I'm reading. What color in the texture image file will be treated as transparent though?
OneSadCookie
2003.10.11, 06:40 PM
No color. The alpha channel is used to determine transparency.
LongJumper
2003.10.13, 02:27 PM
Ok. So I assume I would have to save and load my texture as a targa or some such thing in RGBA format, instead of using pict like I am now? And in photoshop or whatever, I just make sure that whatever parts of my texture that I want to be transparent are alpha of 1?
OneSadCookie
2003.10.13, 03:36 PM
Originally posted by LongJumper
Ok. So I assume I would have to save and load my texture as a targa or some such thing in RGBA format, instead of using pict like I am now? And in photoshop or whatever, I just make sure that whatever parts of my texture that I want to be transparent are alpha of 1?
0 alpha is transparent, 1 (255) alpha is opaque. But yes, that's the theory.
FCCovett
2003.10.13, 04:01 PM
Check out the link from this thread:
http://www.idevgames.com/forum/showthread.php?threadid=5236
If you press any key from 1 to 9, and q to p, the app will blend the RGBA texture from a TGA file with different settings.
LongJumper
2003.10.20, 11:58 PM
So I made a targa file in GraphicConverter, added an alpha mask where the part I want drawn is black(0 alpha) and the other part is white(255, 1?). I don't know to reverse them or not, but either way my code isn't blocking out any of it.
What I want to do is have a obviously square texture drawn into a quad, but only this little circle in the middle showing(the button).
I'm pretty sure the image file(aside from the reversal or the alpha channel values) is set up fine, it loads up as a GL_RGBA and I create the texture that way.
What are appropriate values to send ot glBlendFunc and glAlphaFunc to get this working?
OneSadCookie
2003.10.21, 12:00 AM
The code you posted originally looks good.
LongJumper
2003.10.21, 12:28 AM
Must not have drawn it right then. It just displays the whole thing.
I don't know if you have any experience with GraphicConverter(Everyone here seems to though). I just Add Alpha Mask/Channel, then I do a Show Alpha Channel, and then I draw a black dot in the center, save it as a TGA. Doesn't seem to be saving the alpha channel maybe? I dunna. I have to be missing something somewhere, because it doesn't work :)
edit: acutally, no matter what I do to the image file nothing changes.
FCCovett
2003.10.21, 01:32 AM
Check out this source code:
http://home.earthlink.net/~yexirocks/MyGameSource.dmg
It can load an image from a JPG, PNG, or TGA file, and then display all the possible OpenGL blend combinations.
You may use the TGA that comes with it just to check if your code is working right.
LongJumper
2003.10.21, 02:04 AM
Thanks for all the help. Using that other image really narrowed down where my problem was...it was when I load the texture, for some reason I had a 3 in my internalFormat variable passed to gluBuildMipmaps... that was so annoying :)
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.