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-system
And we run it
./app
The 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.