Loop-based program structure using Banjo's application API.
Loop-based program structure using Banjo's application API.This is the canonical Banjo program shape: a struct bj_app populated with setup, step, and teardown function pointers, passed to bj_run_app which drives the lifecycle. The same source compiles and runs the same way on Linux, macOS, Windows, and Emscripten.
static void*
setup(
struct bj_app* app,
void* init_data) {
(void)init_data;
return 0;
}
return 0;
}
static void step(
struct bj_app* app,
struct bj_tick_info tick,
void* user_data) {
(void)tick;
(void)user_data;
}
static void teardown(
struct bj_app* app,
void* user_data) {
(void)user_data;
}
int main(
int argc,
char* argv[]) {
(void)argc; (void)argv;
}
Application lifecycle: callback-driven setup, step, and teardown.
int main(int argc, char *argv[])
static void step(struct bj_app *app, struct bj_tick_info tick, void *user_data)
static void teardown(struct bj_app *app, void *user_data)
static void * setup(struct bj_app *app, void *init_data)
int bj_run_app(bj_app_setup_fn setup, bj_app_step_fn step, bj_app_fixed_step_fn fixed_step, bj_app_teardown_fn teardown, void *init_data)
Drive the application lifecycle.
void bj_quit_app(struct bj_app *app, int exit_code)
Signal the given application to exit on the next iteration.
Timing snapshot handed to the step and fixed-step callbacks.
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
bj_bool bj_begin(int systems, struct bj_error **error)
Initialises the system.
void bj_end(void)
De-initialises the system.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for system interactions.