Skip to content

Pomilon/Polir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polir Graphics Library

Polir is a lightweight, modern 2D game engine for C++ written on top of SDL2 and OpenGL. It is designed to be a simple, open-source alternative to libraries like SFML, offering a set of features for 2D game development.

This library is a complete modernization of a personal project I created years ago. Originally built as a learning exercise to understand how graphics libraries work and how rendering is implemented under the hood, I have now refactored it years later to be a capable, modern engine suitable for real-world usage.

Documentation

Full documentation for all modules is available in the docs/ directory:

Features

  • Windowing & Input: Simple window creation, event polling, and real-time keyboard/mouse input.
  • Graphics:
    • Sprites & Textures: Load images (PNG, JPG, BMP) and render them efficiently.
    • Shapes: Built-in Rectangle, Circle, Triangle, and Convex shapes.
    • Text Rendering: High-quality text rendering using TrueType fonts (.ttf).
    • Shaders: Support for Vertex and Fragment shaders (GLSL).
    • Render Textures: Rendering to off-screen framebuffers for post-processing effects.
    • Batching: VertexArray support for high-performance rendering.
    • 2D Camera: View system with zooming and rotation.
  • Audio:
    • Sound Effects: Load and play WAV files with mixing support.
    • Music Streaming: Stream long audio tracks from disk to save memory.
  • Math: Comprehensive Vector, Rect, and Matrix (Transform) classes.

Prerequisites

  • C++17 compiler or later.
  • CMake (3.10+).
  • SDL2 development libraries (libsdl2-dev).
  • OpenGL drivers.

Build Instructions

mkdir build
cd build
cmake ..
make

Running the Examples

The project comes with a demo game imitating "Vampire Survivors" to showcase the engine's capabilities.

cd build
./SurvivorGame

Example Code

Here is a minimal example showing how to open a window and draw a shape:

#include <Polir/Core/Window.hpp>
#include <Polir/Graphics/Shape.hpp>
#include <Polir/Graphics/Color.hpp>

int main() {
    Polir::Window window(800, 600, "My Polir App");
    
    Polir::CircleShape circle(50.0f);
    circle.SetColor(Polir::Color::Red);
    circle.SetPosition(400, 300);

    Polir::Event event;
    while (window.IsOpen()) {
        while (window.PollEvent(event)) {
            if (event.type == Polir::Event::Closed) window.Close();
        }

        window.Clear(Polir::Color::Black);
        window.Draw(&circle);
        window.Display();
    }
    return 0;
}

Architecture

  • include/Polir/: Public header files.
  • src/: Implementation files.
  • examples/: Demo applications.
  • third_party/: Single-header dependencies (stb_image, stb_truetype).

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A lightweight, modern C++ 2D game engine built on SDL2 and OpenGL.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published