2d lighting with sdl

Started by
3 comments, last by Roots 19 years, 7 months ago
Hi Im making a top down game in sdl (pure sdl) not opengl and I was wondering if there is any suport in the api for lightning? Or do I just have to use SDL_Get/Set Pixel and do it in software? Also are there any way I perform blending in SDL/or do I need to make this one with set/get pixel also ?
- Me
Advertisement
No, sorry, there is no way to do true lighting in 2d like you would with openGL. But, if you wanted to achieve a fake flashlight effect, what you could do is make a black square the size of the screen, and make a eclipse in the center of that transparent, then blit that last.

See my tutorials on doing colorkeying for more info. I believe thats tutorial 2c. The location is in my sig.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
You can do blending though, you do this with messing with the alpha channel. you can do this pixel by pixel with SDL_MapRGBA, and to mess with the whole image, you can use the set alpha function.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
colorkeying is no good to avhive what i want..
but i think i will be able using alpha maps

thx
- Me
This is one reason why I decided to use OpenGL in my top-down SDL game. If you want to do any fancy effects it's much easier to do with OpenGL than to write routines yourself from scratch, and it will probably look better too.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

This topic is closed to new replies.

Advertisement