Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1
58#ifndef BJ_APP_H
59#define BJ_APP_H
60
61#include <banjo/api.h>
62#include <banjo/math.h> /* bj_real */
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
111#ifndef BJ_NO_TYPEDEF
113#endif
114
121struct bj_app;
122
143typedef void* (*bj_app_setup_fn)(struct bj_app* app, void* init_data);
144
166typedef void (*bj_app_step_fn)(
167 struct bj_app* app,
168 struct bj_tick_info tick,
169 void* user_data
170);
171
193typedef void (*bj_app_fixed_step_fn)(
194 struct bj_app* app,
195 struct bj_tick_info tick,
196 void* user_data
197);
198
209typedef void (*bj_app_teardown_fn)(struct bj_app* app, void* user_data);
210
211
225BANJO_EXPORT void bj_set_fixed_step_rate(struct bj_app* app, int hz);
226
237BANJO_EXPORT int bj_app_fixed_step_rate(const struct bj_app* app);
238
269BANJO_EXPORT void bj_set_frame_rate(struct bj_app* app, int hz);
270
283BANJO_EXPORT int bj_app_frame_rate(const struct bj_app* app);
284
321 void* init_data
322);
323
342BANJO_EXPORT void bj_quit_app(struct bj_app* app, int exit_code);
343
344#ifdef __cplusplus
345}
346#endif
347
349
350#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:142
static void teardown(struct bj_app *app, void *user_data)
Definition audio_pcm.c:168
static void * setup(struct bj_app *app, void *init_data)
Definition audio_pcm.c:107
bj_real delta
Definition app.h:108
bj_real alpha
Definition app.h:109
void(* bj_app_teardown_fn)(struct bj_app *app, void *user_data)
Application teardown callback.
Definition app.h:209
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:166
void *(* bj_app_setup_fn)(struct bj_app *app, void *init_data)
Application setup callback.
Definition app.h:143
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:193
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:107
#define BANJO_EXPORT
Definition api.h:179
float bj_real
Selected real type for float configuration.
Definition math.h:80
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.