I am drawing some textures on screen, and I want to use their alpha value. They were loaded as a texture with an alpha (I’ve visually tested this to be true with glAlphaFunc).
How can I do it? I’ve tried glBlendFunc but it seems to be ignoring the texture alpha.
You should just be able to use :
glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND_FUNC );
If you want to make use of the textures alpha channel once it has been drawn to the frame buffer, you can use :
glBlendFunc( GL_DST_ALPHA , GL_ONE_MINUS_DST_ALPHA );
Only use this however if your 3d hardware supports an alpha channel ( very few do… )
You might get better results if you
glEnable(GL_BLEND);
rather than
glEnable(GL_BLEND_FUNC);
It may also be important to get the right texturing mode(GL_TEXTURE_ENV_MODE, I believe)…whether you’re using GL_REPLACE, GL_MODULATE, GL_DECAL, etc. These affect how it calculates the alpha value for the current fragment(based on the texture’s alpha and the fragment’s alpha as per the current state).
J