Sign in to follow this  
CoMaNdore

2d lighting with sdl

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this