Jump to content
  • Advertisement
Sign in to follow this  

Creating a mask in SDL

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

Ive been trying to create a 2D shadow effect in SDL, by creating a black/transparent mask. The shadow would be a copy of the image it was created from, except the pixels would either be black or transparent. The black pixels would be where the source image was opaque, and the transparent pixels where it was transparent. The closest I've come to success with this was writing my own custom blitting routine, but the complexities of pointer arithmetic and such got the better of me, and at best it only worked with 24bpp images. At worst... it looked like clown vomit, there were randomly coloured pixels everywhere. Does anyone know a way to do this? I'd like to steer away from anything that involves me manipulating the pixels if possible! Cheers

Share this post


Link to post
Share on other sites
Advertisement
Stay the heck away from pixel manipulation.
Instead, have the transparent color be like bright green, and do your black stuff like normal. Then just use the set color key function.

I have a tutorial on masking on my site.

And a quick tip for your masking thing, if your art program has a reduce color depth feature, reduce it to 2 colors, then bring it back up. bang, you have your mask.

Share this post


Link to post
Share on other sites
Yeah I learned my lesson about pixels manipulation...

Looks like I'll have to try it this way. My aim was to generate masks at run time from a surface, but that seems out of the question now :o(

Cheers for the tips.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!