Banjo API 1.0.0-rc.2
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
162#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
163# define BANJO_EXPORT
164# define BANJO_NO_EXPORT
165#else
166# ifdef _MSC_VER
167# ifndef BANJO_EXPORT
168# ifdef BANJO_EXPORTS
169# define BANJO_EXPORT __declspec(dllexport)
170# else
171# define BANJO_EXPORT __declspec( dllexport )
172# endif
173# endif
174# ifndef BANJO_NO_EXPORT
175# define BANJO_NO_EXPORT
176# endif
177# else
178# ifndef BANJO_EXPORT
179# ifdef BANJO_EXPORTS
180# define BANJO_EXPORT __attribute__((visibility("default")))
181# else
182# define BANJO_EXPORT __attribute__((visibility("default")))
183# endif
184# endif
185# ifndef BANJO_NO_EXPORT
186# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
187# endif
188# endif
189#endif
191
196#if defined(__cplusplus)
197 #if defined(__GNUC__) || defined(__clang__)
198 #define BJ_RESTRICT __restrict__
199 #elif defined(_MSC_VER)
200 #define BJ_RESTRICT __restrict
201 #else
202 #define BJ_RESTRICT /* nothing */
203 #endif
204#else
205 /* pure C (C99 or newer) */
206 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
207 #define BJ_RESTRICT restrict
208 #elif defined(__GNUC__) || defined(__clang__)
209 #define BJ_RESTRICT __restrict__
210 #elif defined(_MSC_VER)
211 #define BJ_RESTRICT __restrict
212 #else
213 #define BJ_RESTRICT /* nothing */
214 #endif
215#endif
217
223#if defined(_MSC_VER)
224 #if defined(BJ_API_FORCE_INLINE)
225 #define BJ_INLINE __forceinline
226 #else
227 #if !defined(__cplusplus) && !defined(inline)
228 #define BJ_INLINE __inline
229 #else
230 #define BJ_INLINE inline
231 #endif
232 #endif
233#elif defined(__GNUC__) || defined(__clang__)
234 #if defined(BJ_API_FORCE_INLINE)
235 #define BJ_INLINE inline __attribute__((always_inline))
236 #else
237 #define BJ_INLINE inline
238 #endif
239#else
240 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
241 #define BJ_INLINE inline
242 #else
243 #define BJ_INLINE /* no inline available */
244 #endif
245#endif
247
257typedef uint32_t bj_bool;
258
266#define BJ_FALSE ((bj_bool)0)
267
275#define BJ_TRUE ((bj_bool)1)
276
298
308
320#ifndef BJ_NO_TYPEDEF
321
323typedef struct bj_cli bj_cli;
328typedef struct bj_bitmap bj_bitmap;
333typedef struct bj_error bj_error;
334typedef struct bj_event bj_event;
336typedef struct bj_mat3x2 bj_mat3x2;
337typedef struct bj_mat3x3 bj_mat3;
338typedef struct bj_mat3x3 bj_mat3x3;
339typedef struct bj_mat4x3 bj_mat4x3;
340typedef struct bj_mat4x4 bj_mat4;
341typedef struct bj_mat4x4 bj_mat4x4;
344typedef struct bj_pcg32 bj_pcg32;
345typedef struct bj_rect bj_rect;
349typedef struct bj_stream bj_stream;
350typedef struct bj_vec2 bj_vec2;
351typedef struct bj_vec3 bj_vec3;
352typedef struct bj_vec4 bj_quat;
353typedef struct bj_vec4 bj_vec4;
354typedef struct bj_window bj_window;
355typedef struct bj_address bj_address;
358typedef struct bj_udp bj_udp;
360
361#endif /* BJ_NO_TYPEDEF */
363
364#endif /* BJ_API_H */
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:293
const char * name
API name (see BJ_NAME).
Definition api.h:279
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:296
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:281
bj_bool log_color
Colored log output enabled.
Definition api.h:295
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:290
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:285
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:294
bj_bool backend_wayland
Built with Wayland window support.
Definition api.h:289
const char * compiler_name
Compiler name string.
Definition api.h:282
bj_bool backend_x11
Built with X11 window support.
Definition api.h:291
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:287
const char * variant
API name variant (see BJ_NAME_VARIANT).
Definition api.h:280
bj_bool debug
Non-zero if built with debug info.
Definition api.h:284
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:286
bj_bool checks_abort
Checks abort execution on failure.
Definition api.h:292
int compiler_version
Compiler version number.
Definition api.h:283
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:288
struct bj_mat3x3 bj_mat3
Definition api.h:337
struct bj_datagram bj_datagram
Definition api.h:359
struct bj_render_target bj_render_target
Definition api.h:346
struct bj_stream bj_stream
Definition api.h:349
struct bj_address bj_address
Definition api.h:355
struct bj_error bj_error
Definition api.h:333
#define BANJO_EXPORT
Definition api.h:163
struct bj_udp bj_udp
Definition api.h:358
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:257
struct bj_bitmap bj_bitmap
Definition api.h:328
struct bj_window bj_window
Definition api.h:354
struct bj_vec4 bj_quat
Definition api.h:352
struct bj_tcp_listener bj_tcp_listener
Definition api.h:356
struct bj_audio_device bj_audio_device
Definition api.h:325
struct bj_mat4x4 bj_mat4
Definition api.h:340
struct bj_tcp_stream bj_tcp_stream
Definition api.h:357
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:278
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
Define parameters for generating simple waveforms.
Definition audio.h:332