• Advertisement
Sign in to follow this  

Copying alpha mask from one surface to another in SDL

This topic is 2188 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
Sign in to follow this  

  • Advertisement