Jump to content
  • Advertisement
Sign in to follow this  
ff8

glBlendFunc() and glAlphaFunc() ?

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

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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
mmmmmmmmm ok is there any special setting for the texture or what ?? and GL_GREATER what is it mean??

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!