Sprites and transparency in OpenGL...,
Members - Reputation: 1323
Posted 29 July 2001 - 04:16 AM
you draw the sprite... Of course, it makes the sprite more transparent all over which is rather annoying
I figured this out the hard way the other day... Alpha channels are a really nice thing to have in
OpenGL Game Programming Tutorials
Members - Reputation: 174
Posted 29 July 2001 - 05:35 PM
If you want to use the standard sort of sprites where a certain color value represents transparency, you can create the alpha channel at runtime. In the function you use to load images into a buffer (right before using that buffer to make a texture), analyze the RGB value to determine if it is. If so, make the alpha value 0, otherwise, make it 255 (assuming that you''re using an 8-bit byte per component). Then make the texture as in the paragraph above.
To make the alpha channel useful, you have to enable blending and use some blending such as glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (that''s how I''ve always done it, though GL_SRC_ALPHA, GL_ONE might work as well).
So, then you have to draw the billboard. Since it needs to face the camera always, you just use the camera''s angle to determine the angle necessary to make the billboard parallel to it. Then just draw the billboard using the sprite texture and blending mode.