Creating and managing windows with event handling.
Creating and managing windows with event handling.This demonstrates window creation, event processing, and proper cleanup. Every graphical Banjo application needs a window and must process events to remain responsive.
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)
Sytem event management API.
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.
struct bj_window bj_window
void bj_dispatch_events(void)
Poll and dispatch all pending events.
void bj_close_on_escape(struct bj_window *window, const struct bj_key_event *event, void *user_data)
Handle the ESC key to close a window.
bj_key_callback_fn bj_set_key_callback(bj_key_callback_fn callback, void *user_data)
Set the global callback for keyboard key events.
bj_bool bj_begin(int systems, struct bj_error **error)
Initialises the system.
void bj_end(void)
De-initialises the system.
struct bj_window * bj_bind_window(const char *title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags, struct bj_error **error)
Create a new struct bj_window with the specified attributes.
bj_bool bj_should_close_window(struct bj_window *window)
Get the close flag state of a window.
void bj_unbind_window(struct bj_window *window)
Deletes a struct bj_window object and releases associated memory.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for system interactions.
Header file for bj_window type.