How can I perform a masked erase in SDL2?

Posted by Kvisle on Game Development See other posts from Game Development or by Kvisle
Published on 2014-06-02T01:02:36Z Indexed on 2014/06/02 4:00 UTC
Read the original article Hit count: 204

Filed under:
|

I'm trying to implement some shadow/lighting effects in my 2D-project, and I've concluded that if there is an easy way to perform a masked erase on an SDL_Texture, it would make the drawing operations quite cheap.

  • Let's say I have a texture of the part of the level where light is not meant to be rendered.
  • I also have a texture with my "light map"; I want to use this to just draw omni lights from my light sources.
  • Then I want to use the first image to 'subtract' the portions of the light map that are not to be rendered on the final scene.
  • Then I draw my "light map" texture on top of my scene, with additive blending enabled.

This sounds like a good theory in my head, but I can't see any functions in the SDL2 API that let me do masked erase from a texture.

Am I overlooking something? Does anything like this exist?

© Game Development or respective owner

Related posts about sdl

Related posts about lighting