Banjo API 1.0.0-stable
Low-level C99 game development API
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
5
55
62#ifndef BJ_API_H
63#define BJ_API_H
64
65#include <stddef.h>
66#include <stdint.h>
67
71#if defined(__EMSCRIPTEN__)
72# define BJ_OS_EMSCRIPTEN
73#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
74# define BJ_OS_WINDOWS
75#elif defined(__linux__) || defined(__gnu_linux__)
76# define BJ_OS_LINUX
77#elif __APPLE__
78# define BJ_OS_APPLE
79# include <TargetConditionals.h>
80# if TARGET_OS_IPHONE
81# define BJ_OS_IOS
82# elif TARGET_IPHONE_SIMULATOR
83# define BJ_OS_IOS
84# define BJ_OS_IOS_SIMULATOR
85# elif TARGET_OS_MAC
86# define BJ_OS_MACOS
87# define BJ_OS_UNIX
88# else
89# define BJ_OS_APPLE_UNKNOWN
90# endif
91#else
92# define BJ_OS_UNKNOWN
93#endif
94
95#if defined(__unix__)
96# define BJ_OS_UNIX
97#endif
98
99#if defined(BJ_OS_UNIX)
100# include <unistd.h>
101# if defined(_POSIX_VERSION)
102# define BJ_OS_POSIX
103# endif
104#endif
106
112#if defined(BJ_COMPILER_DOXYGEN)
113# define BJ_COMPILER_NAME "Doxygen"
114# define BJ_COMPILER_VERSION 0
115#elif defined(__EMSCRIPTEN__)
116# include <emscripten/version.h>
117# define BJ_COMPILER_EMSCRIPTEN
118# define BJ_COMPILER_NAME "Emscripten"
119# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
120#elif defined(__GNUC__) && !defined(__clang__)
121# define BJ_COMPILER_GCC
122# define BJ_COMPILER_NAME "GCC"
123# define BJ_COMPILER_VERSION __GNUC__
124#elif defined(__clang__)
125# define BJ_COMPILER_CLANG
126# define BJ_COMPILER_NAME "Clang"
127# define BJ_COMPILER_VERSION __clang_major__
128#elif defined(_MSC_VER)
129# define BJ_COMPILER_MSVC
130# define BJ_COMPILER_NAME "MSVC"
131# define BJ_COMPILER_VERSION _MSC_VER
132#elif defined(__MINGW32__)
133# define BJ_COMPILER_MINGW
134# define BJ_COMPILER_NAME "MinGW"
135# define BJ_COMPILER_VERSION 0
136#else
137# define BJ_COMPILER_UNKNOWN
138# define BJ_COMPILER_NAME "Unknown"
139# define BJ_COMPILER_VERSION 0
140#endif
142
148#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
149# define BJ_BUILD_RELEASE
150#endif
153#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
154# define BJ_BUILD_DEBUG
155#endif
156
158
163#ifdef __cplusplus
164# define BJ_EXTERN_C extern "C"
165#else
166# define BJ_EXTERN_C
167#endif
169
173#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
174# define BANJO_EXPORT BJ_EXTERN_C
175# define BANJO_NO_EXPORT
176#else
177# ifdef _MSC_VER
178# ifdef BANJO_EXPORTS
179# define BANJO_EXPORT BJ_EXTERN_C __declspec(dllexport)
180# else
181# define BANJO_EXPORT BJ_EXTERN_C __declspec(dllimport)
182# endif
183# define BANJO_NO_EXPORT
184# else
185# ifdef BANJO_EXPORTS
186# define BANJO_EXPORT BJ_EXTERN_C __attribute__((visibility("default")))
187# else
188# define BANJO_EXPORT BJ_EXTERN_C __attribute__((visibility("default")))
189# endif
190# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
191# endif
192#endif
194
199#if defined(__cplusplus)
200 #if defined(__GNUC__) || defined(__clang__)
201 #define BJ_RESTRICT __restrict__
202 #elif defined(_MSC_VER)
203 #define BJ_RESTRICT __restrict
204 #else
205 #define BJ_RESTRICT /* nothing */
206 #endif
207#else
208 /* pure C (C99 or newer) */
209 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
210 #define BJ_RESTRICT restrict
211 #elif defined(__GNUC__) || defined(__clang__)
212 #define BJ_RESTRICT __restrict__
213 #elif defined(_MSC_VER)
214 #define BJ_RESTRICT __restrict
215 #else
216 #define BJ_RESTRICT /* nothing */
217 #endif
218#endif
220
226#if defined(_MSC_VER)
227 #if defined(BJ_API_FORCE_INLINE)
228 #define BJ_INLINE __forceinline
229 #else
230 #if !defined(__cplusplus) && !defined(inline)
231 #define BJ_INLINE __inline
232 #else
233 #define BJ_INLINE inline
234 #endif
235 #endif
236#elif defined(__GNUC__) || defined(__clang__)
237 #if defined(BJ_API_FORCE_INLINE)
238 #define BJ_INLINE inline __attribute__((always_inline))
239 #else
240 #define BJ_INLINE inline
241 #endif
242#else
243 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
244 #define BJ_INLINE inline
245 #else
246 #define BJ_INLINE /* no inline available */
247 #endif
248#endif
250
260typedef uint32_t bj_bool;
261
269#define BJ_FALSE ((bj_bool)0)
270
278#define BJ_TRUE ((bj_bool)1)
279
301
311
323#ifndef BJ_NO_TYPEDEF
324
326typedef struct bj_cli bj_cli;
331typedef struct bj_bitmap bj_bitmap;
336typedef struct bj_error bj_error;
337typedef struct bj_event bj_event;
339typedef struct bj_mat3x2 bj_mat3x2;
340typedef struct bj_mat3x3 bj_mat3;
341typedef struct bj_mat3x3 bj_mat3x3;
342typedef struct bj_mat4x3 bj_mat4x3;
343typedef struct bj_mat4x4 bj_mat4;
344typedef struct bj_mat4x4 bj_mat4x4;
347typedef struct bj_pcg32 bj_pcg32;
348typedef struct bj_rect bj_rect;
352typedef struct bj_stream bj_stream;
353typedef struct bj_vec2 bj_vec2;
354typedef struct bj_vec3 bj_vec3;
355typedef struct bj_vec4 bj_quat;
356typedef struct bj_vec4 bj_vec4;
357typedef struct bj_window bj_window;
358typedef struct bj_address bj_address;
361typedef struct bj_udp bj_udp;
363
364#endif /* BJ_NO_TYPEDEF */
366
367#endif /* BJ_API_H */
Define parameters for generating simple waveforms.
Definition audio.h:348
Describe properties of an audio device.
Definition audio.h:186
Parser context and argument list descriptor.
Definition cli.h:173
Descriptor for a single command line argument.
Definition cli.h:151
bj_bool checks_log
Checks log failures.
Definition api.h:296
const char * name
API name (see BJ_NAME).
Definition api.h:282
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:299
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:284
bj_bool log_color
Colored log output enabled.
Definition api.h:298
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:293
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:288
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:297
bj_bool backend_wayland
Built with Wayland window support.
Definition api.h:292
const char * compiler_name
Compiler name string.
Definition api.h:285
bj_bool backend_x11
Built with X11 window support.
Definition api.h:294
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:290
const char * variant
API name variant (see BJ_NAME_VARIANT).
Definition api.h:283
bj_bool debug
Non-zero if built with debug info.
Definition api.h:287
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:289
bj_bool checks_abort
Checks abort execution on failure.
Definition api.h:295
int compiler_version
Compiler version number.
Definition api.h:286
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:291
struct bj_mat3x3 bj_mat3
Definition api.h:340
struct bj_datagram bj_datagram
Definition api.h:362
struct bj_render_target bj_render_target
Definition api.h:349
struct bj_stream bj_stream
Definition api.h:352
struct bj_address bj_address
Definition api.h:358
struct bj_error bj_error
Definition api.h:336
#define BANJO_EXPORT
Definition api.h:174
struct bj_udp bj_udp
Definition api.h:361
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:260
struct bj_bitmap bj_bitmap
Definition api.h:331
struct bj_window bj_window
Definition api.h:357
struct bj_vec4 bj_quat
Definition api.h:355
struct bj_tcp_listener bj_tcp_listener
Definition api.h:359
struct bj_audio_device bj_audio_device
Definition api.h:328
struct bj_mat4x4 bj_mat4
Definition api.h:343
struct bj_tcp_stream bj_tcp_stream
Definition api.h:360
const struct bj_build_info * bj_build_information(void)
Get runtime build information for the loaded Banjo binaries.
Structure holding build information of the binary.
Definition api.h:281
Represent a mouse button event.
Definition event.h:419
Represent a mouse cursor movement event.
Definition event.h:411
Represent a mouse enter or leave event.
Definition event.h:402
Represent a generic window-related event.
Definition event.h:453
Represent a keyboard key event.
Definition event.h:429
3×2 column-major matrix (2D affine).
Definition mat.h:70
3×3 column-major matrix.
Definition mat.h:59
4×3 column-major matrix (3D affine).
Definition mat.h:89
4×4 column-major matrix.
Definition mat.h:79
Axis-aligned rectangle: a top-left corner plus a width and height.
Definition rect.h:33
2D vector of bj_real components.
Definition vec.h:51
3D vector of bj_real components.
Definition vec.h:64
4D vector of bj_real components.
Definition vec.h:79
Custom allocation callbacks.
Definition memory.h:126
2D point mass state and physical properties.
Definition physics_2d.h:98
Rigid body with translational and angular components.
Definition physics_2d.h:288
PCG32 generator state.
Definition random.h:114
Structure representing a simple stopwatch.
Definition time.h:150