rmp::app
rmp/app.h — the entry point, closing the app, and how the world fits the window.
You write on_ready(), on_frame(float) and on_exit(); RMP_ENTRY_POINT writes the runner for your platform. There are three, and the difference between them is who owns the frame loop:
desktop we do: a main() with a while loop, the ordinary raylib shape.
web the browser does. See the PLATFORM_WEB block below — this is not
a style choice, a while loop there costs you ASYNCIFY.
iOS UIKit does, so there is no loop to write and nothing to return
to: three callbacks it calls instead.All three do the same things around your code: start the smoke test, open the asset pack, run you, report to CI whether any asset failed to load, and close the pack afterwards. None of it is yours to remember.
WHAT THIS HEADER DOES NOT INCLUDE, and why it matters.
Not rmp/ui.h and not rmp/assets.h, although a run closes the UI and opens the asset pack. Naming rmp::ui::shutdown() or rmp::assets::init() here would make every translation unit with an entry point pay for the whole interface layer. So the macros DO nothing themselves: they call the functions in rmp::app::detail, compiled once in src/rmp/app/app.cpp, which is where those includes live. A macro is only the platform's entry-point shape.
The rule that comes out of it, and it governs every header we add:
- Include none of our headers. Forward-declare instead.
- If a namespace or a by-value type makes that impossible, include it and write down here why.
- If two headers end up needing each other, one of them should not exist.
rmp/config.h IS THE ONE EXCEPTION, and it is in every public header of ours rather than just this one. It costs nothing — one include, of the generated file of #defines, which includes nothing; 27 ms against an empty file's 28, which is below measurement noise — and rule 1 exists for compile time and coupling, so a leaf header that costs neither is not what the rule is aimed at. What it buys is that RMP_WINDOW_* and the rest are simply THERE, in scenes and objects and everywhere else, with nothing to remember. See rmp/config.h.
quit
Ask the app to close.
Call it from anywhere — a menu callback, a game-over screen, ten frames deep in your own code. It does not need to know where main() is, and there is no value to propagate back up through your call stack.
if (rmp::ui::button("Quit")) rmp::app::quit();It RETURNS. What it does is raise a flag that the entry point checks at the top of the next iteration, so the frame you are in finishes normally and then the stop hook runs, the window closes and the asset pack is released — the same shutdown as closing the window with the X.
That is the whole reason not to call std::exit() yourself: std::exit ends the process immediately, so the stop hook never runs, CloseWindow() never runs, and on Android the Activity is left behind while its process disappears.
It is not an exception either, and deliberately: exceptions are switched off in plenty of game builds, unwinding through raylib's C frames is undefined, and throwing mid-frame would leave BeginDrawing() unbalanced and a UI frame open. A flag costs one branch per frame and cannot leave anything half done.
Per platform:
desktop, BSD, Web the frame loop ends and main() returns
Android plus ANativeActivity_finish(), so the Activity actually
goes away instead of leaving a task behind
iOS NOTHING. It logs a warning and returns.Apple's QA1561 is explicit: an iOS app that terminates
itself "will appear to the user to have crashed", and
App Review rejects apps that crash or appear to. A Quit
control also fails the Human Interface Guidelines by
itself. So the same source ships everywhere and the
button is simply inert on iPhone — hide it with
#if !defined(PLATFORM_IOS) if a dead control bothers you.quit_requested
Has quit() been called? The entry point uses this; you are unlikely to need it unless you want to skip work on the way out.
Stretch
How the world fits a window that is not the size [window] says — a desktop window dragged wider, a phone of another shape, a TV. The [window] width and height are the DESIGN size: what the game was drawn for. s below is how much bigger the window is than that, min(width / design width, height / design height): the most the whole design fits.
NONE the world at 1:1 around the camera: a bigger window shows more
of it and a smaller one less, and nothing is scaled. What
every game got before there was a choice.
LETTERBOX the design, scaled by s and centred, the rest of the window
bars of the clear colour. Every player sees exactly the same
part of the world, the interface stays inside it, and
nothing is ever cut off -- a court, a board, a single screen.
EXPAND scaled by s like LETTERBOX, with no bars: MORE of the world
shows the way the window is longer than the design -- above
and below on a 4:3 monitor for a 16:9 design, at the sides on a
21:9 one. A level that scrolls anyway, where seeing further is
fine.The camera and the pointer follow it: Camera::view(), to_world(), rmp::input::pointer() and a click on an object are right in every mode, and rmp::ui keeps the interface inside the game's area. A game that draws its world in _draw() with its own BeginMode2D() goes through scene.camera.raylib() to get it too.
| Value | Means | |
|---|---|---|
NONE | ||
LETTERBOX | ||
EXPAND |
stretch
The mode in use. It starts as [window] stretch in raylib_multiplatform.toml.
set_stretch
Change it, from anywhere and at once: the next thing that asks — the camera, the pointer, the interface — sees the new mode. The examples share one .toml, so the ones that need another mode set it here, in their first scene's _ready().