# SFML Alpha Testing/Blending

This topic is 3162 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I do Alpha Testing in SFML? More generally, where can I find information on alpha testing/alpha blending? I was looking at the SFML tutorials, and there's blending modes and stuff, but I didn't know what they did, and that made me feel bad about myself :(. Haha just kidding, but that is something I should know about. Assistance please? [Edited by - EmrldDrgn on October 26, 2009 12:55:50 AM]

##### Share on other sites
I think you're getting two concepts mixed up because they are named for the same letter of the Greek alphabet. (Or else there is another definition of alpha testing that I don't know about.)

Alpha testing is the program testing that takes place in a development environment before it gets released to outside testers called beta testers but after the program is complete.

Alpha blending, on the other hand, is a cross-multiple of the source and destination in a blitter by a factor specified either per-pixel or per-surface. If it is per-pixel, it is sometimes referred to as the alpha-channel of the pixel.

##### Share on other sites
I meant alpha testing like I believe OpenGL defines it, where pixels above/below a certain alpha value are not drawn. I got the term from the NeHe lessons.

That's the effect I'm trying to achieve, but there's no corresponding function in SFML, only Sprite::Blend, and I don't know what mode to use to get that effect in SFML. This represents a deeper lack of knowledge on my part as to alpha blending in general, hence my question.

I'll change the title, since yeah, others will probably think the same as you... oops!

##### Share on other sites
To me it looks like you should be able to use alpha testing simply by using Blend::None as your blending mode and setting it up the standard OpenGL way:
glAlphaFunc(GL_GREATER, 0.5f);glEnable(GL_ALPHA_TEST);

##### Share on other sites
Try using Blend::Alpha.

##### Share on other sites
Alpha testing is just an optimization, it will have the same effect as alpha-blending for transparent pixels (alpha == 0). The only difference is that with alpha-testing, the pixels are not written at all (which can make a difference if you have a depth buffer and you are not drawing back to front). But you don't have to care about that if you're not using OpenGL directly.

So in the end, using sf::Blend::Alpha (which is the default) should be enough.
Moreover, SFML will use alpha-testing internally (as an optimization) in the next releases.

##### Share on other sites
Quote:
 Original post by samuraicrow(Or else there is another definition of alpha testing that I don't know about.)
Alpha testing.

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 11
• 23
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631406
• Total Posts
2999907
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!