DEV Community

Cover image for Candle - A 2D lighting library for SFML

Posted on

Candle - A 2D lighting library for SFML

There is a big difference in the look and feel of a 2D game with dynamic lighting and one without it. The bad thing is that, while 2D game development is relatively accessible, lighting algorithms are not as much.

Fortunately, we have amazing people in this world, like javidx9, that has this amazing tutorial on 2D shadow casting. It inspired me to write Candle. It is easy to integrate, it has no dependencies other than SFML itself and it's open for further development!

The code comes with a demo to test the main features, which are dynamic lights, fog and shadows.

demo gif

Any feedback is appreciated! Thank you and have a nice day ;)


GitHub logo MiguelMJ / Candle

2D lighting for SFML



2D lighting for SFML

Candle is a SFML based C++ library that provides light, shadow casting and field of view functionalities with easy integration

Official documentation.



Before anything, here you have a little example of how it looks.

The code comes with a demo program showing the functionalities provided by the library. In it you can place lights and edges that will cast shadows, and modify the behaviour of the fog.

You can check the full manual of the demo here.



You can build the static library and the demo program with CMake.

mkdir build && cd build
cmake .. -DBUILD_DEMO=ON
cmake --build .
Enter fullscreen mode Exit fullscreen mode

This will generate libCandle-s.a or (Candle-s.lib on Windows) in build/lib folder, and the demo program (or demo.exe) in build/bin.


Alternatively, if you work in Linux, you can…

Top comments (0)