Transparent Imaging

Hi,
Im trying to use a texture (loaded bitmap, and I set the white pixels Alpha’s to zero,therefore they are transaprent). Ive wrapped it around a quad ( Im actually creating a 2d game, and drawPixels is HORRIBLY sloooow,so I breifly read a few posts here and saw a mention of how using texturing and quads is much faster). However,
how do I disable the acual quad color? Ive tried to set its alpha value to zero, however my texture then dissapears. Setting it to black defeats the purpose since you still have a black rectangle covering whatever is going to be behind it? I assume it has something to do with the texturing properties but Im having difficulty figuring it out…please help…thanx.

You set the alpha to zero for only those pixels you do want drawn, and maxium alpha for those you do want drawn. Then use alpha testing to remove the unwanted pixels rather than alpha blending.

Originally posted by DFrey:
You set the alpha to zero for only those pixels you do want drawn, and maxium alpha for those you do want drawn. Then use alpha testing to remove the unwanted pixels rather than alpha blending.

how can i do that dfrey ???

On NeHe website there’s a tutorial on alpha testing… I still have to look at it but I hope it will help you.

Find an online copy of the red book (search the discussion board for a link) and look up the section on texture functions (i.e. glTexEnv). This has an explanation of which texture functions can be applied and their respective functions. It won’t take you long to work out what texture function you want.

At a guess, you shouldn’t have to worry about trying to make the quad alphas anything special. Try using glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE). This gives a value of C = Ct, A = At for the outgoing fragment, where Ct and At are the incoming colour and alpha texture values i.e. the quad’s colour/alpha has no bearing on the outgoing result fragment. Then, you can use either alpha test or blending to give you the effect you want. In this way, using blending you can have various degrees of opaqueness, or using alpha test you can have either visible texture or none at all. Of course, you can combine alpha test and blending as well for other effects.

Hope that helps.