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
48
49#if defined(BJ_OS_UNIX)
50# include <unistd.h>
51# if defined(_POSIX_VERSION)
52# define BJ_OS_POSIX
53# endif
54#endif
56
62#if defined(BJ_COMPILER_DOXYGEN)
63# define BJ_COMPILER_NAME "Doxygen"
64# define BJ_COMPILER_VERSION 0
65#elif defined(__EMSCRIPTEN__)
66# include <emscripten/version.h>
67# define BJ_COMPILER_EMSCRIPTEN
68# define BJ_COMPILER_NAME "Emscripten"
69# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
70#elif defined(__GNUC__) && !defined(__clang__)
71# define BJ_COMPILER_GCC
72# define BJ_COMPILER_NAME "GCC"
73# define BJ_COMPILER_VERSION __GNUC__
74#elif defined(__clang__)
75# define BJ_COMPILER_CLANG
76# define BJ_COMPILER_NAME "Clang"
77# define BJ_COMPILER_VERSION __clang_major__
78#elif defined(_MSC_VER)
79# define BJ_COMPILER_MSVC
80# define BJ_COMPILER_NAME "MSVC"
81# define BJ_COMPILER_VERSION _MSC_VER
82#elif defined(__MINGW32__)
83# define BJ_COMPILER_MINGW
84# define BJ_COMPILER_NAME "MinGW"
85# define BJ_COMPILER_VERSION 0
86#else
87# define BJ_COMPILER_UNKNOWN
88# define BJ_COMPILER_NAME "Unknown"
89# define BJ_COMPILER_VERSION 0
90#endif
92
98#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
99# define BJ_BUILD_RELEASE
100#endif
103#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
104# define BJ_BUILD_DEBUG
105#endif
106
108
112#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
113# define BANJO_EXPORT
114# define BANJO_NO_EXPORT
115#else
116# ifdef _MSC_VER
117# ifndef BANJO_EXPORT
118# ifdef BANJO_EXPORTS
119# define BANJO_EXPORT __declspec(dllexport)
120# else
121# define BANJO_EXPORT __declspec( dllexport )
122# endif
123# endif
124# ifndef BANJO_NO_EXPORT
125# define BANJO_NO_EXPORT
126# endif
127# else
128# ifndef BANJO_EXPORT
129# ifdef BANJO_EXPORTS
130# define BANJO_EXPORT __attribute__((visibility("default")))
131# else
132# define BANJO_EXPORT __attribute__((visibility("default")))
133# endif
134# endif
135# ifndef BANJO_NO_EXPORT
136# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
137# endif
138# endif
139#endif
141
146#if defined(__cplusplus)
147 #if defined(__GNUC__) || defined(__clang__)
148 #define BJ_RESTRICT __restrict__
149 #elif defined(_MSC_VER)
150 #define BJ_RESTRICT __restrict
151 #else
152 #define BJ_RESTRICT /* nothing */
153 #endif
154#else
155 /* pure C (C99 or newer) */
156 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
157 #define BJ_RESTRICT restrict
158 #elif defined(__GNUC__) || defined(__clang__)
159 #define BJ_RESTRICT __restrict__
160 #elif defined(_MSC_VER)
161 #define BJ_RESTRICT __restrict
162 #else
163 #define BJ_RESTRICT /* nothing */
164 #endif
165#endif
167
173#if defined(_MSC_VER)
174 #if defined(BJ_API_FORCE_INLINE)
175 #define BJ_INLINE __forceinline
176 #else
177 #if !defined(__cplusplus) && !defined(inline)
178 #define BJ_INLINE __inline
179 #else
180 #define BJ_INLINE inline
181 #endif
182 #endif
183#elif defined(__GNUC__) || defined(__clang__)
184 #if defined(BJ_API_FORCE_INLINE)
185 #define BJ_INLINE inline __attribute__((always_inline))
186 #else
187 #define BJ_INLINE inline
188 #endif
189#else
190 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
191 #define BJ_INLINE inline
192 #else
193 #define BJ_INLINE /* no inline available */
194 #endif
195#endif
197
207typedef uint32_t bj_bool;
208
216#define BJ_FALSE ((bj_bool)0)
217
225#define BJ_TRUE ((bj_bool)1)
226
247
257
269#ifndef BJ_NO_TYPEDEF
270
272typedef struct bj_cli bj_cli;
277typedef struct bj_bitmap bj_bitmap;
282typedef struct bj_error bj_error;
283typedef struct bj_event bj_event;
285typedef struct bj_mat3x2 bj_mat3x2;
286typedef struct bj_mat3x3 bj_mat3;
287typedef struct bj_mat3x3 bj_mat3x3;
288typedef struct bj_mat4x3 bj_mat4x3;
289typedef struct bj_mat4x4 bj_mat4;
290typedef struct bj_mat4x4 bj_mat4x4;
293typedef struct bj_pcg32 bj_pcg32;
294typedef struct bj_rect bj_rect;
298typedef struct bj_stream bj_stream;
299typedef struct bj_vec2 bj_vec2;
300typedef struct bj_vec3 bj_vec3;
301typedef struct bj_vec4 bj_quat;
302typedef struct bj_vec4 bj_vec4;
303typedef struct bj_window bj_window;
304typedef struct bj_address bj_address;
307typedef struct bj_udp bj_udp;
309
310#endif /* BJ_NO_TYPEDEF */
312
313#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:242
const char * name
API name (see BJ_NAME).
Definition api.h:229
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:245
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:231
bj_bool log_color
Colored log output enabled.
Definition api.h:244
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:239
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:235
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:243
const char * compiler_name
Compiler name string.
Definition api.h:232
bj_bool backend_x11
Built with X11 window support.
Definition api.h:240
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:237
const char * variant
API name variant (see BJ_NAME_VARIANT).
Definition api.h:230
bj_bool debug
Non-zero if built with debug info.
Definition api.h:234
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:236
bj_bool checks_abort
Checks abort execution on failure.
Definition api.h:241
int compiler_version
Compiler version number.
Definition api.h:233
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:238
struct bj_mat3x3 bj_mat3
Definition api.h:286
struct bj_datagram bj_datagram
Definition api.h:308
struct bj_stream bj_stream
Definition api.h:298
struct bj_address bj_address
Definition api.h:304
struct bj_error bj_error
Definition api.h:282
#define BANJO_EXPORT
Definition api.h:113
struct bj_udp bj_udp
Definition api.h:307
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:207
struct bj_bitmap bj_bitmap
Definition api.h:277
struct bj_renderer bj_renderer
Definition api.h:295
struct bj_window bj_window
Definition api.h:303
struct bj_vec4 bj_quat
Definition api.h:301
struct bj_tcp_listener bj_tcp_listener
Definition api.h:305
struct bj_audio_device bj_audio_device
Definition api.h:274
struct bj_mat4x4 bj_mat4
Definition api.h:289
struct bj_tcp_stream bj_tcp_stream
Definition api.h:306
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:228
Represent a mouse button event.
Definition event.h:328
Represent a mouse cursor movement event.
Definition event.h:320
Represent a mouse enter or leave event.
Definition event.h:311
Represent a generic window-related event.
Definition event.h:362
Represent a keyboard key event.
Definition event.h:338
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