Masking question (from OpenGL newbie)
What''s the simplest/most efficient way to set OpenGL to read black pixels (RGB 0,0,0) as transparent? I was playing around with glBlendFunc() but couldn''t get anything to work. I''m using 24-bit bitmaps in my images.
Thanks for any help/suggestions
You could use additive blending (be warned, you won''t get exactly what you''re expecting though). My advice is to simply use an alpha channel with alpha testing though. Not only is it faster, it could get you the exact kind of transparency you''re looking for.
thanks for the advice. however, does this mean I can''t use bitmaps anymore? I was under the impression that bitmaps didn''t support alpha channels. If that is the case, I had better get writing my targa file loader
No, bitmaps don''t support alpha channels. Targa''s are pretty easy to load (even the compressed ones are ), so you shouldn''t have a problem with them.
well, since you''ve been so helpful so far
how do i go about using alpha channels to do transparency?
thanks again for your time
how do i go about using alpha channels to do transparency?
thanks again for your time
If you wanted to make all pixels with an alpha value of 0 transparent, you'd do the following:
glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0);
The second line causes only pixels with an alpha value greater than zero to be drawn. Look at the documentation for glAlphaFunc for the other options available to you.
Also, when you create your texture image, it must be 32 bit. Make sure it has an alpah channel where all the pixels you want to be transparent are black, and all those that you want to see are white
'I sure could use a vacation from this bullshit three ring circus sideshow of freaks...' - TOOL
[TheBlackJester]
Edited by - TheBlackJester on February 16, 2002 1:15:35 PM
'I sure could use a vacation from this bullshit three ring circus sideshow of freaks...' - TOOL
[TheBlackJester]
Edited by - TheBlackJester on February 16, 2002 1:15:35 PM
well it was. it loaded once, but it was upside down, so i quit and flipped the image in Gimp. now when i try to load it, it won''t. any ideas?
Targa files (like many image formats) are saved upside-down. I''m not sure why it isn''t loading now, since I can''t see your Targa loading code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement