PDA

View Full Version : transparency in textures



08-16-2005, 08:57 PM
I am applying textures on entity,how do I get
transparency on entity?what kind of opengl commands should I use?

memfr0b
08-17-2005, 12:20 AM
Make sure your texture has an alpha channel. Then enable alpha testing (see glAlphaFunc) and/or blending (see glBlendFunc). If you use blending you probably want to disable zbuffer writes for the blended geometry (see glDepthMask).

08-23-2005, 09:14 AM
I have problens with transparency in textures too, I load image from tiff format (having alfa channel) and loading with

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

The image is printed ok, but the transparency are printed black, or all image are translucid.
Actualy I use blend as:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

I render images in 2d (no depth test) on windows 2000.

Thanks

Hlz
08-23-2005, 10:51 AM
Can you post your code?

08-23-2005, 01:10 PM
I can solve it,
I change

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

to

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Thanks a lot