PDA

View Full Version : partial transparency of textures



cixelsyd
07-11-2003, 11:01 AM
I am working on a 2d game and I want to make the box around my bitmap charaters transparent. I found the following in the FAQs, but I am having trouble understanding it since I am very new to OpenGL. Could anyone explain to me how to do this?

15.080 How can I make part of my texture maps transparent or translucent?

It depends on the effect you're trying to achieve.

If you want blending to occur after the texture has been applied, then use the OpenGL blending feature. Try this:

glEnable (GL_BLEND);

glBlendFunc (GL_ONE, GL_ONE);

You might want to use the alpha values that result from texture mapping in the blend function. If so, (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) is always a good function to start with.

However, if you want blending to occur when the primitive is texture mapped (i.e., you want parts of the texture map to allow the underlying color of the primitive to show through), then don't use OpenGL blending. Instead, you'd use glTexEnv(), and set the texture environment mode to GL_BLEND. In this case, you'd want to leave the texture environment color to its default value of (0,0,0,0).

dorbie
07-11-2003, 11:19 AM
All that's important here is that you have an alpha component in the texture and you enable blending, with src_alpha, one_minus_src_alpha. Your texenv will be modulate by default or if you're drawing pixels it'll work with the alpha. Modulate or replace will work with replace you need to make sure the polygon color is white or something else acceptable.

If you don't understand this then you need to start with some simple OpenGL tutorials, try NeHe.

cixelsyd
07-13-2003, 08:18 PM
Thanks
Since this is a newbie forum, I think it is alright if I ask again if someone could help me with this. Could anyone give me some sample code or names of some useful functions? Any real help would be greatly appreciated.