Jump to content
  • Advertisement
Sign in to follow this  
SomeoneX

openGL transparency

This topic is 3606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was looking for information on how to load a texture with a transparent color, something like SDL's color keying or alpha. I saw some code that actually accomplished this, but did not see any explanations for how or why it does so. The code I looked at was in the NeHe tutorials (lesson 9). Fairly new to openGL, but I think I understand the basics enough to try and throw a little project together, except for this little stumbling block.

Share this post


Link to post
Share on other sites
Advertisement
Basically, what you do is the following:

You load the image (texture). Let's say you colorkey off the first pixel in the image, but this can apply to any color. So, getColor(0,0) ... pseudo code for get the color in the upper left corner of the image; this will be the transparent color. You will have a color with red, green, blue, and alpha values. Then you replace all instances of this color in the image with a color with the same r, g, b values, but you make the alpha value zero. It is now translucent and you basically have colorkeying in OpenGL.

Share this post


Link to post
Share on other sites
Thanks for the response. I'll try that way right now.

I was hoping there was a way to do it with something like an alpha channel from the image. Not sure if .bmp supports alpha, however, and from the little bit of browsing I did loading a .png seems a bit complex for now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!