Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Irrelevant

OpenGL Masking question (from OpenGL newbie)

This topic is 6029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!