Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 24 Jan 2012
Offline Last Active Jan 26 2012 07:36 PM

Topics I've Started

Copying alpha mask from one surface to another in SDL

24 January 2012 - 12:15 PM

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!