Skip to content

6413/fan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fan

License

2D graphics library using OpenGL.

Features

  • 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.

Limitations

  • Limited shapes for collisions
  • The library is still in development, bugs and missing features to be expected

Installation

Requires c++20

Windows

  1. Clone the repository: git clone https://github.com/6413/fan.git
  2. Using Visual Studio use fan.sln. Alternatively compile using clang++ (currently not working for windows)

Linux

  1. Clone the repository: git clone https://github.com/6413/fan.git
  2. Install required dependencies
    sudo ./install.sh
    
    (./uninstall.sh) to remove repos from /usr/local/include/*
  3. 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

Usage

  • 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;
    }

Examples

Check out the examples directory for sample projects demonstrating various features of the library.

Demos

Game demo using fan

image

Developer console support (F3) image

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

alpha blending
image

quadtree_visualize image_2023-11-11_20-24-01

particles image_2023-11-11_20-29-09

sort_visualizer image_2023-11-11_20-33-48

function_graph image_2023-11-11_20-36-10

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

Languages