# Headers

> One header per module and no umbrella: what each of the framework's headers gives a game, and the RMP_ values every one of them carries from the config.

Source: https://omardev29.github.io/rmp-docs/manual/basics/headers.html

The framework is 16 headers under `include/rmp/`, one per module, and there is no header that includes them all. A file includes the modules it uses, and what it does not include it does not pay for.

## Include what you use

A file that draws the HUD includes `rmp/ui.h` and nothing else of the framework's:

```cpp
#include <rmp/ui.h>

#include <string>

void draw_hud(int score) {
    rmp::ui::begin({ .placement = rmp::ui::Align::TOP_CENTER });
    rmp::ui::text("Score " + std::to_string(score));
    rmp::ui::end();
}
```

That file gets the interface layer and only it: no entry point, no asset layer, no scene, and none of the C library's maths behind them. When the HUD changes it recompiles, and when the asset pipeline changes it does not. `examples/platform/03_minimal_includes` is this file as a check the framework's CI compiles on its own, so the claim cannot quietly stop being true.

The split is also what makes the framework something you take a piece at a time. A game can use [`rmp::ui`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ui.html) and draw everything else with raylib, or use scenes and objects and never touch the UI. Each header is a module you can name and decide about — which is the rule for adding one: a new header has to be a part of the framework with a name, because every header is one more thing a reader has to know exists.

A missing include is a compile error that says exactly what is missing. Using `rmp::input::just_pressed` in a file that never included `rmp/input.h` is an error that `rmp::input` was never declared — the compiler telling you which header to add.

## The headers

