Banjo API 1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1
57#ifndef BJ_APP_H
58#define BJ_APP_H
59
60#include <banjo/api.h>
61#include <banjo/math.h> /* bj_real */
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
110#ifndef BJ_NO_TYPEDEF
112#endif
113
120struct bj_app;
121
142typedef void* (*bj_app_setup_fn)(struct bj_app* app, void* init_data);
143
165typedef void (*bj_app_step_fn)(
166 struct bj_app* app,
167 struct bj_tick_info tick,
168 void* user_data
169);
170
192typedef void (*bj_app_fixed_step_fn)(
193 struct bj_app* app,
194 struct bj_tick_info tick,
195 void* user_data
196);
197
208typedef void (*bj_app_teardown_fn)(struct bj_app* app, void* user_data);
209
210
224BANJO_EXPORT void bj_set_fixed_step_rate(struct bj_app* app, int hz);
225
236BANJO_EXPORT int bj_app_fixed_step_rate(const struct bj_app* app);
237
268BANJO_EXPORT void bj_set_frame_rate(struct bj_app* app, int hz);
269
282BANJO_EXPORT int bj_app_frame_rate(const struct bj_app* app);
283
320 void* init_data
321);
322
341BANJO_EXPORT void bj_quit_app(struct bj_app* app, int exit_code);
342
343#ifdef __cplusplus
344}
345#endif
346
348
349#endif /* BJ_APP_H */
General-purpose definitions for Banjo API.
static void step(struct bj_app *app, struct bj_tick_info tick, void *user_data)
Definition audio_pcm.c:144
static void teardown(struct bj_app *app, void *user_data)
Definition audio_pcm.c:170
static void * setup(struct bj_app *app, void *init_data)
Definition audio_pcm.c:107
bj_real delta
Definition app.h:107
bj_real alpha
Definition app.h:108
void(* bj_app_teardown_fn)(struct bj_app *app, void *user_data)
Application teardown callback.
Definition app.h:208
int bj_app_frame_rate(const struct bj_app *app)
Return the configured frame-rate cap (in Hz) for app.
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_set_fixed_step_rate(struct bj_app *app, int hz)
Configure the fixed-step rate (in Hz) for app.
void(* bj_app_step_fn)(struct bj_app *app, struct bj_tick_info tick, void *user_data)
Application per-iteration callback.
Definition app.h:165
void *(* bj_app_setup_fn)(struct bj_app *app, void *init_data)
Application setup callback.
Definition app.h:142
void bj_set_frame_rate(struct bj_app *app, int hz)
Cap the run loop to at most hz iterations per second.
void(* bj_app_fixed_step_fn)(struct bj_app *app, struct bj_tick_info tick, void *user_data)
Application fixed-rate step callback.
Definition app.h:192
void bj_quit_app(struct bj_app *app, int exit_code)
Signal the given application to exit on the next iteration.
int bj_app_fixed_step_rate(const struct bj_app *app)
Return the configured fixed-step rate (in Hz) for app.
Timing snapshot handed to the step and fixed-step callbacks.
Definition app.h:106
#define BANJO_EXPORT
Definition api.h:163
float bj_real
Selected real type for float configuration.
Definition math.h:76
static void fixed_step(struct bj_app *app, struct bj_tick_info tick, void *ud)
C99 math shim with bj_real precision type and scalar utilities.