PDA

View Full Version : 2D no white drawing



darkhorror
09-25-2000, 06:33 PM
I have a 2D texture that is a drawing of a player. Where the player isn't drawn it's white, what do I need to do to not draw the white part? I want to do something like CopyBits() with transparent not src.

Bob
09-26-2000, 12:09 AM
Add an alpha channel to your image before uploading it as a texture, and then set a alpha test function to reject pixels with alpha value below a certain limit. The alpha value you add could be 1.0 where you want to draw the player, and 0.0 for each the pixels.

With glAlphaFunc(0.5, GL_GREATER) you can reject all pixels with an alpha value les than 0.5. And don't forget to call glEnable(GL_ALPHA_TEST) too. And of course, you can set any reference value in glAlphaFunc, aswell as any compare function.