Alpha Blending

If I have an RGBA bitmap structure being applied to an object in a scene, what is the blend function I need to use to get the background to be transparent but not the rest of the graphics? The alpha portion of each pixel in the bitmap structure is set to 0 for all white pixels and 255 for every other color.

glTexImage2D(GL_TEXTURE_2D, Level, ColorComps, aW, aH, Border,
glBlendFunc(gl_one, gl_dst_alpha);

This is the closest I’ve gotten, but it still makes what I don’t want to be transparent semi-transparent.

The best way to make sections of a bitmap transparent is to use a mask, I don’t have the code memorized, but essantially you will have to draw a textured quad twice.
that is a good tutorial on exactly what you have to do, see if that helps

Thanks! That worked great. It was exactly what I needed to get it to work.

“The best way to make sections of a bitmap transparent is to use a mask”

No, the best way to do it is to use alpha testing. What you do is you use the following code:

glAlphaFunc(GL_LESS, 0.5);

Do not enable blending when you do this.

What this does is tells OpenGL to test the Alpha component of each fragment. If that component is GL_LESS than 0.5, then it will not draw that fragment.

The only problem with this is that texel edges near the transparent parts will look a little wierd. But, it is faster than a blend operation, since it doesn’t require the framebuffer read.