This is a port of Candle to SFML3. No additional work/modification/upgrades have been added other than getting the project to compile and run. It has been successfully integrated into an existing SFML3 project, but not all features have been tested.
The only major change to note, though it should not affect existing projects, is that with the deprecation and removal of sf::Quads as a Primitive Type for Vertex Arrays, LightingArea and DirectedLight have had their Vertex Arrays adjusted to use sf::PrimitiveType::Triangles instead. They should function the same, as far as the user is concerned.
The original ReadMe is below.
Candle is a SFML based C++ library that provides light, shadow casting and field of view functionalities with easy integration.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 .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 use make, and also build the docs with it.
make
make docs # optional - SFML v2.5.1
- Graphics module and System module.
This library is meant to be used in SFML applications, so it's assumed that you are familiar with the process of compiling them. If you are not, you can learn in the official website .
- If you want to build the docs, Doxygen 1.9.1 is required.
Thanks to the people that have contributed to this project: (emoji key)
Modar Nasser π π π |
nightroy99 π π |
Lukas DΓΌrrenberger π |
Tim Stoddard π» π |
Dead-Deus π π |
GuillaumeG. π |
This project follows the all-contributors specification.
- Read the contributing guidelines if you want to contribute to the code.
- Open a new issue
to make a request or report a bug.
- Alternatively, comment it on the SFML forum
- If you use it in a project, you don't have to give any credit. But if you did so, that would be fantastic!
- And of course, β star this repository and give it some visibility
.
I will assume that you have SFML installed in your system. If we have a project with the following structure:
|- project
|- libCandle-s.a
|- main.cpp
|- include
|- Candle
|- Candle.hpp
|- ... # Candle headers
the main.cpp file could look like this:
#include <SFML/Graphics.hpp>
#include "Candle/RadialLight.hpp"
int main(){
// create window
sf::RenderWindow w(sf::VideoMode(400, 400), "app");
// create a light source
candle::RadialLight light;
light.setRange(150);
// create an edge pool
candle::EdgeVector edges;
edges.emplace_back(sf::Vector2f(200.f, 100.f),
sf::Vector2f(200.f, 300.f));
// main loop
while(w.isOpen()){
sf::Event e;
while(w.pollEvent(e)){
if(e.type == sf::Event::Closed){
w.close();
}else if(e.type == sf::Event::MouseMoved){
sf::Vector2f mp(sf::Mouse::getPosition(w));
light.setPosition(mp);
light.castLight(edges.begin(), edges.end());
}
}
w.clear();
w.draw(light);
w.display();
}
return 0;
}We can compile it with the following command:
g++ -o app main.cpp -Iinclude -L. -lCandle-s -lsfml-graphics -lsfml-window -lsfml-systemAnd we run it
./appThe result will be a simple light casting a shadow over an invisible wall in the center of the window.
Candle uses the MIT license, a copy of which you can find here, in the repo.
It uses the external library SFML, that is licensed under the zlib/png license.

