Jump to content
  • Advertisement
Sign in to follow this  
CoMaNdore

2d lighting with sdl

This topic is 5135 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 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!