Transparent texture color
Code:
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?
No color. The alpha channel is used to determine transparency.
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?
Quote: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.
Check out the link from this thread:
http://www.idevgames.com/forum/showthrea...eadid=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.
http://www.idevgames.com/forum/showthrea...eadid=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.
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?
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?
The code you posted originally looks good.
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.
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.
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.
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| ? Find color value of 'pixel' in color buffer? | Elphaba | 1 | 3,470 |
Jul 22, 2009 01:23 PM Last Post: Bachus |
|
| Transparent textures | kordeul | 2 | 2,149 |
Aug 27, 2007 01:38 AM Last Post: kordeul |
|
| OpenGL, SDL, and Transparent Bitmaps | RyanA | 4 | 3,351 |
Jun 26, 2006 04:26 PM Last Post: RyanA |
|
| Texture Color is wrong | DesertPenguin | 7 | 3,511 |
Feb 14, 2006 09:04 PM Last Post: DesertPenguin |
|
| About transparent colors un textures | valle | 2 | 2,472 |
Oct 26, 2004 09:52 AM Last Post: valle |
|

