Lightweight 2D game framework for C++

cerlib focuses on a simple design and allows you to design your game architecture your way.


Features

Cross-Platform

Runs on multiple platforms, including Windows, macOS, Linux, Android and iOS.

Free

Permissive license with no royalties attached.

App Framework

Based on a minimal SDL3 fork, with easy-to-use input, window and event handling.

GPU-based 2D Graphics

Efficient GPU-based rendering using the platform’s native graphics API, such as OpenGL and Metal.

Math Library

From colors, to vectors, to matrices, cerlib has it.

Sprite Shading

Simple and safe shading language that transpiles to native shading languages.

Audio Library

Easy-to-use audio API, including faders and channels for playback control.

Content Management

Load common formats such as PNG, JPG, DDS, WAV, MP3, OGG, FLAC and many more.

Particle Systems

Customizable behaviors via emitters, modifiers and shapes.

Built-in Dear ImGui

Automatically available in your game. Simply #include <imgui.h> and use it.

Graphics Debugger Support

Use RenderDoc or Xcode’s Metal Debugger for in-depth frame analysis and shader debugging.

Minimal C++ Subset

Improved containers and strings with bounds-checking and option types.


Minimal Example

#include <cerlib.hpp>
#include <cerlib/Main.hpp>

using namespace cer;

int main(int argc, char* argv[]) {
    // Create the game instance.
    auto game   = Game("My Game");
    auto window = game.window();

    // Load an image.
    auto img = Image("MyImage.png");

    while (game.tick()) {
        // Update game logic. Use 'time' as a reference point for
        // how much time has passed since the last tick.
        const auto time = game.time();

        // Draw an animated image.
        auto imgPos = (window.sizePx() - img.size()) / 2;

        imgPos.x += sin(float(time.totalTime) * 2) * 100;

        drawSprite(img, imgPos, white);
    }

    return 0;
}

What it does not provide

cerlib is not a 2D game engine and doesn’t provide any kind of visual level editor.
cerlib does not have any game scene representation or systems such as an entity-component-system.

In short, cerlib lets you define your game architecture however you desire it.
It doesn’t impose a strict model on the game’s code.

It provides every audiovisual aspect necessary to comfortably make a 2D game using a code-only approach.


Platform Support

Platform

Version / Architecture

Windows

≥ 8 (x64, ARM64)

Linux

Any (x64, ARM64)RISC-V is planned

Android

≥ 7 (All ABIs)

macOS

≥ 13.5 (Intel, Apple Silicon)

iOS, iPadOS, visionOS

≥ 16 (ARM64)In Development


Compiler Support

cerlib has been tested and is confirmed to work with the following compilers:

Compiler

Version

MSVC

VS 2022

Clang

≥ 16.0.6 (June 2023)

GCC

≥ 11.4 (May 2023)

Apple Clang

≥ 15 (September 2023)