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
20#define BJ_VERSION_RELEASE 0
21#define BJ_VERSION_DEV 1
22#define BJ_VERSION_BETA 2
23#define BJ_VERSION_RC 3
25
29#define BJ_VERSION_VARIANT(version) ((version) & 0x3U)
30
34#define BJ_VERSION_MAJOR(version) (((version) >> 22U) & 0x3FFU)
35
39#define BJ_VERSION_MINOR(version) (((version) >> 12U) & 0x3FFU)
40
44#define BJ_VERSION_PATCH(version) (((version) >> 2U) & 0x3FFU)
45
52#define BJ_MAKE_VERSION(major, minor, patch, variant) \
53 ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | \
54 (((uint32_t)(patch)) << 2U) | ((uint32_t)(variant)))
55
56#define BJ_VERSION_MAJOR_NUMBER 0
57#define BJ_VERSION_MINOR_NUMBER 1
58#define BJ_VERSION_PATCH_NUMBER 0
59#define BJ_VERSION_VARIANT_NUMBER BJ_VERSION_DEV
60
62#define BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER, BJ_VERSION_VARIANT_NUMBER)
63
65#define BJ_NAME "Banjo"
66
70#if defined(__EMSCRIPTEN__)
71# define BJ_OS_EMSCRIPTEN
72#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
73# define BJ_OS_WINDOWS
74#elif defined(__linux__) || defined(__gnu_linux__)
75# define BJ_OS_LINUX
76#elif __APPLE__
77# define BJ_OS_APPLE
78# include <TargetConditionals.h>
79# if TARGET_OS_IPHONE
80# define BJ_OS_IOS
81# elif TARGET_IPHONE_SIMULATOR
82# define BJ_OS_IOS
83# define BJ_OS_IOS_SIMULATOR
84# elif TARGET_OS_MAC
85# define BJ_OS_MACOS
86# define BJ_OS_UNIX
87# else
88# define BJ_OS_APPLE_UNKNOWN
89# endif
90#else
91# define BJ_OS_UNKNOWN
92#endif
93
94#if defined(__unix__)
95# define BJ_OS_UNIX
96#endif
98
104#if defined(BJ_COMPILER_DOXYGEN)
105# define BJ_COMPILER_NAME "Doxygen"
106# define BJ_COMPILER_VERSION 0
107#elif defined(__EMSCRIPTEN__)
108# include <emscripten/version.h>
109# define BJ_COMPILER_EMSCRIPTEN
110# define BJ_COMPILER_NAME "Emscripten"
111# define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
112#elif defined(__GNUC__) && !defined(__clang__)
113# define BJ_COMPILER_GCC
114# define BJ_COMPILER_NAME "GCC"
115# define BJ_COMPILER_VERSION __GNUC__
116#elif defined(__clang__)
117# define BJ_COMPILER_CLANG
118# define BJ_COMPILER_NAME "Clang"
119# define BJ_COMPILER_VERSION __clang_major__
120#elif defined(_MSC_VER)
121# define BJ_COMPILER_MSVC
122# define BJ_COMPILER_NAME "MSVC"
123# define BJ_COMPILER_VERSION _MSC_VER
124#elif defined(__MINGW32__)
125# define BJ_COMPILER_MINGW
126# define BJ_COMPILER_NAME "MinGW"
127# define BJ_COMPILER_VERSION 0
128#else
129# define BJ_COMPILER_UNKNOWN
130# define BJ_COMPILER_NAME "Unknown"
131# define BJ_COMPILER_VERSION 0
132#endif
134
140#if defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
141# define BJ_BUILD_RELEASE
142#endif
145#if !defined(NDEBUG) || defined(BJ_COMPILER_DOXYGEN)
146# define BJ_BUILD_DEBUG
147#endif
148
150
154#if defined(BANJO_STATIC) || defined(BJ_COMPILER_DOXYGEN)
155# define BANJO_EXPORT
156# define BANJO_NO_EXPORT
157#else
158# ifdef _MSC_VER
159# ifndef BANJO_EXPORT
160# ifdef BANJO_EXPORTS
161# define BANJO_EXPORT __declspec(dllexport)
162# else
163# define BANJO_EXPORT __declspec( dllexport )
164# endif
165# endif
166# ifndef BANJO_NO_EXPORT
167# define BANJO_NO_EXPORT
168# endif
169# else
170# ifndef BANJO_EXPORT
171# ifdef BANJO_EXPORTS
172# define BANJO_EXPORT __attribute__((visibility("default")))
173# else
174# define BANJO_EXPORT __attribute__((visibility("default")))
175# endif
176# endif
177# ifndef BANJO_NO_EXPORT
178# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
179# endif
180# endif
181#endif
183
188#if defined(__cplusplus)
189 #if defined(__GNUC__) || defined(__clang__)
190 #define BJ_RESTRICT __restrict__
191 #elif defined(_MSC_VER)
192 #define BJ_RESTRICT __restrict
193 #else
194 #define BJ_RESTRICT /* nothing */
195 #endif
196#else
197 /* pure C (C99 or newer) */
198 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
199 #define BJ_RESTRICT restrict
200 #elif 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#endif
209
215#if defined(_MSC_VER)
216 #if defined(BJ_API_FORCE_INLINE)
217 #define BJ_INLINE __forceinline
218 #else
219 #if !defined(__cplusplus) && !defined(inline)
220 #define BJ_INLINE __inline
221 #else
222 #define BJ_INLINE inline
223 #endif
224 #endif
225#elif defined(__GNUC__) || defined(__clang__)
226 #if defined(BJ_API_FORCE_INLINE)
227 #define BJ_INLINE inline __attribute__((always_inline))
228 #else
229 #define BJ_INLINE inline
230 #endif
231#else
232 #if defined(BJ_COMPILER_DOXYGEN) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
233 #define BJ_INLINE inline
234 #else
235 #define BJ_INLINE /* no inline available */
236 #endif
237#endif
239
249typedef uint32_t bj_bool;
250
258#define BJ_FALSE ((bj_bool)0)
259
267#define BJ_TRUE ((bj_bool)1)
268
288
298
310#ifndef BJ_NO_TYPEDEF
311
318typedef enum bj_key bj_key;
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;
358
359#endif /* BJ_NO_TYPEDEF */
361
362#endif /* BJ_API_H */
bj_audio_format
Audio sample format descriptor.
Definition audio.h:51
Describe properties of an audio device.
Definition audio.h:105
bj_blit_op
Raster operation (ROP) to apply during blitting.
Definition bitmap.h:48
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:283
const char * name
API name (see BJ_NAME).
Definition api.h:271
bj_bool pedantic
Extra runtime checks enabled.
Definition api.h:286
uint32_t version
Packed API version (see BJ_VERSION).
Definition api.h:272
bj_bool log_color
Colored log output enabled.
Definition api.h:285
bj_bool backend_win32
Built with Win32 window support.
Definition api.h:280
bj_bool backend_alsa
Built with ALSA audio.
Definition api.h:276
bj_bool fastmath
Built with fast-math optimizations.
Definition api.h:284
const char * compiler_name
Compiler name string.
Definition api.h:273
bj_bool backend_x11
Built with X11 window support.
Definition api.h:281
bj_bool backend_emscripten
Built with Emscripten support.
Definition api.h:278
bj_bool debug
Non-zero if built with debug info.
Definition api.h:275
bj_bool backend_cocoa
Built with Cocoa/macOS support.
Definition api.h:277
bj_bool checks_abort
Checks abort execution on failure.
Definition api.h:282
int compiler_version
Compiler version number.
Definition api.h:274
bj_bool backend_mme
Built with Windows MME audio.
Definition api.h:279
struct bj_mat3x3 bj_mat3
Definition api.h:340
enum bj_callback_result bj_callback_result
Definition api.h:314
struct bj_stream bj_stream
Definition api.h:352
#define BANJO_EXPORT
Definition api.h:155
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:249
struct bj_bitmap bj_bitmap
Definition api.h:331
struct bj_renderer bj_renderer
Definition api.h:349
struct bj_window bj_window
Definition api.h:357
struct bj_vec4 bj_quat
Definition api.h:355
struct bj_audio_device bj_audio_device
Definition api.h:328
struct bj_mat4x4 bj_mat4
Definition api.h:343
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:270
bj_error_code
A numeric representation of an error in Banjo.
Definition error.h:70
Error structure.
Definition error.h:131
bj_key
List of possible keys on a keyboard.
Definition event.h:57
bj_event_type
Identify the type of a generic event.
Definition event.h:339
bj_event_action
Define event action types for keys or mouse buttons.
Definition event.h:294
Represent a mouse button event.
Definition event.h:320
Represent a mouse cursor movement event.
Definition event.h:312
Represent a mouse enter or leave event.
Definition event.h:303
Represent a generic window-related event.
Definition event.h:351
Represent a keyboard key event.
Definition event.h:330
bj_log_level
Log Levels.
Definition log.h:30
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
bj_pixel_mode
Representation of a pixel encoding.
Definition pixel.h:16
PCG32 generator state.
Definition random.h:46
bj_renderer_type
Renderer backend type.
Definition renderer.h:33
bj_shader_flag
Shader input control flags.
Definition shader.h:52
bj_seek_origin
Position in a bj_stream to use for origin.
Definition stream.h:22
Structure representing a simple stopwatch.
Definition time.h:97
bj_window_flag
A set of flags describing some properties of a bj_window.
Definition window.h:44
Define parameters for generating simple waveforms.
Definition audio.h:251