Initialization
Every micro application starts and ends through these three functions. entry is the
recommended wrapper — it calls init, runs your code, catches any exception, and always
calls quit before returning.
entry
template <std::invocable Fn>
int entry(Fn&& fn);
template <std::invocable Fn>
int entry(Fn&& fn, int argc, char** argv);
Runs an application, handling initialization, shutdown, and errors automatically.
Returns EXIT_SUCCESS or EXIT_FAILURE.
int main() {
return micro::entry([] {
micro::window win{"Game", 640, 480};
micro::renderer rend{win};
win.run([&](float) {
rend.clear(micro::color::black);
rend.present();
});
});
}
With command-line arguments:
int main(int argc, char** argv) {
return micro::entry([](std::vector<std::string> args) {
for (const auto& arg : args)
micro::log::info() << arg;
}, argc, argv);
}
init / quit
void init();
void quit();
Manual lifecycle management. Prefer entry unless you need control over when
initialization and shutdown occur. quit is safe to call multiple times.
error
class error : public std::runtime_error { ... };
Thrown by any micro function that fails. The message always includes the originating SDL error string.
try {
auto img = micro::image::load_png("missing.png");
} catch (const micro::error& e) {
micro::log::error() << e.what();
}