Sign in to follow this  
clint8565

question

Recommended Posts

clint8565    118
Hi, You've probably been asked this a million times, but how do I make part of a texture transparent so I can show the background through it with opengl in C++?

Share this post


Link to post
Share on other sites
SiCrane    11839
The two usual methods are to use an color key or an alpha channel.

For a color key, you color the parts you want to be transparent all as a single color, generally one that doesn't show up in the rest of your image. Be careful that the format of your texture doesn't have lossy compression otherwise your color key color will bleed into the rest of the texture giving you ugly artifacts.

For the alpha channel, most image editors offer the ability to simply add and the modify the alpha as a seperate layer or channel or mask. This depends somewhat on the image manipulation software yo use. For example, in Gimp I usually use a layer mask for transparency. Then I work directly on the mask to get the transparency effect I want. This gets flattened into the alpha channel when I export the texture to an image format that's loaded in OpenGL, usually a TGA.

Share this post


Link to post
Share on other sites
darookie    1441
Use an image format that supports alpha channels (OK, according to the specs BMPs can have an alpha channel, too but I have yet to see an application that supports this[wink]). TGA and PNG are the most common formats used for 32 bit images with alpha channels.

Using these formats you best take some image library like OpenIL to load them into an OpenGL texture. This saves you from a lot of hassle with figuring out the formats and writing a custom loader.

Good luck,
Pat.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this