Jump to content
  • Advertisement
Sign in to follow this  
Aternus

OpenGL Setting up a color key in OpenGL?

This topic is 4506 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

Just curious how would you go about setting up a colour key in OpenGL? You know, for having a "trasnparent" colour in your images. Would I have to say cut them out when I load the .BMP? Or is there a specific function for it? Or am I supposed to improvise here? Just curious, and all help is appreciated. :) --Aternus

Share this post


Link to post
Share on other sites
Advertisement
There is no color keying in OpenGL. You have to use the alpha channel in the texture and set the alpha channel depending on the color value. Before uploading the texture, add an alpha channel to the texture and set alpha to zero for whatever key color you choose, and one otherwise. Then use blendin or alpha testing to treat the alpha channel as the transparent parts.

Share this post


Link to post
Share on other sites
Great. Now I just have to figure out how to edit in alpha values into me .BMP's, as all I've got is MS Paint. Anyways, it's working (though I had to use someone else's .BMP as a test), and thanks for your help!

--Aternus

Share this post


Link to post
Share on other sites
There is no alpha channel in BMP.

Do the colour keying yourself:

- Assign one colour as the key, like you are doing now

- When loading the BMP into your application, create the alpha data at runtime by using your colour key information manually

Share this post


Link to post
Share on other sites
If you don't have the money for a more expensive program, go grab gimp, which is free, and quite capable. On that note, you could quite easily use Open IL (I think the name is DevIL which is an image loading library) to load just about any image type you'd like, and you just create the images in gimp, and then go load them up.

hope that helps
-Dan

Share this post


Link to post
Share on other sites
Thanks, taby! Just had to do some quick pixel checking while I swapped BGR for loading textures, and I have a globally defined (and working!) colour key now!

Ademan555, thanks for the offer on DevIL, but I try to avoid using extra .DLL's whenever I possible. I know that's kinda dumb, but I find the less files I can make a program have (and still have it run top notch) the better. And my .BMP will hold me for a while now. Though I will take a look into GiMP. So thanks. :)

--Aternus

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!