cerlib logo startpage 1

Cross-platform 2D Game Library for C++

A lightweight library for easy 2D game development using C++ 20 and newer.
cerlib focuses on a simple design and at the same time offers you the possibility to design your game architecture your way.

cerlib Demo

Cross-platform

Runs on multiple platforms, including Windows, macOS, Linux, Android and your web browser.

Audio

Easy-to-use audio interface to play back sounds and songs.
Includes simple volume, panning and looping controls.

Open Source

cerlib is open source under a permissive Apache 2.0 license, with no royalties attached.

Content Management

Load resources such as images and sounds with ease, with automatic reference counting. Support for common file formats included.

Math

Comes with a math library that seamlessly integrates into both the C++ API as well as the shading language.

App Framework

Get a game running with just a few function calls. Allows rendering into multiple windows and event handling.

Sprite Shading

A custom, simple shading language allows you to customize your sprite rendering at the pixel level. Transpiles to native shading languages automatically.

Example

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

struct MyGame : cer::Game {
  MyGame() {
    window = cer::Window("My Game Window");
  }

  void load_content() override {
    image = cer::load_image("MyImage.png");
  }

  bool update(const cer::GameTime& time) override {
    // Update game logic. Use the time parameter as a reference point for
    // how much time has passed since the last update:
    // ...
    return true;
  }

  void draw(const cer::Window& window) override {
    // Draw game content into 'window':
    // ...
    cer::draw_sprite(image, {100, 200}, cer::white);
  }

  cer::Window window;
  cer::Image image;
};

int main() {
  // Create & run our game.
  return cer::run_game<MyGame>();
}