Archived

This topic is now archived and is closed to further replies.

fallout2600

Texture Mapping Problem

Recommended Posts

What you do is set the alpha value of the texture coordinate
to 0.0 if you want it to be transparent. 1.0 means totally
opague. Transparency is done through alpha-blending.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

So any and all color can be transparent, not just a single one.
It''s up to you to set up and bind the texture with the
desired alpha values.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
First, make sure the texture you loaded has an alpha channel. TGA files support alpha channels and are really easy to load (although, IMO, just DevIL use http://openil.sourceforge.net/ to load your images/textures). Then when you call glTexImage2D, use GL_RGBA for the component and format parameters (DevIL will take care of this for you).

When drawing, do as tangentz said and enabling alpha blending. To correct visual results, however, you''ll either have to sort your polygons and draw from back to front, or disable depth buffer writing before drawing your image via glDepthMask(false). You may have to also fiddle with the blend function.

Share this post


Link to post
Share on other sites
Oh i miss-understood you. So you want black to be transparent.

You need an alpha channel in your images as the previous posters have written.

And the effect is called alpha testing (when i remeber correct).

Share this post


Link to post
Share on other sites