Texturing with Alpha test

I was trying to draw a texture mapped polygon. Certain pixels in texture has Alpha value as 0( manually done to make transparent).
Now the problem is it does not work.
I have done,
a. Enable ALPHA TEST
b. Alpha function ( greater, 0.5)

i have used
0, GL_RGBA, image);
but nothing is displayed. but if i mention 3rd paramenter in glTexImage2D as 3( instead of 4), the image is displayed but with all pixels( no transparency). Why is this?
how come it works with ‘components’ as 3 even if image is RGBA?

please help!!

My guess is that all pixels has alpha=0 in your image. You can check this by disabling the alpha test.


Oh, sorry

Set the alpha test to be less or equal to instead of greater, and set the test value to 0. It wasn’t working because you were telling it not to draw pixels with an alpha value of more than .5, and when it drew the 0 alpha texels, they were invisible anyway. If you use a visible alpha value, you should see an inverse image of what you want.


On my site, I’ve a little example who use the alpha chanel.

The program displays a simple rotating tree and if you press ‘A’ key, you’ll enable the alpjha test and if you press the ‘Z’ key, you’ll disable de alpha test.

“Download” section.

Please, send me feedback …