glBlendFunc() and glAlphaFunc() ?

Started by
8 comments, last by ff8 19 years, 4 months ago
hello everyone ...,how are you today :)? i have two questions about these two function and i hope you answer me :) 1)what is the different between these glBlendFunc() and glAlphaFunc(), cause i think they have the same functions? 2)is there any basic sample for glAlphaFunc because i search in google and i don't find anything? cya :)
Advertisement
glBlendFunc lets you blend what you are drawing with what's on the screen or some constant value. glAlphaFunc lets you specify what alpha values you want to not draw or let draw.

For instance if you have an image of a fence and you want the holes in the fence to be transparent, you could set the alpha values to 0, and call

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);

This will only lets pixels with alpha value greater than 0 be drawn. Try http://nehe.gamedev.net, there are numerous tutorials on this kind of stuff.
Author Freeworld3Dhttp://www.freeworld3d.org
mmmmmmmmm ok is there any special setting for the texture or what ?? and GL_GREATER what is it mean??
Up please answer me :) ...
GL_GREATER means that only pixels with a higher z-value than the pixel alredy on the screen will be drawn.

And there is no special setting for the texture, but you can change it's alpha value at some places to make it more/less transparent.
Quote:Original post by master of void
GL_GREATER means that only pixels with a higher z-value than the pixel alredy on the screen will be drawn.


That is for glDepthFunc()

In the glAlphaFunc context, GL_GREATER means that only the texels with an alpha greater than the second parameter passed to glAlphaFunc(GL_GREATER, x) will be used. "x" is a float value between 0.0f and 1.0f, all values are clamped to this range. Not using a texel means that the fragment which used it has an alpha of 0, making it completly transparent.

To use glAlphaFunc effectively, make your texture with 4 color compoments (RGBA) and calculate or draw your alpha layer.

You should look in the opengl red book for examples. See the forum FAQ.
thanks all :)
BTW ... do you have any tutorials about drawing alpha layer?
Quote:Original post by oconnellseanm
Try http://nehe.gamedev.net, there are numerous tutorials on this kind of stuff.

Failing that, maybe gametutorials.com. I know NeHe has at least one tutorial on alpha blending, but that may or may not be specific enough for you.
ok i'll check it thanks

This topic is closed to new replies.

Advertisement