On this page
  1. Your game
    1. The entry point
    2. Scenes, objects and resources
    3. One configuration file
  2. The modules
  3. The core
  4. raylib 6.2, modified
  5. The targets

Architecture

A game made with this framework is five layers deep. At the top is the code you write; under it, the modules you choose to use; under those, a small core that runs the frame; under that, raylib; and at the bottom, the 17 targets the same source is built for. Each layer only reaches down, never up.

The layers of a game made with the framework, top to bottom Your game what you write RMP_GAME src/main.cpp Scenes one per screen Objects your classes resources/ art, sound, levels The .toml one config file Modules include what you use rmp::ui on Clay rmp::input named actions rmp::assets files or a pack rmp::Tilemap LDtk and Tiled rmp::audio sounds by name rmp::save on cJSON rmp::random seeded rmp::ads raymob, Android rmp/math.h vector operators rmp::Camera in every scene rmp::behavior the catalogue The core compiled once: rmp App and loop the frame Scene stack deferred changes Object storage slots and handles Collision objects and map Behavior engine any struct raylib 6.2 modified, marked rcore window, input rlgl OpenGL rshapes shapes rtextures images rtext fonts raudio sound rmodels 3D 17 targets in 6 families linux glibc, musl, DRM windows x64, arm64 apple macOS, iOS web WebAssembly android APK and AAB bsd Free, Open, Net The layers of a game made with the framework, top to bottom Your game what you write RMP_GAME src/main.cpp Scenes one per screen Objects your classes resources/ art, sound, levels The .toml one config file Modules include what you use rmp::ui on Clay rmp::input named actions rmp::assets files or a pack rmp::Tilemap LDtk and Tiled rmp::audio sounds by name rmp::save on cJSON rmp::random seeded rmp::ads raymob, Android rmp/math.h vector operators rmp::Camera in every scene rmp::behavior the catalogue The core compiled once: rmp App and loop the frame Scene stack deferred changes Object storage slots and handles Collision objects and map Behavior engine any struct raylib 6.2 modified, marked rcore window, input rlgl OpenGL rshapes shapes rtextures images rtext fonts raudio sound rmodels 3D 17 targets in 6 families linux glibc, musl, DRM windows x64, arm64 apple macOS, iOS web WebAssembly android APK and AAB bsd Free, Open, Net
Each layer is built on the one under it. A box with a link goes to its page.

The rest of this page takes the layers one at a time, from the top.

Your game#

What a game is made of is deliberately small. The entry point is one line, the screens are scenes, the things in them are objects, the art is in a folder, and every setting is in one file.

The entry point#

The whole of src/main.cpp, as the framework ships it and as rmp new copies it into a new game:

// Your game starts here, and this is all of it.
//
// RMP_GAME opens the window from [window] in raylib_multiplatform.toml, enters
// the scene you name, runs it every frame, and shuts everything down on the way
// out — on every target, including the two where main() is not a main() at
// all. Your work is in src/scenes/ and src/objects/.

#include <rmp/app.h>

#include "scenes/main_menu.h"

RMP_GAME(MainMenuScene);

RMP_GAME opens the window from [window] in raylib_multiplatform.toml, enters the scene you name, runs the scene stack every frame and closes everything on the way out. There is no InitWindow() to write and no loop: those lines were the same in every game, and on the web and on iOS the loop is not even yours to write — the browser and UIKit own it.

The first scene is named in code and not in the .toml on purpose. Choosing a scene by name means a table from names to types, and in C++ that table is built by objects that register themselves when the program starts. A linker building a static library or an iOS framework throws away any object file nothing refers to, and a self-registering object is exactly that: the game would build, run on a desktop and find no scenes on a phone. So the type is named where the compiler can see it.

Scenes, objects and resources#

A scene is one screen — a menu, a level, a pause overlay — and an object is anything inside one: the player, a bullet, a coin. Both are classes you derive from rmp::Scene and rmp::Object, one per file, under src/. A game made by rmp new starts with one, src/scenes/main_menu.cpp.

Every build system collects src/ recursively, so a new file or a new folder needs no change to CMake, Gradle or Xcode.

The art, the sounds and the levels go in resources/ and are loaded by name: rmp::assets::load_texture("player.png"). While you develop they are read from that folder; a release packs them into one resources.rres file, optionally encrypted, and the same call reads them from there (rmp pack does the packing by hand).

One configuration file#

Everything a build system needs to know about the game — its name, its window, its identifiers on the stores, the targets it is built for — is in raylib_multiplatform.toml. It is the only file of that kind you edit: tools/configure.py turns it into what CMake, Gradle and Xcode read, so the three cannot disagree with it. The config pipeline follows it all the way through, and Configuration lists every key.

The modules#

Everything the framework adds to raylib is under rmp::, one header per module. There is no header that includes them all: a file that draws the HUD includes rmp/ui.h and knows nothing of saving or sound. Why it is split this way has the reasons and the measurements.

