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 3.3, (Vulkan Alpha).

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.

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 ./compile_main.sh -DMAIN="examples/engine_demos/engine_demo.cpp", which also compiles fan

Compiling fan as a library:

  • Using -DBUILD_FAN_LIBRARY= can be set to either STATIC or SHARED

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

Examples

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

Engine Demo that is kept up to date with newest library usage.

Demos

A game demo using fan image

A program that demonstrates fan's and the engine's features image

Developer console support (F3) image

output

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

image

image_2023-11-11_20-24-01

image_2023-11-11_20-29-09

sort_visualizer image_2023-11-11_20-33-48

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

Contributors 2

  •  
  •