Jump to content
  • Advertisement

Archived

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

Hayato

OpenGL Bitmaps in opengl. how to filter the background

This topic is 6143 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

I saw nehe''s program on how to move bitmaps in 3d space but like, how did it know to filter out the black background? There is that linear filtering but I doubt that does it. Also, do you need to put the bitmap/texture onto a surface? I saw the glDrawPixels() that can draw bitmaps.. but hmm, i dont know. Please help me!! thanks!

Share this post


Link to post
Share on other sites
Advertisement
WHen you say filter, do you mean take away the surrounding black/white around the actual image ( bitmap )?

"I''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''Urden

Share this post


Link to post
Share on other sites
The blend function huh?

Doesn''t that juat make everything transparent depending on the alpha value and etc.

So what you are saying is, if i make a series of bitmaps with black backgrounds AND i use the blend function, opengl will automatically know that the black part in the bitmaps are just backgrounds?

if i were to use white backgrounds, opengl will NOT filter the white part right?

Share this post


Link to post
Share on other sites
No, it would not know that (at least not with the type of blending you''d want). You have to input one byte for every three that you load (a runtime created alpha value) to tell it whether that pixel is transparent or not. So what you do is: Read a pixel from the file, test if it is black (or whatever), if yes add a 0x00 alpha value, if no add a 0xFF alpha value, repeat until image is loaded.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
also for extra speed dont use blend but use the alpha test
glEnable( GL_ALPHA_TEST );
glAlphaFunc( GL_GREATER, 0 );

ok so all pixels with an alpha of 0 will not get drawn , all the others will

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!