HeaderWhat it gives youBuilt on
rmp/ui.hrmp::ui: menus, buttons, layout, themes, in screen spaceClay, the layout engine
rmp/input.hrmp::input: named actions bound to keys, buttons and sticks, and the pointerraylib's input, sampled once a frame
rmp/assets.hrmp::assets and rmp::Texture and its siblings: loading by name, released by themselvesrres for the pack, cute_aseprite for sprite sheets
rmp/tilemap.hrmp::Tilemap: a level made in LDtk or TiledcJSON for LDtk, cute_tiled for Tiled
rmp/audio.hrmp::audio: sounds and music by name, three volume busesraylib's raudio
rmp/save.hrmp::save and rmp::Value: save slots in the platform's own foldercJSON, and Monocypher to seal a file
rmp/random.hrmp::random: one seeded generator you can replayxoshiro128++, written out
rmp/ads.hrmp::ads: interstitial and rewarded adsraymob's AdMob bridge on Android, once [android.admob] enabled turns it on; nothing anywhere else
rmp/math.harithmetic: +, - and * on raylib's own vectors, and raylib-cpp's math classes for those who want methodsraylib's raymath, and the math headers of raylib-cpp
rmp/behavior.hrmp::behavior: the catalogue — movement, health, timers, spawnersthe core's behavior engine
rmp/scene.hrmp::Scene and rmp::Camerathe core
rmp/object.hrmp::Object, rmp::Handle, rmp::Callbackthe core
rmp/app.hRMP_GAME, rmp::app::quit() and rmp::globalthe core

Opt-in means two things here, and it is worth being exact about both.

You include what you use. Each header is a module you can take or leave, and none of them is an umbrella for the others. A few do bring another one with them, and say why at the top: rmp/scene.h includes rmp/object.h and rmp/tilemap.h, because a scene holds its map by value and spawns objects; rmp/object.h includes rmp/assets.h, because a sprite holds a texture by value. Every public header also includes rmp/config.h, the values from the .toml, so you never type that one.

You pay for what you use. A camera and a map are fields of every scene: a map nobody loads draws nothing and stops nothing, and a camera nobody touches shows the world at the design resolution as it is. The UI starts Clay on the first rmp::ui::begin() of the game, and the sound device opens on the first call that needs it, so a game with no menus has no UI arena and a game with no sound never opens the device.

None of it walls raylib off. An rmp::Texture converts to the Texture2D it wraps, so every raylib function that takes one takes it; a scene can open the camera and draw with raylib directly; and a game in plain C can skip the framework altogether and still be built for every target but the two where the loop is not the game's to write, the web and iOS.

The core#

Under the modules is the part every game uses, whether it includes a module or not: the code that runs a frame. It is five pieces, and their order within one frame is the subject of One frame.

The app and the frame loop

RMP_ENTRY_POINT writes the program's entry point for the platform it is compiled for, because there are three shapes of one. On Windows, Linux, macOS, the BSDs and Android it is a main() with a loop. On the web the browser owns the loop and calls a function back once a frame, through emscripten_set_main_loop(). On iOS UIKit owns it, and the program is three callbacks. All three do the same things in the same order around your code, and RMP_GAME is that macro with the three hooks written for you.

The scene stack

A vector of owning pointers, and a queue of the transitions asked for during the frame. change, push, replace and pop only record; the stack changes when the frame is over, because the call usually comes from inside the scene that is about to go.

The object storage

Every object of every scene lives in one pool of slots. A slot owns its object through a std::unique_ptr and carries a generation number. A rmp::Handle is the slot's index and that generation, so a handle to an object that died stays dead even when the slot holds something new. Destruction is deferred to the end of the frame, which is what makes the reference spawn() returns good for the rest of it.

Collision and the map

Arcade collision, written for the framework: rectangles and circles, a uniform grid so only near pairs are tested, a swept test so a fast object cannot pass through a thin one between two frames, and separation for the pairs that are both solid. A solid object that is not immovable is stopped by the map's solid cells one axis at a time, so it runs along a floor of tiles without catching on the seams. It is not a physics engine, by decision: a rigid-body library would make position a mirror of somebody else's body, and a Pong ball would need a density and a friction to bounce.

The behavior engine

A behavior is a struct with an _update(rmp::Object &, float), or a _late_update with the same signature when its whole job is to correct where the object ended up, as GridSnap does, and no virtual functions, so that it stays an aggregate. The engine finds its optional hooks at compile time with requires, keeps one table of function pointers per type, and owns the struct through a std::shared_ptr<void> that carries its destructor. A behavior of yours and one of the catalogue's are the same kind of thing; there is no base class and nothing to register.

In a CMake build — the desktops, the BSDs and the web — the framework is compiled once into a static library called rmp, and the game and every example written in C++ link it. The one file kept out of the library is src/rmp/app/app.cpp: each executable compiles its own copy, because it refers to the symbol the entry-point macro defines, and that reference is what turns a program with no RMP_GAME into a link error that names what is missing. The Android build and the iOS project compile src/ as a whole into the app, framework and game together.

