Jump to content
  • Advertisement
Sign in to follow this  
Milo87

Copying alpha mask from one surface to another in SDL

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

Hi guys, first post here!

Is there a way to easily copy the alpha mask from one SDL surface to another?

I have a surface containing a dirt texture, and can carve out tunnels by modifying its per pixel alpha using a function. Is there a way to have another surface (a shadow, offset down and to the right of the dirt surface) inherit the dirt surface's alpha mask so that the shadow matches the carved-out dirt. At the moment I'm just parsing two surfaces into the carve function:

carveHole(SDL_Surface* surface, SDL_Surface* shadow, int x, int y, int radius)

However, this isn't very neat in my opinion, and I'd prefer to automate the shadow carving.

Failing that, would it be possible to blit the dirt twice, but have the first blit filled in black to simulate the shadow? Would save on having a whole different surface in memory, right?

Please forgive any stupidity, still early days with SDL!

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!