Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
5
57
64#ifndef BJ_API_H
65#define BJ_API_H
66
67#include <stddef.h>
68#include <stdint.h>
69
73#if defined(__EMSCRIPTEN__)
74# define BJ_OS_EMSCRIPTEN
75#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
76# define BJ_OS_WINDOWS
77#elif defined(__linux__) || defined(__gnu_linux__)
78# define BJ_OS_LINUX
79#elif __APPLE__
80# define BJ_OS_APPLE
81# include <TargetConditionals.h>
82# if TARGET_OS_IPHONE
83# define BJ_OS_IOS
84# elif TARGET_IPHONE_SIMULATOR
85# define BJ_OS_IOS
86# define BJ_OS_IOS_SIMULATOR
87# elif TARGET_OS_MAC
88# define BJ_OS_MACOS
89# define BJ_OS_UNIX
90# else
91# define BJ_OS_APPLE_UNKNOWN
92# endif
93#else
94# define BJ_OS_UNKNOWN
95#endif
96
97#if defined(__unix__)
98# define BJ_OS_UNIX
99#endif
100
101#if defined(BJ_OS_UNIX)
102# include <unistd.h>
103# if defined(_POSIX_VERSION)
104# define BJ_OS_POSIX
105# endif
106#endif
108
114#if defined(BJ_COMPILER_DOXYGEN)
115# define BJ_COMPILER_NAME "Doxygen"
116# define BJ_COMPILER_VERSION 0
117#elif defined(__EMSCRIPTEN__)
118# include <emscripten/version.h>
119# define BJ_COMPILER_EMSCRIPTEN
120# define BJ_COMPILER_NAME "Emscripten"
121# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
122#elif defined(__GNUC__) && !defined(__clang__)
123# define BJ_COMPILER_GCC
124# define BJ_COMPILER_NAME "GCC"
125# define BJ_COMPILER_VERSION __GNUC__
126#elif defined(__clang__)
127# define BJ_COMPILER_CLANG
128# define BJ_COMPILER_NAME "Clang"
129# define BJ_COMPILER_VERSION __clang_major__
130#elif defined(_MSC_VER)
131# define BJ_COMPILER_MSVC
132# define BJ_COMPILER_NAME "MSVC"
133# define BJ_COMPILER_VERSION _MSC_VER
134#elif defined(__MINGW32__)
135# define BJ_COMPILER_MINGW
136# define BJ_COMPILER_NAME "MinGW"
137# define BJ_COMPILER_VERSION 0
138#else
139# define BJ_COMPILER_UNKNOWN
140# define BJ_COMPILER_NAME "Unknown"
141# define BJ_COMPILER_VERSION 0
142#endif
144
152#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
153# define BJ_BUILD_RELEASE
154#endif
158#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
159# define BJ_BUILD_DEBUG
160#endif
161
163
168#ifdef __cplusplus
169# define BJ_EXTERN_C extern "C"
170#else
171# define BJ_EXTERN_C
172#endif
174
178#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
179# define BANJO_EXPORT BJ_EXTERN_C
180# define BANJO_NO_EXPORT
181#elif defined(_WIN32) || defined(__CYGWIN__)
182# if defined(BANJO_EXPORTS)
183# define BANJO_EXPORT BJ_EXTERN_C __declspec(dllexport)
184# elif defined(_MSC_VER)
185# define BANJO_EXPORT BJ_EXTERN_C __declspec(dllimport)
186# else
187 /* GCC-based Windows toolchains (MinGW, Cygwin) call DLL functions
188 * through the import library without dllimport. Leaving it out keeps
189 * a static libbanjo.a usable without defining BANJO_STATIC. */
190# define BANJO_EXPORT BJ_EXTERN_C
191# endif
192# define BANJO_NO_EXPORT
193#else
194# define BANJO_EXPORT BJ_EXTERN_C __attribute__((visibility("default")))
195# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
196#endif
198
203#if defined(__cplusplus)
204 #if defined(__GNUC__) || defined(__clang__)
205 #define BJ_RESTRICT __restrict__
206 #elif defined(_MSC_VER)
207 #define BJ_RESTRICT __restrict
208 #else
209 #define BJ_RESTRICT /* nothing */
210 #endif
211#else
212 /* pure C (C99 or newer) */
213 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
214 #define BJ_RESTRICT restrict
215 #elif defined(__GNUC__) || defined(__clang__)
216 #define BJ_RESTRICT __restrict__
217 #elif defined(_MSC_VER)
218 #define BJ_RESTRICT __restrict
219 #else
220 #define BJ_RESTRICT /* nothing */
221 #endif
222#endif
224
230#if defined(_MSC_VER)
231 #if defined(BJ_API_FORCE_INLINE)
232 #define BJ_INLINE __forceinline
233 #else
234 #if !defined(__cplusplus) && !defined(inline)
235 #define BJ_INLINE __inline
236 #else
237 #define BJ_INLINE inline
238 #endif
239 #endif
240#elif defined(__GNUC__) || defined(__clang__)
241 #if defined(BJ_API_FORCE_INLINE)
242 #define BJ_INLINE inline __attribute__((always_inline))
243 #else
244 #define BJ_INLINE inline
245 #endif
246#else
247 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
248 #define BJ_INLINE inline
249 #else
250 #define BJ_INLINE /* no inline available */
251 #endif
252#endif
254
264typedef uint32_t bj_bool;
265
273#define BJ_FALSE ((bj_bool)0)
274
282#define BJ_TRUE ((bj_bool)1)
283
311
321
333#ifndef BJ_NO_TYPEDEF
334
335typedef struct bj_address bj_address;
340typedef struct bj_bitmap bj_bitmap;
343typedef struct bj_cli bj_cli;
348typedef struct bj_error bj_error;
349typedef struct bj_event bj_event;
351typedef struct bj_mat3 bj_mat3;
352typedef struct bj_mat32 bj_mat32;
353typedef struct bj_mat4 bj_mat4;
354typedef struct bj_mat43 bj_mat43;
356typedef struct bj_mat3 bj_mat3x3;
358typedef struct bj_mat32 bj_mat3x2;
360typedef struct bj_mat4 bj_mat4x4;
362typedef struct bj_mat43 bj_mat4x3;
363typedef struct bj_maze bj_maze;
367typedef struct bj_pcg32 bj_pcg32;
368typedef struct bj_rect bj_rect;
372typedef struct bj_str bj_str;
373typedef struct bj_string bj_string;
374typedef struct bj_stream bj_stream;
379typedef struct bj_udp bj_udp;
380typedef struct bj_vec2 bj_vec2;
381typedef struct bj_vec3 bj_vec3;
382typedef struct bj_vec4 bj_quat;
383typedef struct bj_vec4 bj_vec4;
384typedef struct bj_window bj_window;
385
386#endif /* BJ_NO_TYPEDEF */
388
389#endif /* BJ_API_H */
Define parameters for generating simple waveforms.
Definition audio.h:400
Describe properties of an audio device.
Definition audio.h:193
Parser context and argument list descriptor.
Definition cli.h:185
Descriptor for a single command line argument.
Definition cli.h:159
bj_bool checks_log
Checks log failures.
Definition api.h:303
size_t real_size
Size of bj_real in the library, in bytes (since 1.1).
Definition api.h:309
const char * name
API name (see BJ_NAME).
Definition api.h:289
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:306
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:291
bj_bool backend_fake
Built with the fake video and audio backends (since 1.1).
Definition api.h:308
bj_bool log_color
Colored log output enabled.
Definition api.h:305
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:300
bj_bool backend_coreaudio
Built with CoreAudio audio (since 1.1).
Definition api.h:307
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:295
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:304
bj_bool backend_wayland
Built with Wayland window support.
Definition api.h:299
const char * compiler_name
Compiler name string.
Definition api.h:292
bj_bool backend_x11
Built with X11 window support.
Definition api.h:301
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:297
const char * variant
API name variant (see BJ_NAME_VARIANT).
Definition api.h:290
bj_bool debug
Non-zero if built with debug info: describes this library's own build, not the including program's ND...
Definition api.h:294
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:296
bj_bool checks_abort
Built with BJ_CONFIG_CHECKS_ABORT, deprecated and without effect.
Definition api.h:302
int compiler_version
Compiler version number.
Definition api.h:293
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:298
struct bj_maze bj_maze
Definition api.h:363
struct bj_datagram bj_datagram
Definition api.h:346
struct bj_render_target bj_render_target
Definition api.h:369
struct bj_stream bj_stream
Definition api.h:374
struct bj_address bj_address
Definition api.h:335
struct bj_mat3 bj_mat3x3
Definition api.h:356
struct bj_error bj_error
Definition api.h:348
#define BANJO_EXPORT
Definition api.h:179
struct bj_udp bj_udp
Definition api.h:379
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
struct bj_bitmap bj_bitmap
Definition api.h:340
struct bj_maze_builder bj_maze_builder
Definition api.h:364
struct bj_window bj_window
Definition api.h:384
struct bj_vec4 bj_quat
Definition api.h:382
struct bj_tcp_listener bj_tcp_listener
Definition api.h:376
struct bj_audio_device bj_audio_device
Definition api.h:337
struct bj_mat4 bj_mat4x4
Definition api.h:360
struct bj_tcp_stream bj_tcp_stream
Definition api.h:377
const struct bj_build_info * bj_build_information(void)
Get runtime build information for the loaded Banjo binaries.
struct bj_text_wrapper bj_text_wrapper
Definition api.h:378
struct bj_mat43 bj_mat4x3
Definition api.h:362
struct bj_mat32 bj_mat3x2
Definition api.h:358
Structure holding build information of the binary.
Definition api.h:288
Represent a mouse button event.
Definition event.h:443
Represent a mouse cursor movement event.
Definition event.h:435
Represent a mouse enter or leave event.
Definition event.h:426
Represent a generic window-related event.
Definition event.h:477
Represent a keyboard key event.
Definition event.h:453
3×3 column-major matrix.
Definition mat.h:75
3×2 column-major matrix (2D affine).
Definition mat.h:86
4×4 column-major matrix.
Definition mat.h:95
4×3 column-major matrix (3D affine).
Definition mat.h:105
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:57
3D vector of bj_real components.
Definition vec.h:70
4D vector of bj_real components.
Definition vec.h:85
Custom allocation callbacks.
Definition memory.h:128
2D point mass state and physical properties.
Definition physics_2d.h:100
Rigid body with translational and angular components.
Definition physics_2d.h:304
PCG32 generator state.
Definition random.h:117
The functions of a source the program supplies.
Definition stream.h:257
A borrowed view of a sequence of bytes.
Definition string.h:57
An owning string containing valid UTF-8.
Structure representing a simple stopwatch.
Definition time.h:153