Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

OpenGL Transparency in OpenGL/SDL

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

When my game was in 2D and using SDL_BlitSurface to render images, I used SDL_SetColorKey to set pink (255, 0, 255) to transparent. Now, I'm using OpenGL with SDL and texturing quads with the same graphics. SetColorKey doesn't work anymore, apparently. I'm using IMG_Load (sdl_image.h) to load all my graphics. My question is: if I specify transparent areas in an image editor (like paintshop) and save them in a format that has an alpha layer, will they have those transparent areas in-game? Also, and especially if not, is there anything like SDL_SetColorKey that I can use to set pink to transparent on all the loaded surfaces and have those areas rendered transparent on the quads they texture? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Images with alpha channels should be properly transparent when used as GL textures, provided you remember to enable blending. (glEnable(GL_BLEND);)

Share this post


Link to post
Share on other sites
To use colorkey in OGL you need to use the alpha channel...
Like this sample from CodeSampler.com http://www.codesampler.com/source/ogl_color_key.zip.

The idea is set alpha to 0.0f for the rgb color...
if rgb == blue ( just a example )
alpha = 0
else
alpha = 1

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Images with alpha channels should be properly transparent when used as GL textures, provided you remember to enable blending. (glEnable(GL_BLEND);)


Alrighty. Thanks - now I just have to find someone to make pixel art for me. I can't even make a freakin asteroid! My art skills are that bad.

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!