2D graphics library using OpenGL, designed to support various shapes, lighting, GUI elements, collisions, and particle effects.
- Shapes: Draw lines, rectangles, and sprite.
- Lighting: Illuminate your scenes with customizable lighting effects.
- GUI: (Dear ImGui) Easily integrate graphical user interfaces into your applications.
- 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:
-
To compile fan and it's libs to an object file use
./compile_fan.sh
you can set thread amount for compile using -jN -
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"
Optionally you can compile fan with main file like so (good for if fan source changes):
- To compile libs
./compile_all_libs.sh
you can set thread amount for compile using -jN - For linux you can export files to /usr/local/lib, by doing
sudo ./copy_to_default_paths.sh
- To compile main
./compile_main.sh -DBUILD_FAN=1 -DMAIN="examples/graphics/2D/shapes/rectangle.cpp"
- To compile libs
- 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.