2D graphics library using OpenGL.
- Shapes: line, circle, rectangle, sprite, etc...
- Lighting: Library supports lighting.
- GUI: (Dear ImGui) Uses Dear ImGui for the GUI.
- Collisions (Box2D):
- Continuous collision detection
- Contact events and sensors
- Convex polygons, capsules, circles, rounded polygons, segments, and chains
- Multiple shapes per body
- Collision filtering
- Ray casts, shape casts, and overlap queries
- Image formats: JPEG (baseline & progressive), PNG (1/2/4/8/16-bit-per-channel), TGA (a subset), BMP (non-1bpp, non-RLE), PSD (composited view only, no extra channels, 8/16 bit-per-channel), GIF (always reports as 4-channel), HDR (radiance rgbE format), PIC (Softimage PIC), PNM (PPM and PGM binary only), WebP
- Audio: Currently only SAC is supported.
- Limited shapes for collisions
- The library is still in development, bugs and missing features to be expected
Requires c++20
- Clone the repository:
git clone https://github.com/6413/fan.git
- Using Visual Studio use fan.sln. Alternatively compile using clang++ (currently not working for windows)
- Clone the repository:
git clone https://github.com/6413/fan.git
- Install required dependencies
(
sudo ./install.sh
./uninstall.sh
) to remove repos from /usr/local/include/* - Main usage:
- For linux you can export files to /usr/local/lib, by doing
sudo ./copy_to_default_paths.sh
- To compile main use
./compile_main.sh -DMAIN="examples/graphics/2D/shapes/rectangle.cpp"
, which also compiles fan
- Hello world rectangle:
#include <fan/pch.h> int main() { loco_t loco; fan::graphics::rectangle_t rect{{ .position = 400, .size = 200, .color = fan::colors::red }}; loco.loop([&] { }); }
- Text rendering:
#include <fan/pch.h> int main() { loco_t loco; loco.loop([&] { fan::graphics::text("top left", fan::vec2(0, 0), fan::colors::red); fan::graphics::text_bottom_right("bottom right", fan::colors::green); }); return 0; }
Check out the examples directory for sample projects demonstrating various features of the library.
Developer console support (F3)
This project is licensed under the MIT License, however some external libraries might have different license - see the LICENSE file for details.