Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
5
12#ifndef BJ_API_H
13#define BJ_API_H
14
15#include <stddef.h>
16#include <stdint.h>
17
21#if defined(__EMSCRIPTEN__)
22# define BJ_OS_EMSCRIPTEN
23#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
24# define BJ_OS_WINDOWS
25#elif defined(__linux__) || defined(__gnu_linux__)
26# define BJ_OS_LINUX
27#elif __APPLE__
28# define BJ_OS_APPLE
29# include <TargetConditionals.h>
30# if TARGET_OS_IPHONE
31# define BJ_OS_IOS
32# elif TARGET_IPHONE_SIMULATOR
33# define BJ_OS_IOS
34# define BJ_OS_IOS_SIMULATOR
35# elif TARGET_OS_MAC
36# define BJ_OS_MACOS
37# define BJ_OS_UNIX
38# else
39# define BJ_OS_APPLE_UNKNOWN
40# endif
41#else
42# define BJ_OS_UNKNOWN
43#endif
44
45#if defined(__unix__)
46# define BJ_OS_UNIX
47#endif
49
55#if defined(BJ_COMPILER_DOXYGEN)
56# define BJ_COMPILER_NAME "Doxygen"
57# define BJ_COMPILER_VERSION 0
58#elif defined(__EMSCRIPTEN__)
59# include <emscripten/version.h>
60# define BJ_COMPILER_EMSCRIPTEN
61# define BJ_COMPILER_NAME "Emscripten"
62# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
63#elif defined(__GNUC__) && !defined(__clang__)
64# define BJ_COMPILER_GCC
65# define BJ_COMPILER_NAME "GCC"
66# define BJ_COMPILER_VERSION __GNUC__
67#elif defined(__clang__)
68# define BJ_COMPILER_CLANG
69# define BJ_COMPILER_NAME "Clang"
70# define BJ_COMPILER_VERSION __clang_major__
71#elif defined(_MSC_VER)
72# define BJ_COMPILER_MSVC
73# define BJ_COMPILER_NAME "MSVC"
74# define BJ_COMPILER_VERSION _MSC_VER
75#elif defined(__MINGW32__)
76# define BJ_COMPILER_MINGW
77# define BJ_COMPILER_NAME "MinGW"
78# define BJ_COMPILER_VERSION 0
79#else
80# define BJ_COMPILER_UNKNOWN
81# define BJ_COMPILER_NAME "Unknown"
82# define BJ_COMPILER_VERSION 0
83#endif
85
91#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
92# define BJ_BUILD_RELEASE
93#endif
96#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
97# define BJ_BUILD_DEBUG
98#endif
99
101
105#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
106# define BANJO_EXPORT
107# define BANJO_NO_EXPORT
108#else
109# ifdef _MSC_VER
110# ifndef BANJO_EXPORT
111# ifdef BANJO_EXPORTS
112# define BANJO_EXPORT __declspec(dllexport)
113# else
114# define BANJO_EXPORT __declspec( dllexport )
115# endif
116# endif
117# ifndef BANJO_NO_EXPORT
118# define BANJO_NO_EXPORT
119# endif
120# else
121# ifndef BANJO_EXPORT
122# ifdef BANJO_EXPORTS
123# define BANJO_EXPORT __attribute__((visibility("default")))
124# else
125# define BANJO_EXPORT __attribute__((visibility("default")))
126# endif
127# endif
128# ifndef BANJO_NO_EXPORT
129# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
130# endif
131# endif
132#endif
134
139#if defined(__cplusplus)
140 #if defined(__GNUC__) || defined(__clang__)
141 #define BJ_RESTRICT __restrict__
142 #elif defined(_MSC_VER)
143 #define BJ_RESTRICT __restrict
144 #else
145 #define BJ_RESTRICT /* nothing */
146 #endif
147#else
148 /* pure C (C99 or newer) */
149 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
150 #define BJ_RESTRICT restrict
151 #elif defined(__GNUC__) || defined(__clang__)
152 #define BJ_RESTRICT __restrict__
153 #elif defined(_MSC_VER)
154 #define BJ_RESTRICT __restrict
155 #else
156 #define BJ_RESTRICT /* nothing */
157 #endif
158#endif
160
166#if defined(_MSC_VER)
167 #if defined(BJ_API_FORCE_INLINE)
168 #define BJ_INLINE __forceinline
169 #else
170 #if !defined(__cplusplus) && !defined(inline)
171 #define BJ_INLINE __inline
172 #else
173 #define BJ_INLINE inline
174 #endif
175 #endif
176#elif defined(__GNUC__) || defined(__clang__)
177 #if defined(BJ_API_FORCE_INLINE)
178 #define BJ_INLINE inline __attribute__((always_inline))
179 #else
180 #define BJ_INLINE inline
181 #endif
182#else
183 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
184 #define BJ_INLINE inline
185 #else
186 #define BJ_INLINE /* no inline available */
187 #endif
188#endif
190
200typedef uint32_t bj_bool;
201
209#define BJ_FALSE ((bj_bool)0)
210
218#define BJ_TRUE ((bj_bool)1)
219
240
250
262#ifndef BJ_NO_TYPEDEF
263
265typedef struct bj_cli bj_cli;
270typedef struct bj_bitmap bj_bitmap;
275typedef struct bj_error bj_error;
276typedef struct bj_event bj_event;
278typedef struct bj_mat3x2 bj_mat3x2;
279typedef struct bj_mat3x3 bj_mat3;
280typedef struct bj_mat3x3 bj_mat3x3;
281typedef struct bj_mat4x3 bj_mat4x3;
282typedef struct bj_mat4x4 bj_mat4;
283typedef struct bj_mat4x4 bj_mat4x4;
286typedef struct bj_pcg32 bj_pcg32;
287typedef struct bj_rect bj_rect;
291typedef struct bj_stream bj_stream;
292typedef struct bj_vec2 bj_vec2;
293typedef struct bj_vec3 bj_vec3;
294typedef struct bj_vec4 bj_quat;
295typedef struct bj_vec4 bj_vec4;
296typedef struct bj_window bj_window;
297
298#endif /* BJ_NO_TYPEDEF */
300
301#endif /* BJ_API_H */
Describe properties of an audio device.
Definition audio.h:108
Parser context and argument list descriptor.
Definition cli.h:161
Descriptor for a single command line argument.
Definition cli.h:139
bj_bool checks_log
Checks log failures.
Definition api.h:235
const char * name
API name (see BJ_NAME).
Definition api.h:222
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:238
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:224
bj_bool log_color
Colored log output enabled.
Definition api.h:237
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:232
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:228
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:236
const char * compiler_name
Compiler name string.
Definition api.h:225
bj_bool backend_x11
Built with X11 window support.
Definition api.h:233
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:230
const char * variant
API name variant (see BJ_NAME_VARIANT).
Definition api.h:223
bj_bool debug
Non-zero if built with debug info.
Definition api.h:227
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:229
bj_bool checks_abort
Checks abort execution on failure.
Definition api.h:234
int compiler_version
Compiler version number.
Definition api.h:226
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:231
struct bj_mat3x3 bj_mat3
Definition api.h:279
struct bj_stream bj_stream
Definition api.h:291
struct bj_error bj_error
Definition api.h:275
#define BANJO_EXPORT
Definition api.h:106
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:200
struct bj_bitmap bj_bitmap
Definition api.h:270
struct bj_renderer bj_renderer
Definition api.h:288
struct bj_window bj_window
Definition api.h:296
struct bj_vec4 bj_quat
Definition api.h:294
struct bj_audio_device bj_audio_device
Definition api.h:267
struct bj_mat4x4 bj_mat4
Definition api.h:282
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:221
Represent a mouse button event.
Definition event.h:326
Represent a mouse cursor movement event.
Definition event.h:318
Represent a mouse enter or leave event.
Definition event.h:309
Represent a generic window-related event.
Definition event.h:360
Represent a keyboard key event.
Definition event.h:336
struct bj_mat3x2: 3×2 column-major matrix backed by struct bj_vec2.
Definition mat.h:35
Definition mat.h:25
struct bj_mat4x3: 4×3 column-major matrix backed by struct bj_vec3.
Definition mat.h:53
struct bj_mat4x4: 4×4 column-major matrix backed by struct bj_vec4.
Definition mat.h:43
Represents a rectangle with position and dimensions.
Definition rect.h:19
struct bj_vec2: 2D vector of bj_real values.
Definition vec.h:26
struct bj_vec3: 3D vector of bj_real values.
Definition vec.h:38
struct bj_vec4: 4D vector of bj_real values.
Definition vec.h:51
Custom allocation callbacks.
Definition memory.h:71
Angular.
Definition physics_2d.h:226
2D point mass state and physical properties.
Definition physics_2d.h:78
Rigid body with translational and angular components.
Definition physics_2d.h:268
PCG32 generator state.
Definition random.h:46
Structure representing a simple stopwatch.
Definition time.h:97
Define parameters for generating simple waveforms.
Definition audio.h:254