The library is built only when src/rmp/ has sources. A game in plain C deletes that folder because nothing in it is used: a game with no C++ of its own in src/, outside src/rmp/, is linked to raylib alone, so a src/rmp/ left behind would be the whole framework compiled for nothing in a CMake build, and compiled into the game on Android and iOS, which take everything under src/. With it gone the build has no framework library at all — only raylib, the game's own C, and the headers that are plain C.

Those headers are on a plain C game's include path on every target: rmp/config.h for the values of the .toml, tests/smoke_test.h for the CI's hooks, and <admob.h> from thirdparty/raymob for the ads as C functions, which do nothing anywhere but Android.

raylib 6.2, modified#

Under the core is raylib 6.2, vendored in thirdparty/raylib. The copy is modified, and says so: the zlib licence requires an altered copy to be plainly marked, and its PATCHES.md lists every change. It is raylib 6.2 as raylib_cmake_template carries it — with raylib's own fixes from after 6.2 and the gaps its security audit left closed — with the framework's patches on top. Most of those are build-system and platform-selection patches, so the windowing backend can be chosen from the .toml; one makes Android's EGL ask for the OpenGL ES version raylib was compiled for, and the DRM backend's card probe, Escape on its terminal and its flow control are fixed. Among the libraries raylib bundles, three files are changed: the software renderer's nearest-texel lookup is clamped to the texture, a fix of the framework's own that upstream does not have, so the far edge of a texture reads its last texel and not the one past it; the OBJ loader takes raylib's face fix from after 6.2; and RGFW's gamepad code builds on older kernel headers. Licences has the rest.

The iOS app is the one target that does not build this copy. It links a raylib.xcframework built from a fork, omardev29/raylib-iOS, pinned at tag 6.0.3-iOS as the submodule thirdparty/raylib-ios, so the changes PATCHES.md lists are what every other target runs, not what iOS runs.

raylib is built in modules, and the framework leans on most of them:

ModuleWhat it doesCan a game leave it out?
rcorethe window, input, timingNo: raylib requires it
rlglthe OpenGL layer under every draw callNo: raylib requires it
rshapesrectangles, circles, linesNo: rmp::ui draws every panel and button with it
rtexturesimages and texturesNo: the asset layer and the CI render check are built on it
rtextfonts and textNo: the rres loader calls into it
raudiosound and musicYes
rmodels3D models and meshesYes

Leaving one out is [raylib] disabled_modules, and configure.py refuses the modules in the third column that say no, with the reason, before anything compiles. The iOS build links a prebuilt raylib and ignores the setting.

[raylib]
disabled_modules = ["rshapes"]
  raylib_multiplatform.toml:2: disabled_modules = ["rshapes"]
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  configure: error: [raylib] disabled_modules: 'rshapes' cannot be disabled — rmp::ui draws every panel, button and border with it — DrawRectangleRounded and three others — and the UI is always compiled in, so there is nothing left to link against.

The targets#

At the bottom are the platforms the same source is built for: 17 targets in 6 families. A family is the set of targets one CI workflow builds.

TargetWhat it isFamilyGroups it is in
linux-x64-glibcLinux x86-64linuxall, desktop, linux
linux-arm64-glibcLinux ARM64linuxall, desktop, linux
linux-riscv64-glibcLinux RISC-Vlinuxall, desktop, linux
linux-x64-muslLinux x86-64 (musl / Alpine)linuxall, linux
windows-x64Windows x86-64windowsall, desktop, windows
windows-arm64Windows ARM64windowsall, desktop, windows
macosmacOS (universal)appleall, apple, desktop
iosiOS (simulator)appleall, apple, mobile
webWeb (WebAssembly)weball, web
androidAndroidandroidall, android, mobile
freebsd-x64FreeBSD x86-64bsdall, bsd
freebsd-arm64FreeBSD ARM64bsdall, bsd
openbsd-x64OpenBSD x86-64bsdall, bsd
openbsd-arm64OpenBSD ARM64bsdall, bsd
netbsd-x64NetBSD x86-64bsdall, bsd
linux-x64-glibc-drmLinux DRM/KMS (no X11)linuxall, drm, linux
linux-arm64-glibc-drmLinux ARM64 DRM/KMS (no X11)linuxall, drm, linux

A target's name is <os>-<arch>-<libc>-<env>, and each part is there only when it can differ. linux-x64-glibc and linux-x64-musl name their C library because a binary built for one does not start on a system with the other: musl and glibc are two libraries, not two versions of one. The last part is the windowing system — drm draws straight to the screen with no X11 and no Wayland — and is absent when the binary carries every backend and picks one when it starts. windows-x64 and macos stop early because Windows has one C library and the macOS build is universal.

Each family has its own build system underneath, all of them fed from the same .toml: CMake for the desktops, the BSDs and the web, Gradle for Android, and an Xcode project generated by XcodeGen for iOS. A push to the framework builds Linux x64, the web, Android and Windows x64; a release tag builds every target, boots the ones a runner can boot, and checks that each one drew — Testing says how.