Jump to content
  • Advertisement

Archived

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

stan_k

OpenGL color keying in openGL?

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

im writing a 2D game in openGL, and learning it in the process, love the api so far. here is my plan, i output a quad and wrap a texture of a bitmap on it, so its like a DDraw surface with a bitmap loaded into it, i need to ger rid of the black stuff around the actual sprite in the bitmap, so the rest of the quad is transparent. how do i do this in openGL?

Share this post


Link to post
Share on other sites
Advertisement
Basically, you want the black to be invisible. In your opengl initialization code, You can try:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ZERO);

I''ve never tried this in a 2d game setting, so I''m not sure if this is the effect you''re looking for. But you can play with different constants if this doesn''t work. Basically, the GL_SRC_COLOR scale factor will be multiplied with the source color, and added to GL_ZERO multiplied with the destination color (which will always be zero in this case). You''ll then end up with the non-black portions of the sprite.

What kind of game are you making, anyway?

Share this post


Link to post
Share on other sites
thats could sort of work but the only proper way is to have an alpha channel + set the black pixels alpha to zero and the rest to 1 + enable alpha testing

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites

  • 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!