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.
Full documentation for all modules is available in the docs/ directory:
- Core Module (Windowing, Input, Time)
- Graphics Module (Sprites, Text, Shapes, Shaders)
- Audio Module (Sound, Music)
- Math Module (Vectors, Rects, Transforms)
- 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:
VertexArraysupport for high-performance rendering. - 2D Camera:
Viewsystem 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.
- C++17 compiler or later.
- CMake (3.10+).
- SDL2 development libraries (
libsdl2-dev). - OpenGL drivers.
mkdir build
cd build
cmake ..
makeThe project comes with a demo game imitating "Vampire Survivors" to showcase the engine's capabilities.
cd build
./SurvivorGameHere 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;
}- include/Polir/: Public header files.
- src/: Implementation files.
- examples/: Demo applications.
- third_party/: Single-header dependencies (
stb_image,stb_truetype).
This project is licensed under the MIT License - see the LICENSE file for details.