| Header | What it gives | Manual |
|---|---|---|
| `rmp/app.h` | The entry point — [`RMP_GAME`](https://omardev29.github.io/rmp-docs/reference/macros.html#RMP_GAME) and [`RMP_ENTRY_POINT`](https://omardev29.github.io/rmp-docs/reference/macros.html#RMP_ENTRY_POINT) — closing the app with [`rmp::app::quit()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-app.html#quit), and [`rmp::global<T>()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#global). Reference: [`rmp::app`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-app.html). | [The app](https://omardev29.github.io/rmp-docs/manual/core/app.html) |
| `rmp/scene.h` | [`rmp::Scene`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Scene.html), the stack of scenes, spawning and raycasting, and [`rmp::Camera`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Camera.html). | [Scenes](https://omardev29.github.io/rmp-docs/manual/core/scenes.html), [Camera](https://omardev29.github.io/rmp-docs/manual/core/camera.html) |
| `rmp/object.h` | [`rmp::Object`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Object.html), [`rmp::Handle`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Handle.html), [`rmp::Callback`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Callback.html), [`rmp::Sprite`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Sprite.html), the shapes, the edges and the ray queries. | [Objects](https://omardev29.github.io/rmp-docs/manual/core/objects.html), [Collision](https://omardev29.github.io/rmp-docs/manual/core/collision.html) |
| `rmp/behavior.h` | The catalogue of [`rmp::behavior`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-behavior.html): movement, tweens, timers, spawners, health. | [Behaviors](https://omardev29.github.io/rmp-docs/manual/core/behaviors.html) |
| `rmp/input.h` | [`rmp::input`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-input.html): named actions with up to eight bindings each, axes and directions, and the pointer. | [Input](https://omardev29.github.io/rmp-docs/manual/modules/input.html) |
| `rmp/ui.h` | [`rmp::ui`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ui.html): menus, buttons, text, layout, the controls of a settings screen, and themes. | [Interface](https://omardev29.github.io/rmp-docs/manual/modules/ui.html) |
| `rmp/assets.h` | [`rmp::assets`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-assets.html): loading from `resources/` by name, and the counted handles that release what they own — [`rmp::Texture`, `rmp::Font`, `rmp::Sound`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-detail-Resource.html) and the rest — with [`rmp::SheetData`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-SheetData.html) behind an Aseprite sheet. | [Assets](https://omardev29.github.io/rmp-docs/manual/modules/assets.html), [Sprites](https://omardev29.github.io/rmp-docs/manual/modules/sprites.html) |
| `rmp/tilemap.h` | [`rmp::Tilemap`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Tilemap.html) and [`rmp::MapObject`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-MapObject.html): levels from LDtk, and from Tiled. | [Tilemaps](https://omardev29.github.io/rmp-docs/manual/modules/tilemaps.html) |
| `rmp/audio.h` | [`rmp::audio`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-audio.html): sound effects and music by name, and three volume buses. | [Audio](https://omardev29.github.io/rmp-docs/manual/modules/audio.html) |
| `rmp/save.h` | [`rmp::save`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-save.html) and [`rmp::Value`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Value.html): saving the game, in the right folder on every platform. | [Saving](https://omardev29.github.io/rmp-docs/manual/modules/saving.html) |
| `rmp/random.h` | [`rmp::random`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-random.html): one seeded generator, so a run can be reproduced. | [Random](https://omardev29.github.io/rmp-docs/manual/modules/random.html) |
| `rmp/ads.h` | [`rmp::ads`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-ads.html): interstitial and rewarded ads, real on Android once `[android.admob] enabled` turns them on, and silently nothing otherwise. | [Ads](https://omardev29.github.io/rmp-docs/manual/modules/ads.html) |
| `rmp/math.h` | raymath's operators on raylib's own `Vector2`, `Vector3`, `Vector4` and `Matrix`, and raylib-cpp's methods on those and on `Rectangle` and `Color`. | [raylib in your game](https://omardev29.github.io/rmp-docs/manual/raylib/raylib.html) |
| `rmp/config.h` | The `RMP_` values from `raylib_multiplatform.toml`. Every header above includes it, so you never write it. | [Below](https://omardev29.github.io/rmp-docs/manual/basics/headers.html#rmp-config-h) |

Everything the framework adds is under `rmp::`, and everything else is raylib's, so in a file that mixes the two you can always tell which is which. All of raylib is there: `DrawTexture`, `IsKeyPressed`, `LoadModel`. The framework's types take and convert to raylib's own, so a `Vector2` is the same `Vector2` on both sides.

### rmp/math.h

This header exists for one line:

```cpp
position = position + velocity * delta;
```

The operators come from raylib's own `raymath.h`, which defines them for C++, so they work on the plain `Vector2` every raylib function takes; there is no second vector type to convert to and from. raylib-cpp's maths classes — `raylib::Vector2` and its siblings — derive from raylib's structs and add methods such as `Normalize`, for whoever prefers them. The rest of raylib-cpp is not vendored: its loaders throw on a failure, and nothing in this framework throws to the game.

It is a header of its own because the C library's `<math.h>` behind it is the expensive part, and a file that only draws menus should not pay for it. `rmp/ui.h` deliberately does not include it.

## Which header brings which

The framework's headers do not include each other. Where one needs a type from another it declares the name and nothing more — `rmp/app.h` names `rmp::Scene` without including `rmp/scene.h` — so that a header can grow without dragging the rest of the framework into every file that touches it.

The exceptions are where a type is held *by value*, which a declaration cannot provide, and each one says so at the top of the header:

| This header | Includes | Because |
|---|---|---|
| `rmp/scene.h` | `rmp/object.h`, `rmp/tilemap.h` | Every scene holds its `map` and its `camera`, and the camera holds a handle to the object it follows. |
| `rmp/object.h` | `rmp/assets.h` | An object's sprite holds an `rmp::Texture` or an `rmp::SpriteSheet`. |
| `rmp/tilemap.h` | `rmp/object.h` | A map stores the factories registered with `on_object()` as `rmp::Callback`s. |
| `rmp/behavior.h` | `rmp/object.h`, `rmp/scene.h` | The behaviors hold handles and callbacks, and a spawner's callback is handed the scene. |

So `rmp/scene.h` alone is enough to write a scene with objects in it. Including the headers you use by name anyway costs nothing and keeps the file honest about what it depends on.

The rule is about the framework's own headers only. The standard library and raylib are used wherever the job needs them: `rmp/app.h` includes `<memory>`, because the first scene is handed over as a `std::unique_ptr`. What each header costs to include is measured, and the framework's checks fail when one grows or shrinks by more than a fifth of what it was measured at.

## rmp/config.h

The values a game reads from `raylib_multiplatform.toml` arrive as macros:

```cpp
InitWindow(RMP_WINDOW_WIDTH, RMP_WINDOW_HEIGHT, RMP_WINDOW_TITLE);
```

`rmp/config.h` is the one framework header that every other one includes, and the only exception to the rule above. It earns that by costing nothing: its one include is the generated file of `#define`s, which includes nothing itself, and the two parse as fast as an empty file, within the noise of measuring it. In return the values are simply there, in every scene and every object, with nothing to remember. The framework's checks compile every public header on its own and fail the one that forgets it, so a new header cannot hand you an undefined macro.

It includes `rmp/generated/config.h`, which `tools/configure.py` rewrites on every configure and which is never committed. The file you can see in your editor exists so that the word "generated" never appears in anyone's code, and so that an editor that has not configured yet still resolves the include.

They are macros, not `constexpr` constants, so that a game in plain C can use the same values: a C file has no namespace to reach into. [Plain C](https://omardev29.github.io/rmp-docs/manual/raylib/plain-c.html) is also the one place you include it yourself, because a C file includes none of the framework's C++ headers.

| Macro | From |
|---|---|
| `RMP_PROJECT_NAME` | `[project] name` |
| `RMP_WINDOW_TITLE`, `RMP_WINDOW_WIDTH`, `RMP_WINDOW_HEIGHT` | `[window] title`, `width`, `height` — the design resolution |
| `RMP_WINDOW_VSYNC`, `RMP_WINDOW_FPS` | `[window] vsync` and `fps`, as 0 or 1 and a number |
| `RMP_MAX_DELTA` | `[app] max_delta` |
| `RMP_UI_THEME`, `RMP_UI_FONT`, `RMP_UI_FONT_SIZE`, `RMP_UI_SCALE`, `RMP_UI_MAX_ELEMENTS` | `[ui]`: what the interface starts with |
| `RMP_INPUT_DEADZONE` | `[input] deadzone` |
| `RMP_AUDIO_MASTER`, `RMP_AUDIO_MUSIC`, `RMP_AUDIO_SFX` | `[audio]`: the volumes the buses start at |
| `RMP_SAVE_PORTABLE`, `RMP_SAVE_ENCRYPT`, `RMP_SAVE_VERSION` | `[save]` |
| `RMP_RRES_PASSWORD` | `[resources] rres_password` |
| `RMP_DEV_STRICT` | `[dev] strict` |

The [macros reference](https://omardev29.github.io/rmp-docs/reference/macros.html#from-the-toml) has the same list with the framework's own values.

`RMP_RRES_PASSWORD` is in the header, and not only in the CMake build, because Android and iOS take nothing from CMake: a value defined there alone would differ on those two, and they could not open the pack they shipped with.

### Set by the build, not the .toml

Two more values come from the build system rather than from the `.toml`, and every build system defines both — CMake from its preset, Gradle from the build variant, Xcode per configuration:

```cpp
#if RMP_PRODUCTION_BUILD
    // compiled into a release build only
#endif
TraceLog(LOG_INFO, "assets are read from %s", RMP_RESOURCES_PATH);
```

The first is 1 in a release build and 0 in a debug one. It is defined everywhere on purpose: an undefined macro in `#if` is not an error but 0, which would quietly compile a game's debug-only code into its release on whichever platform forgot it. A build that forgets it fails to compile instead. The second is where the loose files of `resources/` are read from. On a desktop that is the project's folder by its absolute path in a debug build, and `./resources/` in a release. A desktop release moves into the executable's folder when it starts, when there is a `resources/` there, so that the path means the folder shipped beside it — [The app](https://omardev29.github.io/rmp-docs/manual/core/app.html#where-a-release-finds-its-files) has the detail. The web, Android and iOS read the copy packaged with the game.
