Skip to content

6413/fan

Repository files navigation

fan

License

2D graphics library using OpenGL 3.3, (Vulkan Alpha).

Features

  • Shapes: lines, circles, rectangles, sprites, etc.
  • Depth sorting
  • Batch rendering
  • Lighting
  • GUI
  • Collisions:
    • 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.

Installation

  • Requirements:
    • C++23 (modules)
    • Clang >= 20
    • CMake >= 2.8.*
    • Ninja >= 1.11.1

Linux

  1. Clone the repository: git clone https://github.com/6413/fan.git

  2. Install required dependencies:

    sudo ./apt_install.sh (optional)

    ./install.sh

    (./uninstall.sh) to remove repos from /usr/local/include/*

  3. Main usage:

  • To compile main use ./xcompile_main.sh, which also compiles fan

Windows

  1. Clone the repository: git clone https://github.com/6413/fan.git
  2. Code compiles using Visual Studio, external libraries are to be installed.

Basic Usage Examples

  • Hello world rectangle:
    // Creates graphics engine that opens a window and draws:
    // red rectangle at the position (400, 400), size 200x200 in pixels.
    import fan;
    
    int main() {
      fan::graphics::engine_t engine;
    
      fan::graphics::rectangle_t rect{{
          .position = 400,
          .size = 200,
          .color = fan::colors::red
      }};
      
      engine.loop();
    }
  • Text rendering:
    // Creates graphics engine that opens a window and draws:
    // red text at the top-left of window (0, 0) and
    // green text at the bottom-right using immediate-mode GUI.
    import fan;
    
    int main() {
      fan::graphics::engine_t engine;
    
      engine.loop([]{
        fan::graphics::gui::text("top left", fan::vec2(0, 0), fan::colors::red);
        fan::graphics::gui::text_bottom_right("bottom right", fan::colors::green);
      });
    }

Demos

Engine demo image

Game image

Console image

output

tilemap editor image Older versions image image_2023-11-11_20-32-21

Particles editor output image

License

This project is licensed under the MIT License, however some external libraries might have different license - see the LICENSE file for details.

About

fan - opengl graphics lib

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •