Bitmaps in opengl. how to filter the background

Started by
7 comments, last by Hayato 22 years, 7 months ago
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!
(^o^)/
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
------------------------------Put THAT in your smoke and pipe it
ya! exactly what i mean
(^o^)/
You use blending for that.

"I''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''Urden
------------------------------Put THAT in your smoke and pipe it
Either load an image with an alpha channel already in it, or add the alpha channel as it''s being loaded by testing if the pixel is a certain color. Then you render while blending or alpha testing, as has been stated.

[Resist Windows XP''s Invasive Production Activation Technology!]
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?
(^o^)/
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!]
ahh, just like in directx!! i see, thanks.
(^o^)/
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

This topic is closed to new replies.

Advertisement