A retro platform game
git clone git://soophie.de/freezo
diff --git a/.gitignore b/.gitignore
index bf5699a..562d7aa 100644
--- a/.gitignore
+++ b/.gitignore
1
@@ -1,2 +1,2 @@2
-.DS_Store3
freezo4
+build/
diff --git a/Makefile b/Makefile
index 324f193..93f8f8e 100644
--- a/Makefile
+++ b/Makefile
1
@@ -1,8 +1,16 @@2
-build:3
- cc -o freezo -I/opt/homebrew/Cellar/raylib/5.0/include -L/opt/homebrew/Cellar/raylib/5.0/lib -lraylib -rdynamic -Wall -Wextra -Werror -pedantic src/*.c4
+CC=cc5
+CFLAGS=-Werror -Wall -Wextra -pedantic6
+LIBS=-I/opt/homebrew/Cellar/raylib/5.0/include -L/opt/homebrew/Cellar/raylib/5.0/lib -lraylib7
+8
+build: src/*.c9
+ mkdir -p ./build10
+ $(CC) -o ./build/freezo $(CFLAGS) $(LIBS) $^12
run: build13
- ./freezo14
+ ./build/freezo15
+16
+web: src/*.c17
+ emcc -o ./build/freezo.html $^ -Os -Wall ../raylib/src/libraylib.a -I. -L. -Lpath-to-libraylib-a -s USE_GLFW=3 -DPLATFORM_WEB --preload-file ./assets19
clean:20
- rm freezo21
+ rm -rf ./build
diff --git a/assets/entities.png b/assets/entities.png
index c2f29cb..df2bead 100644
Binary files a/assets/entities.png and b/assets/entities.png differ
diff --git a/include/const.h b/include/const.h
new file mode 100644
index 0000000..51e62ba
--- /dev/null
+++ b/include/const.h
1
@@ -0,0 +1,14 @@2
+#define SCALE 33
+#define TILE_WIDTH 8 * SCALE4
+#define TILE_HEIGHT 8 * SCALE5
+#define WINDOW_WIDTH 24 * TILE_WIDTH6
+#define WINDOW_HEIGHT 16 * TILE_HEIGHT7
+#define PLAYER_WIDTH 8 * SCALE8
+#define PLAYER_HEIGHT 12 *SCALE9
+#define ENEMY_WIDTH 8 * SCALE10
+#define ENEMY_HEIGHT 12 * SCALE11
+#define PLAYER_HEALTH 612
+#define PLAYER_SHOOTING_RANGE 2 * TILE_WIDTH13
+#define PLAYER_GRAVITY 1014
+#define FONT_WIDTH 5 * (SCALE - 1)15
+#define FONT_HEIGHT 7 * (SCALE - 1)
diff --git a/include/effect.h b/include/effect.h
new file mode 100644
index 0000000..ffcc199
--- /dev/null
+++ b/include/effect.h
1
@@ -0,0 +1,26 @@2
+#pragma once3
+4
+typedef struct Effect effect_t;5
+6
+#include "game.h"7
+#include "util.h"8
+9
+typedef enum {10
+ EFFECT_FALL,11
+ EFFECT_BREAK,12
+ EFFECT_PARTICLE,13
+} effect_e;14
+15
+struct Effect {16
+ effect_e type;17
+ pos_t pos;18
+ fz_timer_t *timer;19
+ int count;20
+};21
+22
+effect_t *effect_create(pos_t pos, effect_e type);23
+void effect_update(effect_t *effect, game_t *game);24
+void effect_draw(effect_t *effect, game_t *game);25
+void effect_free(effect_t *effect);26
+27
+void effect_play(pos_t pos, effect_e type, game_t *game);
diff --git a/include/enemy.h b/include/enemy.h
new file mode 100644
index 0000000..088f3f1
--- /dev/null
+++ b/include/enemy.h
1
@@ -0,0 +1,31 @@2
+#pragma once3
+4
+typedef struct Enemy enemy_t;5
+6
+#include "game.h"7
+#include "util.h"8
+9
+typedef enum {10
+ ENEMY_TEST,11
+} enemy_e;12
+13
+struct Enemy {14
+ pos_t pos;15
+ enemy_e type;16
+ bool on_ground;17
+ float velocity;18
+ float gravity;19
+ int dir;20
+ bool stunned;21
+ bool frozen;22
+ int frozen_timer;23
+ float fall_height;24
+ fz_timer_t *timer_walking;25
+ fz_timer_t *timer_sneaking;26
+};27
+28
+enemy_t *enemy_create(pos_t pos, enemy_e type);29
+void enemy_update(enemy_t *enemy, game_t *game);30
+void enemy_draw(enemy_t *enemy, game_t *game);31
+void enemy_kill(enemy_t *enemy, game_t *game);32
+void enemy_free(enemy_t *enemy);
diff --git a/include/entity.h b/include/entity.h
new file mode 100644
index 0000000..0524eee
--- /dev/null
+++ b/include/entity.h
1
@@ -0,0 +1,26 @@2
+#pragma once3
+4
+typedef struct Entity entity_t;5
+6
+#include "enemy.h"7
+#include "gate.h"8
+#include "game.h"9
+10
+typedef enum {11
+ ENTITY_ENEMY,12
+ ENTITY_GATE,13
+} entity_e;14
+15
+struct Entity {16
+ entity_e type;17
+ union {18
+ enemy_t *enemy;19
+ gate_t *gate;20
+ };21
+};22
+23
+entity_t *entity_create(entity_e type);24
+void entity_update(entity_t *entity, game_t *game);25
+void entity_draw(entity_t *entity, game_t *game);26
+void entity_detach(entity_t *entity);27
+void entity_free(entity_t *entity);
diff --git a/include/game.h b/include/game.h
new file mode 100644
index 0000000..cb8e14b
--- /dev/null
+++ b/include/game.h
1
@@ -0,0 +1,48 @@2
+#pragma once3
+4
+typedef struct Assets assets_t;5
+typedef struct Game game_t;6
+7
+#include "entity.h"8
+#include "player.h"9
+#include "tile.h"10
+#include "menu.h"11
+#include "level.h"12
+#include "effect.h"13
+14
+typedef enum {15
+ STATE_MENU,16
+ STATE_GAME,17
+} state_e;18
+19
+struct Assets {20
+ Texture2D tiles;21
+ Texture2D entities;22
+ Texture2D font;23
+ Texture2D images;24
+};25
+26
+struct Game {27
+ state_e state;28
+ level_t *level;29
+ bool quit;30
+ bool defeat;31
+ bool victory;32
+ menu_t *menu;33
+ player_t *player;34
+ tile_t **tiles;35
+ int tiles_len;36
+ entity_t *entities;37
+ int entities_len;38
+ effect_t **effects;39
+ int effects_len;40
+ assets_t assets;41
+ Camera2D camera;42
+ int xp;43
+ int sceen_timer;44
+};45
+46
+game_t *game_create(void);47
+void game_update(game_t *game);48
+void game_draw(game_t *game);49
+void game_free(game_t *game);
diff --git a/include/gate.h b/include/gate.h
new file mode 100644
index 0000000..c340b62
--- /dev/null
+++ b/include/gate.h
1
@@ -0,0 +1,19 @@2
+#pragma once3
+4
+typedef struct Gate gate_t;5
+6
+#include "game.h"7
+#include "util.h"8
+9
+struct Gate {10
+ pos_t pos;11
+ int enemy_max;12
+ fz_timer_t *timer_spawn;13
+ bool frozen;14
+ int frozen_timer;15
+};16
+17
+gate_t *gate_create(pos_t pos, int enemy_max, int time);18
+void gate_update(gate_t *gate, game_t *game);19
+void gate_draw(gate_t *gate, game_t *game);20
+void gate_free(gate_t *gate);
diff --git a/include/level.h b/include/level.h
new file mode 100644
index 0000000..d6b96ba
--- /dev/null
+++ b/include/level.h
1
@@ -0,0 +1,23 @@2
+#pragma once3
+4
+#define LEVELS 35
+6
+typedef struct Level level_t;7
+8
+typedef enum {9
+ LEVEL_NULL,10
+ LEVEL_1,11
+ LEVEL_2,12
+ LEVEL_3,13
+} level_e;14
+15
+#include "game.h"16
+17
+struct Level {18
+ level_e type;19
+ int width;20
+ int height;21
+};22
+23
+void level_load(game_t *game, level_e type);24
+void level_unload(game_t *game);
diff --git a/include/menu.h b/include/menu.h
new file mode 100644
index 0000000..cd4cbb9
--- /dev/null
+++ b/include/menu.h
1
@@ -0,0 +1,14 @@2
+#pragma once3
+4
+typedef struct Menu menu_t;5
+6
+#include "game.h"7
+8
+struct Menu {9
+ int idx;10
+};11
+12
+menu_t *menu_create(void);13
+void menu_update(menu_t *menu, game_t *game);14
+void menu_draw(menu_t *menu, game_t *game);15
+void menu_free(menu_t *menu);
diff --git a/include/player.h b/include/player.h
new file mode 100644
index 0000000..7b24aa4
--- /dev/null
+++ b/include/player.h
1
@@ -0,0 +1,32 @@2
+#pragma once3
+4
+typedef struct Player player_t;5
+6
+#include "util.h"7
+#include "enemy.h"8
+#include "game.h"9
+#include "entity.h"10
+11
+struct Player {12
+ pos_t pos;13
+ int health;14
+ bool on_ground;15
+ float velocity;16
+ float gravity;17
+ int dir;18
+ bool sneaking;19
+ bool shooting;20
+ int damage_timer;21
+ float fall_height;22
+ enemy_t *held_enemy;23
+ bool moving;24
+ fz_timer_t *timer_walking;25
+ fz_timer_t *timer_sneaking;26
+ entity_t *target_entity;27
+ float shooting_distance;28
+};29
+30
+player_t *player_create(pos_t pos);31
+void player_update(player_t *player, game_t *game);32
+void player_draw(player_t *player, game_t *game);33
+void player_free(player_t *player);
diff --git a/include/tile.h b/include/tile.h
new file mode 100644
index 0000000..11b4976
--- /dev/null
+++ b/include/tile.h
1
@@ -0,0 +1,31 @@2
+#pragma once3
+4
+typedef struct Tile tile_t;5
+6
+#include "util.h"7
+#include "game.h"8
+9
+typedef enum {10
+ TILE_AIR,11
+ TILE_WOOD_PLATFORM,12
+ TILE_STONE_JOINT,13
+ TILE_STONE_WALL,14
+ TILE_GRASS,15
+ TILE_STONE,16
+ TILE_SNOW,17
+ TILE_SAND,18
+} tile_e;19
+20
+struct Tile {21
+ pos_t pos;22
+ tile_e type;23
+};24
+25
+tile_t *tile_create(pos_t pos, tile_e type);26
+void tile_update(tile_t *tile, game_t *game);27
+void tile_draw(tile_t *tile, game_t *game);28
+tile_t *tile_get(game_t *game, int x, int y);29
+bool tile_ground(tile_t *tile);30
+bool tile_solid(tile_t *tile);31
+bool tile_wall(tile_t *tile);32
+void tile_free(tile_t *tile);
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..4717fec
--- /dev/null
+++ b/include/util.h
1
@@ -0,0 +1,42 @@2
+#pragma once3
+4
+#include <stdbool.h>5
+6
+#include "../lib/raylib.h"7
+8
+#define UNUSED(x) (void)(x)9
+10
+typedef Vector2 pos_t;11
+typedef Rectangle rect_t;12
+typedef struct Timer fz_timer_t;13
+14
+#include "game.h"15
+16
+struct Timer {17
+ int frames;18
+ int count;19
+ int step;20
+};21
+22
+fz_timer_t *fz_timer_create(int frames, int step);23
+bool fz_timer_check(fz_timer_t *timer);24
+void fz_timer_update(fz_timer_t *timer);25
+void fz_timer_reset(fz_timer_t *timer);26
+int fz_timer_get(fz_timer_t *timer);27
+void fz_timer_free(fz_timer_t *timer);28
+29
+pos_t pos_snap(pos_t vec);30
+31
+rect_t rect_from_pos(pos_t pos, int width, int height);32
+bool rect_collide(rect_t a, rect_t b);33
+34
+Texture texture_load(char *filename, int scale);35
+Rectangle texture_rect(int x, int y, int width, int height);36
+37
+typedef enum {38
+ TEXT_ALIGNMENT_LEFT,39
+ TEXT_ALIGNMENT_RIGHT,40
+ TEXT_ALIGNMENT_CENTER,41
+} text_alignment_e;42
+43
+void text_draw(pos_t pos, char *text, text_alignment_e alignment, game_t *game);
diff --git a/lib/raylib.h b/lib/raylib.h
new file mode 100644
index 0000000..5ff2399
--- /dev/null
+++ b/lib/raylib.h
1
@@ -0,0 +1,1673 @@2
+/**********************************************************************************************3
+*4
+* raylib v5.1-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)5
+*6
+* FEATURES:7
+* - NO external dependencies, all required libraries included with raylib8
+* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly,9
+* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5.10
+* - Written in plain C code (C99) in PascalCase/camelCase notation11
+* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile)12
+* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]13
+* - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts)14
+* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)15
+* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!16
+* - Flexible Materials system, supporting classic maps and PBR maps17
+* - Animated 3D models supported (skeletal bones animation) (IQM)18
+* - Shaders support, including Model shaders and Postprocessing shaders19
+* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]20
+* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)21
+* - VR stereo rendering with configurable HMD device parameters22
+* - Bindings to multiple programming languages available!23
+*24
+* NOTES:25
+* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text]26
+* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2)27
+* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)28
+* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)29
+*30
+* DEPENDENCIES (included):31
+* [rcore] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP)32
+* [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP)33
+* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management34
+*35
+* OPTIONAL DEPENDENCIES (included):36
+* [rcore] msf_gif (Miles Fogle) for GIF recording37
+* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm38
+* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm39
+* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...)40
+* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)41
+* [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms42
+* [rtext] stb_truetype (Sean Barret) for ttf fonts loading43
+* [rtext] stb_rect_pack (Sean Barret) for rectangles packing44
+* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation45
+* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)46
+* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF)47
+* [rmodels] Model3D (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)48
+* [raudio] dr_wav (David Reid) for WAV audio file loading49
+* [raudio] dr_flac (David Reid) for FLAC audio file loading50
+* [raudio] dr_mp3 (David Reid) for MP3 audio file loading51
+* [raudio] stb_vorbis (Sean Barret) for OGG audio loading52
+* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading53
+* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading54
+*55
+*56
+* LICENSE: zlib/libpng57
+*58
+* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,59
+* BSD-like license that allows static linking with closed source software:60
+*61
+* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)62
+*63
+* This software is provided "as-is", without any express or implied warranty. In no event64
+* will the authors be held liable for any damages arising from the use of this software.65
+*66
+* Permission is granted to anyone to use this software for any purpose, including commercial67
+* applications, and to alter it and redistribute it freely, subject to the following restrictions:68
+*69
+* 1. The origin of this software must not be misrepresented; you must not claim that you70
+* wrote the original software. If you use this software in a product, an acknowledgment71
+* in the product documentation would be appreciated but is not required.72
+*73
+* 2. Altered source versions must be plainly marked as such, and must not be misrepresented74
+* as being the original software.75
+*76
+* 3. This notice may not be removed or altered from any source distribution.77
+*78
+**********************************************************************************************/79
+80
+#ifndef RAYLIB_H81
+#define RAYLIB_H82
+83
+#include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback84
+85
+#define RAYLIB_VERSION_MAJOR 586
+#define RAYLIB_VERSION_MINOR 187
+#define RAYLIB_VERSION_PATCH 088
+#define RAYLIB_VERSION "5.1-dev"89
+90
+// Function specifiers in case library is build/used as a shared library91
+// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll92
+// NOTE: visibility("default") attribute makes symbols "visible" when compiled with -fvisibility=hidden93
+#if defined(_WIN32)94
+ #if defined(__TINYC__)95
+ #define __declspec(x) __attribute__((x))96
+ #endif97
+ #if defined(BUILD_LIBTYPE_SHARED)98
+ #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)99
+ #elif defined(USE_LIBTYPE_SHARED)100
+ #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)101
+ #endif102
+#else103
+ #if defined(BUILD_LIBTYPE_SHARED)104
+ #define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib)105
+ #endif106
+#endif107
+108
+#ifndef RLAPI109
+ #define RLAPI // Functions defined as 'extern' by default (implicit specifiers)110
+#endif111
+112
+//----------------------------------------------------------------------------------113
+// Some basic Defines114
+//----------------------------------------------------------------------------------115
+#ifndef PI116
+ #define PI 3.14159265358979323846f117
+#endif118
+#ifndef DEG2RAD119
+ #define DEG2RAD (PI/180.0f)120
+#endif121
+#ifndef RAD2DEG122
+ #define RAD2DEG (180.0f/PI)123
+#endif124
+125
+// Allow custom memory allocators126
+// NOTE: Require recompiling raylib sources127
+#ifndef RL_MALLOC128
+ #define RL_MALLOC(sz) malloc(sz)129
+#endif130
+#ifndef RL_CALLOC131
+ #define RL_CALLOC(n,sz) calloc(n,sz)132
+#endif133
+#ifndef RL_REALLOC134
+ #define RL_REALLOC(ptr,sz) realloc(ptr,sz)135
+#endif136
+#ifndef RL_FREE137
+ #define RL_FREE(ptr) free(ptr)138
+#endif139
+140
+// NOTE: MSVC C++ compiler does not support compound literals (C99 feature)141
+// Plain structures in C++ (without constructors) can be initialized with { }142
+// This is called aggregate initialization (C++11 feature)143
+#if defined(__cplusplus)144
+ #define CLITERAL(type) type145
+#else146
+ #define CLITERAL(type) (type)147
+#endif148
+149
+// Some compilers (mostly macos clang) default to C++98,150
+// where aggregate initialization can't be used151
+// So, give a more clear error stating how to fix this152
+// #if !defined(_MSC_VER) && (defined(__cplusplus) && __cplusplus < 201103L)153
+// #error "C++11 or later is required. Add -std=c++11"154
+// #endif155
+156
+// NOTE: We set some defines with some data types declared by raylib157
+// Other modules (raymath, rlgl) also require some of those types, so,158
+// to be able to use those other modules as standalone (not depending on raylib)159
+// this defines are very useful for internal check and avoid type (re)definitions160
+#define RL_COLOR_TYPE161
+#define RL_RECTANGLE_TYPE162
+#define RL_VECTOR2_TYPE163
+#define RL_VECTOR3_TYPE164
+#define RL_VECTOR4_TYPE165
+#define RL_QUATERNION_TYPE166
+#define RL_MATRIX_TYPE167
+168
+// Some Basic Colors169
+// NOTE: Custom raylib color palette for amazing visuals on WHITE background170
+#define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray171
+#define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray172
+#define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray173
+#define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow174
+#define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold175
+#define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange176
+#define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink177
+#define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red178
+#define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon179
+#define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green180
+#define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime181
+#define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green182
+#define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue183
+#define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue184
+#define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue185
+#define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple186
+#define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet187
+#define DARKPURPLE CLITERAL(Color){ 112, 31, 126, 255 } // Dark Purple188
+#define BEIGE CLITERAL(Color){ 211, 176, 131, 255 } // Beige189
+#define BROWN CLITERAL(Color){ 127, 106, 79, 255 } // Brown190
+#define DARKBROWN CLITERAL(Color){ 76, 63, 47, 255 } // Dark Brown191
+192
+#define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White193
+#define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black194
+#define BLANK CLITERAL(Color){ 0, 0, 0, 0 } // Blank (Transparent)195
+#define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta196
+#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo)197
+198
+//----------------------------------------------------------------------------------199
+// Structures Definition200
+//----------------------------------------------------------------------------------201
+// Boolean type202
+#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)203
+ #include <stdbool.h>204
+#elif !defined(__cplusplus) && !defined(bool)205
+ typedef enum bool { false = 0, true = !false } bool;206
+ #define RL_BOOL_TYPE207
+#endif208
+209
+// Vector2, 2 components210
+typedef struct Vector2 {211
+ float x; // Vector x component212
+ float y; // Vector y component213
+} Vector2;214
+215
+// Vector3, 3 components216
+typedef struct Vector3 {217
+ float x; // Vector x component218
+ float y; // Vector y component219
+ float z; // Vector z component220
+} Vector3;221
+222
+// Vector4, 4 components223
+typedef struct Vector4 {224
+ float x; // Vector x component225
+ float y; // Vector y component226
+ float z; // Vector z component227
+ float w; // Vector w component228
+} Vector4;229
+230
+// Quaternion, 4 components (Vector4 alias)231
+typedef Vector4 Quaternion;232
+233
+// Matrix, 4x4 components, column major, OpenGL style, right-handed234
+typedef struct Matrix {235
+ float m0, m4, m8, m12; // Matrix first row (4 components)236
+ float m1, m5, m9, m13; // Matrix second row (4 components)237
+ float m2, m6, m10, m14; // Matrix third row (4 components)238
+ float m3, m7, m11, m15; // Matrix fourth row (4 components)239
+} Matrix;240
+241
+// Color, 4 components, R8G8B8A8 (32bit)242
+typedef struct Color {243
+ unsigned char r; // Color red value244
+ unsigned char g; // Color green value245
+ unsigned char b; // Color blue value246
+ unsigned char a; // Color alpha value247
+} Color;248
+249
+// Rectangle, 4 components250
+typedef struct Rectangle {251
+ float x; // Rectangle top-left corner position x252
+ float y; // Rectangle top-left corner position y253
+ float width; // Rectangle width254
+ float height; // Rectangle height255
+} Rectangle;256
+257
+// Image, pixel data stored in CPU memory (RAM)258
+typedef struct Image {259
+ void *data; // Image raw data260
+ int width; // Image base width261
+ int height; // Image base height262
+ int mipmaps; // Mipmap levels, 1 by default263
+ int format; // Data format (PixelFormat type)264
+} Image;265
+266
+// Texture, tex data stored in GPU memory (VRAM)267
+typedef struct Texture {268
+ unsigned int id; // OpenGL texture id269
+ int width; // Texture base width270
+ int height; // Texture base height271
+ int mipmaps; // Mipmap levels, 1 by default272
+ int format; // Data format (PixelFormat type)273
+} Texture;274
+275
+// Texture2D, same as Texture276
+typedef Texture Texture2D;277
+278
+// TextureCubemap, same as Texture279
+typedef Texture TextureCubemap;280
+281
+// RenderTexture, fbo for texture rendering282
+typedef struct RenderTexture {283
+ unsigned int id; // OpenGL framebuffer object id284
+ Texture texture; // Color buffer attachment texture285
+ Texture depth; // Depth buffer attachment texture286
+} RenderTexture;287
+288
+// RenderTexture2D, same as RenderTexture289
+typedef RenderTexture RenderTexture2D;290
+291
+// NPatchInfo, n-patch layout info292
+typedef struct NPatchInfo {293
+ Rectangle source; // Texture source rectangle294
+ int left; // Left border offset295
+ int top; // Top border offset296
+ int right; // Right border offset297
+ int bottom; // Bottom border offset298
+ int layout; // Layout of the n-patch: 3x3, 1x3 or 3x1299
+} NPatchInfo;300
+301
+// GlyphInfo, font characters glyphs info302
+typedef struct GlyphInfo {303
+ int value; // Character value (Unicode)304
+ int offsetX; // Character offset X when drawing305
+ int offsetY; // Character offset Y when drawing306
+ int advanceX; // Character advance position X307
+ Image image; // Character image data308
+} GlyphInfo;309
+310
+// Font, font texture and GlyphInfo array data311
+typedef struct Font {312
+ int baseSize; // Base size (default chars height)313
+ int glyphCount; // Number of glyph characters314
+ int glyphPadding; // Padding around the glyph characters315
+ Texture2D texture; // Texture atlas containing the glyphs316
+ Rectangle *recs; // Rectangles in texture for the glyphs317
+ GlyphInfo *glyphs; // Glyphs info data318
+} Font;319
+320
+// Camera, defines position/orientation in 3d space321
+typedef struct Camera3D {322
+ Vector3 position; // Camera position323
+ Vector3 target; // Camera target it looks-at324
+ Vector3 up; // Camera up vector (rotation over its axis)325
+ float fovy; // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic326
+ int projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC327
+} Camera3D;328
+329
+typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D330
+331
+// Camera2D, defines position/orientation in 2d space332
+typedef struct Camera2D {333
+ Vector2 offset; // Camera offset (displacement from target)334
+ Vector2 target; // Camera target (rotation and zoom origin)335
+ float rotation; // Camera rotation in degrees336
+ float zoom; // Camera zoom (scaling), should be 1.0f by default337
+} Camera2D;338
+339
+// Mesh, vertex data and vao/vbo340
+typedef struct Mesh {341
+ int vertexCount; // Number of vertices stored in arrays342
+ int triangleCount; // Number of triangles stored (indexed or not)343
+344
+ // Vertex attributes data345
+ float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)346
+ float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)347
+ float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)348
+ float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)349
+ float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)350
+ unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)351
+ unsigned short *indices; // Vertex indices (in case vertex data comes indexed)352
+353
+ // Animation vertex data354
+ float *animVertices; // Animated vertex positions (after bones transformations)355
+ float *animNormals; // Animated normals (after bones transformations)356
+ unsigned char *boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning)357
+ float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning)358
+359
+ // OpenGL identifiers360
+ unsigned int vaoId; // OpenGL Vertex Array Object id361
+ unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data)362
+} Mesh;363
+364
+// Shader365
+typedef struct Shader {366
+ unsigned int id; // Shader program id367
+ int *locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS)368
+} Shader;369
+370
+// MaterialMap371
+typedef struct MaterialMap {372
+ Texture2D texture; // Material map texture373
+ Color color; // Material map color374
+ float value; // Material map value375
+} MaterialMap;376
+377
+// Material, includes shader and maps378
+typedef struct Material {379
+ Shader shader; // Material shader380
+ MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)381
+ float params[4]; // Material generic parameters (if required)382
+} Material;383
+384
+// Transform, vertex transformation data385
+typedef struct Transform {386
+ Vector3 translation; // Translation387
+ Quaternion rotation; // Rotation388
+ Vector3 scale; // Scale389
+} Transform;390
+391
+// Bone, skeletal animation bone392
+typedef struct BoneInfo {393
+ char name[32]; // Bone name394
+ int parent; // Bone parent395
+} BoneInfo;396
+397
+// Model, meshes, materials and animation data398
+typedef struct Model {399
+ Matrix transform; // Local transform matrix400
+401
+ int meshCount; // Number of meshes402
+ int materialCount; // Number of materials403
+ Mesh *meshes; // Meshes array404
+ Material *materials; // Materials array405
+ int *meshMaterial; // Mesh material number406
+407
+ // Animation data408
+ int boneCount; // Number of bones409
+ BoneInfo *bones; // Bones information (skeleton)410
+ Transform *bindPose; // Bones base transformation (pose)411
+} Model;412
+413
+// ModelAnimation414
+typedef struct ModelAnimation {415
+ int boneCount; // Number of bones416
+ int frameCount; // Number of animation frames417
+ BoneInfo *bones; // Bones information (skeleton)418
+ Transform **framePoses; // Poses array by frame419
+ char name[32]; // Animation name420
+} ModelAnimation;421
+422
+// Ray, ray for raycasting423
+typedef struct Ray {424
+ Vector3 position; // Ray position (origin)425
+ Vector3 direction; // Ray direction426
+} Ray;427
+428
+// RayCollision, ray hit information429
+typedef struct RayCollision {430
+ bool hit; // Did the ray hit something?431
+ float distance; // Distance to the nearest hit432
+ Vector3 point; // Point of the nearest hit433
+ Vector3 normal; // Surface normal of hit434
+} RayCollision;435
+436
+// BoundingBox437
+typedef struct BoundingBox {438
+ Vector3 min; // Minimum vertex box-corner439
+ Vector3 max; // Maximum vertex box-corner440
+} BoundingBox;441
+442
+// Wave, audio wave data443
+typedef struct Wave {444
+ unsigned int frameCount; // Total number of frames (considering channels)445
+ unsigned int sampleRate; // Frequency (samples per second)446
+ unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)447
+ unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)448
+ void *data; // Buffer data pointer449
+} Wave;450
+451
+// Opaque structs declaration452
+// NOTE: Actual structs are defined internally in raudio module453
+typedef struct rAudioBuffer rAudioBuffer;454
+typedef struct rAudioProcessor rAudioProcessor;455
+456
+// AudioStream, custom audio stream457
+typedef struct AudioStream {458
+ rAudioBuffer *buffer; // Pointer to internal data used by the audio system459
+ rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects460
+461
+ unsigned int sampleRate; // Frequency (samples per second)462
+ unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)463
+ unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)464
+} AudioStream;465
+466
+// Sound467
+typedef struct Sound {468
+ AudioStream stream; // Audio stream469
+ unsigned int frameCount; // Total number of frames (considering channels)470
+} Sound;471
+472
+// Music, audio stream, anything longer than ~10 seconds should be streamed473
+typedef struct Music {474
+ AudioStream stream; // Audio stream475
+ unsigned int frameCount; // Total number of frames (considering channels)476
+ bool looping; // Music looping enable477
+478
+ int ctxType; // Type of music context (audio filetype)479
+ void *ctxData; // Audio context data, depends on type480
+} Music;481
+482
+// VrDeviceInfo, Head-Mounted-Display device parameters483
+typedef struct VrDeviceInfo {484
+ int hResolution; // Horizontal resolution in pixels485
+ int vResolution; // Vertical resolution in pixels486
+ float hScreenSize; // Horizontal size in meters487
+ float vScreenSize; // Vertical size in meters488
+ float eyeToScreenDistance; // Distance between eye and display in meters489
+ float lensSeparationDistance; // Lens separation distance in meters490
+ float interpupillaryDistance; // IPD (distance between pupils) in meters491
+ float lensDistortionValues[4]; // Lens distortion constant parameters492
+ float chromaAbCorrection[4]; // Chromatic aberration correction parameters493
+} VrDeviceInfo;494
+495
+// VrStereoConfig, VR stereo rendering configuration for simulator496
+typedef struct VrStereoConfig {497
+ Matrix projection[2]; // VR projection matrices (per eye)498
+ Matrix viewOffset[2]; // VR view offset matrices (per eye)499
+ float leftLensCenter[2]; // VR left lens center500
+ float rightLensCenter[2]; // VR right lens center501
+ float leftScreenCenter[2]; // VR left screen center502
+ float rightScreenCenter[2]; // VR right screen center503
+ float scale[2]; // VR distortion scale504
+ float scaleIn[2]; // VR distortion scale in505
+} VrStereoConfig;506
+507
+// File path list508
+typedef struct FilePathList {509
+ unsigned int capacity; // Filepaths max entries510
+ unsigned int count; // Filepaths entries count511
+ char **paths; // Filepaths entries512
+} FilePathList;513
+514
+// Automation event515
+typedef struct AutomationEvent {516
+ unsigned int frame; // Event frame517
+ unsigned int type; // Event type (AutomationEventType)518
+ int params[4]; // Event parameters (if required)519
+} AutomationEvent;520
+521
+// Automation event list522
+typedef struct AutomationEventList {523
+ unsigned int capacity; // Events max entries (MAX_AUTOMATION_EVENTS)524
+ unsigned int count; // Events entries count525
+ AutomationEvent *events; // Events entries526
+} AutomationEventList;527
+528
+//----------------------------------------------------------------------------------529
+// Enumerators Definition530
+//----------------------------------------------------------------------------------531
+// System/Window config flags532
+// NOTE: Every bit registers one state (use it with bit masks)533
+// By default all flags are set to 0534
+typedef enum {535
+ FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU536
+ FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen537
+ FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window538
+ FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons)539
+ FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window540
+ FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify)541
+ FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor)542
+ FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused543
+ FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top544
+ FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized545
+ FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer546
+ FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI547
+ FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED548
+ FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode549
+ FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X550
+ FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)551
+} ConfigFlags;552
+553
+// Trace log level554
+// NOTE: Organized by priority level555
+typedef enum {556
+ LOG_ALL = 0, // Display all logs557
+ LOG_TRACE, // Trace logging, intended for internal use only558
+ LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds559
+ LOG_INFO, // Info logging, used for program execution info560
+ LOG_WARNING, // Warning logging, used on recoverable failures561
+ LOG_ERROR, // Error logging, used on unrecoverable failures562
+ LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE)563
+ LOG_NONE // Disable logging564
+} TraceLogLevel;565
+566
+// Keyboard keys (US keyboard layout)567
+// NOTE: Use GetKeyPressed() to allow redefining568
+// required keys for alternative layouts569
+typedef enum {570
+ KEY_NULL = 0, // Key: NULL, used for no key pressed571
+ // Alphanumeric keys572
+ KEY_APOSTROPHE = 39, // Key: '573
+ KEY_COMMA = 44, // Key: ,574
+ KEY_MINUS = 45, // Key: -575
+ KEY_PERIOD = 46, // Key: .576
+ KEY_SLASH = 47, // Key: /577
+ KEY_ZERO = 48, // Key: 0578
+ KEY_ONE = 49, // Key: 1579
+ KEY_TWO = 50, // Key: 2580
+ KEY_THREE = 51, // Key: 3581
+ KEY_FOUR = 52, // Key: 4582
+ KEY_FIVE = 53, // Key: 5583
+ KEY_SIX = 54, // Key: 6584
+ KEY_SEVEN = 55, // Key: 7585
+ KEY_EIGHT = 56, // Key: 8586
+ KEY_NINE = 57, // Key: 9587
+ KEY_SEMICOLON = 59, // Key: ;588
+ KEY_EQUAL = 61, // Key: =589
+ KEY_A = 65, // Key: A | a590
+ KEY_B = 66, // Key: B | b591
+ KEY_C = 67, // Key: C | c592
+ KEY_D = 68, // Key: D | d593
+ KEY_E = 69, // Key: E | e594
+ KEY_F = 70, // Key: F | f595
+ KEY_G = 71, // Key: G | g596
+ KEY_H = 72, // Key: H | h597
+ KEY_I = 73, // Key: I | i598
+ KEY_J = 74, // Key: J | j599
+ KEY_K = 75, // Key: K | k600
+ KEY_L = 76, // Key: L | l601
+ KEY_M = 77, // Key: M | m602
+ KEY_N = 78, // Key: N | n603
+ KEY_O = 79, // Key: O | o604
+ KEY_P = 80, // Key: P | p605
+ KEY_Q = 81, // Key: Q | q606
+ KEY_R = 82, // Key: R | r607
+ KEY_S = 83, // Key: S | s608
+ KEY_T = 84, // Key: T | t609
+ KEY_U = 85, // Key: U | u610
+ KEY_V = 86, // Key: V | v611
+ KEY_W = 87, // Key: W | w612
+ KEY_X = 88, // Key: X | x613
+ KEY_Y = 89, // Key: Y | y614
+ KEY_Z = 90, // Key: Z | z615
+ KEY_LEFT_BRACKET = 91, // Key: [616
+ KEY_BACKSLASH = 92, // Key: '\'617
+ KEY_RIGHT_BRACKET = 93, // Key: ]618
+ KEY_GRAVE = 96, // Key: `619
+ // Function keys620
+ KEY_SPACE = 32, // Key: Space621
+ KEY_ESCAPE = 256, // Key: Esc622
+ KEY_ENTER = 257, // Key: Enter623
+ KEY_TAB = 258, // Key: Tab624
+ KEY_BACKSPACE = 259, // Key: Backspace625
+ KEY_INSERT = 260, // Key: Ins626
+ KEY_DELETE = 261, // Key: Del627
+ KEY_RIGHT = 262, // Key: Cursor right628
+ KEY_LEFT = 263, // Key: Cursor left629
+ KEY_DOWN = 264, // Key: Cursor down630
+ KEY_UP = 265, // Key: Cursor up631
+ KEY_PAGE_UP = 266, // Key: Page up632
+ KEY_PAGE_DOWN = 267, // Key: Page down633
+ KEY_HOME = 268, // Key: Home634
+ KEY_END = 269, // Key: End635
+ KEY_CAPS_LOCK = 280, // Key: Caps lock636
+ KEY_SCROLL_LOCK = 281, // Key: Scroll down637
+ KEY_NUM_LOCK = 282, // Key: Num lock638
+ KEY_PRINT_SCREEN = 283, // Key: Print screen639
+ KEY_PAUSE = 284, // Key: Pause640
+ KEY_F1 = 290, // Key: F1641
+ KEY_F2 = 291, // Key: F2642
+ KEY_F3 = 292, // Key: F3643
+ KEY_F4 = 293, // Key: F4644
+ KEY_F5 = 294, // Key: F5645
+ KEY_F6 = 295, // Key: F6646
+ KEY_F7 = 296, // Key: F7647
+ KEY_F8 = 297, // Key: F8648
+ KEY_F9 = 298, // Key: F9649
+ KEY_F10 = 299, // Key: F10650
+ KEY_F11 = 300, // Key: F11651
+ KEY_F12 = 301, // Key: F12652
+ KEY_LEFT_SHIFT = 340, // Key: Shift left653
+ KEY_LEFT_CONTROL = 341, // Key: Control left654
+ KEY_LEFT_ALT = 342, // Key: Alt left655
+ KEY_LEFT_SUPER = 343, // Key: Super left656
+ KEY_RIGHT_SHIFT = 344, // Key: Shift right657
+ KEY_RIGHT_CONTROL = 345, // Key: Control right658
+ KEY_RIGHT_ALT = 346, // Key: Alt right659
+ KEY_RIGHT_SUPER = 347, // Key: Super right660
+ KEY_KB_MENU = 348, // Key: KB menu661
+ // Keypad keys662
+ KEY_KP_0 = 320, // Key: Keypad 0663
+ KEY_KP_1 = 321, // Key: Keypad 1664
+ KEY_KP_2 = 322, // Key: Keypad 2665
+ KEY_KP_3 = 323, // Key: Keypad 3666
+ KEY_KP_4 = 324, // Key: Keypad 4667
+ KEY_KP_5 = 325, // Key: Keypad 5668
+ KEY_KP_6 = 326, // Key: Keypad 6669
+ KEY_KP_7 = 327, // Key: Keypad 7670
+ KEY_KP_8 = 328, // Key: Keypad 8671
+ KEY_KP_9 = 329, // Key: Keypad 9672
+ KEY_KP_DECIMAL = 330, // Key: Keypad .673
+ KEY_KP_DIVIDE = 331, // Key: Keypad /674
+ KEY_KP_MULTIPLY = 332, // Key: Keypad *675
+ KEY_KP_SUBTRACT = 333, // Key: Keypad -676
+ KEY_KP_ADD = 334, // Key: Keypad +677
+ KEY_KP_ENTER = 335, // Key: Keypad Enter678
+ KEY_KP_EQUAL = 336, // Key: Keypad =679
+ // Android key buttons680
+ KEY_BACK = 4, // Key: Android back button681
+ KEY_MENU = 5, // Key: Android menu button682
+ KEY_VOLUME_UP = 24, // Key: Android volume up button683
+ KEY_VOLUME_DOWN = 25 // Key: Android volume down button684
+} KeyboardKey;685
+686
+// Add backwards compatibility support for deprecated names687
+#define MOUSE_LEFT_BUTTON MOUSE_BUTTON_LEFT688
+#define MOUSE_RIGHT_BUTTON MOUSE_BUTTON_RIGHT689
+#define MOUSE_MIDDLE_BUTTON MOUSE_BUTTON_MIDDLE690
+691
+// Mouse buttons692
+typedef enum {693
+ MOUSE_BUTTON_LEFT = 0, // Mouse button left694
+ MOUSE_BUTTON_RIGHT = 1, // Mouse button right695
+ MOUSE_BUTTON_MIDDLE = 2, // Mouse button middle (pressed wheel)696
+ MOUSE_BUTTON_SIDE = 3, // Mouse button side (advanced mouse device)697
+ MOUSE_BUTTON_EXTRA = 4, // Mouse button extra (advanced mouse device)698
+ MOUSE_BUTTON_FORWARD = 5, // Mouse button forward (advanced mouse device)699
+ MOUSE_BUTTON_BACK = 6, // Mouse button back (advanced mouse device)700
+} MouseButton;701
+702
+// Mouse cursor703
+typedef enum {704
+ MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape705
+ MOUSE_CURSOR_ARROW = 1, // Arrow shape706
+ MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape707
+ MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape708
+ MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor709
+ MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape710
+ MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape711
+ MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape712
+ MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape713
+ MOUSE_CURSOR_RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape714
+ MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape715
+} MouseCursor;716
+717
+// Gamepad buttons718
+typedef enum {719
+ GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, just for error checking720
+ GAMEPAD_BUTTON_LEFT_FACE_UP, // Gamepad left DPAD up button721
+ GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Gamepad left DPAD right button722
+ GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Gamepad left DPAD down button723
+ GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Gamepad left DPAD left button724
+ GAMEPAD_BUTTON_RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y)725
+ GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Square, Xbox: X)726
+ GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A)727
+ GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Circle, Xbox: B)728
+ GAMEPAD_BUTTON_LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button729
+ GAMEPAD_BUTTON_LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button730
+ GAMEPAD_BUTTON_RIGHT_TRIGGER_1, // Gamepad top/back trigger right (one), it could be a trailing button731
+ GAMEPAD_BUTTON_RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button732
+ GAMEPAD_BUTTON_MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select)733
+ GAMEPAD_BUTTON_MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX)734
+ GAMEPAD_BUTTON_MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start)735
+ GAMEPAD_BUTTON_LEFT_THUMB, // Gamepad joystick pressed button left736
+ GAMEPAD_BUTTON_RIGHT_THUMB // Gamepad joystick pressed button right737
+} GamepadButton;738
+739
+// Gamepad axis740
+typedef enum {741
+ GAMEPAD_AXIS_LEFT_X = 0, // Gamepad left stick X axis742
+ GAMEPAD_AXIS_LEFT_Y = 1, // Gamepad left stick Y axis743
+ GAMEPAD_AXIS_RIGHT_X = 2, // Gamepad right stick X axis744
+ GAMEPAD_AXIS_RIGHT_Y = 3, // Gamepad right stick Y axis745
+ GAMEPAD_AXIS_LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1]746
+ GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // Gamepad back trigger right, pressure level: [1..-1]747
+} GamepadAxis;748
+749
+// Material map index750
+typedef enum {751
+ MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)752
+ MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR)753
+ MATERIAL_MAP_NORMAL, // Normal material754
+ MATERIAL_MAP_ROUGHNESS, // Roughness material755
+ MATERIAL_MAP_OCCLUSION, // Ambient occlusion material756
+ MATERIAL_MAP_EMISSION, // Emission material757
+ MATERIAL_MAP_HEIGHT, // Heightmap material758
+ MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP)759
+ MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP)760
+ MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP)761
+ MATERIAL_MAP_BRDF // Brdf material762
+} MaterialMapIndex;763
+764
+#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO765
+#define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS766
+767
+// Shader location index768
+typedef enum {769
+ SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position770
+ SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01771
+ SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02772
+ SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal773
+ SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent774
+ SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color775
+ SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection776
+ SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform)777
+ SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection778
+ SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform)779
+ SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal780
+ SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view781
+ SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color782
+ SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color783
+ SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color784
+ SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE)785
+ SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR)786
+ SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal787
+ SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness788
+ SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion789
+ SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission790
+ SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height791
+ SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap792
+ SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance793
+ SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter794
+ SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf795
+} ShaderLocationIndex;796
+797
+#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO798
+#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS799
+800
+// Shader uniform data type801
+typedef enum {802
+ SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float803
+ SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)804
+ SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)805
+ SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)806
+ SHADER_UNIFORM_INT, // Shader uniform type: int807
+ SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)808
+ SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)809
+ SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)810
+ SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d811
+} ShaderUniformDataType;812
+813
+// Shader attribute data types814
+typedef enum {815
+ SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float816
+ SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float)817
+ SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float)818
+ SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)819
+} ShaderAttributeDataType;820
+821
+// Pixel formats822
+// NOTE: Support depends on OpenGL version and platform823
+typedef enum {824
+ PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)825
+ PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)826
+ PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp827
+ PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp828
+ PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)829
+ PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)830
+ PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp831
+ PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)832
+ PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)833
+ PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)834
+ PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float)835
+ PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float)836
+ PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float)837
+ PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)838
+ PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)839
+ PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp840
+ PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp841
+ PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp842
+ PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp843
+ PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp844
+ PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp845
+ PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp846
+ PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp847
+ PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp848
+} PixelFormat;849
+850
+// Texture parameters: filter mode851
+// NOTE 1: Filtering considers mipmaps if available in the texture852
+// NOTE 2: Filter is accordingly set for minification and magnification853
+typedef enum {854
+ TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation855
+ TEXTURE_FILTER_BILINEAR, // Linear filtering856
+ TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)857
+ TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x858
+ TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x859
+ TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x860
+} TextureFilter;861
+862
+// Texture parameters: wrap mode863
+typedef enum {864
+ TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode865
+ TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode866
+ TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode867
+ TEXTURE_WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode868
+} TextureWrap;869
+870
+// Cubemap layouts871
+typedef enum {872
+ CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type873
+ CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces874
+ CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces875
+ CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces876
+ CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces877
+ CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirrectangular map)878
+} CubemapLayout;879
+880
+// Font type, defines generation method881
+typedef enum {882
+ FONT_DEFAULT = 0, // Default font generation, anti-aliased883
+ FONT_BITMAP, // Bitmap font generation, no anti-aliasing884
+ FONT_SDF // SDF font generation, requires external shader885
+} FontType;886
+887
+// Color blending modes (pre-defined)888
+typedef enum {889
+ BLEND_ALPHA = 0, // Blend textures considering alpha (default)890
+ BLEND_ADDITIVE, // Blend textures adding colors891
+ BLEND_MULTIPLIED, // Blend textures multiplying colors892
+ BLEND_ADD_COLORS, // Blend textures adding colors (alternative)893
+ BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)894
+ BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha895
+ BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors())896
+ BLEND_CUSTOM_SEPARATE // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())897
+} BlendMode;898
+899
+// Gesture900
+// NOTE: Provided as bit-wise flags to enable only desired gestures901
+typedef enum {902
+ GESTURE_NONE = 0, // No gesture903
+ GESTURE_TAP = 1, // Tap gesture904
+ GESTURE_DOUBLETAP = 2, // Double tap gesture905
+ GESTURE_HOLD = 4, // Hold gesture906
+ GESTURE_DRAG = 8, // Drag gesture907
+ GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture908
+ GESTURE_SWIPE_LEFT = 32, // Swipe left gesture909
+ GESTURE_SWIPE_UP = 64, // Swipe up gesture910
+ GESTURE_SWIPE_DOWN = 128, // Swipe down gesture911
+ GESTURE_PINCH_IN = 256, // Pinch in gesture912
+ GESTURE_PINCH_OUT = 512 // Pinch out gesture913
+} Gesture;914
+915
+// Camera system modes916
+typedef enum {917
+ CAMERA_CUSTOM = 0, // Custom camera918
+ CAMERA_FREE, // Free camera919
+ CAMERA_ORBITAL, // Orbital camera920
+ CAMERA_FIRST_PERSON, // First person camera921
+ CAMERA_THIRD_PERSON // Third person camera922
+} CameraMode;923
+924
+// Camera projection925
+typedef enum {926
+ CAMERA_PERSPECTIVE = 0, // Perspective projection927
+ CAMERA_ORTHOGRAPHIC // Orthographic projection928
+} CameraProjection;929
+930
+// N-patch layout931
+typedef enum {932
+ NPATCH_NINE_PATCH = 0, // Npatch layout: 3x3 tiles933
+ NPATCH_THREE_PATCH_VERTICAL, // Npatch layout: 1x3 tiles934
+ NPATCH_THREE_PATCH_HORIZONTAL // Npatch layout: 3x1 tiles935
+} NPatchLayout;936
+937
+// Callbacks to hook some internal functions938
+// WARNING: These callbacks are intended for advance users939
+typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages940
+typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, int *dataSize); // FileIO: Load binary data941
+typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, int dataSize); // FileIO: Save binary data942
+typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data943
+typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data944
+945
+//------------------------------------------------------------------------------------946
+// Global Variables Definition947
+//------------------------------------------------------------------------------------948
+// It's lonely here...949
+950
+//------------------------------------------------------------------------------------951
+// Window and Graphics Device Functions (Module: core)952
+//------------------------------------------------------------------------------------953
+954
+#if defined(__cplusplus)955
+extern "C" { // Prevents name mangling of functions956
+#endif957
+958
+// Window-related functions959
+RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context960
+RLAPI void CloseWindow(void); // Close window and unload OpenGL context961
+RLAPI bool WindowShouldClose(void); // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)962
+RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully963
+RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen964
+RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP)965
+RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP)966
+RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP)967
+RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP)968
+RLAPI bool IsWindowResized(void); // Check if window has been resized last frame969
+RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled970
+RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)971
+RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags972
+RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)973
+RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed (only PLATFORM_DESKTOP)974
+RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)975
+RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)976
+RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)977
+RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)978
+RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)979
+RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)980
+RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)981
+RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window982
+RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)983
+RLAPI void SetWindowMaxSize(int width, int height); // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)984
+RLAPI void SetWindowSize(int width, int height); // Set window dimensions985
+RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)986
+RLAPI void SetWindowFocused(void); // Set window focused (only PLATFORM_DESKTOP)987
+RLAPI void *GetWindowHandle(void); // Get native window handle988
+RLAPI int GetScreenWidth(void); // Get current screen width989
+RLAPI int GetScreenHeight(void); // Get current screen height990
+RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI)991
+RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI)992
+RLAPI int GetMonitorCount(void); // Get number of connected monitors993
+RLAPI int GetCurrentMonitor(void); // Get current connected monitor994
+RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position995
+RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)996
+RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)997
+RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres998
+RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres999
+RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate1000
+RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor1001
+RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor1002
+RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor1003
+RLAPI void SetClipboardText(const char *text); // Set clipboard text content1004
+RLAPI const char *GetClipboardText(void); // Get clipboard text content1005
+RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling1006
+RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling1007
+1008
+// Cursor-related functions1009
+RLAPI void ShowCursor(void); // Shows cursor1010
+RLAPI void HideCursor(void); // Hides cursor1011
+RLAPI bool IsCursorHidden(void); // Check if cursor is not visible1012
+RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)1013
+RLAPI void DisableCursor(void); // Disables cursor (lock cursor)1014
+RLAPI bool IsCursorOnScreen(void); // Check if cursor is on the screen1015
+1016
+// Drawing-related functions1017
+RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)1018
+RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing1019
+RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)1020
+RLAPI void BeginMode2D(Camera2D camera); // Begin 2D mode with custom camera (2D)1021
+RLAPI void EndMode2D(void); // Ends 2D mode with custom camera1022
+RLAPI void BeginMode3D(Camera3D camera); // Begin 3D mode with custom camera (3D)1023
+RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode1024
+RLAPI void BeginTextureMode(RenderTexture2D target); // Begin drawing to render texture1025
+RLAPI void EndTextureMode(void); // Ends drawing to render texture1026
+RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing1027
+RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)1028
+RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied, subtract, custom)1029
+RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)1030
+RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)1031
+RLAPI void EndScissorMode(void); // End scissor mode1032
+RLAPI void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering (requires VR simulator)1033
+RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator)1034
+1035
+// VR stereo config functions for VR simulator1036
+RLAPI VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); // Load VR stereo config for VR simulator device parameters1037
+RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR stereo config1038
+1039
+// Shader management functions1040
+// NOTE: Shader functionality is not available on OpenGL 1.11041
+RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations1042
+RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations1043
+RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready1044
+RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location1045
+RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location1046
+RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value1047
+RLAPI void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); // Set shader uniform value vector1048
+RLAPI void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); // Set shader uniform value (matrix 4x4)1049
+RLAPI void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); // Set shader uniform value for texture (sampler2d)1050
+RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)1051
+1052
+// Screen-space-related functions1053
+RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position1054
+RLAPI Ray GetViewRay(Vector2 mousePosition, Camera camera, float width, float height); // Get a ray trace from mouse position in a viewport1055
+RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position1056
+RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position1057
+RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position1058
+RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position1059
+RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)1060
+RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix1061
+1062
+// Timing-related functions1063
+RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)1064
+RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)1065
+RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()1066
+RLAPI int GetFPS(void); // Get current FPS1067
+1068
+// Custom frame control functions1069
+// NOTE: Those functions are intended for advance users that want full control over the frame processing1070
+// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()1071
+// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL1072
+RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)1073
+RLAPI void PollInputEvents(void); // Register all input events1074
+RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)1075
+1076
+// Random values generation functions1077
+RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator1078
+RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)1079
+RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load random values sequence, no values repeated1080
+RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence1081
+1082
+// Misc. functions1083
+RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)1084
+RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)1085
+RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)1086
+1087
+// NOTE: Following functions implemented in module [utils]1088
+//------------------------------------------------------------------1089
+RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)1090
+RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level1091
+RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator1092
+RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator1093
+RLAPI void MemFree(void *ptr); // Internal memory free1094
+1095
+// Set custom callbacks1096
+// WARNING: Callbacks setup is intended for advance users1097
+RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log1098
+RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader1099
+RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver1100
+RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader1101
+RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver1102
+1103
+// Files management functions1104
+RLAPI unsigned char *LoadFileData(const char *fileName, int *dataSize); // Load file data as byte array (read)1105
+RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()1106
+RLAPI bool SaveFileData(const char *fileName, void *data, int dataSize); // Save data to file from byte array (write), returns true on success1107
+RLAPI bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileName); // Export data to code (.h), returns true on success1108
+RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string1109
+RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()1110
+RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success1111
+//------------------------------------------------------------------1112
+1113
+// File system functions1114
+RLAPI bool FileExists(const char *fileName); // Check if file exists1115
+RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists1116
+RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav)1117
+RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)1118
+RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')1119
+RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string1120
+RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)1121
+RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)1122
+RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string)1123
+RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)1124
+RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)1125
+RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success1126
+RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory1127
+RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths1128
+RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan1129
+RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths1130
+RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window1131
+RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths1132
+RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths1133
+RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)1134
+1135
+// Compression/Encoding functionality1136
+RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()1137
+RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree()1138
+RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()1139
+RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()1140
+1141
+// Automation events functionality1142
+RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS1143
+RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file1144
+RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file1145
+RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to1146
+RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording1147
+RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set)1148
+RLAPI void StopAutomationEventRecording(void); // Stop recording automation events1149
+RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event1150
+1151
+//------------------------------------------------------------------------------------1152
+// Input Handling Functions (Module: core)1153
+//------------------------------------------------------------------------------------1154
+1155
+// Input-related functions: keyboard1156
+RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once1157
+RLAPI bool IsKeyPressedRepeat(int key); // Check if a key has been pressed again (Only PLATFORM_DESKTOP)1158
+RLAPI bool IsKeyDown(int key); // Check if a key is being pressed1159
+RLAPI bool IsKeyReleased(int key); // Check if a key has been released once1160
+RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed1161
+RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty1162
+RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty1163
+RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)1164
+1165
+// Input-related functions: gamepads1166
+RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available1167
+RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id1168
+RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once1169
+RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed1170
+RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once1171
+RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed1172
+RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed1173
+RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad1174
+RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis1175
+RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)1176
+1177
+// Input-related functions: mouse1178
+RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once1179
+RLAPI bool IsMouseButtonDown(int button); // Check if a mouse button is being pressed1180
+RLAPI bool IsMouseButtonReleased(int button); // Check if a mouse button has been released once1181
+RLAPI bool IsMouseButtonUp(int button); // Check if a mouse button is NOT being pressed1182
+RLAPI int GetMouseX(void); // Get mouse position X1183
+RLAPI int GetMouseY(void); // Get mouse position Y1184
+RLAPI Vector2 GetMousePosition(void); // Get mouse position XY1185
+RLAPI Vector2 GetMouseDelta(void); // Get mouse delta between frames1186
+RLAPI void SetMousePosition(int x, int y); // Set mouse position XY1187
+RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset1188
+RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling1189
+RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement for X or Y, whichever is larger1190
+RLAPI Vector2 GetMouseWheelMoveV(void); // Get mouse wheel movement for both X and Y1191
+RLAPI void SetMouseCursor(int cursor); // Set mouse cursor1192
+1193
+// Input-related functions: touch1194
+RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)1195
+RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)1196
+RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)1197
+RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index1198
+RLAPI int GetTouchPointCount(void); // Get number of touch points1199
+1200
+//------------------------------------------------------------------------------------1201
+// Gestures and Touch Handling Functions (Module: rgestures)1202
+//------------------------------------------------------------------------------------1203
+RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags1204
+RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected1205
+RLAPI int GetGestureDetected(void); // Get latest detected gesture1206
+RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds1207
+RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector1208
+RLAPI float GetGestureDragAngle(void); // Get gesture drag angle1209
+RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta1210
+RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle1211
+1212
+//------------------------------------------------------------------------------------1213
+// Camera System Functions (Module: rcamera)1214
+//------------------------------------------------------------------------------------1215
+RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode1216
+RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation1217
+1218
+//------------------------------------------------------------------------------------1219
+// Basic Shapes Drawing Functions (Module: shapes)1220
+//------------------------------------------------------------------------------------1221
+// Set texture and rectangle to be used on shapes drawing1222
+// NOTE: It can be useful when using basic shapes and one single font,1223
+// defining a font char white rectangle would allow drawing everything in a single draw call1224
+RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing1225
+RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing1226
+RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing1227
+1228
+// Basic shapes drawing functions1229
+RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel1230
+RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)1231
+RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line1232
+RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (using gl lines)1233
+RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line (using triangles/quads)1234
+RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence (using gl lines)1235
+RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw line segment cubic-bezier in-out interpolation1236
+RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle1237
+RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle1238
+RLAPI void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw circle sector outline1239
+RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle1240
+RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)1241
+RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline1242
+RLAPI void DrawCircleLinesV(Vector2 center, float radius, Color color); // Draw circle outline (Vector version)1243
+RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse1244
+RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline1245
+RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring1246
+RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring outline1247
+RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle1248
+RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)1249
+RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle1250
+RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters1251
+RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle1252
+RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle1253
+RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors1254
+RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline1255
+RLAPI void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); // Draw rectangle outline with extended parameters1256
+RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges1257
+RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, float lineThick, Color color); // Draw rectangle with rounded edges outline1258
+RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!)1259
+RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline (vertex in counter-clockwise order!)1260
+RLAPI void DrawTriangleFan(Vector2 *points, int pointCount, Color color); // Draw a triangle fan defined by points (first vertex is the center)1261
+RLAPI void DrawTriangleStrip(Vector2 *points, int pointCount, Color color); // Draw a triangle strip defined by points1262
+RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)1263
+RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides1264
+RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters1265
+1266
+// Splines drawing functions1267
+RLAPI void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points1268
+RLAPI void DrawSplineBasis(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points1269
+RLAPI void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points1270
+RLAPI void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]1271
+RLAPI void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]1272
+RLAPI void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); // Draw spline segment: Linear, 2 points1273
+RLAPI void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: B-Spline, 4 points1274
+RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: Catmull-Rom, 4 points1275
+RLAPI void DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color); // Draw spline segment: Quadratic Bezier, 2 points, 1 control point1276
+RLAPI void DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color); // Draw spline segment: Cubic Bezier, 2 points, 2 control points1277
+1278
+// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f]1279
+RLAPI Vector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t); // Get (evaluate) spline point: Linear1280
+RLAPI Vector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: B-Spline1281
+RLAPI Vector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: Catmull-Rom1282
+RLAPI Vector2 GetSplinePointBezierQuad(Vector2 p1, Vector2 c2, Vector2 p3, float t); // Get (evaluate) spline point: Quadratic Bezier1283
+RLAPI Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t); // Get (evaluate) spline point: Cubic Bezier1284
+1285
+// Basic shapes collision detection functions1286
+RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles1287
+RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles1288
+RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle1289
+RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle1290
+RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle1291
+RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle1292
+RLAPI bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount); // Check if point is within a polygon described by array of vertices1293
+RLAPI bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); // Check the collision between two lines defined by two points each, returns collision point by reference1294
+RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]1295
+RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision1296
+1297
+//------------------------------------------------------------------------------------1298
+// Texture Loading and Drawing Functions (Module: textures)1299
+//------------------------------------------------------------------------------------1300
+1301
+// Image loading functions1302
+// NOTE: These functions do not require GPU access1303
+RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)1304
+RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data1305
+RLAPI Image LoadImageSvg(const char *fileNameOrString, int width, int height); // Load image from SVG file data or string with specified size1306
+RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data)1307
+RLAPI Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int *frames); // Load image sequence from memory buffer1308
+RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'1309
+RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data1310
+RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)1311
+RLAPI bool IsImageReady(Image image); // Check if an image is ready1312
+RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)1313
+RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success1314
+RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer1315
+RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success1316
+1317
+// Image generation functions1318
+RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color1319
+RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient1320
+RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient1321
+RLAPI Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer); // Generate image: square gradient1322
+RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked1323
+RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise1324
+RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise1325
+RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells1326
+RLAPI Image GenImageText(int width, int height, const char *text); // Generate image: grayscale image from text data1327
+1328
+// Image manipulation functions1329
+RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)1330
+RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece1331
+RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)1332
+RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)1333
+RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format1334
+RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two)1335
+RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle1336
+RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value1337
+RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color1338
+RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image1339
+RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel1340
+RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation1341
+RLAPI void ImageKernelConvolution(Image *image, float* kernel, int kernelSize); // Apply Custom Square image convolution kernel1342
+RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)1343
+RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)1344
+RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color1345
+RLAPI void ImageMipmaps(Image *image); // Compute all mipmap levels for a provided image1346
+RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)1347
+RLAPI void ImageFlipVertical(Image *image); // Flip image vertically1348
+RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally1349
+RLAPI void ImageRotate(Image *image, int degrees); // Rotate image by input angle in degrees (-359 to 359)1350
+RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg1351
+RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg1352
+RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint1353
+RLAPI void ImageColorInvert(Image *image); // Modify image color: invert1354
+RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale1355
+RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)1356
+RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)1357
+RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color1358
+RLAPI Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit)1359
+RLAPI Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount); // Load colors palette from image as a Color array (RGBA - 32bit)1360
+RLAPI void UnloadImageColors(Color *colors); // Unload color data loaded with LoadImageColors()1361
+RLAPI void UnloadImagePalette(Color *colors); // Unload colors palette loaded with LoadImagePalette()1362
+RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle1363
+RLAPI Color GetImageColor(Image image, int x, int y); // Get image pixel color at (x, y) position1364
+1365
+// Image drawing functions1366
+// NOTE: Image software-rendering functions (CPU)1367
+RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color1368
+RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image1369
+RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)1370
+RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image1371
+RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version)1372
+RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw a filled circle within an image1373
+RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw a filled circle within an image (Vector version)1374
+RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image1375
+RLAPI void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color); // Draw circle outline within an image (Vector version)1376
+RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image1377
+RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version)1378
+RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image1379
+RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image1380
+RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source)1381
+RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination)1382
+RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)1383
+1384
+// Texture loading functions1385
+// NOTE: These functions require GPU access1386
+RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM)1387
+RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data1388
+RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported1389
+RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)1390
+RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready1391
+RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)1392
+RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready1393
+RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)1394
+RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data1395
+RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data1396
+1397
+// Texture configuration functions1398
+RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture1399
+RLAPI void SetTextureFilter(Texture2D texture, int filter); // Set texture scaling filter mode1400
+RLAPI void SetTextureWrap(Texture2D texture, int wrap); // Set texture wrapping mode1401
+1402
+// Texture drawing functions1403
+RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D1404
+RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector21405
+RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters1406
+RLAPI void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle1407
+RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters1408
+RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely1409
+1410
+// Color/pixel related functions1411
+RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f1412
+RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color1413
+RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]1414
+RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]1415
+RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]1416
+RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]1417
+RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color1418
+RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f1419
+RLAPI Color ColorContrast(Color color, float contrast); // Get color with contrast correction, contrast values between -1.0f and 1.0f1420
+RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f1421
+RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint1422
+RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value1423
+RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format1424
+RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer1425
+RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format1426
+1427
+//------------------------------------------------------------------------------------1428
+// Font Loading and Text Drawing Functions (Module: text)1429
+//------------------------------------------------------------------------------------1430
+1431
+// Font loading/unloading functions1432
+RLAPI Font GetFontDefault(void); // Get the default Font1433
+RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)1434
+RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set1435
+RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)1436
+RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'1437
+RLAPI bool IsFontReady(Font font); // Check if a font is ready1438
+RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use1439
+RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info1440
+RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)1441
+RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM)1442
+RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success1443
+1444
+// Text drawing functions1445
+RLAPI void DrawFPS(int posX, int posY); // Draw current FPS1446
+RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)1447
+RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters1448
+RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)1449
+RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)1450
+RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)1451
+1452
+// Text font info functions1453
+RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks1454
+RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font1455
+RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font1456
+RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found1457
+RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found1458
+RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found1459
+1460
+// Text codepoints management functions (unicode characters)1461
+RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array1462
+RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array1463
+RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter1464
+RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory1465
+RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string1466
+RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1467
+RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1468
+RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1469
+RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)1470
+1471
+// Text strings management functions (no UTF-8 strings, only byte chars)1472
+// NOTE: Some strings allocate memory internally for returned strings, just be careful!1473
+RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied1474
+RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal1475
+RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending1476
+RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style)1477
+RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string1478
+RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!)1479
+RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!)1480
+RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter1481
+RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings1482
+RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor!1483
+RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string1484
+RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string1485
+RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string1486
+RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string1487
+RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported)1488
+RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported)1489
+1490
+//------------------------------------------------------------------------------------1491
+// Basic 3d Shapes Drawing Functions (Module: models)1492
+//------------------------------------------------------------------------------------1493
+1494
+// Basic geometric 3D shapes drawing functions1495
+RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space1496
+RLAPI void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line1497
+RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space1498
+RLAPI void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!)1499
+RLAPI void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color); // Draw a triangle strip defined by points1500
+RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube1501
+RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)1502
+RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires1503
+RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)1504
+RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere1505
+RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters1506
+RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires1507
+RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone1508
+RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos1509
+RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires1510
+RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos1511
+RLAPI void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw a capsule with the center of its sphere caps at startPos and endPos1512
+RLAPI void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw capsule wireframe with the center of its sphere caps at startPos and endPos1513
+RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ1514
+RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line1515
+RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))1516
+1517
+//------------------------------------------------------------------------------------1518
+// Model 3d Loading and Drawing Functions (Module: models)1519
+//------------------------------------------------------------------------------------1520
+1521
+// Model management functions1522
+RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)1523
+RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)1524
+RLAPI bool IsModelReady(Model model); // Check if a model is ready1525
+RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)1526
+RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)1527
+1528
+// Model drawing functions1529
+RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)1530
+RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters1531
+RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)1532
+RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters1533
+RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)1534
+RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture1535
+RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source1536
+RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation1537
+1538
+// Mesh management functions1539
+RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids1540
+RLAPI void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index1541
+RLAPI void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU1542
+RLAPI void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform1543
+RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms1544
+RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits1545
+RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents1546
+RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success1547
+RLAPI bool ExportMeshAsCode(Mesh mesh, const char *fileName); // Export mesh as code file (.h) defining multiple arrays of vertex attributes1548
+1549
+// Mesh generation functions1550
+RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh1551
+RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)1552
+RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh1553
+RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere)1554
+RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap)1555
+RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh1556
+RLAPI Mesh GenMeshCone(float radius, float height, int slices); // Generate cone/pyramid mesh1557
+RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh1558
+RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh1559
+RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data1560
+RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data1561
+1562
+// Material loading/unloading functions1563
+RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file1564
+RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)1565
+RLAPI bool IsMaterialReady(Material material); // Check if a material is ready1566
+RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)1567
+RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)1568
+RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh1569
+1570
+// Model animations loading/unloading functions1571
+RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file1572
+RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose1573
+RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data1574
+RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); // Unload animation array data1575
+RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match1576
+1577
+// Collision detection functions1578
+RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres1579
+RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes1580
+RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere1581
+RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere1582
+RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box1583
+RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh1584
+RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle1585
+RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad1586
+1587
+//------------------------------------------------------------------------------------1588
+// Audio Loading and Playing Functions (Module: audio)1589
+//------------------------------------------------------------------------------------1590
+typedef void (*AudioCallback)(void *bufferData, unsigned int frames);1591
+1592
+// Audio device management functions1593
+RLAPI void InitAudioDevice(void); // Initialize audio device and context1594
+RLAPI void CloseAudioDevice(void); // Close the audio device and context1595
+RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully1596
+RLAPI void SetMasterVolume(float volume); // Set master volume (listener)1597
+RLAPI float GetMasterVolume(void); // Get master volume (listener)1598
+1599
+// Wave/Sound loading/unloading functions1600
+RLAPI Wave LoadWave(const char *fileName); // Load wave data from file1601
+RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'1602
+RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready1603
+RLAPI Sound LoadSound(const char *fileName); // Load sound from file1604
+RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data1605
+RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data1606
+RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready1607
+RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data1608
+RLAPI void UnloadWave(Wave wave); // Unload wave data1609
+RLAPI void UnloadSound(Sound sound); // Unload sound1610
+RLAPI void UnloadSoundAlias(Sound alias); // Unload a sound alias (does not deallocate sample data)1611
+RLAPI bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success1612
+RLAPI bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success1613
+1614
+// Wave/Sound management functions1615
+RLAPI void PlaySound(Sound sound); // Play a sound1616
+RLAPI void StopSound(Sound sound); // Stop playing a sound1617
+RLAPI void PauseSound(Sound sound); // Pause a sound1618
+RLAPI void ResumeSound(Sound sound); // Resume a paused sound1619
+RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing1620
+RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)1621
+RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)1622
+RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center)1623
+RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave1624
+RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range1625
+RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format1626
+RLAPI float *LoadWaveSamples(Wave wave); // Load samples data from wave as a 32bit float data array1627
+RLAPI void UnloadWaveSamples(float *samples); // Unload samples data loaded with LoadWaveSamples()1628
+1629
+// Music management functions1630
+RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file1631
+RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data1632
+RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready1633
+RLAPI void UnloadMusicStream(Music music); // Unload music stream1634
+RLAPI void PlayMusicStream(Music music); // Start music playing1635
+RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing1636
+RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming1637
+RLAPI void StopMusicStream(Music music); // Stop music playing1638
+RLAPI void PauseMusicStream(Music music); // Pause music playing1639
+RLAPI void ResumeMusicStream(Music music); // Resume playing paused music1640
+RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)1641
+RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)1642
+RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)1643
+RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center)1644
+RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)1645
+RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)1646
+1647
+// AudioStream management functions1648
+RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)1649
+RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready1650
+RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory1651
+RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data1652
+RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill1653
+RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream1654
+RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream1655
+RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream1656
+RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing1657
+RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream1658
+RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)1659
+RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)1660
+RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered)1661
+RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams1662
+RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data1663
+1664
+RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as <float>s1665
+RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream1666
+1667
+RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as <float>s1668
+RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline1669
+1670
+#if defined(__cplusplus)1671
+}1672
+#endif1673
+1674
+#endif // RAYLIB_H
diff --git a/lib/raymath.h b/lib/raymath.h
new file mode 100644
index 0000000..15e403c
--- /dev/null
+++ b/lib/raymath.h
1
@@ -0,0 +1,2191 @@2
+/**********************************************************************************************3
+*4
+* raymath v1.5 - Math functions to work with Vector2, Vector3, Matrix and Quaternions5
+*6
+* CONVENTIONS:7
+* - Matrix structure is defined as row-major (memory layout) but parameters naming AND all8
+* math operations performed by the library consider the structure as it was column-major9
+* It is like transposed versions of the matrices are used for all the maths10
+* It benefits some functions making them cache-friendly and also avoids matrix11
+* transpositions sometimes required by OpenGL12
+* Example: In memory order, row0 is [m0 m4 m8 m12] but in semantic math row0 is [m0 m1 m2 m3]13
+* - Functions are always self-contained, no function use another raymath function inside,14
+* required code is directly re-implemented inside15
+* - Functions input parameters are always received by value (2 unavoidable exceptions)16
+* - Functions use always a "result" variable for return17
+* - Functions are always defined inline18
+* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)19
+* - No compound literals used to make sure libray is compatible with C++20
+*21
+* CONFIGURATION:22
+* #define RAYMATH_IMPLEMENTATION23
+* Generates the implementation of the library into the included file.24
+* If not defined, the library is in header only mode and can be included in other headers25
+* or source files without problems. But only ONE file should hold the implementation.26
+*27
+* #define RAYMATH_STATIC_INLINE28
+* Define static inline functions code, so #include header suffices for use.29
+* This may use up lots of memory.30
+*31
+*32
+* LICENSE: zlib/libpng33
+*34
+* Copyright (c) 2015-2024 Ramon Santamaria (@raysan5)35
+*36
+* This software is provided "as-is", without any express or implied warranty. In no event37
+* will the authors be held liable for any damages arising from the use of this software.38
+*39
+* Permission is granted to anyone to use this software for any purpose, including commercial40
+* applications, and to alter it and redistribute it freely, subject to the following restrictions:41
+*42
+* 1. The origin of this software must not be misrepresented; you must not claim that you43
+* wrote the original software. If you use this software in a product, an acknowledgment44
+* in the product documentation would be appreciated but is not required.45
+*46
+* 2. Altered source versions must be plainly marked as such, and must not be misrepresented47
+* as being the original software.48
+*49
+* 3. This notice may not be removed or altered from any source distribution.50
+*51
+**********************************************************************************************/52
+53
+#ifndef RAYMATH_H54
+#define RAYMATH_H55
+56
+#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE)57
+ #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory"58
+#endif59
+60
+// Function specifiers definition61
+#if defined(RAYMATH_IMPLEMENTATION)62
+ #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)63
+ #define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll)64
+ #elif defined(BUILD_LIBTYPE_SHARED)65
+ #define RMAPI __attribute__((visibility("default"))) // We are building raylib as a Unix shared library (.so/.dylib)66
+ #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)67
+ #define RMAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)68
+ #else69
+ #define RMAPI extern inline // Provide external definition70
+ #endif71
+#elif defined(RAYMATH_STATIC_INLINE)72
+ #define RMAPI static inline // Functions may be inlined, no external out-of-line definition73
+#else74
+ #if defined(__TINYC__)75
+ #define RMAPI static inline // plain inline not supported by tinycc (See issue #435)76
+ #else77
+ #define RMAPI inline // Functions may be inlined or external definition used78
+ #endif79
+#endif80
+81
+//----------------------------------------------------------------------------------82
+// Defines and Macros83
+//----------------------------------------------------------------------------------84
+#ifndef PI85
+ #define PI 3.14159265358979323846f86
+#endif87
+88
+#ifndef EPSILON89
+ #define EPSILON 0.000001f90
+#endif91
+92
+#ifndef DEG2RAD93
+ #define DEG2RAD (PI/180.0f)94
+#endif95
+96
+#ifndef RAD2DEG97
+ #define RAD2DEG (180.0f/PI)98
+#endif99
+100
+// Get float vector for Matrix101
+#ifndef MatrixToFloat102
+ #define MatrixToFloat(mat) (MatrixToFloatV(mat).v)103
+#endif104
+105
+// Get float vector for Vector3106
+#ifndef Vector3ToFloat107
+ #define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v)108
+#endif109
+110
+//----------------------------------------------------------------------------------111
+// Types and Structures Definition112
+//----------------------------------------------------------------------------------113
+#if !defined(RL_VECTOR2_TYPE)114
+// Vector2 type115
+typedef struct Vector2 {116
+ float x;117
+ float y;118
+} Vector2;119
+#define RL_VECTOR2_TYPE120
+#endif121
+122
+#if !defined(RL_VECTOR3_TYPE)123
+// Vector3 type124
+typedef struct Vector3 {125
+ float x;126
+ float y;127
+ float z;128
+} Vector3;129
+#define RL_VECTOR3_TYPE130
+#endif131
+132
+#if !defined(RL_VECTOR4_TYPE)133
+// Vector4 type134
+typedef struct Vector4 {135
+ float x;136
+ float y;137
+ float z;138
+ float w;139
+} Vector4;140
+#define RL_VECTOR4_TYPE141
+#endif142
+143
+#if !defined(RL_QUATERNION_TYPE)144
+// Quaternion type145
+typedef Vector4 Quaternion;146
+#define RL_QUATERNION_TYPE147
+#endif148
+149
+#if !defined(RL_MATRIX_TYPE)150
+// Matrix type (OpenGL style 4x4 - right handed, column major)151
+typedef struct Matrix {152
+ float m0, m4, m8, m12; // Matrix first row (4 components)153
+ float m1, m5, m9, m13; // Matrix second row (4 components)154
+ float m2, m6, m10, m14; // Matrix third row (4 components)155
+ float m3, m7, m11, m15; // Matrix fourth row (4 components)156
+} Matrix;157
+#define RL_MATRIX_TYPE158
+#endif159
+160
+// NOTE: Helper types to be used instead of array return types for *ToFloat functions161
+typedef struct float3 {162
+ float v[3];163
+} float3;164
+165
+typedef struct float16 {166
+ float v[16];167
+} float16;168
+169
+#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf()170
+171
+//----------------------------------------------------------------------------------172
+// Module Functions Definition - Utils math173
+//----------------------------------------------------------------------------------174
+175
+// Clamp float value176
+RMAPI float Clamp(float value, float min, float max)177
+{178
+ float result = (value < min) ? min : value;179
+180
+ if (result > max) result = max;181
+182
+ return result;183
+}184
+185
+// Calculate linear interpolation between two floats186
+RMAPI float Lerp(float start, float end, float amount)187
+{188
+ float result = start + amount*(end - start);189
+190
+ return result;191
+}192
+193
+// Normalize input value within input range194
+RMAPI float Normalize(float value, float start, float end)195
+{196
+ float result = (value - start)/(end - start);197
+198
+ return result;199
+}200
+201
+// Remap input value within input range to output range202
+RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)203
+{204
+ float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart;205
+206
+ return result;207
+}208
+209
+// Wrap input value from min to max210
+RMAPI float Wrap(float value, float min, float max)211
+{212
+ float result = value - (max - min)*floorf((value - min)/(max - min));213
+214
+ return result;215
+}216
+217
+// Check whether two given floats are almost equal218
+RMAPI int FloatEquals(float x, float y)219
+{220
+#if !defined(EPSILON)221
+ #define EPSILON 0.000001f222
+#endif223
+224
+ int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y))));225
+226
+ return result;227
+}228
+229
+//----------------------------------------------------------------------------------230
+// Module Functions Definition - Vector2 math231
+//----------------------------------------------------------------------------------232
+233
+// Vector with components value 0.0f234
+RMAPI Vector2 Vector2Zero(void)235
+{236
+ Vector2 result = { 0.0f, 0.0f };237
+238
+ return result;239
+}240
+241
+// Vector with components value 1.0f242
+RMAPI Vector2 Vector2One(void)243
+{244
+ Vector2 result = { 1.0f, 1.0f };245
+246
+ return result;247
+}248
+249
+// Add two vectors (v1 + v2)250
+RMAPI Vector2 Vector2Add(Vector2 v1, Vector2 v2)251
+{252
+ Vector2 result = { v1.x + v2.x, v1.y + v2.y };253
+254
+ return result;255
+}256
+257
+// Add vector and float value258
+RMAPI Vector2 Vector2AddValue(Vector2 v, float add)259
+{260
+ Vector2 result = { v.x + add, v.y + add };261
+262
+ return result;263
+}264
+265
+// Subtract two vectors (v1 - v2)266
+RMAPI Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)267
+{268
+ Vector2 result = { v1.x - v2.x, v1.y - v2.y };269
+270
+ return result;271
+}272
+273
+// Subtract vector by float value274
+RMAPI Vector2 Vector2SubtractValue(Vector2 v, float sub)275
+{276
+ Vector2 result = { v.x - sub, v.y - sub };277
+278
+ return result;279
+}280
+281
+// Calculate vector length282
+RMAPI float Vector2Length(Vector2 v)283
+{284
+ float result = sqrtf((v.x*v.x) + (v.y*v.y));285
+286
+ return result;287
+}288
+289
+// Calculate vector square length290
+RMAPI float Vector2LengthSqr(Vector2 v)291
+{292
+ float result = (v.x*v.x) + (v.y*v.y);293
+294
+ return result;295
+}296
+297
+// Calculate two vectors dot product298
+RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2)299
+{300
+ float result = (v1.x*v2.x + v1.y*v2.y);301
+302
+ return result;303
+}304
+305
+// Calculate distance between two vectors306
+RMAPI float Vector2Distance(Vector2 v1, Vector2 v2)307
+{308
+ float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));309
+310
+ return result;311
+}312
+313
+// Calculate square distance between two vectors314
+RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)315
+{316
+ float result = ((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));317
+318
+ return result;319
+}320
+321
+// Calculate angle between two vectors322
+// NOTE: Angle is calculated from origin point (0, 0)323
+RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)324
+{325
+ float result = 0.0f;326
+327
+ float dot = v1.x*v2.x + v1.y*v2.y;328
+ float det = v1.x*v2.y - v1.y*v2.x;329
+330
+ result = atan2f(det, dot);331
+332
+ return result;333
+}334
+335
+// Calculate angle defined by a two vectors line336
+// NOTE: Parameters need to be normalized337
+// Current implementation should be aligned with glm::angle338
+RMAPI float Vector2LineAngle(Vector2 start, Vector2 end)339
+{340
+ float result = 0.0f;341
+342
+ // TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior343
+ result = -atan2f(end.y - start.y, end.x - start.x);344
+345
+ return result;346
+}347
+348
+// Scale vector (multiply by value)349
+RMAPI Vector2 Vector2Scale(Vector2 v, float scale)350
+{351
+ Vector2 result = { v.x*scale, v.y*scale };352
+353
+ return result;354
+}355
+356
+// Multiply vector by vector357
+RMAPI Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)358
+{359
+ Vector2 result = { v1.x*v2.x, v1.y*v2.y };360
+361
+ return result;362
+}363
+364
+// Negate vector365
+RMAPI Vector2 Vector2Negate(Vector2 v)366
+{367
+ Vector2 result = { -v.x, -v.y };368
+369
+ return result;370
+}371
+372
+// Divide vector by vector373
+RMAPI Vector2 Vector2Divide(Vector2 v1, Vector2 v2)374
+{375
+ Vector2 result = { v1.x/v2.x, v1.y/v2.y };376
+377
+ return result;378
+}379
+380
+// Normalize provided vector381
+RMAPI Vector2 Vector2Normalize(Vector2 v)382
+{383
+ Vector2 result = { 0 };384
+ float length = sqrtf((v.x*v.x) + (v.y*v.y));385
+386
+ if (length > 0)387
+ {388
+ float ilength = 1.0f/length;389
+ result.x = v.x*ilength;390
+ result.y = v.y*ilength;391
+ }392
+393
+ return result;394
+}395
+396
+// Transforms a Vector2 by a given Matrix397
+RMAPI Vector2 Vector2Transform(Vector2 v, Matrix mat)398
+{399
+ Vector2 result = { 0 };400
+401
+ float x = v.x;402
+ float y = v.y;403
+ float z = 0;404
+405
+ result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;406
+ result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;407
+408
+ return result;409
+}410
+411
+// Calculate linear interpolation between two vectors412
+RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)413
+{414
+ Vector2 result = { 0 };415
+416
+ result.x = v1.x + amount*(v2.x - v1.x);417
+ result.y = v1.y + amount*(v2.y - v1.y);418
+419
+ return result;420
+}421
+422
+// Calculate reflected vector to normal423
+RMAPI Vector2 Vector2Reflect(Vector2 v, Vector2 normal)424
+{425
+ Vector2 result = { 0 };426
+427
+ float dotProduct = (v.x*normal.x + v.y*normal.y); // Dot product428
+429
+ result.x = v.x - (2.0f*normal.x)*dotProduct;430
+ result.y = v.y - (2.0f*normal.y)*dotProduct;431
+432
+ return result;433
+}434
+435
+// Rotate vector by angle436
+RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)437
+{438
+ Vector2 result = { 0 };439
+440
+ float cosres = cosf(angle);441
+ float sinres = sinf(angle);442
+443
+ result.x = v.x*cosres - v.y*sinres;444
+ result.y = v.x*sinres + v.y*cosres;445
+446
+ return result;447
+}448
+449
+// Move Vector towards target450
+RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)451
+{452
+ Vector2 result = { 0 };453
+454
+ float dx = target.x - v.x;455
+ float dy = target.y - v.y;456
+ float value = (dx*dx) + (dy*dy);457
+458
+ if ((value == 0) || ((maxDistance >= 0) && (value <= maxDistance*maxDistance))) return target;459
+460
+ float dist = sqrtf(value);461
+462
+ result.x = v.x + dx/dist*maxDistance;463
+ result.y = v.y + dy/dist*maxDistance;464
+465
+ return result;466
+}467
+468
+// Invert the given vector469
+RMAPI Vector2 Vector2Invert(Vector2 v)470
+{471
+ Vector2 result = { 1.0f/v.x, 1.0f/v.y };472
+473
+ return result;474
+}475
+476
+// Clamp the components of the vector between477
+// min and max values specified by the given vectors478
+RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)479
+{480
+ Vector2 result = { 0 };481
+482
+ result.x = fminf(max.x, fmaxf(min.x, v.x));483
+ result.y = fminf(max.y, fmaxf(min.y, v.y));484
+485
+ return result;486
+}487
+488
+// Clamp the magnitude of the vector between two min and max values489
+RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)490
+{491
+ Vector2 result = v;492
+493
+ float length = (v.x*v.x) + (v.y*v.y);494
+ if (length > 0.0f)495
+ {496
+ length = sqrtf(length);497
+498
+ float scale = 1; // By default, 1 as the neutral element.499
+ if (length < min)500
+ {501
+ scale = min/length;502
+ }503
+ else if (length > max)504
+ {505
+ scale = max/length;506
+ }507
+508
+ result.x = v.x*scale;509
+ result.y = v.y*scale;510
+ }511
+512
+ return result;513
+}514
+515
+// Check whether two given vectors are almost equal516
+RMAPI int Vector2Equals(Vector2 p, Vector2 q)517
+{518
+#if !defined(EPSILON)519
+ #define EPSILON 0.000001f520
+#endif521
+522
+ int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&523
+ ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y)))));524
+525
+ return result;526
+}527
+528
+//----------------------------------------------------------------------------------529
+// Module Functions Definition - Vector3 math530
+//----------------------------------------------------------------------------------531
+532
+// Vector with components value 0.0f533
+RMAPI Vector3 Vector3Zero(void)534
+{535
+ Vector3 result = { 0.0f, 0.0f, 0.0f };536
+537
+ return result;538
+}539
+540
+// Vector with components value 1.0f541
+RMAPI Vector3 Vector3One(void)542
+{543
+ Vector3 result = { 1.0f, 1.0f, 1.0f };544
+545
+ return result;546
+}547
+548
+// Add two vectors549
+RMAPI Vector3 Vector3Add(Vector3 v1, Vector3 v2)550
+{551
+ Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };552
+553
+ return result;554
+}555
+556
+// Add vector and float value557
+RMAPI Vector3 Vector3AddValue(Vector3 v, float add)558
+{559
+ Vector3 result = { v.x + add, v.y + add, v.z + add };560
+561
+ return result;562
+}563
+564
+// Subtract two vectors565
+RMAPI Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)566
+{567
+ Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };568
+569
+ return result;570
+}571
+572
+// Subtract vector by float value573
+RMAPI Vector3 Vector3SubtractValue(Vector3 v, float sub)574
+{575
+ Vector3 result = { v.x - sub, v.y - sub, v.z - sub };576
+577
+ return result;578
+}579
+580
+// Multiply vector by scalar581
+RMAPI Vector3 Vector3Scale(Vector3 v, float scalar)582
+{583
+ Vector3 result = { v.x*scalar, v.y*scalar, v.z*scalar };584
+585
+ return result;586
+}587
+588
+// Multiply vector by vector589
+RMAPI Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)590
+{591
+ Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z };592
+593
+ return result;594
+}595
+596
+// Calculate two vectors cross product597
+RMAPI Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)598
+{599
+ Vector3 result = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };600
+601
+ return result;602
+}603
+604
+// Calculate one vector perpendicular vector605
+RMAPI Vector3 Vector3Perpendicular(Vector3 v)606
+{607
+ Vector3 result = { 0 };608
+609
+ float min = fabsf(v.x);610
+ Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};611
+612
+ if (fabsf(v.y) < min)613
+ {614
+ min = fabsf(v.y);615
+ Vector3 tmp = {0.0f, 1.0f, 0.0f};616
+ cardinalAxis = tmp;617
+ }618
+619
+ if (fabsf(v.z) < min)620
+ {621
+ Vector3 tmp = {0.0f, 0.0f, 1.0f};622
+ cardinalAxis = tmp;623
+ }624
+625
+ // Cross product between vectors626
+ result.x = v.y*cardinalAxis.z - v.z*cardinalAxis.y;627
+ result.y = v.z*cardinalAxis.x - v.x*cardinalAxis.z;628
+ result.z = v.x*cardinalAxis.y - v.y*cardinalAxis.x;629
+630
+ return result;631
+}632
+633
+// Calculate vector length634
+RMAPI float Vector3Length(const Vector3 v)635
+{636
+ float result = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);637
+638
+ return result;639
+}640
+641
+// Calculate vector square length642
+RMAPI float Vector3LengthSqr(const Vector3 v)643
+{644
+ float result = v.x*v.x + v.y*v.y + v.z*v.z;645
+646
+ return result;647
+}648
+649
+// Calculate two vectors dot product650
+RMAPI float Vector3DotProduct(Vector3 v1, Vector3 v2)651
+{652
+ float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);653
+654
+ return result;655
+}656
+657
+// Calculate distance between two vectors658
+RMAPI float Vector3Distance(Vector3 v1, Vector3 v2)659
+{660
+ float result = 0.0f;661
+662
+ float dx = v2.x - v1.x;663
+ float dy = v2.y - v1.y;664
+ float dz = v2.z - v1.z;665
+ result = sqrtf(dx*dx + dy*dy + dz*dz);666
+667
+ return result;668
+}669
+670
+// Calculate square distance between two vectors671
+RMAPI float Vector3DistanceSqr(Vector3 v1, Vector3 v2)672
+{673
+ float result = 0.0f;674
+675
+ float dx = v2.x - v1.x;676
+ float dy = v2.y - v1.y;677
+ float dz = v2.z - v1.z;678
+ result = dx*dx + dy*dy + dz*dz;679
+680
+ return result;681
+}682
+683
+// Calculate angle between two vectors684
+RMAPI float Vector3Angle(Vector3 v1, Vector3 v2)685
+{686
+ float result = 0.0f;687
+688
+ Vector3 cross = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };689
+ float len = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z);690
+ float dot = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);691
+ result = atan2f(len, dot);692
+693
+ return result;694
+}695
+696
+// Negate provided vector (invert direction)697
+RMAPI Vector3 Vector3Negate(Vector3 v)698
+{699
+ Vector3 result = { -v.x, -v.y, -v.z };700
+701
+ return result;702
+}703
+704
+// Divide vector by vector705
+RMAPI Vector3 Vector3Divide(Vector3 v1, Vector3 v2)706
+{707
+ Vector3 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z };708
+709
+ return result;710
+}711
+712
+// Normalize provided vector713
+RMAPI Vector3 Vector3Normalize(Vector3 v)714
+{715
+ Vector3 result = v;716
+717
+ float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);718
+ if (length != 0.0f)719
+ {720
+ float ilength = 1.0f/length;721
+722
+ result.x *= ilength;723
+ result.y *= ilength;724
+ result.z *= ilength;725
+ }726
+727
+ return result;728
+}729
+730
+//Calculate the projection of the vector v1 on to v2731
+RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)732
+{733
+ Vector3 result = { 0 };734
+735
+ float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);736
+ float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);737
+738
+ float mag = v1dv2/v2dv2;739
+740
+ result.x = v2.x*mag;741
+ result.y = v2.y*mag;742
+ result.z = v2.z*mag;743
+744
+ return result;745
+}746
+747
+//Calculate the rejection of the vector v1 on to v2748
+RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)749
+{750
+ Vector3 result = { 0 };751
+752
+ float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);753
+ float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);754
+755
+ float mag = v1dv2/v2dv2;756
+757
+ result.x = v1.x - (v2.x*mag);758
+ result.y = v1.y - (v2.y*mag);759
+ result.z = v1.z - (v2.z*mag);760
+761
+ return result;762
+}763
+764
+// Orthonormalize provided vectors765
+// Makes vectors normalized and orthogonal to each other766
+// Gram-Schmidt function implementation767
+RMAPI void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2)768
+{769
+ float length = 0.0f;770
+ float ilength = 0.0f;771
+772
+ // Vector3Normalize(*v1);773
+ Vector3 v = *v1;774
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);775
+ if (length == 0.0f) length = 1.0f;776
+ ilength = 1.0f/length;777
+ v1->x *= ilength;778
+ v1->y *= ilength;779
+ v1->z *= ilength;780
+781
+ // Vector3CrossProduct(*v1, *v2)782
+ Vector3 vn1 = { v1->y*v2->z - v1->z*v2->y, v1->z*v2->x - v1->x*v2->z, v1->x*v2->y - v1->y*v2->x };783
+784
+ // Vector3Normalize(vn1);785
+ v = vn1;786
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);787
+ if (length == 0.0f) length = 1.0f;788
+ ilength = 1.0f/length;789
+ vn1.x *= ilength;790
+ vn1.y *= ilength;791
+ vn1.z *= ilength;792
+793
+ // Vector3CrossProduct(vn1, *v1)794
+ Vector3 vn2 = { vn1.y*v1->z - vn1.z*v1->y, vn1.z*v1->x - vn1.x*v1->z, vn1.x*v1->y - vn1.y*v1->x };795
+796
+ *v2 = vn2;797
+}798
+799
+// Transforms a Vector3 by a given Matrix800
+RMAPI Vector3 Vector3Transform(Vector3 v, Matrix mat)801
+{802
+ Vector3 result = { 0 };803
+804
+ float x = v.x;805
+ float y = v.y;806
+ float z = v.z;807
+808
+ result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;809
+ result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;810
+ result.z = mat.m2*x + mat.m6*y + mat.m10*z + mat.m14;811
+812
+ return result;813
+}814
+815
+// Transform a vector by quaternion rotation816
+RMAPI Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)817
+{818
+ Vector3 result = { 0 };819
+820
+ result.x = v.x*(q.x*q.x + q.w*q.w - q.y*q.y - q.z*q.z) + v.y*(2*q.x*q.y - 2*q.w*q.z) + v.z*(2*q.x*q.z + 2*q.w*q.y);821
+ result.y = v.x*(2*q.w*q.z + 2*q.x*q.y) + v.y*(q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z) + v.z*(-2*q.w*q.x + 2*q.y*q.z);822
+ result.z = v.x*(-2*q.w*q.y + 2*q.x*q.z) + v.y*(2*q.w*q.x + 2*q.y*q.z)+ v.z*(q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);823
+824
+ return result;825
+}826
+827
+// Rotates a vector around an axis828
+RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle)829
+{830
+ // Using Euler-Rodrigues Formula831
+ // Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula832
+833
+ Vector3 result = v;834
+835
+ // Vector3Normalize(axis);836
+ float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);837
+ if (length == 0.0f) length = 1.0f;838
+ float ilength = 1.0f/length;839
+ axis.x *= ilength;840
+ axis.y *= ilength;841
+ axis.z *= ilength;842
+843
+ angle /= 2.0f;844
+ float a = sinf(angle);845
+ float b = axis.x*a;846
+ float c = axis.y*a;847
+ float d = axis.z*a;848
+ a = cosf(angle);849
+ Vector3 w = { b, c, d };850
+851
+ // Vector3CrossProduct(w, v)852
+ Vector3 wv = { w.y*v.z - w.z*v.y, w.z*v.x - w.x*v.z, w.x*v.y - w.y*v.x };853
+854
+ // Vector3CrossProduct(w, wv)855
+ Vector3 wwv = { w.y*wv.z - w.z*wv.y, w.z*wv.x - w.x*wv.z, w.x*wv.y - w.y*wv.x };856
+857
+ // Vector3Scale(wv, 2*a)858
+ a *= 2;859
+ wv.x *= a;860
+ wv.y *= a;861
+ wv.z *= a;862
+863
+ // Vector3Scale(wwv, 2)864
+ wwv.x *= 2;865
+ wwv.y *= 2;866
+ wwv.z *= 2;867
+868
+ result.x += wv.x;869
+ result.y += wv.y;870
+ result.z += wv.z;871
+872
+ result.x += wwv.x;873
+ result.y += wwv.y;874
+ result.z += wwv.z;875
+876
+ return result;877
+}878
+879
+// Calculate linear interpolation between two vectors880
+RMAPI Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)881
+{882
+ Vector3 result = { 0 };883
+884
+ result.x = v1.x + amount*(v2.x - v1.x);885
+ result.y = v1.y + amount*(v2.y - v1.y);886
+ result.z = v1.z + amount*(v2.z - v1.z);887
+888
+ return result;889
+}890
+891
+// Calculate reflected vector to normal892
+RMAPI Vector3 Vector3Reflect(Vector3 v, Vector3 normal)893
+{894
+ Vector3 result = { 0 };895
+896
+ // I is the original vector897
+ // N is the normal of the incident plane898
+ // R = I - (2*N*(DotProduct[I, N]))899
+900
+ float dotProduct = (v.x*normal.x + v.y*normal.y + v.z*normal.z);901
+902
+ result.x = v.x - (2.0f*normal.x)*dotProduct;903
+ result.y = v.y - (2.0f*normal.y)*dotProduct;904
+ result.z = v.z - (2.0f*normal.z)*dotProduct;905
+906
+ return result;907
+}908
+909
+// Get min value for each pair of components910
+RMAPI Vector3 Vector3Min(Vector3 v1, Vector3 v2)911
+{912
+ Vector3 result = { 0 };913
+914
+ result.x = fminf(v1.x, v2.x);915
+ result.y = fminf(v1.y, v2.y);916
+ result.z = fminf(v1.z, v2.z);917
+918
+ return result;919
+}920
+921
+// Get max value for each pair of components922
+RMAPI Vector3 Vector3Max(Vector3 v1, Vector3 v2)923
+{924
+ Vector3 result = { 0 };925
+926
+ result.x = fmaxf(v1.x, v2.x);927
+ result.y = fmaxf(v1.y, v2.y);928
+ result.z = fmaxf(v1.z, v2.z);929
+930
+ return result;931
+}932
+933
+// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)934
+// NOTE: Assumes P is on the plane of the triangle935
+RMAPI Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)936
+{937
+ Vector3 result = { 0 };938
+939
+ Vector3 v0 = { b.x - a.x, b.y - a.y, b.z - a.z }; // Vector3Subtract(b, a)940
+ Vector3 v1 = { c.x - a.x, c.y - a.y, c.z - a.z }; // Vector3Subtract(c, a)941
+ Vector3 v2 = { p.x - a.x, p.y - a.y, p.z - a.z }; // Vector3Subtract(p, a)942
+ float d00 = (v0.x*v0.x + v0.y*v0.y + v0.z*v0.z); // Vector3DotProduct(v0, v0)943
+ float d01 = (v0.x*v1.x + v0.y*v1.y + v0.z*v1.z); // Vector3DotProduct(v0, v1)944
+ float d11 = (v1.x*v1.x + v1.y*v1.y + v1.z*v1.z); // Vector3DotProduct(v1, v1)945
+ float d20 = (v2.x*v0.x + v2.y*v0.y + v2.z*v0.z); // Vector3DotProduct(v2, v0)946
+ float d21 = (v2.x*v1.x + v2.y*v1.y + v2.z*v1.z); // Vector3DotProduct(v2, v1)947
+948
+ float denom = d00*d11 - d01*d01;949
+950
+ result.y = (d11*d20 - d01*d21)/denom;951
+ result.z = (d00*d21 - d01*d20)/denom;952
+ result.x = 1.0f - (result.z + result.y);953
+954
+ return result;955
+}956
+957
+// Projects a Vector3 from screen space into object space958
+// NOTE: We are avoiding calling other raymath functions despite available959
+RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)960
+{961
+ Vector3 result = { 0 };962
+963
+ // Calculate unprojected matrix (multiply view matrix by projection matrix) and invert it964
+ Matrix matViewProj = { // MatrixMultiply(view, projection);965
+ view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12,966
+ view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13,967
+ view.m0*projection.m2 + view.m1*projection.m6 + view.m2*projection.m10 + view.m3*projection.m14,968
+ view.m0*projection.m3 + view.m1*projection.m7 + view.m2*projection.m11 + view.m3*projection.m15,969
+ view.m4*projection.m0 + view.m5*projection.m4 + view.m6*projection.m8 + view.m7*projection.m12,970
+ view.m4*projection.m1 + view.m5*projection.m5 + view.m6*projection.m9 + view.m7*projection.m13,971
+ view.m4*projection.m2 + view.m5*projection.m6 + view.m6*projection.m10 + view.m7*projection.m14,972
+ view.m4*projection.m3 + view.m5*projection.m7 + view.m6*projection.m11 + view.m7*projection.m15,973
+ view.m8*projection.m0 + view.m9*projection.m4 + view.m10*projection.m8 + view.m11*projection.m12,974
+ view.m8*projection.m1 + view.m9*projection.m5 + view.m10*projection.m9 + view.m11*projection.m13,975
+ view.m8*projection.m2 + view.m9*projection.m6 + view.m10*projection.m10 + view.m11*projection.m14,976
+ view.m8*projection.m3 + view.m9*projection.m7 + view.m10*projection.m11 + view.m11*projection.m15,977
+ view.m12*projection.m0 + view.m13*projection.m4 + view.m14*projection.m8 + view.m15*projection.m12,978
+ view.m12*projection.m1 + view.m13*projection.m5 + view.m14*projection.m9 + view.m15*projection.m13,979
+ view.m12*projection.m2 + view.m13*projection.m6 + view.m14*projection.m10 + view.m15*projection.m14,980
+ view.m12*projection.m3 + view.m13*projection.m7 + view.m14*projection.m11 + view.m15*projection.m15 };981
+982
+ // Calculate inverted matrix -> MatrixInvert(matViewProj);983
+ // Cache the matrix values (speed optimization)984
+ float a00 = matViewProj.m0, a01 = matViewProj.m1, a02 = matViewProj.m2, a03 = matViewProj.m3;985
+ float a10 = matViewProj.m4, a11 = matViewProj.m5, a12 = matViewProj.m6, a13 = matViewProj.m7;986
+ float a20 = matViewProj.m8, a21 = matViewProj.m9, a22 = matViewProj.m10, a23 = matViewProj.m11;987
+ float a30 = matViewProj.m12, a31 = matViewProj.m13, a32 = matViewProj.m14, a33 = matViewProj.m15;988
+989
+ float b00 = a00*a11 - a01*a10;990
+ float b01 = a00*a12 - a02*a10;991
+ float b02 = a00*a13 - a03*a10;992
+ float b03 = a01*a12 - a02*a11;993
+ float b04 = a01*a13 - a03*a11;994
+ float b05 = a02*a13 - a03*a12;995
+ float b06 = a20*a31 - a21*a30;996
+ float b07 = a20*a32 - a22*a30;997
+ float b08 = a20*a33 - a23*a30;998
+ float b09 = a21*a32 - a22*a31;999
+ float b10 = a21*a33 - a23*a31;1000
+ float b11 = a22*a33 - a23*a32;1001
+1002
+ // Calculate the invert determinant (inlined to avoid double-caching)1003
+ float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06);1004
+1005
+ Matrix matViewProjInv = {1006
+ (a11*b11 - a12*b10 + a13*b09)*invDet,1007
+ (-a01*b11 + a02*b10 - a03*b09)*invDet,1008
+ (a31*b05 - a32*b04 + a33*b03)*invDet,1009
+ (-a21*b05 + a22*b04 - a23*b03)*invDet,1010
+ (-a10*b11 + a12*b08 - a13*b07)*invDet,1011
+ (a00*b11 - a02*b08 + a03*b07)*invDet,1012
+ (-a30*b05 + a32*b02 - a33*b01)*invDet,1013
+ (a20*b05 - a22*b02 + a23*b01)*invDet,1014
+ (a10*b10 - a11*b08 + a13*b06)*invDet,1015
+ (-a00*b10 + a01*b08 - a03*b06)*invDet,1016
+ (a30*b04 - a31*b02 + a33*b00)*invDet,1017
+ (-a20*b04 + a21*b02 - a23*b00)*invDet,1018
+ (-a10*b09 + a11*b07 - a12*b06)*invDet,1019
+ (a00*b09 - a01*b07 + a02*b06)*invDet,1020
+ (-a30*b03 + a31*b01 - a32*b00)*invDet,1021
+ (a20*b03 - a21*b01 + a22*b00)*invDet };1022
+1023
+ // Create quaternion from source point1024
+ Quaternion quat = { source.x, source.y, source.z, 1.0f };1025
+1026
+ // Multiply quat point by unprojecte matrix1027
+ Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv)1028
+ matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w,1029
+ matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w,1030
+ matViewProjInv.m2*quat.x + matViewProjInv.m6*quat.y + matViewProjInv.m10*quat.z + matViewProjInv.m14*quat.w,1031
+ matViewProjInv.m3*quat.x + matViewProjInv.m7*quat.y + matViewProjInv.m11*quat.z + matViewProjInv.m15*quat.w };1032
+1033
+ // Normalized world points in vectors1034
+ result.x = qtransformed.x/qtransformed.w;1035
+ result.y = qtransformed.y/qtransformed.w;1036
+ result.z = qtransformed.z/qtransformed.w;1037
+1038
+ return result;1039
+}1040
+1041
+// Get Vector3 as float array1042
+RMAPI float3 Vector3ToFloatV(Vector3 v)1043
+{1044
+ float3 buffer = { 0 };1045
+1046
+ buffer.v[0] = v.x;1047
+ buffer.v[1] = v.y;1048
+ buffer.v[2] = v.z;1049
+1050
+ return buffer;1051
+}1052
+1053
+// Invert the given vector1054
+RMAPI Vector3 Vector3Invert(Vector3 v)1055
+{1056
+ Vector3 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z };1057
+1058
+ return result;1059
+}1060
+1061
+// Clamp the components of the vector between1062
+// min and max values specified by the given vectors1063
+RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max)1064
+{1065
+ Vector3 result = { 0 };1066
+1067
+ result.x = fminf(max.x, fmaxf(min.x, v.x));1068
+ result.y = fminf(max.y, fmaxf(min.y, v.y));1069
+ result.z = fminf(max.z, fmaxf(min.z, v.z));1070
+1071
+ return result;1072
+}1073
+1074
+// Clamp the magnitude of the vector between two values1075
+RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)1076
+{1077
+ Vector3 result = v;1078
+1079
+ float length = (v.x*v.x) + (v.y*v.y) + (v.z*v.z);1080
+ if (length > 0.0f)1081
+ {1082
+ length = sqrtf(length);1083
+1084
+ float scale = 1; // By default, 1 as the neutral element.1085
+ if (length < min)1086
+ {1087
+ scale = min/length;1088
+ }1089
+ else if (length > max)1090
+ {1091
+ scale = max/length;1092
+ }1093
+1094
+ result.x = v.x*scale;1095
+ result.y = v.y*scale;1096
+ result.z = v.z*scale;1097
+ }1098
+1099
+ return result;1100
+}1101
+1102
+// Check whether two given vectors are almost equal1103
+RMAPI int Vector3Equals(Vector3 p, Vector3 q)1104
+{1105
+#if !defined(EPSILON)1106
+ #define EPSILON 0.000001f1107
+#endif1108
+1109
+ int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&1110
+ ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&1111
+ ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z)))));1112
+1113
+ return result;1114
+}1115
+1116
+// Compute the direction of a refracted ray1117
+// v: normalized direction of the incoming ray1118
+// n: normalized normal vector of the interface of two optical media1119
+// r: ratio of the refractive index of the medium from where the ray comes1120
+// to the refractive index of the medium on the other side of the surface1121
+RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r)1122
+{1123
+ Vector3 result = { 0 };1124
+1125
+ float dot = v.x*n.x + v.y*n.y + v.z*n.z;1126
+ float d = 1.0f - r*r*(1.0f - dot*dot);1127
+1128
+ if (d >= 0.0f)1129
+ {1130
+ d = sqrtf(d);1131
+ v.x = r*v.x - (r*dot + d)*n.x;1132
+ v.y = r*v.y - (r*dot + d)*n.y;1133
+ v.z = r*v.z - (r*dot + d)*n.z;1134
+1135
+ result = v;1136
+ }1137
+1138
+ return result;1139
+}1140
+1141
+//----------------------------------------------------------------------------------1142
+// Module Functions Definition - Matrix math1143
+//----------------------------------------------------------------------------------1144
+1145
+// Compute matrix determinant1146
+RMAPI float MatrixDeterminant(Matrix mat)1147
+{1148
+ float result = 0.0f;1149
+1150
+ // Cache the matrix values (speed optimization)1151
+ float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;1152
+ float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;1153
+ float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;1154
+ float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;1155
+1156
+ result = a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 +1157
+ a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 +1158
+ a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 +1159
+ a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 +1160
+ a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 +1161
+ a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33;1162
+1163
+ return result;1164
+}1165
+1166
+// Get the trace of the matrix (sum of the values along the diagonal)1167
+RMAPI float MatrixTrace(Matrix mat)1168
+{1169
+ float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15);1170
+1171
+ return result;1172
+}1173
+1174
+// Transposes provided matrix1175
+RMAPI Matrix MatrixTranspose(Matrix mat)1176
+{1177
+ Matrix result = { 0 };1178
+1179
+ result.m0 = mat.m0;1180
+ result.m1 = mat.m4;1181
+ result.m2 = mat.m8;1182
+ result.m3 = mat.m12;1183
+ result.m4 = mat.m1;1184
+ result.m5 = mat.m5;1185
+ result.m6 = mat.m9;1186
+ result.m7 = mat.m13;1187
+ result.m8 = mat.m2;1188
+ result.m9 = mat.m6;1189
+ result.m10 = mat.m10;1190
+ result.m11 = mat.m14;1191
+ result.m12 = mat.m3;1192
+ result.m13 = mat.m7;1193
+ result.m14 = mat.m11;1194
+ result.m15 = mat.m15;1195
+1196
+ return result;1197
+}1198
+1199
+// Invert provided matrix1200
+RMAPI Matrix MatrixInvert(Matrix mat)1201
+{1202
+ Matrix result = { 0 };1203
+1204
+ // Cache the matrix values (speed optimization)1205
+ float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;1206
+ float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;1207
+ float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;1208
+ float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;1209
+1210
+ float b00 = a00*a11 - a01*a10;1211
+ float b01 = a00*a12 - a02*a10;1212
+ float b02 = a00*a13 - a03*a10;1213
+ float b03 = a01*a12 - a02*a11;1214
+ float b04 = a01*a13 - a03*a11;1215
+ float b05 = a02*a13 - a03*a12;1216
+ float b06 = a20*a31 - a21*a30;1217
+ float b07 = a20*a32 - a22*a30;1218
+ float b08 = a20*a33 - a23*a30;1219
+ float b09 = a21*a32 - a22*a31;1220
+ float b10 = a21*a33 - a23*a31;1221
+ float b11 = a22*a33 - a23*a32;1222
+1223
+ // Calculate the invert determinant (inlined to avoid double-caching)1224
+ float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06);1225
+1226
+ result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet;1227
+ result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet;1228
+ result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet;1229
+ result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet;1230
+ result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet;1231
+ result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet;1232
+ result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet;1233
+ result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet;1234
+ result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet;1235
+ result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet;1236
+ result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet;1237
+ result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet;1238
+ result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet;1239
+ result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet;1240
+ result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet;1241
+ result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet;1242
+1243
+ return result;1244
+}1245
+1246
+// Get identity matrix1247
+RMAPI Matrix MatrixIdentity(void)1248
+{1249
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1250
+ 0.0f, 1.0f, 0.0f, 0.0f,1251
+ 0.0f, 0.0f, 1.0f, 0.0f,1252
+ 0.0f, 0.0f, 0.0f, 1.0f };1253
+1254
+ return result;1255
+}1256
+1257
+// Add two matrices1258
+RMAPI Matrix MatrixAdd(Matrix left, Matrix right)1259
+{1260
+ Matrix result = { 0 };1261
+1262
+ result.m0 = left.m0 + right.m0;1263
+ result.m1 = left.m1 + right.m1;1264
+ result.m2 = left.m2 + right.m2;1265
+ result.m3 = left.m3 + right.m3;1266
+ result.m4 = left.m4 + right.m4;1267
+ result.m5 = left.m5 + right.m5;1268
+ result.m6 = left.m6 + right.m6;1269
+ result.m7 = left.m7 + right.m7;1270
+ result.m8 = left.m8 + right.m8;1271
+ result.m9 = left.m9 + right.m9;1272
+ result.m10 = left.m10 + right.m10;1273
+ result.m11 = left.m11 + right.m11;1274
+ result.m12 = left.m12 + right.m12;1275
+ result.m13 = left.m13 + right.m13;1276
+ result.m14 = left.m14 + right.m14;1277
+ result.m15 = left.m15 + right.m15;1278
+1279
+ return result;1280
+}1281
+1282
+// Subtract two matrices (left - right)1283
+RMAPI Matrix MatrixSubtract(Matrix left, Matrix right)1284
+{1285
+ Matrix result = { 0 };1286
+1287
+ result.m0 = left.m0 - right.m0;1288
+ result.m1 = left.m1 - right.m1;1289
+ result.m2 = left.m2 - right.m2;1290
+ result.m3 = left.m3 - right.m3;1291
+ result.m4 = left.m4 - right.m4;1292
+ result.m5 = left.m5 - right.m5;1293
+ result.m6 = left.m6 - right.m6;1294
+ result.m7 = left.m7 - right.m7;1295
+ result.m8 = left.m8 - right.m8;1296
+ result.m9 = left.m9 - right.m9;1297
+ result.m10 = left.m10 - right.m10;1298
+ result.m11 = left.m11 - right.m11;1299
+ result.m12 = left.m12 - right.m12;1300
+ result.m13 = left.m13 - right.m13;1301
+ result.m14 = left.m14 - right.m14;1302
+ result.m15 = left.m15 - right.m15;1303
+1304
+ return result;1305
+}1306
+1307
+// Get two matrix multiplication1308
+// NOTE: When multiplying matrices... the order matters!1309
+RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)1310
+{1311
+ Matrix result = { 0 };1312
+1313
+ result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12;1314
+ result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13;1315
+ result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14;1316
+ result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15;1317
+ result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12;1318
+ result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13;1319
+ result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14;1320
+ result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15;1321
+ result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12;1322
+ result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13;1323
+ result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14;1324
+ result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15;1325
+ result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12;1326
+ result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13;1327
+ result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14;1328
+ result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15;1329
+1330
+ return result;1331
+}1332
+1333
+// Get translation matrix1334
+RMAPI Matrix MatrixTranslate(float x, float y, float z)1335
+{1336
+ Matrix result = { 1.0f, 0.0f, 0.0f, x,1337
+ 0.0f, 1.0f, 0.0f, y,1338
+ 0.0f, 0.0f, 1.0f, z,1339
+ 0.0f, 0.0f, 0.0f, 1.0f };1340
+1341
+ return result;1342
+}1343
+1344
+// Create rotation matrix from axis and angle1345
+// NOTE: Angle should be provided in radians1346
+RMAPI Matrix MatrixRotate(Vector3 axis, float angle)1347
+{1348
+ Matrix result = { 0 };1349
+1350
+ float x = axis.x, y = axis.y, z = axis.z;1351
+1352
+ float lengthSquared = x*x + y*y + z*z;1353
+1354
+ if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f))1355
+ {1356
+ float ilength = 1.0f/sqrtf(lengthSquared);1357
+ x *= ilength;1358
+ y *= ilength;1359
+ z *= ilength;1360
+ }1361
+1362
+ float sinres = sinf(angle);1363
+ float cosres = cosf(angle);1364
+ float t = 1.0f - cosres;1365
+1366
+ result.m0 = x*x*t + cosres;1367
+ result.m1 = y*x*t + z*sinres;1368
+ result.m2 = z*x*t - y*sinres;1369
+ result.m3 = 0.0f;1370
+1371
+ result.m4 = x*y*t - z*sinres;1372
+ result.m5 = y*y*t + cosres;1373
+ result.m6 = z*y*t + x*sinres;1374
+ result.m7 = 0.0f;1375
+1376
+ result.m8 = x*z*t + y*sinres;1377
+ result.m9 = y*z*t - x*sinres;1378
+ result.m10 = z*z*t + cosres;1379
+ result.m11 = 0.0f;1380
+1381
+ result.m12 = 0.0f;1382
+ result.m13 = 0.0f;1383
+ result.m14 = 0.0f;1384
+ result.m15 = 1.0f;1385
+1386
+ return result;1387
+}1388
+1389
+// Get x-rotation matrix1390
+// NOTE: Angle must be provided in radians1391
+RMAPI Matrix MatrixRotateX(float angle)1392
+{1393
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1394
+ 0.0f, 1.0f, 0.0f, 0.0f,1395
+ 0.0f, 0.0f, 1.0f, 0.0f,1396
+ 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1397
+1398
+ float cosres = cosf(angle);1399
+ float sinres = sinf(angle);1400
+1401
+ result.m5 = cosres;1402
+ result.m6 = sinres;1403
+ result.m9 = -sinres;1404
+ result.m10 = cosres;1405
+1406
+ return result;1407
+}1408
+1409
+// Get y-rotation matrix1410
+// NOTE: Angle must be provided in radians1411
+RMAPI Matrix MatrixRotateY(float angle)1412
+{1413
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1414
+ 0.0f, 1.0f, 0.0f, 0.0f,1415
+ 0.0f, 0.0f, 1.0f, 0.0f,1416
+ 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1417
+1418
+ float cosres = cosf(angle);1419
+ float sinres = sinf(angle);1420
+1421
+ result.m0 = cosres;1422
+ result.m2 = -sinres;1423
+ result.m8 = sinres;1424
+ result.m10 = cosres;1425
+1426
+ return result;1427
+}1428
+1429
+// Get z-rotation matrix1430
+// NOTE: Angle must be provided in radians1431
+RMAPI Matrix MatrixRotateZ(float angle)1432
+{1433
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1434
+ 0.0f, 1.0f, 0.0f, 0.0f,1435
+ 0.0f, 0.0f, 1.0f, 0.0f,1436
+ 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1437
+1438
+ float cosres = cosf(angle);1439
+ float sinres = sinf(angle);1440
+1441
+ result.m0 = cosres;1442
+ result.m1 = sinres;1443
+ result.m4 = -sinres;1444
+ result.m5 = cosres;1445
+1446
+ return result;1447
+}1448
+1449
+1450
+// Get xyz-rotation matrix1451
+// NOTE: Angle must be provided in radians1452
+RMAPI Matrix MatrixRotateXYZ(Vector3 angle)1453
+{1454
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1455
+ 0.0f, 1.0f, 0.0f, 0.0f,1456
+ 0.0f, 0.0f, 1.0f, 0.0f,1457
+ 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1458
+1459
+ float cosz = cosf(-angle.z);1460
+ float sinz = sinf(-angle.z);1461
+ float cosy = cosf(-angle.y);1462
+ float siny = sinf(-angle.y);1463
+ float cosx = cosf(-angle.x);1464
+ float sinx = sinf(-angle.x);1465
+1466
+ result.m0 = cosz*cosy;1467
+ result.m1 = (cosz*siny*sinx) - (sinz*cosx);1468
+ result.m2 = (cosz*siny*cosx) + (sinz*sinx);1469
+1470
+ result.m4 = sinz*cosy;1471
+ result.m5 = (sinz*siny*sinx) + (cosz*cosx);1472
+ result.m6 = (sinz*siny*cosx) - (cosz*sinx);1473
+1474
+ result.m8 = -siny;1475
+ result.m9 = cosy*sinx;1476
+ result.m10= cosy*cosx;1477
+1478
+ return result;1479
+}1480
+1481
+// Get zyx-rotation matrix1482
+// NOTE: Angle must be provided in radians1483
+RMAPI Matrix MatrixRotateZYX(Vector3 angle)1484
+{1485
+ Matrix result = { 0 };1486
+1487
+ float cz = cosf(angle.z);1488
+ float sz = sinf(angle.z);1489
+ float cy = cosf(angle.y);1490
+ float sy = sinf(angle.y);1491
+ float cx = cosf(angle.x);1492
+ float sx = sinf(angle.x);1493
+1494
+ result.m0 = cz*cy;1495
+ result.m4 = cz*sy*sx - cx*sz;1496
+ result.m8 = sz*sx + cz*cx*sy;1497
+ result.m12 = 0;1498
+1499
+ result.m1 = cy*sz;1500
+ result.m5 = cz*cx + sz*sy*sx;1501
+ result.m9 = cx*sz*sy - cz*sx;1502
+ result.m13 = 0;1503
+1504
+ result.m2 = -sy;1505
+ result.m6 = cy*sx;1506
+ result.m10 = cy*cx;1507
+ result.m14 = 0;1508
+1509
+ result.m3 = 0;1510
+ result.m7 = 0;1511
+ result.m11 = 0;1512
+ result.m15 = 1;1513
+1514
+ return result;1515
+}1516
+1517
+// Get scaling matrix1518
+RMAPI Matrix MatrixScale(float x, float y, float z)1519
+{1520
+ Matrix result = { x, 0.0f, 0.0f, 0.0f,1521
+ 0.0f, y, 0.0f, 0.0f,1522
+ 0.0f, 0.0f, z, 0.0f,1523
+ 0.0f, 0.0f, 0.0f, 1.0f };1524
+1525
+ return result;1526
+}1527
+1528
+// Get perspective projection matrix1529
+RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)1530
+{1531
+ Matrix result = { 0 };1532
+1533
+ float rl = (float)(right - left);1534
+ float tb = (float)(top - bottom);1535
+ float fn = (float)(far - near);1536
+1537
+ result.m0 = ((float)near*2.0f)/rl;1538
+ result.m1 = 0.0f;1539
+ result.m2 = 0.0f;1540
+ result.m3 = 0.0f;1541
+1542
+ result.m4 = 0.0f;1543
+ result.m5 = ((float)near*2.0f)/tb;1544
+ result.m6 = 0.0f;1545
+ result.m7 = 0.0f;1546
+1547
+ result.m8 = ((float)right + (float)left)/rl;1548
+ result.m9 = ((float)top + (float)bottom)/tb;1549
+ result.m10 = -((float)far + (float)near)/fn;1550
+ result.m11 = -1.0f;1551
+1552
+ result.m12 = 0.0f;1553
+ result.m13 = 0.0f;1554
+ result.m14 = -((float)far*(float)near*2.0f)/fn;1555
+ result.m15 = 0.0f;1556
+1557
+ return result;1558
+}1559
+1560
+// Get perspective projection matrix1561
+// NOTE: Fovy angle must be provided in radians1562
+RMAPI Matrix MatrixPerspective(double fovY, double aspect, double nearPlane, double farPlane)1563
+{1564
+ Matrix result = { 0 };1565
+1566
+ double top = nearPlane*tan(fovY*0.5);1567
+ double bottom = -top;1568
+ double right = top*aspect;1569
+ double left = -right;1570
+1571
+ // MatrixFrustum(-right, right, -top, top, near, far);1572
+ float rl = (float)(right - left);1573
+ float tb = (float)(top - bottom);1574
+ float fn = (float)(farPlane - nearPlane);1575
+1576
+ result.m0 = ((float)nearPlane*2.0f)/rl;1577
+ result.m5 = ((float)nearPlane*2.0f)/tb;1578
+ result.m8 = ((float)right + (float)left)/rl;1579
+ result.m9 = ((float)top + (float)bottom)/tb;1580
+ result.m10 = -((float)farPlane + (float)nearPlane)/fn;1581
+ result.m11 = -1.0f;1582
+ result.m14 = -((float)farPlane*(float)nearPlane*2.0f)/fn;1583
+1584
+ return result;1585
+}1586
+1587
+// Get orthographic projection matrix1588
+RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double nearPlane, double farPlane)1589
+{1590
+ Matrix result = { 0 };1591
+1592
+ float rl = (float)(right - left);1593
+ float tb = (float)(top - bottom);1594
+ float fn = (float)(farPlane - nearPlane);1595
+1596
+ result.m0 = 2.0f/rl;1597
+ result.m1 = 0.0f;1598
+ result.m2 = 0.0f;1599
+ result.m3 = 0.0f;1600
+ result.m4 = 0.0f;1601
+ result.m5 = 2.0f/tb;1602
+ result.m6 = 0.0f;1603
+ result.m7 = 0.0f;1604
+ result.m8 = 0.0f;1605
+ result.m9 = 0.0f;1606
+ result.m10 = -2.0f/fn;1607
+ result.m11 = 0.0f;1608
+ result.m12 = -((float)left + (float)right)/rl;1609
+ result.m13 = -((float)top + (float)bottom)/tb;1610
+ result.m14 = -((float)farPlane + (float)nearPlane)/fn;1611
+ result.m15 = 1.0f;1612
+1613
+ return result;1614
+}1615
+1616
+// Get camera look-at matrix (view matrix)1617
+RMAPI Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)1618
+{1619
+ Matrix result = { 0 };1620
+1621
+ float length = 0.0f;1622
+ float ilength = 0.0f;1623
+1624
+ // Vector3Subtract(eye, target)1625
+ Vector3 vz = { eye.x - target.x, eye.y - target.y, eye.z - target.z };1626
+1627
+ // Vector3Normalize(vz)1628
+ Vector3 v = vz;1629
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);1630
+ if (length == 0.0f) length = 1.0f;1631
+ ilength = 1.0f/length;1632
+ vz.x *= ilength;1633
+ vz.y *= ilength;1634
+ vz.z *= ilength;1635
+1636
+ // Vector3CrossProduct(up, vz)1637
+ Vector3 vx = { up.y*vz.z - up.z*vz.y, up.z*vz.x - up.x*vz.z, up.x*vz.y - up.y*vz.x };1638
+1639
+ // Vector3Normalize(x)1640
+ v = vx;1641
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);1642
+ if (length == 0.0f) length = 1.0f;1643
+ ilength = 1.0f/length;1644
+ vx.x *= ilength;1645
+ vx.y *= ilength;1646
+ vx.z *= ilength;1647
+1648
+ // Vector3CrossProduct(vz, vx)1649
+ Vector3 vy = { vz.y*vx.z - vz.z*vx.y, vz.z*vx.x - vz.x*vx.z, vz.x*vx.y - vz.y*vx.x };1650
+1651
+ result.m0 = vx.x;1652
+ result.m1 = vy.x;1653
+ result.m2 = vz.x;1654
+ result.m3 = 0.0f;1655
+ result.m4 = vx.y;1656
+ result.m5 = vy.y;1657
+ result.m6 = vz.y;1658
+ result.m7 = 0.0f;1659
+ result.m8 = vx.z;1660
+ result.m9 = vy.z;1661
+ result.m10 = vz.z;1662
+ result.m11 = 0.0f;1663
+ result.m12 = -(vx.x*eye.x + vx.y*eye.y + vx.z*eye.z); // Vector3DotProduct(vx, eye)1664
+ result.m13 = -(vy.x*eye.x + vy.y*eye.y + vy.z*eye.z); // Vector3DotProduct(vy, eye)1665
+ result.m14 = -(vz.x*eye.x + vz.y*eye.y + vz.z*eye.z); // Vector3DotProduct(vz, eye)1666
+ result.m15 = 1.0f;1667
+1668
+ return result;1669
+}1670
+1671
+// Get float array of matrix data1672
+RMAPI float16 MatrixToFloatV(Matrix mat)1673
+{1674
+ float16 result = { 0 };1675
+1676
+ result.v[0] = mat.m0;1677
+ result.v[1] = mat.m1;1678
+ result.v[2] = mat.m2;1679
+ result.v[3] = mat.m3;1680
+ result.v[4] = mat.m4;1681
+ result.v[5] = mat.m5;1682
+ result.v[6] = mat.m6;1683
+ result.v[7] = mat.m7;1684
+ result.v[8] = mat.m8;1685
+ result.v[9] = mat.m9;1686
+ result.v[10] = mat.m10;1687
+ result.v[11] = mat.m11;1688
+ result.v[12] = mat.m12;1689
+ result.v[13] = mat.m13;1690
+ result.v[14] = mat.m14;1691
+ result.v[15] = mat.m15;1692
+1693
+ return result;1694
+}1695
+1696
+//----------------------------------------------------------------------------------1697
+// Module Functions Definition - Quaternion math1698
+//----------------------------------------------------------------------------------1699
+1700
+// Add two quaternions1701
+RMAPI Quaternion QuaternionAdd(Quaternion q1, Quaternion q2)1702
+{1703
+ Quaternion result = {q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w};1704
+1705
+ return result;1706
+}1707
+1708
+// Add quaternion and float value1709
+RMAPI Quaternion QuaternionAddValue(Quaternion q, float add)1710
+{1711
+ Quaternion result = {q.x + add, q.y + add, q.z + add, q.w + add};1712
+1713
+ return result;1714
+}1715
+1716
+// Subtract two quaternions1717
+RMAPI Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2)1718
+{1719
+ Quaternion result = {q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w};1720
+1721
+ return result;1722
+}1723
+1724
+// Subtract quaternion and float value1725
+RMAPI Quaternion QuaternionSubtractValue(Quaternion q, float sub)1726
+{1727
+ Quaternion result = {q.x - sub, q.y - sub, q.z - sub, q.w - sub};1728
+1729
+ return result;1730
+}1731
+1732
+// Get identity quaternion1733
+RMAPI Quaternion QuaternionIdentity(void)1734
+{1735
+ Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };1736
+1737
+ return result;1738
+}1739
+1740
+// Computes the length of a quaternion1741
+RMAPI float QuaternionLength(Quaternion q)1742
+{1743
+ float result = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1744
+1745
+ return result;1746
+}1747
+1748
+// Normalize provided quaternion1749
+RMAPI Quaternion QuaternionNormalize(Quaternion q)1750
+{1751
+ Quaternion result = { 0 };1752
+1753
+ float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1754
+ if (length == 0.0f) length = 1.0f;1755
+ float ilength = 1.0f/length;1756
+1757
+ result.x = q.x*ilength;1758
+ result.y = q.y*ilength;1759
+ result.z = q.z*ilength;1760
+ result.w = q.w*ilength;1761
+1762
+ return result;1763
+}1764
+1765
+// Invert provided quaternion1766
+RMAPI Quaternion QuaternionInvert(Quaternion q)1767
+{1768
+ Quaternion result = q;1769
+1770
+ float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;1771
+1772
+ if (lengthSq != 0.0f)1773
+ {1774
+ float invLength = 1.0f/lengthSq;1775
+1776
+ result.x *= -invLength;1777
+ result.y *= -invLength;1778
+ result.z *= -invLength;1779
+ result.w *= invLength;1780
+ }1781
+1782
+ return result;1783
+}1784
+1785
+// Calculate two quaternion multiplication1786
+RMAPI Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2)1787
+{1788
+ Quaternion result = { 0 };1789
+1790
+ float qax = q1.x, qay = q1.y, qaz = q1.z, qaw = q1.w;1791
+ float qbx = q2.x, qby = q2.y, qbz = q2.z, qbw = q2.w;1792
+1793
+ result.x = qax*qbw + qaw*qbx + qay*qbz - qaz*qby;1794
+ result.y = qay*qbw + qaw*qby + qaz*qbx - qax*qbz;1795
+ result.z = qaz*qbw + qaw*qbz + qax*qby - qay*qbx;1796
+ result.w = qaw*qbw - qax*qbx - qay*qby - qaz*qbz;1797
+1798
+ return result;1799
+}1800
+1801
+// Scale quaternion by float value1802
+RMAPI Quaternion QuaternionScale(Quaternion q, float mul)1803
+{1804
+ Quaternion result = { 0 };1805
+1806
+ result.x = q.x*mul;1807
+ result.y = q.y*mul;1808
+ result.z = q.z*mul;1809
+ result.w = q.w*mul;1810
+1811
+ return result;1812
+}1813
+1814
+// Divide two quaternions1815
+RMAPI Quaternion QuaternionDivide(Quaternion q1, Quaternion q2)1816
+{1817
+ Quaternion result = { q1.x/q2.x, q1.y/q2.y, q1.z/q2.z, q1.w/q2.w };1818
+1819
+ return result;1820
+}1821
+1822
+// Calculate linear interpolation between two quaternions1823
+RMAPI Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)1824
+{1825
+ Quaternion result = { 0 };1826
+1827
+ result.x = q1.x + amount*(q2.x - q1.x);1828
+ result.y = q1.y + amount*(q2.y - q1.y);1829
+ result.z = q1.z + amount*(q2.z - q1.z);1830
+ result.w = q1.w + amount*(q2.w - q1.w);1831
+1832
+ return result;1833
+}1834
+1835
+// Calculate slerp-optimized interpolation between two quaternions1836
+RMAPI Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)1837
+{1838
+ Quaternion result = { 0 };1839
+1840
+ // QuaternionLerp(q1, q2, amount)1841
+ result.x = q1.x + amount*(q2.x - q1.x);1842
+ result.y = q1.y + amount*(q2.y - q1.y);1843
+ result.z = q1.z + amount*(q2.z - q1.z);1844
+ result.w = q1.w + amount*(q2.w - q1.w);1845
+1846
+ // QuaternionNormalize(q);1847
+ Quaternion q = result;1848
+ float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1849
+ if (length == 0.0f) length = 1.0f;1850
+ float ilength = 1.0f/length;1851
+1852
+ result.x = q.x*ilength;1853
+ result.y = q.y*ilength;1854
+ result.z = q.z*ilength;1855
+ result.w = q.w*ilength;1856
+1857
+ return result;1858
+}1859
+1860
+// Calculates spherical linear interpolation between two quaternions1861
+RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)1862
+{1863
+ Quaternion result = { 0 };1864
+1865
+#if !defined(EPSILON)1866
+ #define EPSILON 0.000001f1867
+#endif1868
+1869
+ float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w;1870
+1871
+ if (cosHalfTheta < 0)1872
+ {1873
+ q2.x = -q2.x; q2.y = -q2.y; q2.z = -q2.z; q2.w = -q2.w;1874
+ cosHalfTheta = -cosHalfTheta;1875
+ }1876
+1877
+ if (fabsf(cosHalfTheta) >= 1.0f) result = q1;1878
+ else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);1879
+ else1880
+ {1881
+ float halfTheta = acosf(cosHalfTheta);1882
+ float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta);1883
+1884
+ if (fabsf(sinHalfTheta) < EPSILON)1885
+ {1886
+ result.x = (q1.x*0.5f + q2.x*0.5f);1887
+ result.y = (q1.y*0.5f + q2.y*0.5f);1888
+ result.z = (q1.z*0.5f + q2.z*0.5f);1889
+ result.w = (q1.w*0.5f + q2.w*0.5f);1890
+ }1891
+ else1892
+ {1893
+ float ratioA = sinf((1 - amount)*halfTheta)/sinHalfTheta;1894
+ float ratioB = sinf(amount*halfTheta)/sinHalfTheta;1895
+1896
+ result.x = (q1.x*ratioA + q2.x*ratioB);1897
+ result.y = (q1.y*ratioA + q2.y*ratioB);1898
+ result.z = (q1.z*ratioA + q2.z*ratioB);1899
+ result.w = (q1.w*ratioA + q2.w*ratioB);1900
+ }1901
+ }1902
+1903
+ return result;1904
+}1905
+1906
+// Calculate quaternion based on the rotation from one vector to another1907
+RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)1908
+{1909
+ Quaternion result = { 0 };1910
+1911
+ float cos2Theta = (from.x*to.x + from.y*to.y + from.z*to.z); // Vector3DotProduct(from, to)1912
+ Vector3 cross = { from.y*to.z - from.z*to.y, from.z*to.x - from.x*to.z, from.x*to.y - from.y*to.x }; // Vector3CrossProduct(from, to)1913
+1914
+ result.x = cross.x;1915
+ result.y = cross.y;1916
+ result.z = cross.z;1917
+ result.w = 1.0f + cos2Theta;1918
+1919
+ // QuaternionNormalize(q);1920
+ // NOTE: Normalize to essentially nlerp the original and identity to 0.51921
+ Quaternion q = result;1922
+ float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1923
+ if (length == 0.0f) length = 1.0f;1924
+ float ilength = 1.0f/length;1925
+1926
+ result.x = q.x*ilength;1927
+ result.y = q.y*ilength;1928
+ result.z = q.z*ilength;1929
+ result.w = q.w*ilength;1930
+1931
+ return result;1932
+}1933
+1934
+// Get a quaternion for a given rotation matrix1935
+RMAPI Quaternion QuaternionFromMatrix(Matrix mat)1936
+{1937
+ Quaternion result = { 0 };1938
+1939
+ float fourWSquaredMinus1 = mat.m0 + mat.m5 + mat.m10;1940
+ float fourXSquaredMinus1 = mat.m0 - mat.m5 - mat.m10;1941
+ float fourYSquaredMinus1 = mat.m5 - mat.m0 - mat.m10;1942
+ float fourZSquaredMinus1 = mat.m10 - mat.m0 - mat.m5;1943
+1944
+ int biggestIndex = 0;1945
+ float fourBiggestSquaredMinus1 = fourWSquaredMinus1;1946
+ if (fourXSquaredMinus1 > fourBiggestSquaredMinus1)1947
+ {1948
+ fourBiggestSquaredMinus1 = fourXSquaredMinus1;1949
+ biggestIndex = 1;1950
+ }1951
+1952
+ if (fourYSquaredMinus1 > fourBiggestSquaredMinus1)1953
+ {1954
+ fourBiggestSquaredMinus1 = fourYSquaredMinus1;1955
+ biggestIndex = 2;1956
+ }1957
+1958
+ if (fourZSquaredMinus1 > fourBiggestSquaredMinus1)1959
+ {1960
+ fourBiggestSquaredMinus1 = fourZSquaredMinus1;1961
+ biggestIndex = 3;1962
+ }1963
+1964
+ float biggestVal = sqrtf(fourBiggestSquaredMinus1 + 1.0f)*0.5f;1965
+ float mult = 0.25f/biggestVal;1966
+1967
+ switch (biggestIndex)1968
+ {1969
+ case 0:1970
+ result.w = biggestVal;1971
+ result.x = (mat.m6 - mat.m9)*mult;1972
+ result.y = (mat.m8 - mat.m2)*mult;1973
+ result.z = (mat.m1 - mat.m4)*mult;1974
+ break;1975
+ case 1:1976
+ result.x = biggestVal;1977
+ result.w = (mat.m6 - mat.m9)*mult;1978
+ result.y = (mat.m1 + mat.m4)*mult;1979
+ result.z = (mat.m8 + mat.m2)*mult;1980
+ break;1981
+ case 2:1982
+ result.y = biggestVal;1983
+ result.w = (mat.m8 - mat.m2)*mult;1984
+ result.x = (mat.m1 + mat.m4)*mult;1985
+ result.z = (mat.m6 + mat.m9)*mult;1986
+ break;1987
+ case 3:1988
+ result.z = biggestVal;1989
+ result.w = (mat.m1 - mat.m4)*mult;1990
+ result.x = (mat.m8 + mat.m2)*mult;1991
+ result.y = (mat.m6 + mat.m9)*mult;1992
+ break;1993
+ }1994
+1995
+ return result;1996
+}1997
+1998
+// Get a matrix for a given quaternion1999
+RMAPI Matrix QuaternionToMatrix(Quaternion q)2000
+{2001
+ Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,2002
+ 0.0f, 1.0f, 0.0f, 0.0f,2003
+ 0.0f, 0.0f, 1.0f, 0.0f,2004
+ 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()2005
+2006
+ float a2 = q.x*q.x;2007
+ float b2 = q.y*q.y;2008
+ float c2 = q.z*q.z;2009
+ float ac = q.x*q.z;2010
+ float ab = q.x*q.y;2011
+ float bc = q.y*q.z;2012
+ float ad = q.w*q.x;2013
+ float bd = q.w*q.y;2014
+ float cd = q.w*q.z;2015
+2016
+ result.m0 = 1 - 2*(b2 + c2);2017
+ result.m1 = 2*(ab + cd);2018
+ result.m2 = 2*(ac - bd);2019
+2020
+ result.m4 = 2*(ab - cd);2021
+ result.m5 = 1 - 2*(a2 + c2);2022
+ result.m6 = 2*(bc + ad);2023
+2024
+ result.m8 = 2*(ac + bd);2025
+ result.m9 = 2*(bc - ad);2026
+ result.m10 = 1 - 2*(a2 + b2);2027
+2028
+ return result;2029
+}2030
+2031
+// Get rotation quaternion for an angle and axis2032
+// NOTE: Angle must be provided in radians2033
+RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)2034
+{2035
+ Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };2036
+2037
+ float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);2038
+2039
+ if (axisLength != 0.0f)2040
+ {2041
+ angle *= 0.5f;2042
+2043
+ float length = 0.0f;2044
+ float ilength = 0.0f;2045
+2046
+ // Vector3Normalize(axis)2047
+ Vector3 v = axis;2048
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);2049
+ if (length == 0.0f) length = 1.0f;2050
+ ilength = 1.0f/length;2051
+ axis.x *= ilength;2052
+ axis.y *= ilength;2053
+ axis.z *= ilength;2054
+2055
+ float sinres = sinf(angle);2056
+ float cosres = cosf(angle);2057
+2058
+ result.x = axis.x*sinres;2059
+ result.y = axis.y*sinres;2060
+ result.z = axis.z*sinres;2061
+ result.w = cosres;2062
+2063
+ // QuaternionNormalize(q);2064
+ Quaternion q = result;2065
+ length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);2066
+ if (length == 0.0f) length = 1.0f;2067
+ ilength = 1.0f/length;2068
+ result.x = q.x*ilength;2069
+ result.y = q.y*ilength;2070
+ result.z = q.z*ilength;2071
+ result.w = q.w*ilength;2072
+ }2073
+2074
+ return result;2075
+}2076
+2077
+// Get the rotation angle and axis for a given quaternion2078
+RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)2079
+{2080
+ if (fabsf(q.w) > 1.0f)2081
+ {2082
+ // QuaternionNormalize(q);2083
+ float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);2084
+ if (length == 0.0f) length = 1.0f;2085
+ float ilength = 1.0f/length;2086
+2087
+ q.x = q.x*ilength;2088
+ q.y = q.y*ilength;2089
+ q.z = q.z*ilength;2090
+ q.w = q.w*ilength;2091
+ }2092
+2093
+ Vector3 resAxis = { 0.0f, 0.0f, 0.0f };2094
+ float resAngle = 2.0f*acosf(q.w);2095
+ float den = sqrtf(1.0f - q.w*q.w);2096
+2097
+ if (den > EPSILON)2098
+ {2099
+ resAxis.x = q.x/den;2100
+ resAxis.y = q.y/den;2101
+ resAxis.z = q.z/den;2102
+ }2103
+ else2104
+ {2105
+ // This occurs when the angle is zero.2106
+ // Not a problem: just set an arbitrary normalized axis.2107
+ resAxis.x = 1.0f;2108
+ }2109
+2110
+ *outAxis = resAxis;2111
+ *outAngle = resAngle;2112
+}2113
+2114
+// Get the quaternion equivalent to Euler angles2115
+// NOTE: Rotation order is ZYX2116
+RMAPI Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)2117
+{2118
+ Quaternion result = { 0 };2119
+2120
+ float x0 = cosf(pitch*0.5f);2121
+ float x1 = sinf(pitch*0.5f);2122
+ float y0 = cosf(yaw*0.5f);2123
+ float y1 = sinf(yaw*0.5f);2124
+ float z0 = cosf(roll*0.5f);2125
+ float z1 = sinf(roll*0.5f);2126
+2127
+ result.x = x1*y0*z0 - x0*y1*z1;2128
+ result.y = x0*y1*z0 + x1*y0*z1;2129
+ result.z = x0*y0*z1 - x1*y1*z0;2130
+ result.w = x0*y0*z0 + x1*y1*z1;2131
+2132
+ return result;2133
+}2134
+2135
+// Get the Euler angles equivalent to quaternion (roll, pitch, yaw)2136
+// NOTE: Angles are returned in a Vector3 struct in radians2137
+RMAPI Vector3 QuaternionToEuler(Quaternion q)2138
+{2139
+ Vector3 result = { 0 };2140
+2141
+ // Roll (x-axis rotation)2142
+ float x0 = 2.0f*(q.w*q.x + q.y*q.z);2143
+ float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y);2144
+ result.x = atan2f(x0, x1);2145
+2146
+ // Pitch (y-axis rotation)2147
+ float y0 = 2.0f*(q.w*q.y - q.z*q.x);2148
+ y0 = y0 > 1.0f ? 1.0f : y0;2149
+ y0 = y0 < -1.0f ? -1.0f : y0;2150
+ result.y = asinf(y0);2151
+2152
+ // Yaw (z-axis rotation)2153
+ float z0 = 2.0f*(q.w*q.z + q.x*q.y);2154
+ float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z);2155
+ result.z = atan2f(z0, z1);2156
+2157
+ return result;2158
+}2159
+2160
+// Transform a quaternion given a transformation matrix2161
+RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat)2162
+{2163
+ Quaternion result = { 0 };2164
+2165
+ result.x = mat.m0*q.x + mat.m4*q.y + mat.m8*q.z + mat.m12*q.w;2166
+ result.y = mat.m1*q.x + mat.m5*q.y + mat.m9*q.z + mat.m13*q.w;2167
+ result.z = mat.m2*q.x + mat.m6*q.y + mat.m10*q.z + mat.m14*q.w;2168
+ result.w = mat.m3*q.x + mat.m7*q.y + mat.m11*q.z + mat.m15*q.w;2169
+2170
+ return result;2171
+}2172
+2173
+// Check whether two given quaternions are almost equal2174
+RMAPI int QuaternionEquals(Quaternion p, Quaternion q)2175
+{2176
+#if !defined(EPSILON)2177
+ #define EPSILON 0.000001f2178
+#endif2179
+2180
+ int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&2181
+ ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&2182
+ ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&2183
+ ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) ||2184
+ (((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&2185
+ ((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&2186
+ ((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&2187
+ ((fabsf(p.w + q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w))))));2188
+2189
+ return result;2190
+}2191
+2192
+#endif // RAYMATH_H
diff --git a/src/const.h b/src/const.h
deleted file mode 100644
index 51e62ba..0000000
--- a/src/const.h
+++ /dev/null
1
@@ -1,14 +0,0 @@2
-#define SCALE 33
-#define TILE_WIDTH 8 * SCALE4
-#define TILE_HEIGHT 8 * SCALE5
-#define WINDOW_WIDTH 24 * TILE_WIDTH6
-#define WINDOW_HEIGHT 16 * TILE_HEIGHT7
-#define PLAYER_WIDTH 8 * SCALE8
-#define PLAYER_HEIGHT 12 *SCALE9
-#define ENEMY_WIDTH 8 * SCALE10
-#define ENEMY_HEIGHT 12 * SCALE11
-#define PLAYER_HEALTH 612
-#define PLAYER_SHOOTING_RANGE 2 * TILE_WIDTH13
-#define PLAYER_GRAVITY 1014
-#define FONT_WIDTH 5 * (SCALE - 1)15
-#define FONT_HEIGHT 7 * (SCALE - 1)
diff --git a/src/effect.c b/src/effect.c
index c87fec6..ae8dcf4 100644
--- a/src/effect.c
+++ b/src/effect.c
1
@@ -1,8 +1,8 @@2
#include <stdlib.h>4
-#include "effect.h"5
-#include "util.h"6
-#include "const.h"7
+#include "../include/effect.h"8
+#include "../include/util.h"9
+#include "../include/const.h"11
effect_t *effect_create(pos_t pos, effect_e type) {12
effect_t *effect = malloc(sizeof(effect_t));13
@@ -10,13 +10,13 @@ effect_t *effect_create(pos_t pos, effect_e type) {14
effect->pos = pos;15
switch (type) {16
case EFFECT_FALL:17
- effect->timer = timer_create(7, 3);18
+ effect->timer = fz_timer_create(7, 3);19
break;20
case EFFECT_BREAK:21
- effect->timer = timer_create(10, 3);22
+ effect->timer = fz_timer_create(10, 3);23
break;24
case EFFECT_PARTICLE:25
- effect->timer = timer_create(14, 4);26
+ effect->timer = fz_timer_create(14, 4);27
break;28
}29
effect->count = 0;30
@@ -24,8 +24,8 @@ effect_t *effect_create(pos_t pos, effect_e type) {31
}33
void effect_update(effect_t *effect, game_t *game) {34
- timer_update(effect->timer);35
- if (timer_check(effect->timer)) {36
+ fz_timer_update(effect->timer);37
+ if (fz_timer_check(effect->timer)) {38
effect->count++;39
}40
// remove effect after one iteration41
@@ -58,7 +58,7 @@ void effect_draw(effect_t *effect, game_t *game) {42
x = 3;43
break;44
}45
- int frame = timer_get(effect->timer);46
+ int frame = fz_timer_get(effect->timer);47
DrawTextureRec(game->assets.entities, texture_rect(frame, x, PLAYER_WIDTH, PLAYER_HEIGHT), pos_snap(effect->pos), WHITE);48
}
diff --git a/src/effect.h b/src/effect.h
deleted file mode 100644
index e37b19a..0000000
--- a/src/effect.h
+++ /dev/null
1
@@ -1,26 +0,0 @@2
-#pragma once3
-4
-typedef struct Effect effect_t;5
-6
-#include "game.h"7
-#include "util.h"8
-9
-typedef enum {10
- EFFECT_FALL,11
- EFFECT_BREAK,12
- EFFECT_PARTICLE,13
-} effect_e;14
-15
-struct Effect {16
- effect_e type;17
- pos_t pos;18
- timer_t *timer;19
- int count;20
-};21
-22
-effect_t *effect_create(pos_t pos, effect_e type);23
-void effect_update(effect_t *effect, game_t *game);24
-void effect_draw(effect_t *effect, game_t *game);25
-void effect_free(effect_t *effect);26
-27
-void effect_play(pos_t pos, effect_e type, game_t *game);
diff --git a/src/enemy.c b/src/enemy.c
index c4d2540..53c84ba 100644
--- a/src/enemy.c
+++ b/src/enemy.c
1
@@ -1,10 +1,10 @@2
#include <stdlib.h>3
#include <math.h>5
-#include "enemy.h"6
-#include "const.h"7
-#include "entity.h"8
-#include "effect.h"9
+#include "../include/enemy.h"10
+#include "../include/const.h"11
+#include "../include/entity.h"12
+#include "../include/effect.h"14
enemy_t *enemy_create(pos_t pos, enemy_e type) {15
enemy_t *enemy = malloc(sizeof(enemy_t));16
@@ -19,8 +19,8 @@ enemy_t *enemy_create(pos_t pos, enemy_e type) {17
.frozen = false,18
.frozen_timer = 0,19
.fall_height = 0.0,20
- .timer_walking = timer_create(9, 8),21
- .timer_sneaking = timer_create(9, 16),22
+ .timer_walking = fz_timer_create(9, 8),23
+ .timer_sneaking = fz_timer_create(9, 16),24
};25
return enemy;26
}27
@@ -157,19 +157,19 @@ void enemy_update(enemy_t *enemy, game_t *game) {28
}29
// update timer30
if (enemy->on_ground && !enemy->frozen) {31
- timer_update(enemy->timer_walking);32
- timer_update(enemy->timer_sneaking);33
+ fz_timer_update(enemy->timer_walking);34
+ fz_timer_update(enemy->timer_sneaking);35
}36
else {37
- timer_reset(enemy->timer_walking);38
- timer_reset(enemy->timer_sneaking);39
+ fz_timer_reset(enemy->timer_walking);40
+ fz_timer_reset(enemy->timer_sneaking);41
}42
}44
void enemy_draw(enemy_t *enemy, game_t *game) {45
pos_t pos = pos_snap(enemy->pos);46
- int frame_walking = timer_get(enemy->timer_walking);47
- int frame_sneaking = timer_get(enemy->timer_sneaking);48
+ int frame_walking = fz_timer_get(enemy->timer_walking);49
+ int frame_sneaking = fz_timer_get(enemy->timer_sneaking);50
if (enemy->dir > 0) {51
DrawTextureRec(game->assets.entities, texture_rect(enemy->stunned ? frame_sneaking : frame_walking, 8, PLAYER_WIDTH, PLAYER_HEIGHT), pos, WHITE);52
}53
@@ -220,7 +220,7 @@ void enemy_kill(enemy_t *enemy, game_t *game) {54
}56
void enemy_free(enemy_t *enemy) {57
- timer_free(enemy->timer_walking);58
- timer_free(enemy->timer_sneaking);59
+ fz_timer_free(enemy->timer_walking);60
+ fz_timer_free(enemy->timer_sneaking);61
free(enemy);62
}
diff --git a/src/enemy.h b/src/enemy.h
deleted file mode 100644
index 657bd44..0000000
--- a/src/enemy.h
+++ /dev/null
1
@@ -1,31 +0,0 @@2
-#pragma once3
-4
-typedef struct Enemy enemy_t;5
-6
-#include "game.h"7
-#include "util.h"8
-9
-typedef enum {10
- ENEMY_TEST,11
-} enemy_e;12
-13
-struct Enemy {14
- pos_t pos;15
- enemy_e type;16
- bool on_ground;17
- float velocity;18
- float gravity;19
- int dir;20
- bool stunned;21
- bool frozen;22
- int frozen_timer;23
- float fall_height;24
- timer_t *timer_walking;25
- timer_t *timer_sneaking;26
-};27
-28
-enemy_t *enemy_create(pos_t pos, enemy_e type);29
-void enemy_update(enemy_t *enemy, game_t *game);30
-void enemy_draw(enemy_t *enemy, game_t *game);31
-void enemy_kill(enemy_t *enemy, game_t *game);32
-void enemy_free(enemy_t *enemy);
diff --git a/src/entity.c b/src/entity.c
index a1d9ba2..5ee085a 100644
--- a/src/entity.c
+++ b/src/entity.c
1
@@ -1,8 +1,8 @@2
#include <stdlib.h>4
-#include "entity.h"5
-#include "enemy.h"6
-#include "gate.h"7
+#include "../include/entity.h"8
+#include "../include/enemy.h"9
+#include "../include/gate.h"11
entity_t *entity_create(entity_e type) {12
entity_t *entity = malloc(sizeof(entity_t));
diff --git a/src/entity.h b/src/entity.h
deleted file mode 100644
index 0524eee..0000000
--- a/src/entity.h
+++ /dev/null
1
@@ -1,26 +0,0 @@2
-#pragma once3
-4
-typedef struct Entity entity_t;5
-6
-#include "enemy.h"7
-#include "gate.h"8
-#include "game.h"9
-10
-typedef enum {11
- ENTITY_ENEMY,12
- ENTITY_GATE,13
-} entity_e;14
-15
-struct Entity {16
- entity_e type;17
- union {18
- enemy_t *enemy;19
- gate_t *gate;20
- };21
-};22
-23
-entity_t *entity_create(entity_e type);24
-void entity_update(entity_t *entity, game_t *game);25
-void entity_draw(entity_t *entity, game_t *game);26
-void entity_detach(entity_t *entity);27
-void entity_free(entity_t *entity);
diff --git a/src/game.c b/src/game.c
index a98017c..38d6b9d 100644
--- a/src/game.c
+++ b/src/game.c
1
@@ -2,14 +2,14 @@2
#include <stdlib.h>3
#include <string.h>5
-#include "libs/raylib.h"6
-#include "entity.h"7
-#include "game.h"8
-#include "tile.h"9
-#include "util.h"10
-#include "player.h"11
-#include "const.h"12
-#include "level.h"13
+#include "../lib/raylib.h"14
+#include "../include/entity.h"15
+#include "../include/game.h"16
+#include "../include/tile.h"17
+#include "../include/util.h"18
+#include "../include/player.h"19
+#include "../include/const.h"20
+#include "../include/level.h"22
game_t *game_create(void) {23
game_t *game = malloc(sizeof(game_t));
diff --git a/src/game.h b/src/game.h
deleted file mode 100644
index cb8e14b..0000000
--- a/src/game.h
+++ /dev/null
1
@@ -1,48 +0,0 @@2
-#pragma once3
-4
-typedef struct Assets assets_t;5
-typedef struct Game game_t;6
-7
-#include "entity.h"8
-#include "player.h"9
-#include "tile.h"10
-#include "menu.h"11
-#include "level.h"12
-#include "effect.h"13
-14
-typedef enum {15
- STATE_MENU,16
- STATE_GAME,17
-} state_e;18
-19
-struct Assets {20
- Texture2D tiles;21
- Texture2D entities;22
- Texture2D font;23
- Texture2D images;24
-};25
-26
-struct Game {27
- state_e state;28
- level_t *level;29
- bool quit;30
- bool defeat;31
- bool victory;32
- menu_t *menu;33
- player_t *player;34
- tile_t **tiles;35
- int tiles_len;36
- entity_t *entities;37
- int entities_len;38
- effect_t **effects;39
- int effects_len;40
- assets_t assets;41
- Camera2D camera;42
- int xp;43
- int sceen_timer;44
-};45
-46
-game_t *game_create(void);47
-void game_update(game_t *game);48
-void game_draw(game_t *game);49
-void game_free(game_t *game);
diff --git a/src/gate.c b/src/gate.c
index 53dac9b..f51f444 100644
--- a/src/gate.c
+++ b/src/gate.c
1
@@ -1,14 +1,14 @@2
#include <stdlib.h>4
-#include "entity.h"5
-#include "gate.h"6
-#include "const.h"7
+#include "../include/entity.h"8
+#include "../include/gate.h"9
+#include "../include/const.h"11
gate_t *gate_create(pos_t pos, int enemy_max, int time) {12
gate_t *gate = malloc(sizeof(gate_t));13
gate->pos = pos;14
gate->enemy_max = enemy_max;15
- gate->timer_spawn = timer_create(1, time);16
+ gate->timer_spawn = fz_timer_create(1, time);17
gate->frozen = false;18
gate->frozen_timer = 0;19
return gate;20
@@ -47,14 +47,14 @@ void gate_update(gate_t *gate, game_t *game) {21
gate->frozen_timer--;22
}23
// handle spawning24
- timer_update(gate->timer_spawn);25
+ fz_timer_update(gate->timer_spawn);26
int enemies_len = 0;27
for (int i = 0; i < game->entities_len; i++) {28
if(game->entities[i].type == ENTITY_ENEMY) {29
enemies_len++;30
}31
}32
- if (timer_check(gate->timer_spawn) && enemies_len < gate->enemy_max) {33
+ if (fz_timer_check(gate->timer_spawn) && enemies_len < gate->enemy_max) {34
game->entities = realloc(game->entities, sizeof(entity_t) * (game->entities_len + 1));35
enemy_t *enemy = enemy_create((pos_t) {36
.x = gate->pos.x + (TILE_WIDTH - ENEMY_WIDTH) / 2.0,
diff --git a/src/gate.h b/src/gate.h
deleted file mode 100644
index 5b644d6..0000000
--- a/src/gate.h
+++ /dev/null
1
@@ -1,19 +0,0 @@2
-#pragma once3
-4
-typedef struct Gate gate_t;5
-6
-#include "game.h"7
-#include "util.h"8
-9
-struct Gate {10
- pos_t pos;11
- int enemy_max;12
- timer_t *timer_spawn;13
- bool frozen;14
- int frozen_timer;15
-};16
-17
-gate_t *gate_create(pos_t pos, int enemy_max, int time);18
-void gate_update(gate_t *gate, game_t *game);19
-void gate_draw(gate_t *gate, game_t *game);20
-void gate_free(gate_t *gate);
diff --git a/src/level.c b/src/level.c
index 9359d7b..09de3cd 100644
--- a/src/level.c
+++ b/src/level.c
1
@@ -1,10 +1,10 @@2
#include <stdlib.h>4
-#include "enemy.h"5
-#include "level.h"6
-#include "const.h"7
-#include "tile.h"8
-#include "entity.h"9
+#include "../include/enemy.h"10
+#include "../include/level.h"11
+#include "../include/const.h"12
+#include "../include/tile.h"13
+#include "../include/entity.h"15
const char *LEVEL_MAP_1 = {16
"........................"
diff --git a/src/level.h b/src/level.h
deleted file mode 100644
index d6b96ba..0000000
--- a/src/level.h
+++ /dev/null
1
@@ -1,23 +0,0 @@2
-#pragma once3
-4
-#define LEVELS 35
-6
-typedef struct Level level_t;7
-8
-typedef enum {9
- LEVEL_NULL,10
- LEVEL_1,11
- LEVEL_2,12
- LEVEL_3,13
-} level_e;14
-15
-#include "game.h"16
-17
-struct Level {18
- level_e type;19
- int width;20
- int height;21
-};22
-23
-void level_load(game_t *game, level_e type);24
-void level_unload(game_t *game);
diff --git a/src/libs/raylib.h b/src/libs/raylib.h
deleted file mode 100644
index 5ff2399..0000000
--- a/src/libs/raylib.h
+++ /dev/null
1
@@ -1,1673 +0,0 @@2
-/**********************************************************************************************3
-*4
-* raylib v5.1-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)5
-*6
-* FEATURES:7
-* - NO external dependencies, all required libraries included with raylib8
-* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly,9
-* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5.10
-* - Written in plain C code (C99) in PascalCase/camelCase notation11
-* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile)12
-* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]13
-* - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts)14
-* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)15
-* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!16
-* - Flexible Materials system, supporting classic maps and PBR maps17
-* - Animated 3D models supported (skeletal bones animation) (IQM)18
-* - Shaders support, including Model shaders and Postprocessing shaders19
-* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]20
-* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)21
-* - VR stereo rendering with configurable HMD device parameters22
-* - Bindings to multiple programming languages available!23
-*24
-* NOTES:25
-* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text]26
-* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2)27
-* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)28
-* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)29
-*30
-* DEPENDENCIES (included):31
-* [rcore] rglfw (Camilla Löwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP)32
-* [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP)33
-* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management34
-*35
-* OPTIONAL DEPENDENCIES (included):36
-* [rcore] msf_gif (Miles Fogle) for GIF recording37
-* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm38
-* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm39
-* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...)40
-* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)41
-* [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms42
-* [rtext] stb_truetype (Sean Barret) for ttf fonts loading43
-* [rtext] stb_rect_pack (Sean Barret) for rectangles packing44
-* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation45
-* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)46
-* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF)47
-* [rmodels] Model3D (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)48
-* [raudio] dr_wav (David Reid) for WAV audio file loading49
-* [raudio] dr_flac (David Reid) for FLAC audio file loading50
-* [raudio] dr_mp3 (David Reid) for MP3 audio file loading51
-* [raudio] stb_vorbis (Sean Barret) for OGG audio loading52
-* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading53
-* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading54
-*55
-*56
-* LICENSE: zlib/libpng57
-*58
-* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,59
-* BSD-like license that allows static linking with closed source software:60
-*61
-* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)62
-*63
-* This software is provided "as-is", without any express or implied warranty. In no event64
-* will the authors be held liable for any damages arising from the use of this software.65
-*66
-* Permission is granted to anyone to use this software for any purpose, including commercial67
-* applications, and to alter it and redistribute it freely, subject to the following restrictions:68
-*69
-* 1. The origin of this software must not be misrepresented; you must not claim that you70
-* wrote the original software. If you use this software in a product, an acknowledgment71
-* in the product documentation would be appreciated but is not required.72
-*73
-* 2. Altered source versions must be plainly marked as such, and must not be misrepresented74
-* as being the original software.75
-*76
-* 3. This notice may not be removed or altered from any source distribution.77
-*78
-**********************************************************************************************/79
-80
-#ifndef RAYLIB_H81
-#define RAYLIB_H82
-83
-#include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback84
-85
-#define RAYLIB_VERSION_MAJOR 586
-#define RAYLIB_VERSION_MINOR 187
-#define RAYLIB_VERSION_PATCH 088
-#define RAYLIB_VERSION "5.1-dev"89
-90
-// Function specifiers in case library is build/used as a shared library91
-// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll92
-// NOTE: visibility("default") attribute makes symbols "visible" when compiled with -fvisibility=hidden93
-#if defined(_WIN32)94
- #if defined(__TINYC__)95
- #define __declspec(x) __attribute__((x))96
- #endif97
- #if defined(BUILD_LIBTYPE_SHARED)98
- #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)99
- #elif defined(USE_LIBTYPE_SHARED)100
- #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)101
- #endif102
-#else103
- #if defined(BUILD_LIBTYPE_SHARED)104
- #define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib)105
- #endif106
-#endif107
-108
-#ifndef RLAPI109
- #define RLAPI // Functions defined as 'extern' by default (implicit specifiers)110
-#endif111
-112
-//----------------------------------------------------------------------------------113
-// Some basic Defines114
-//----------------------------------------------------------------------------------115
-#ifndef PI116
- #define PI 3.14159265358979323846f117
-#endif118
-#ifndef DEG2RAD119
- #define DEG2RAD (PI/180.0f)120
-#endif121
-#ifndef RAD2DEG122
- #define RAD2DEG (180.0f/PI)123
-#endif124
-125
-// Allow custom memory allocators126
-// NOTE: Require recompiling raylib sources127
-#ifndef RL_MALLOC128
- #define RL_MALLOC(sz) malloc(sz)129
-#endif130
-#ifndef RL_CALLOC131
- #define RL_CALLOC(n,sz) calloc(n,sz)132
-#endif133
-#ifndef RL_REALLOC134
- #define RL_REALLOC(ptr,sz) realloc(ptr,sz)135
-#endif136
-#ifndef RL_FREE137
- #define RL_FREE(ptr) free(ptr)138
-#endif139
-140
-// NOTE: MSVC C++ compiler does not support compound literals (C99 feature)141
-// Plain structures in C++ (without constructors) can be initialized with { }142
-// This is called aggregate initialization (C++11 feature)143
-#if defined(__cplusplus)144
- #define CLITERAL(type) type145
-#else146
- #define CLITERAL(type) (type)147
-#endif148
-149
-// Some compilers (mostly macos clang) default to C++98,150
-// where aggregate initialization can't be used151
-// So, give a more clear error stating how to fix this152
-// #if !defined(_MSC_VER) && (defined(__cplusplus) && __cplusplus < 201103L)153
-// #error "C++11 or later is required. Add -std=c++11"154
-// #endif155
-156
-// NOTE: We set some defines with some data types declared by raylib157
-// Other modules (raymath, rlgl) also require some of those types, so,158
-// to be able to use those other modules as standalone (not depending on raylib)159
-// this defines are very useful for internal check and avoid type (re)definitions160
-#define RL_COLOR_TYPE161
-#define RL_RECTANGLE_TYPE162
-#define RL_VECTOR2_TYPE163
-#define RL_VECTOR3_TYPE164
-#define RL_VECTOR4_TYPE165
-#define RL_QUATERNION_TYPE166
-#define RL_MATRIX_TYPE167
-168
-// Some Basic Colors169
-// NOTE: Custom raylib color palette for amazing visuals on WHITE background170
-#define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray171
-#define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray172
-#define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray173
-#define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow174
-#define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold175
-#define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange176
-#define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink177
-#define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red178
-#define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon179
-#define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green180
-#define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime181
-#define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green182
-#define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue183
-#define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue184
-#define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue185
-#define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple186
-#define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet187
-#define DARKPURPLE CLITERAL(Color){ 112, 31, 126, 255 } // Dark Purple188
-#define BEIGE CLITERAL(Color){ 211, 176, 131, 255 } // Beige189
-#define BROWN CLITERAL(Color){ 127, 106, 79, 255 } // Brown190
-#define DARKBROWN CLITERAL(Color){ 76, 63, 47, 255 } // Dark Brown191
-192
-#define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White193
-#define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black194
-#define BLANK CLITERAL(Color){ 0, 0, 0, 0 } // Blank (Transparent)195
-#define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta196
-#define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo)197
-198
-//----------------------------------------------------------------------------------199
-// Structures Definition200
-//----------------------------------------------------------------------------------201
-// Boolean type202
-#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)203
- #include <stdbool.h>204
-#elif !defined(__cplusplus) && !defined(bool)205
- typedef enum bool { false = 0, true = !false } bool;206
- #define RL_BOOL_TYPE207
-#endif208
-209
-// Vector2, 2 components210
-typedef struct Vector2 {211
- float x; // Vector x component212
- float y; // Vector y component213
-} Vector2;214
-215
-// Vector3, 3 components216
-typedef struct Vector3 {217
- float x; // Vector x component218
- float y; // Vector y component219
- float z; // Vector z component220
-} Vector3;221
-222
-// Vector4, 4 components223
-typedef struct Vector4 {224
- float x; // Vector x component225
- float y; // Vector y component226
- float z; // Vector z component227
- float w; // Vector w component228
-} Vector4;229
-230
-// Quaternion, 4 components (Vector4 alias)231
-typedef Vector4 Quaternion;232
-233
-// Matrix, 4x4 components, column major, OpenGL style, right-handed234
-typedef struct Matrix {235
- float m0, m4, m8, m12; // Matrix first row (4 components)236
- float m1, m5, m9, m13; // Matrix second row (4 components)237
- float m2, m6, m10, m14; // Matrix third row (4 components)238
- float m3, m7, m11, m15; // Matrix fourth row (4 components)239
-} Matrix;240
-241
-// Color, 4 components, R8G8B8A8 (32bit)242
-typedef struct Color {243
- unsigned char r; // Color red value244
- unsigned char g; // Color green value245
- unsigned char b; // Color blue value246
- unsigned char a; // Color alpha value247
-} Color;248
-249
-// Rectangle, 4 components250
-typedef struct Rectangle {251
- float x; // Rectangle top-left corner position x252
- float y; // Rectangle top-left corner position y253
- float width; // Rectangle width254
- float height; // Rectangle height255
-} Rectangle;256
-257
-// Image, pixel data stored in CPU memory (RAM)258
-typedef struct Image {259
- void *data; // Image raw data260
- int width; // Image base width261
- int height; // Image base height262
- int mipmaps; // Mipmap levels, 1 by default263
- int format; // Data format (PixelFormat type)264
-} Image;265
-266
-// Texture, tex data stored in GPU memory (VRAM)267
-typedef struct Texture {268
- unsigned int id; // OpenGL texture id269
- int width; // Texture base width270
- int height; // Texture base height271
- int mipmaps; // Mipmap levels, 1 by default272
- int format; // Data format (PixelFormat type)273
-} Texture;274
-275
-// Texture2D, same as Texture276
-typedef Texture Texture2D;277
-278
-// TextureCubemap, same as Texture279
-typedef Texture TextureCubemap;280
-281
-// RenderTexture, fbo for texture rendering282
-typedef struct RenderTexture {283
- unsigned int id; // OpenGL framebuffer object id284
- Texture texture; // Color buffer attachment texture285
- Texture depth; // Depth buffer attachment texture286
-} RenderTexture;287
-288
-// RenderTexture2D, same as RenderTexture289
-typedef RenderTexture RenderTexture2D;290
-291
-// NPatchInfo, n-patch layout info292
-typedef struct NPatchInfo {293
- Rectangle source; // Texture source rectangle294
- int left; // Left border offset295
- int top; // Top border offset296
- int right; // Right border offset297
- int bottom; // Bottom border offset298
- int layout; // Layout of the n-patch: 3x3, 1x3 or 3x1299
-} NPatchInfo;300
-301
-// GlyphInfo, font characters glyphs info302
-typedef struct GlyphInfo {303
- int value; // Character value (Unicode)304
- int offsetX; // Character offset X when drawing305
- int offsetY; // Character offset Y when drawing306
- int advanceX; // Character advance position X307
- Image image; // Character image data308
-} GlyphInfo;309
-310
-// Font, font texture and GlyphInfo array data311
-typedef struct Font {312
- int baseSize; // Base size (default chars height)313
- int glyphCount; // Number of glyph characters314
- int glyphPadding; // Padding around the glyph characters315
- Texture2D texture; // Texture atlas containing the glyphs316
- Rectangle *recs; // Rectangles in texture for the glyphs317
- GlyphInfo *glyphs; // Glyphs info data318
-} Font;319
-320
-// Camera, defines position/orientation in 3d space321
-typedef struct Camera3D {322
- Vector3 position; // Camera position323
- Vector3 target; // Camera target it looks-at324
- Vector3 up; // Camera up vector (rotation over its axis)325
- float fovy; // Camera field-of-view aperture in Y (degrees) in perspective, used as near plane width in orthographic326
- int projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC327
-} Camera3D;328
-329
-typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D330
-331
-// Camera2D, defines position/orientation in 2d space332
-typedef struct Camera2D {333
- Vector2 offset; // Camera offset (displacement from target)334
- Vector2 target; // Camera target (rotation and zoom origin)335
- float rotation; // Camera rotation in degrees336
- float zoom; // Camera zoom (scaling), should be 1.0f by default337
-} Camera2D;338
-339
-// Mesh, vertex data and vao/vbo340
-typedef struct Mesh {341
- int vertexCount; // Number of vertices stored in arrays342
- int triangleCount; // Number of triangles stored (indexed or not)343
-344
- // Vertex attributes data345
- float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0)346
- float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)347
- float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)348
- float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)349
- float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)350
- unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)351
- unsigned short *indices; // Vertex indices (in case vertex data comes indexed)352
-353
- // Animation vertex data354
- float *animVertices; // Animated vertex positions (after bones transformations)355
- float *animNormals; // Animated normals (after bones transformations)356
- unsigned char *boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning)357
- float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning)358
-359
- // OpenGL identifiers360
- unsigned int vaoId; // OpenGL Vertex Array Object id361
- unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data)362
-} Mesh;363
-364
-// Shader365
-typedef struct Shader {366
- unsigned int id; // Shader program id367
- int *locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS)368
-} Shader;369
-370
-// MaterialMap371
-typedef struct MaterialMap {372
- Texture2D texture; // Material map texture373
- Color color; // Material map color374
- float value; // Material map value375
-} MaterialMap;376
-377
-// Material, includes shader and maps378
-typedef struct Material {379
- Shader shader; // Material shader380
- MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS)381
- float params[4]; // Material generic parameters (if required)382
-} Material;383
-384
-// Transform, vertex transformation data385
-typedef struct Transform {386
- Vector3 translation; // Translation387
- Quaternion rotation; // Rotation388
- Vector3 scale; // Scale389
-} Transform;390
-391
-// Bone, skeletal animation bone392
-typedef struct BoneInfo {393
- char name[32]; // Bone name394
- int parent; // Bone parent395
-} BoneInfo;396
-397
-// Model, meshes, materials and animation data398
-typedef struct Model {399
- Matrix transform; // Local transform matrix400
-401
- int meshCount; // Number of meshes402
- int materialCount; // Number of materials403
- Mesh *meshes; // Meshes array404
- Material *materials; // Materials array405
- int *meshMaterial; // Mesh material number406
-407
- // Animation data408
- int boneCount; // Number of bones409
- BoneInfo *bones; // Bones information (skeleton)410
- Transform *bindPose; // Bones base transformation (pose)411
-} Model;412
-413
-// ModelAnimation414
-typedef struct ModelAnimation {415
- int boneCount; // Number of bones416
- int frameCount; // Number of animation frames417
- BoneInfo *bones; // Bones information (skeleton)418
- Transform **framePoses; // Poses array by frame419
- char name[32]; // Animation name420
-} ModelAnimation;421
-422
-// Ray, ray for raycasting423
-typedef struct Ray {424
- Vector3 position; // Ray position (origin)425
- Vector3 direction; // Ray direction426
-} Ray;427
-428
-// RayCollision, ray hit information429
-typedef struct RayCollision {430
- bool hit; // Did the ray hit something?431
- float distance; // Distance to the nearest hit432
- Vector3 point; // Point of the nearest hit433
- Vector3 normal; // Surface normal of hit434
-} RayCollision;435
-436
-// BoundingBox437
-typedef struct BoundingBox {438
- Vector3 min; // Minimum vertex box-corner439
- Vector3 max; // Maximum vertex box-corner440
-} BoundingBox;441
-442
-// Wave, audio wave data443
-typedef struct Wave {444
- unsigned int frameCount; // Total number of frames (considering channels)445
- unsigned int sampleRate; // Frequency (samples per second)446
- unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)447
- unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)448
- void *data; // Buffer data pointer449
-} Wave;450
-451
-// Opaque structs declaration452
-// NOTE: Actual structs are defined internally in raudio module453
-typedef struct rAudioBuffer rAudioBuffer;454
-typedef struct rAudioProcessor rAudioProcessor;455
-456
-// AudioStream, custom audio stream457
-typedef struct AudioStream {458
- rAudioBuffer *buffer; // Pointer to internal data used by the audio system459
- rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects460
-461
- unsigned int sampleRate; // Frequency (samples per second)462
- unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)463
- unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)464
-} AudioStream;465
-466
-// Sound467
-typedef struct Sound {468
- AudioStream stream; // Audio stream469
- unsigned int frameCount; // Total number of frames (considering channels)470
-} Sound;471
-472
-// Music, audio stream, anything longer than ~10 seconds should be streamed473
-typedef struct Music {474
- AudioStream stream; // Audio stream475
- unsigned int frameCount; // Total number of frames (considering channels)476
- bool looping; // Music looping enable477
-478
- int ctxType; // Type of music context (audio filetype)479
- void *ctxData; // Audio context data, depends on type480
-} Music;481
-482
-// VrDeviceInfo, Head-Mounted-Display device parameters483
-typedef struct VrDeviceInfo {484
- int hResolution; // Horizontal resolution in pixels485
- int vResolution; // Vertical resolution in pixels486
- float hScreenSize; // Horizontal size in meters487
- float vScreenSize; // Vertical size in meters488
- float eyeToScreenDistance; // Distance between eye and display in meters489
- float lensSeparationDistance; // Lens separation distance in meters490
- float interpupillaryDistance; // IPD (distance between pupils) in meters491
- float lensDistortionValues[4]; // Lens distortion constant parameters492
- float chromaAbCorrection[4]; // Chromatic aberration correction parameters493
-} VrDeviceInfo;494
-495
-// VrStereoConfig, VR stereo rendering configuration for simulator496
-typedef struct VrStereoConfig {497
- Matrix projection[2]; // VR projection matrices (per eye)498
- Matrix viewOffset[2]; // VR view offset matrices (per eye)499
- float leftLensCenter[2]; // VR left lens center500
- float rightLensCenter[2]; // VR right lens center501
- float leftScreenCenter[2]; // VR left screen center502
- float rightScreenCenter[2]; // VR right screen center503
- float scale[2]; // VR distortion scale504
- float scaleIn[2]; // VR distortion scale in505
-} VrStereoConfig;506
-507
-// File path list508
-typedef struct FilePathList {509
- unsigned int capacity; // Filepaths max entries510
- unsigned int count; // Filepaths entries count511
- char **paths; // Filepaths entries512
-} FilePathList;513
-514
-// Automation event515
-typedef struct AutomationEvent {516
- unsigned int frame; // Event frame517
- unsigned int type; // Event type (AutomationEventType)518
- int params[4]; // Event parameters (if required)519
-} AutomationEvent;520
-521
-// Automation event list522
-typedef struct AutomationEventList {523
- unsigned int capacity; // Events max entries (MAX_AUTOMATION_EVENTS)524
- unsigned int count; // Events entries count525
- AutomationEvent *events; // Events entries526
-} AutomationEventList;527
-528
-//----------------------------------------------------------------------------------529
-// Enumerators Definition530
-//----------------------------------------------------------------------------------531
-// System/Window config flags532
-// NOTE: Every bit registers one state (use it with bit masks)533
-// By default all flags are set to 0534
-typedef enum {535
- FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU536
- FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen537
- FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window538
- FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons)539
- FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window540
- FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify)541
- FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor)542
- FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused543
- FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top544
- FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized545
- FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer546
- FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI547
- FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED548
- FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode549
- FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X550
- FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)551
-} ConfigFlags;552
-553
-// Trace log level554
-// NOTE: Organized by priority level555
-typedef enum {556
- LOG_ALL = 0, // Display all logs557
- LOG_TRACE, // Trace logging, intended for internal use only558
- LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds559
- LOG_INFO, // Info logging, used for program execution info560
- LOG_WARNING, // Warning logging, used on recoverable failures561
- LOG_ERROR, // Error logging, used on unrecoverable failures562
- LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE)563
- LOG_NONE // Disable logging564
-} TraceLogLevel;565
-566
-// Keyboard keys (US keyboard layout)567
-// NOTE: Use GetKeyPressed() to allow redefining568
-// required keys for alternative layouts569
-typedef enum {570
- KEY_NULL = 0, // Key: NULL, used for no key pressed571
- // Alphanumeric keys572
- KEY_APOSTROPHE = 39, // Key: '573
- KEY_COMMA = 44, // Key: ,574
- KEY_MINUS = 45, // Key: -575
- KEY_PERIOD = 46, // Key: .576
- KEY_SLASH = 47, // Key: /577
- KEY_ZERO = 48, // Key: 0578
- KEY_ONE = 49, // Key: 1579
- KEY_TWO = 50, // Key: 2580
- KEY_THREE = 51, // Key: 3581
- KEY_FOUR = 52, // Key: 4582
- KEY_FIVE = 53, // Key: 5583
- KEY_SIX = 54, // Key: 6584
- KEY_SEVEN = 55, // Key: 7585
- KEY_EIGHT = 56, // Key: 8586
- KEY_NINE = 57, // Key: 9587
- KEY_SEMICOLON = 59, // Key: ;588
- KEY_EQUAL = 61, // Key: =589
- KEY_A = 65, // Key: A | a590
- KEY_B = 66, // Key: B | b591
- KEY_C = 67, // Key: C | c592
- KEY_D = 68, // Key: D | d593
- KEY_E = 69, // Key: E | e594
- KEY_F = 70, // Key: F | f595
- KEY_G = 71, // Key: G | g596
- KEY_H = 72, // Key: H | h597
- KEY_I = 73, // Key: I | i598
- KEY_J = 74, // Key: J | j599
- KEY_K = 75, // Key: K | k600
- KEY_L = 76, // Key: L | l601
- KEY_M = 77, // Key: M | m602
- KEY_N = 78, // Key: N | n603
- KEY_O = 79, // Key: O | o604
- KEY_P = 80, // Key: P | p605
- KEY_Q = 81, // Key: Q | q606
- KEY_R = 82, // Key: R | r607
- KEY_S = 83, // Key: S | s608
- KEY_T = 84, // Key: T | t609
- KEY_U = 85, // Key: U | u610
- KEY_V = 86, // Key: V | v611
- KEY_W = 87, // Key: W | w612
- KEY_X = 88, // Key: X | x613
- KEY_Y = 89, // Key: Y | y614
- KEY_Z = 90, // Key: Z | z615
- KEY_LEFT_BRACKET = 91, // Key: [616
- KEY_BACKSLASH = 92, // Key: '\'617
- KEY_RIGHT_BRACKET = 93, // Key: ]618
- KEY_GRAVE = 96, // Key: `619
- // Function keys620
- KEY_SPACE = 32, // Key: Space621
- KEY_ESCAPE = 256, // Key: Esc622
- KEY_ENTER = 257, // Key: Enter623
- KEY_TAB = 258, // Key: Tab624
- KEY_BACKSPACE = 259, // Key: Backspace625
- KEY_INSERT = 260, // Key: Ins626
- KEY_DELETE = 261, // Key: Del627
- KEY_RIGHT = 262, // Key: Cursor right628
- KEY_LEFT = 263, // Key: Cursor left629
- KEY_DOWN = 264, // Key: Cursor down630
- KEY_UP = 265, // Key: Cursor up631
- KEY_PAGE_UP = 266, // Key: Page up632
- KEY_PAGE_DOWN = 267, // Key: Page down633
- KEY_HOME = 268, // Key: Home634
- KEY_END = 269, // Key: End635
- KEY_CAPS_LOCK = 280, // Key: Caps lock636
- KEY_SCROLL_LOCK = 281, // Key: Scroll down637
- KEY_NUM_LOCK = 282, // Key: Num lock638
- KEY_PRINT_SCREEN = 283, // Key: Print screen639
- KEY_PAUSE = 284, // Key: Pause640
- KEY_F1 = 290, // Key: F1641
- KEY_F2 = 291, // Key: F2642
- KEY_F3 = 292, // Key: F3643
- KEY_F4 = 293, // Key: F4644
- KEY_F5 = 294, // Key: F5645
- KEY_F6 = 295, // Key: F6646
- KEY_F7 = 296, // Key: F7647
- KEY_F8 = 297, // Key: F8648
- KEY_F9 = 298, // Key: F9649
- KEY_F10 = 299, // Key: F10650
- KEY_F11 = 300, // Key: F11651
- KEY_F12 = 301, // Key: F12652
- KEY_LEFT_SHIFT = 340, // Key: Shift left653
- KEY_LEFT_CONTROL = 341, // Key: Control left654
- KEY_LEFT_ALT = 342, // Key: Alt left655
- KEY_LEFT_SUPER = 343, // Key: Super left656
- KEY_RIGHT_SHIFT = 344, // Key: Shift right657
- KEY_RIGHT_CONTROL = 345, // Key: Control right658
- KEY_RIGHT_ALT = 346, // Key: Alt right659
- KEY_RIGHT_SUPER = 347, // Key: Super right660
- KEY_KB_MENU = 348, // Key: KB menu661
- // Keypad keys662
- KEY_KP_0 = 320, // Key: Keypad 0663
- KEY_KP_1 = 321, // Key: Keypad 1664
- KEY_KP_2 = 322, // Key: Keypad 2665
- KEY_KP_3 = 323, // Key: Keypad 3666
- KEY_KP_4 = 324, // Key: Keypad 4667
- KEY_KP_5 = 325, // Key: Keypad 5668
- KEY_KP_6 = 326, // Key: Keypad 6669
- KEY_KP_7 = 327, // Key: Keypad 7670
- KEY_KP_8 = 328, // Key: Keypad 8671
- KEY_KP_9 = 329, // Key: Keypad 9672
- KEY_KP_DECIMAL = 330, // Key: Keypad .673
- KEY_KP_DIVIDE = 331, // Key: Keypad /674
- KEY_KP_MULTIPLY = 332, // Key: Keypad *675
- KEY_KP_SUBTRACT = 333, // Key: Keypad -676
- KEY_KP_ADD = 334, // Key: Keypad +677
- KEY_KP_ENTER = 335, // Key: Keypad Enter678
- KEY_KP_EQUAL = 336, // Key: Keypad =679
- // Android key buttons680
- KEY_BACK = 4, // Key: Android back button681
- KEY_MENU = 5, // Key: Android menu button682
- KEY_VOLUME_UP = 24, // Key: Android volume up button683
- KEY_VOLUME_DOWN = 25 // Key: Android volume down button684
-} KeyboardKey;685
-686
-// Add backwards compatibility support for deprecated names687
-#define MOUSE_LEFT_BUTTON MOUSE_BUTTON_LEFT688
-#define MOUSE_RIGHT_BUTTON MOUSE_BUTTON_RIGHT689
-#define MOUSE_MIDDLE_BUTTON MOUSE_BUTTON_MIDDLE690
-691
-// Mouse buttons692
-typedef enum {693
- MOUSE_BUTTON_LEFT = 0, // Mouse button left694
- MOUSE_BUTTON_RIGHT = 1, // Mouse button right695
- MOUSE_BUTTON_MIDDLE = 2, // Mouse button middle (pressed wheel)696
- MOUSE_BUTTON_SIDE = 3, // Mouse button side (advanced mouse device)697
- MOUSE_BUTTON_EXTRA = 4, // Mouse button extra (advanced mouse device)698
- MOUSE_BUTTON_FORWARD = 5, // Mouse button forward (advanced mouse device)699
- MOUSE_BUTTON_BACK = 6, // Mouse button back (advanced mouse device)700
-} MouseButton;701
-702
-// Mouse cursor703
-typedef enum {704
- MOUSE_CURSOR_DEFAULT = 0, // Default pointer shape705
- MOUSE_CURSOR_ARROW = 1, // Arrow shape706
- MOUSE_CURSOR_IBEAM = 2, // Text writing cursor shape707
- MOUSE_CURSOR_CROSSHAIR = 3, // Cross shape708
- MOUSE_CURSOR_POINTING_HAND = 4, // Pointing hand cursor709
- MOUSE_CURSOR_RESIZE_EW = 5, // Horizontal resize/move arrow shape710
- MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape711
- MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape712
- MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape713
- MOUSE_CURSOR_RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape714
- MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape715
-} MouseCursor;716
-717
-// Gamepad buttons718
-typedef enum {719
- GAMEPAD_BUTTON_UNKNOWN = 0, // Unknown button, just for error checking720
- GAMEPAD_BUTTON_LEFT_FACE_UP, // Gamepad left DPAD up button721
- GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Gamepad left DPAD right button722
- GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Gamepad left DPAD down button723
- GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Gamepad left DPAD left button724
- GAMEPAD_BUTTON_RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y)725
- GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Square, Xbox: X)726
- GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A)727
- GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Circle, Xbox: B)728
- GAMEPAD_BUTTON_LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button729
- GAMEPAD_BUTTON_LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button730
- GAMEPAD_BUTTON_RIGHT_TRIGGER_1, // Gamepad top/back trigger right (one), it could be a trailing button731
- GAMEPAD_BUTTON_RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button732
- GAMEPAD_BUTTON_MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select)733
- GAMEPAD_BUTTON_MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX)734
- GAMEPAD_BUTTON_MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start)735
- GAMEPAD_BUTTON_LEFT_THUMB, // Gamepad joystick pressed button left736
- GAMEPAD_BUTTON_RIGHT_THUMB // Gamepad joystick pressed button right737
-} GamepadButton;738
-739
-// Gamepad axis740
-typedef enum {741
- GAMEPAD_AXIS_LEFT_X = 0, // Gamepad left stick X axis742
- GAMEPAD_AXIS_LEFT_Y = 1, // Gamepad left stick Y axis743
- GAMEPAD_AXIS_RIGHT_X = 2, // Gamepad right stick X axis744
- GAMEPAD_AXIS_RIGHT_Y = 3, // Gamepad right stick Y axis745
- GAMEPAD_AXIS_LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1]746
- GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // Gamepad back trigger right, pressure level: [1..-1]747
-} GamepadAxis;748
-749
-// Material map index750
-typedef enum {751
- MATERIAL_MAP_ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE)752
- MATERIAL_MAP_METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR)753
- MATERIAL_MAP_NORMAL, // Normal material754
- MATERIAL_MAP_ROUGHNESS, // Roughness material755
- MATERIAL_MAP_OCCLUSION, // Ambient occlusion material756
- MATERIAL_MAP_EMISSION, // Emission material757
- MATERIAL_MAP_HEIGHT, // Heightmap material758
- MATERIAL_MAP_CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP)759
- MATERIAL_MAP_IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP)760
- MATERIAL_MAP_PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP)761
- MATERIAL_MAP_BRDF // Brdf material762
-} MaterialMapIndex;763
-764
-#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO765
-#define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS766
-767
-// Shader location index768
-typedef enum {769
- SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position770
- SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01771
- SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02772
- SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal773
- SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent774
- SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color775
- SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection776
- SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform)777
- SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection778
- SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform)779
- SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal780
- SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view781
- SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color782
- SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color783
- SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color784
- SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE)785
- SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR)786
- SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal787
- SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness788
- SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion789
- SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission790
- SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height791
- SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap792
- SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance793
- SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter794
- SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf795
-} ShaderLocationIndex;796
-797
-#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO798
-#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS799
-800
-// Shader uniform data type801
-typedef enum {802
- SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float803
- SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float)804
- SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float)805
- SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float)806
- SHADER_UNIFORM_INT, // Shader uniform type: int807
- SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int)808
- SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int)809
- SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int)810
- SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d811
-} ShaderUniformDataType;812
-813
-// Shader attribute data types814
-typedef enum {815
- SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float816
- SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float)817
- SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float)818
- SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)819
-} ShaderAttributeDataType;820
-821
-// Pixel formats822
-// NOTE: Support depends on OpenGL version and platform823
-typedef enum {824
- PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)825
- PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)826
- PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp827
- PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp828
- PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)829
- PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)830
- PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp831
- PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float)832
- PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)833
- PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)834
- PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float)835
- PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float)836
- PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float)837
- PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)838
- PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)839
- PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp840
- PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp841
- PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp842
- PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp843
- PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp844
- PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp845
- PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp846
- PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp847
- PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp848
-} PixelFormat;849
-850
-// Texture parameters: filter mode851
-// NOTE 1: Filtering considers mipmaps if available in the texture852
-// NOTE 2: Filter is accordingly set for minification and magnification853
-typedef enum {854
- TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation855
- TEXTURE_FILTER_BILINEAR, // Linear filtering856
- TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)857
- TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x858
- TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x859
- TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x860
-} TextureFilter;861
-862
-// Texture parameters: wrap mode863
-typedef enum {864
- TEXTURE_WRAP_REPEAT = 0, // Repeats texture in tiled mode865
- TEXTURE_WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode866
- TEXTURE_WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode867
- TEXTURE_WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode868
-} TextureWrap;869
-870
-// Cubemap layouts871
-typedef enum {872
- CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type873
- CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces874
- CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces875
- CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces876
- CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces877
- CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirrectangular map)878
-} CubemapLayout;879
-880
-// Font type, defines generation method881
-typedef enum {882
- FONT_DEFAULT = 0, // Default font generation, anti-aliased883
- FONT_BITMAP, // Bitmap font generation, no anti-aliasing884
- FONT_SDF // SDF font generation, requires external shader885
-} FontType;886
-887
-// Color blending modes (pre-defined)888
-typedef enum {889
- BLEND_ALPHA = 0, // Blend textures considering alpha (default)890
- BLEND_ADDITIVE, // Blend textures adding colors891
- BLEND_MULTIPLIED, // Blend textures multiplying colors892
- BLEND_ADD_COLORS, // Blend textures adding colors (alternative)893
- BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative)894
- BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha895
- BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors())896
- BLEND_CUSTOM_SEPARATE // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())897
-} BlendMode;898
-899
-// Gesture900
-// NOTE: Provided as bit-wise flags to enable only desired gestures901
-typedef enum {902
- GESTURE_NONE = 0, // No gesture903
- GESTURE_TAP = 1, // Tap gesture904
- GESTURE_DOUBLETAP = 2, // Double tap gesture905
- GESTURE_HOLD = 4, // Hold gesture906
- GESTURE_DRAG = 8, // Drag gesture907
- GESTURE_SWIPE_RIGHT = 16, // Swipe right gesture908
- GESTURE_SWIPE_LEFT = 32, // Swipe left gesture909
- GESTURE_SWIPE_UP = 64, // Swipe up gesture910
- GESTURE_SWIPE_DOWN = 128, // Swipe down gesture911
- GESTURE_PINCH_IN = 256, // Pinch in gesture912
- GESTURE_PINCH_OUT = 512 // Pinch out gesture913
-} Gesture;914
-915
-// Camera system modes916
-typedef enum {917
- CAMERA_CUSTOM = 0, // Custom camera918
- CAMERA_FREE, // Free camera919
- CAMERA_ORBITAL, // Orbital camera920
- CAMERA_FIRST_PERSON, // First person camera921
- CAMERA_THIRD_PERSON // Third person camera922
-} CameraMode;923
-924
-// Camera projection925
-typedef enum {926
- CAMERA_PERSPECTIVE = 0, // Perspective projection927
- CAMERA_ORTHOGRAPHIC // Orthographic projection928
-} CameraProjection;929
-930
-// N-patch layout931
-typedef enum {932
- NPATCH_NINE_PATCH = 0, // Npatch layout: 3x3 tiles933
- NPATCH_THREE_PATCH_VERTICAL, // Npatch layout: 1x3 tiles934
- NPATCH_THREE_PATCH_HORIZONTAL // Npatch layout: 3x1 tiles935
-} NPatchLayout;936
-937
-// Callbacks to hook some internal functions938
-// WARNING: These callbacks are intended for advance users939
-typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages940
-typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, int *dataSize); // FileIO: Load binary data941
-typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, int dataSize); // FileIO: Save binary data942
-typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data943
-typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data944
-945
-//------------------------------------------------------------------------------------946
-// Global Variables Definition947
-//------------------------------------------------------------------------------------948
-// It's lonely here...949
-950
-//------------------------------------------------------------------------------------951
-// Window and Graphics Device Functions (Module: core)952
-//------------------------------------------------------------------------------------953
-954
-#if defined(__cplusplus)955
-extern "C" { // Prevents name mangling of functions956
-#endif957
-958
-// Window-related functions959
-RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context960
-RLAPI void CloseWindow(void); // Close window and unload OpenGL context961
-RLAPI bool WindowShouldClose(void); // Check if application should close (KEY_ESCAPE pressed or windows close icon clicked)962
-RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully963
-RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen964
-RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP)965
-RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP)966
-RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP)967
-RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP)968
-RLAPI bool IsWindowResized(void); // Check if window has been resized last frame969
-RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled970
-RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)971
-RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags972
-RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)973
-RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed (only PLATFORM_DESKTOP)974
-RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)975
-RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)976
-RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)977
-RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)978
-RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)979
-RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)980
-RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)981
-RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window982
-RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)983
-RLAPI void SetWindowMaxSize(int width, int height); // Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)984
-RLAPI void SetWindowSize(int width, int height); // Set window dimensions985
-RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)986
-RLAPI void SetWindowFocused(void); // Set window focused (only PLATFORM_DESKTOP)987
-RLAPI void *GetWindowHandle(void); // Get native window handle988
-RLAPI int GetScreenWidth(void); // Get current screen width989
-RLAPI int GetScreenHeight(void); // Get current screen height990
-RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI)991
-RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI)992
-RLAPI int GetMonitorCount(void); // Get number of connected monitors993
-RLAPI int GetCurrentMonitor(void); // Get current connected monitor994
-RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position995
-RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)996
-RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)997
-RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres998
-RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres999
-RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate1000
-RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor1001
-RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor1002
-RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor1003
-RLAPI void SetClipboardText(const char *text); // Set clipboard text content1004
-RLAPI const char *GetClipboardText(void); // Get clipboard text content1005
-RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling1006
-RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling1007
-1008
-// Cursor-related functions1009
-RLAPI void ShowCursor(void); // Shows cursor1010
-RLAPI void HideCursor(void); // Hides cursor1011
-RLAPI bool IsCursorHidden(void); // Check if cursor is not visible1012
-RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)1013
-RLAPI void DisableCursor(void); // Disables cursor (lock cursor)1014
-RLAPI bool IsCursorOnScreen(void); // Check if cursor is on the screen1015
-1016
-// Drawing-related functions1017
-RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)1018
-RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing1019
-RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)1020
-RLAPI void BeginMode2D(Camera2D camera); // Begin 2D mode with custom camera (2D)1021
-RLAPI void EndMode2D(void); // Ends 2D mode with custom camera1022
-RLAPI void BeginMode3D(Camera3D camera); // Begin 3D mode with custom camera (3D)1023
-RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode1024
-RLAPI void BeginTextureMode(RenderTexture2D target); // Begin drawing to render texture1025
-RLAPI void EndTextureMode(void); // Ends drawing to render texture1026
-RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing1027
-RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)1028
-RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied, subtract, custom)1029
-RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)1030
-RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)1031
-RLAPI void EndScissorMode(void); // End scissor mode1032
-RLAPI void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering (requires VR simulator)1033
-RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator)1034
-1035
-// VR stereo config functions for VR simulator1036
-RLAPI VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); // Load VR stereo config for VR simulator device parameters1037
-RLAPI void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR stereo config1038
-1039
-// Shader management functions1040
-// NOTE: Shader functionality is not available on OpenGL 1.11041
-RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations1042
-RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations1043
-RLAPI bool IsShaderReady(Shader shader); // Check if a shader is ready1044
-RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location1045
-RLAPI int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location1046
-RLAPI void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value1047
-RLAPI void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); // Set shader uniform value vector1048
-RLAPI void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); // Set shader uniform value (matrix 4x4)1049
-RLAPI void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); // Set shader uniform value for texture (sampler2d)1050
-RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)1051
-1052
-// Screen-space-related functions1053
-RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray trace from mouse position1054
-RLAPI Ray GetViewRay(Vector2 mousePosition, Camera camera, float width, float height); // Get a ray trace from mouse position in a viewport1055
-RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position1056
-RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position1057
-RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position1058
-RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position1059
-RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix)1060
-RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix1061
-1062
-// Timing-related functions1063
-RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)1064
-RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)1065
-RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()1066
-RLAPI int GetFPS(void); // Get current FPS1067
-1068
-// Custom frame control functions1069
-// NOTE: Those functions are intended for advance users that want full control over the frame processing1070
-// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()1071
-// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL1072
-RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)1073
-RLAPI void PollInputEvents(void); // Register all input events1074
-RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)1075
-1076
-// Random values generation functions1077
-RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator1078
-RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)1079
-RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load random values sequence, no values repeated1080
-RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence1081
-1082
-// Misc. functions1083
-RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)1084
-RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)1085
-RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)1086
-1087
-// NOTE: Following functions implemented in module [utils]1088
-//------------------------------------------------------------------1089
-RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)1090
-RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level1091
-RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator1092
-RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator1093
-RLAPI void MemFree(void *ptr); // Internal memory free1094
-1095
-// Set custom callbacks1096
-// WARNING: Callbacks setup is intended for advance users1097
-RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log1098
-RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader1099
-RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver1100
-RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader1101
-RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver1102
-1103
-// Files management functions1104
-RLAPI unsigned char *LoadFileData(const char *fileName, int *dataSize); // Load file data as byte array (read)1105
-RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()1106
-RLAPI bool SaveFileData(const char *fileName, void *data, int dataSize); // Save data to file from byte array (write), returns true on success1107
-RLAPI bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileName); // Export data to code (.h), returns true on success1108
-RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string1109
-RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()1110
-RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success1111
-//------------------------------------------------------------------1112
-1113
-// File system functions1114
-RLAPI bool FileExists(const char *fileName); // Check if file exists1115
-RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists1116
-RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav)1117
-RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)1118
-RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')1119
-RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string1120
-RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)1121
-RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)1122
-RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string)1123
-RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)1124
-RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)1125
-RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success1126
-RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory1127
-RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths1128
-RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan1129
-RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths1130
-RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window1131
-RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths1132
-RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths1133
-RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)1134
-1135
-// Compression/Encoding functionality1136
-RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()1137
-RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree()1138
-RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()1139
-RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()1140
-1141
-// Automation events functionality1142
-RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS1143
-RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file1144
-RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file1145
-RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to1146
-RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording1147
-RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set)1148
-RLAPI void StopAutomationEventRecording(void); // Stop recording automation events1149
-RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event1150
-1151
-//------------------------------------------------------------------------------------1152
-// Input Handling Functions (Module: core)1153
-//------------------------------------------------------------------------------------1154
-1155
-// Input-related functions: keyboard1156
-RLAPI bool IsKeyPressed(int key); // Check if a key has been pressed once1157
-RLAPI bool IsKeyPressedRepeat(int key); // Check if a key has been pressed again (Only PLATFORM_DESKTOP)1158
-RLAPI bool IsKeyDown(int key); // Check if a key is being pressed1159
-RLAPI bool IsKeyReleased(int key); // Check if a key has been released once1160
-RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed1161
-RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty1162
-RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty1163
-RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)1164
-1165
-// Input-related functions: gamepads1166
-RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available1167
-RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id1168
-RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once1169
-RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed1170
-RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once1171
-RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed1172
-RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed1173
-RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad1174
-RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis1175
-RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)1176
-1177
-// Input-related functions: mouse1178
-RLAPI bool IsMouseButtonPressed(int button); // Check if a mouse button has been pressed once1179
-RLAPI bool IsMouseButtonDown(int button); // Check if a mouse button is being pressed1180
-RLAPI bool IsMouseButtonReleased(int button); // Check if a mouse button has been released once1181
-RLAPI bool IsMouseButtonUp(int button); // Check if a mouse button is NOT being pressed1182
-RLAPI int GetMouseX(void); // Get mouse position X1183
-RLAPI int GetMouseY(void); // Get mouse position Y1184
-RLAPI Vector2 GetMousePosition(void); // Get mouse position XY1185
-RLAPI Vector2 GetMouseDelta(void); // Get mouse delta between frames1186
-RLAPI void SetMousePosition(int x, int y); // Set mouse position XY1187
-RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset1188
-RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling1189
-RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement for X or Y, whichever is larger1190
-RLAPI Vector2 GetMouseWheelMoveV(void); // Get mouse wheel movement for both X and Y1191
-RLAPI void SetMouseCursor(int cursor); // Set mouse cursor1192
-1193
-// Input-related functions: touch1194
-RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)1195
-RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)1196
-RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)1197
-RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index1198
-RLAPI int GetTouchPointCount(void); // Get number of touch points1199
-1200
-//------------------------------------------------------------------------------------1201
-// Gestures and Touch Handling Functions (Module: rgestures)1202
-//------------------------------------------------------------------------------------1203
-RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags1204
-RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected1205
-RLAPI int GetGestureDetected(void); // Get latest detected gesture1206
-RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds1207
-RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector1208
-RLAPI float GetGestureDragAngle(void); // Get gesture drag angle1209
-RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta1210
-RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle1211
-1212
-//------------------------------------------------------------------------------------1213
-// Camera System Functions (Module: rcamera)1214
-//------------------------------------------------------------------------------------1215
-RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode1216
-RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation1217
-1218
-//------------------------------------------------------------------------------------1219
-// Basic Shapes Drawing Functions (Module: shapes)1220
-//------------------------------------------------------------------------------------1221
-// Set texture and rectangle to be used on shapes drawing1222
-// NOTE: It can be useful when using basic shapes and one single font,1223
-// defining a font char white rectangle would allow drawing everything in a single draw call1224
-RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing1225
-RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing1226
-RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing1227
-1228
-// Basic shapes drawing functions1229
-RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel1230
-RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)1231
-RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line1232
-RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (using gl lines)1233
-RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line (using triangles/quads)1234
-RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence (using gl lines)1235
-RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw line segment cubic-bezier in-out interpolation1236
-RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle1237
-RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle1238
-RLAPI void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw circle sector outline1239
-RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle1240
-RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)1241
-RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline1242
-RLAPI void DrawCircleLinesV(Vector2 center, float radius, Color color); // Draw circle outline (Vector version)1243
-RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse1244
-RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline1245
-RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring1246
-RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring outline1247
-RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle1248
-RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)1249
-RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle1250
-RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters1251
-RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle1252
-RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle1253
-RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors1254
-RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline1255
-RLAPI void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); // Draw rectangle outline with extended parameters1256
-RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges1257
-RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, float lineThick, Color color); // Draw rectangle with rounded edges outline1258
-RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!)1259
-RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline (vertex in counter-clockwise order!)1260
-RLAPI void DrawTriangleFan(Vector2 *points, int pointCount, Color color); // Draw a triangle fan defined by points (first vertex is the center)1261
-RLAPI void DrawTriangleStrip(Vector2 *points, int pointCount, Color color); // Draw a triangle strip defined by points1262
-RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)1263
-RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides1264
-RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters1265
-1266
-// Splines drawing functions1267
-RLAPI void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points1268
-RLAPI void DrawSplineBasis(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points1269
-RLAPI void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points1270
-RLAPI void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]1271
-RLAPI void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]1272
-RLAPI void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); // Draw spline segment: Linear, 2 points1273
-RLAPI void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: B-Spline, 4 points1274
-RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: Catmull-Rom, 4 points1275
-RLAPI void DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color); // Draw spline segment: Quadratic Bezier, 2 points, 1 control point1276
-RLAPI void DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color); // Draw spline segment: Cubic Bezier, 2 points, 2 control points1277
-1278
-// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f]1279
-RLAPI Vector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t); // Get (evaluate) spline point: Linear1280
-RLAPI Vector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: B-Spline1281
-RLAPI Vector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t); // Get (evaluate) spline point: Catmull-Rom1282
-RLAPI Vector2 GetSplinePointBezierQuad(Vector2 p1, Vector2 c2, Vector2 p3, float t); // Get (evaluate) spline point: Quadratic Bezier1283
-RLAPI Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t); // Get (evaluate) spline point: Cubic Bezier1284
-1285
-// Basic shapes collision detection functions1286
-RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles1287
-RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles1288
-RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle1289
-RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle1290
-RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle1291
-RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle1292
-RLAPI bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount); // Check if point is within a polygon described by array of vertices1293
-RLAPI bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); // Check the collision between two lines defined by two points each, returns collision point by reference1294
-RLAPI bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold); // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]1295
-RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision1296
-1297
-//------------------------------------------------------------------------------------1298
-// Texture Loading and Drawing Functions (Module: textures)1299
-//------------------------------------------------------------------------------------1300
-1301
-// Image loading functions1302
-// NOTE: These functions do not require GPU access1303
-RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)1304
-RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data1305
-RLAPI Image LoadImageSvg(const char *fileNameOrString, int width, int height); // Load image from SVG file data or string with specified size1306
-RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data)1307
-RLAPI Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int *frames); // Load image sequence from memory buffer1308
-RLAPI Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load image from memory buffer, fileType refers to extension: i.e. '.png'1309
-RLAPI Image LoadImageFromTexture(Texture2D texture); // Load image from GPU texture data1310
-RLAPI Image LoadImageFromScreen(void); // Load image from screen buffer and (screenshot)1311
-RLAPI bool IsImageReady(Image image); // Check if an image is ready1312
-RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)1313
-RLAPI bool ExportImage(Image image, const char *fileName); // Export image data to file, returns true on success1314
-RLAPI unsigned char *ExportImageToMemory(Image image, const char *fileType, int *fileSize); // Export image to memory buffer1315
-RLAPI bool ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes, returns true on success1316
-1317
-// Image generation functions1318
-RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color1319
-RLAPI Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end); // Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient1320
-RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient1321
-RLAPI Image GenImageGradientSquare(int width, int height, float density, Color inner, Color outer); // Generate image: square gradient1322
-RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked1323
-RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise1324
-RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise1325
-RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm, bigger tileSize means bigger cells1326
-RLAPI Image GenImageText(int width, int height, const char *text); // Generate image: grayscale image from text data1327
-1328
-// Image manipulation functions1329
-RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)1330
-RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece1331
-RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)1332
-RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)1333
-RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format1334
-RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two)1335
-RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle1336
-RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value1337
-RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color1338
-RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image1339
-RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel1340
-RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation1341
-RLAPI void ImageKernelConvolution(Image *image, float* kernel, int kernelSize); // Apply Custom Square image convolution kernel1342
-RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)1343
-RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)1344
-RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color1345
-RLAPI void ImageMipmaps(Image *image); // Compute all mipmap levels for a provided image1346
-RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)1347
-RLAPI void ImageFlipVertical(Image *image); // Flip image vertically1348
-RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally1349
-RLAPI void ImageRotate(Image *image, int degrees); // Rotate image by input angle in degrees (-359 to 359)1350
-RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg1351
-RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg1352
-RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint1353
-RLAPI void ImageColorInvert(Image *image); // Modify image color: invert1354
-RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale1355
-RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)1356
-RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)1357
-RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color1358
-RLAPI Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit)1359
-RLAPI Color *LoadImagePalette(Image image, int maxPaletteSize, int *colorCount); // Load colors palette from image as a Color array (RGBA - 32bit)1360
-RLAPI void UnloadImageColors(Color *colors); // Unload color data loaded with LoadImageColors()1361
-RLAPI void UnloadImagePalette(Color *colors); // Unload colors palette loaded with LoadImagePalette()1362
-RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle1363
-RLAPI Color GetImageColor(Image image, int x, int y); // Get image pixel color at (x, y) position1364
-1365
-// Image drawing functions1366
-// NOTE: Image software-rendering functions (CPU)1367
-RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color1368
-RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image1369
-RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)1370
-RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image1371
-RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version)1372
-RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw a filled circle within an image1373
-RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw a filled circle within an image (Vector version)1374
-RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image1375
-RLAPI void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color); // Draw circle outline within an image (Vector version)1376
-RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image1377
-RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version)1378
-RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image1379
-RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image1380
-RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source)1381
-RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination)1382
-RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)1383
-1384
-// Texture loading functions1385
-// NOTE: These functions require GPU access1386
-RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM)1387
-RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data1388
-RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported1389
-RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)1390
-RLAPI bool IsTextureReady(Texture2D texture); // Check if a texture is ready1391
-RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)1392
-RLAPI bool IsRenderTextureReady(RenderTexture2D target); // Check if a render texture is ready1393
-RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)1394
-RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data1395
-RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data1396
-1397
-// Texture configuration functions1398
-RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture1399
-RLAPI void SetTextureFilter(Texture2D texture, int filter); // Set texture scaling filter mode1400
-RLAPI void SetTextureWrap(Texture2D texture, int wrap); // Set texture wrapping mode1401
-1402
-// Texture drawing functions1403
-RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D1404
-RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector21405
-RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters1406
-RLAPI void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle1407
-RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters1408
-RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely1409
-1410
-// Color/pixel related functions1411
-RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f1412
-RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color1413
-RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]1414
-RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]1415
-RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]1416
-RLAPI Color ColorFromHSV(float hue, float saturation, float value); // Get a Color from HSV values, hue [0..360], saturation/value [0..1]1417
-RLAPI Color ColorTint(Color color, Color tint); // Get color multiplied with another color1418
-RLAPI Color ColorBrightness(Color color, float factor); // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f1419
-RLAPI Color ColorContrast(Color color, float contrast); // Get color with contrast correction, contrast values between -1.0f and 1.0f1420
-RLAPI Color ColorAlpha(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f1421
-RLAPI Color ColorAlphaBlend(Color dst, Color src, Color tint); // Get src alpha-blended into dst color with tint1422
-RLAPI Color GetColor(unsigned int hexValue); // Get Color structure from hexadecimal value1423
-RLAPI Color GetPixelColor(void *srcPtr, int format); // Get Color from a source pixel pointer of certain format1424
-RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // Set color formatted into destination pixel pointer1425
-RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format1426
-1427
-//------------------------------------------------------------------------------------1428
-// Font Loading and Text Drawing Functions (Module: text)1429
-//------------------------------------------------------------------------------------1430
-1431
-// Font loading/unloading functions1432
-RLAPI Font GetFontDefault(void); // Get the default Font1433
-RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)1434
-RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set1435
-RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)1436
-RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'1437
-RLAPI bool IsFontReady(Font font); // Check if a font is ready1438
-RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use1439
-RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info1440
-RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)1441
-RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM)1442
-RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success1443
-1444
-// Text drawing functions1445
-RLAPI void DrawFPS(int posX, int posY); // Draw current FPS1446
-RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)1447
-RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters1448
-RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)1449
-RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)1450
-RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)1451
-1452
-// Text font info functions1453
-RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks1454
-RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font1455
-RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font1456
-RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found1457
-RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found1458
-RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found1459
-1460
-// Text codepoints management functions (unicode characters)1461
-RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array1462
-RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array1463
-RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter1464
-RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory1465
-RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string1466
-RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1467
-RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1468
-RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure1469
-RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)1470
-1471
-// Text strings management functions (no UTF-8 strings, only byte chars)1472
-// NOTE: Some strings allocate memory internally for returned strings, just be careful!1473
-RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied1474
-RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal1475
-RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending1476
-RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style)1477
-RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string1478
-RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!)1479
-RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!)1480
-RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter1481
-RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings1482
-RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor!1483
-RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string1484
-RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string1485
-RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string1486
-RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string1487
-RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported)1488
-RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported)1489
-1490
-//------------------------------------------------------------------------------------1491
-// Basic 3d Shapes Drawing Functions (Module: models)1492
-//------------------------------------------------------------------------------------1493
-1494
-// Basic geometric 3D shapes drawing functions1495
-RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space1496
-RLAPI void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line1497
-RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space1498
-RLAPI void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!)1499
-RLAPI void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color); // Draw a triangle strip defined by points1500
-RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube1501
-RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)1502
-RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires1503
-RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)1504
-RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere1505
-RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters1506
-RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires1507
-RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone1508
-RLAPI void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder with base at startPos and top at endPos1509
-RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires1510
-RLAPI void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color); // Draw a cylinder wires with base at startPos and top at endPos1511
-RLAPI void DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw a capsule with the center of its sphere caps at startPos and endPos1512
-RLAPI void DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color); // Draw capsule wireframe with the center of its sphere caps at startPos and endPos1513
-RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ1514
-RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line1515
-RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))1516
-1517
-//------------------------------------------------------------------------------------1518
-// Model 3d Loading and Drawing Functions (Module: models)1519
-//------------------------------------------------------------------------------------1520
-1521
-// Model management functions1522
-RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)1523
-RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)1524
-RLAPI bool IsModelReady(Model model); // Check if a model is ready1525
-RLAPI void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM)1526
-RLAPI BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes)1527
-1528
-// Model drawing functions1529
-RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)1530
-RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters1531
-RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)1532
-RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters1533
-RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)1534
-RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture1535
-RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source1536
-RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation1537
-1538
-// Mesh management functions1539
-RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids1540
-RLAPI void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index1541
-RLAPI void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU1542
-RLAPI void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform1543
-RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms1544
-RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits1545
-RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents1546
-RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success1547
-RLAPI bool ExportMeshAsCode(Mesh mesh, const char *fileName); // Export mesh as code file (.h) defining multiple arrays of vertex attributes1548
-1549
-// Mesh generation functions1550
-RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh1551
-RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)1552
-RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh1553
-RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere)1554
-RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap)1555
-RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh1556
-RLAPI Mesh GenMeshCone(float radius, float height, int slices); // Generate cone/pyramid mesh1557
-RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh1558
-RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh1559
-RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data1560
-RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data1561
-1562
-// Material loading/unloading functions1563
-RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file1564
-RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)1565
-RLAPI bool IsMaterialReady(Material material); // Check if a material is ready1566
-RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)1567
-RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)1568
-RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh1569
-1570
-// Model animations loading/unloading functions1571
-RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file1572
-RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose1573
-RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data1574
-RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); // Unload animation array data1575
-RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match1576
-1577
-// Collision detection functions1578
-RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres1579
-RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes1580
-RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere1581
-RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere1582
-RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box1583
-RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh1584
-RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle1585
-RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad1586
-1587
-//------------------------------------------------------------------------------------1588
-// Audio Loading and Playing Functions (Module: audio)1589
-//------------------------------------------------------------------------------------1590
-typedef void (*AudioCallback)(void *bufferData, unsigned int frames);1591
-1592
-// Audio device management functions1593
-RLAPI void InitAudioDevice(void); // Initialize audio device and context1594
-RLAPI void CloseAudioDevice(void); // Close the audio device and context1595
-RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully1596
-RLAPI void SetMasterVolume(float volume); // Set master volume (listener)1597
-RLAPI float GetMasterVolume(void); // Get master volume (listener)1598
-1599
-// Wave/Sound loading/unloading functions1600
-RLAPI Wave LoadWave(const char *fileName); // Load wave data from file1601
-RLAPI Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. '.wav'1602
-RLAPI bool IsWaveReady(Wave wave); // Checks if wave data is ready1603
-RLAPI Sound LoadSound(const char *fileName); // Load sound from file1604
-RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data1605
-RLAPI Sound LoadSoundAlias(Sound source); // Create a new sound that shares the same sample data as the source sound, does not own the sound data1606
-RLAPI bool IsSoundReady(Sound sound); // Checks if a sound is ready1607
-RLAPI void UpdateSound(Sound sound, const void *data, int sampleCount); // Update sound buffer with new data1608
-RLAPI void UnloadWave(Wave wave); // Unload wave data1609
-RLAPI void UnloadSound(Sound sound); // Unload sound1610
-RLAPI void UnloadSoundAlias(Sound alias); // Unload a sound alias (does not deallocate sample data)1611
-RLAPI bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success1612
-RLAPI bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success1613
-1614
-// Wave/Sound management functions1615
-RLAPI void PlaySound(Sound sound); // Play a sound1616
-RLAPI void StopSound(Sound sound); // Stop playing a sound1617
-RLAPI void PauseSound(Sound sound); // Pause a sound1618
-RLAPI void ResumeSound(Sound sound); // Resume a paused sound1619
-RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing1620
-RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)1621
-RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)1622
-RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (0.5 is center)1623
-RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave1624
-RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range1625
-RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format1626
-RLAPI float *LoadWaveSamples(Wave wave); // Load samples data from wave as a 32bit float data array1627
-RLAPI void UnloadWaveSamples(float *samples); // Unload samples data loaded with LoadWaveSamples()1628
-1629
-// Music management functions1630
-RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file1631
-RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data1632
-RLAPI bool IsMusicReady(Music music); // Checks if a music stream is ready1633
-RLAPI void UnloadMusicStream(Music music); // Unload music stream1634
-RLAPI void PlayMusicStream(Music music); // Start music playing1635
-RLAPI bool IsMusicStreamPlaying(Music music); // Check if music is playing1636
-RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming1637
-RLAPI void StopMusicStream(Music music); // Stop music playing1638
-RLAPI void PauseMusicStream(Music music); // Pause music playing1639
-RLAPI void ResumeMusicStream(Music music); // Resume playing paused music1640
-RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)1641
-RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)1642
-RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)1643
-RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (0.5 is center)1644
-RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)1645
-RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)1646
-1647
-// AudioStream management functions1648
-RLAPI AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data)1649
-RLAPI bool IsAudioStreamReady(AudioStream stream); // Checks if an audio stream is ready1650
-RLAPI void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory1651
-RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data1652
-RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill1653
-RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream1654
-RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream1655
-RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream1656
-RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing1657
-RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream1658
-RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)1659
-RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)1660
-RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan for audio stream (0.5 is centered)1661
-RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams1662
-RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data1663
-1664
-RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as <float>s1665
-RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream1666
-1667
-RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as <float>s1668
-RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline1669
-1670
-#if defined(__cplusplus)1671
-}1672
-#endif1673
-1674
-#endif // RAYLIB_H
diff --git a/src/libs/raymath.h b/src/libs/raymath.h
deleted file mode 100644
index 15e403c..0000000
--- a/src/libs/raymath.h
+++ /dev/null
1
@@ -1,2191 +0,0 @@2
-/**********************************************************************************************3
-*4
-* raymath v1.5 - Math functions to work with Vector2, Vector3, Matrix and Quaternions5
-*6
-* CONVENTIONS:7
-* - Matrix structure is defined as row-major (memory layout) but parameters naming AND all8
-* math operations performed by the library consider the structure as it was column-major9
-* It is like transposed versions of the matrices are used for all the maths10
-* It benefits some functions making them cache-friendly and also avoids matrix11
-* transpositions sometimes required by OpenGL12
-* Example: In memory order, row0 is [m0 m4 m8 m12] but in semantic math row0 is [m0 m1 m2 m3]13
-* - Functions are always self-contained, no function use another raymath function inside,14
-* required code is directly re-implemented inside15
-* - Functions input parameters are always received by value (2 unavoidable exceptions)16
-* - Functions use always a "result" variable for return17
-* - Functions are always defined inline18
-* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)19
-* - No compound literals used to make sure libray is compatible with C++20
-*21
-* CONFIGURATION:22
-* #define RAYMATH_IMPLEMENTATION23
-* Generates the implementation of the library into the included file.24
-* If not defined, the library is in header only mode and can be included in other headers25
-* or source files without problems. But only ONE file should hold the implementation.26
-*27
-* #define RAYMATH_STATIC_INLINE28
-* Define static inline functions code, so #include header suffices for use.29
-* This may use up lots of memory.30
-*31
-*32
-* LICENSE: zlib/libpng33
-*34
-* Copyright (c) 2015-2024 Ramon Santamaria (@raysan5)35
-*36
-* This software is provided "as-is", without any express or implied warranty. In no event37
-* will the authors be held liable for any damages arising from the use of this software.38
-*39
-* Permission is granted to anyone to use this software for any purpose, including commercial40
-* applications, and to alter it and redistribute it freely, subject to the following restrictions:41
-*42
-* 1. The origin of this software must not be misrepresented; you must not claim that you43
-* wrote the original software. If you use this software in a product, an acknowledgment44
-* in the product documentation would be appreciated but is not required.45
-*46
-* 2. Altered source versions must be plainly marked as such, and must not be misrepresented47
-* as being the original software.48
-*49
-* 3. This notice may not be removed or altered from any source distribution.50
-*51
-**********************************************************************************************/52
-53
-#ifndef RAYMATH_H54
-#define RAYMATH_H55
-56
-#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE)57
- #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory"58
-#endif59
-60
-// Function specifiers definition61
-#if defined(RAYMATH_IMPLEMENTATION)62
- #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)63
- #define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll)64
- #elif defined(BUILD_LIBTYPE_SHARED)65
- #define RMAPI __attribute__((visibility("default"))) // We are building raylib as a Unix shared library (.so/.dylib)66
- #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)67
- #define RMAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)68
- #else69
- #define RMAPI extern inline // Provide external definition70
- #endif71
-#elif defined(RAYMATH_STATIC_INLINE)72
- #define RMAPI static inline // Functions may be inlined, no external out-of-line definition73
-#else74
- #if defined(__TINYC__)75
- #define RMAPI static inline // plain inline not supported by tinycc (See issue #435)76
- #else77
- #define RMAPI inline // Functions may be inlined or external definition used78
- #endif79
-#endif80
-81
-//----------------------------------------------------------------------------------82
-// Defines and Macros83
-//----------------------------------------------------------------------------------84
-#ifndef PI85
- #define PI 3.14159265358979323846f86
-#endif87
-88
-#ifndef EPSILON89
- #define EPSILON 0.000001f90
-#endif91
-92
-#ifndef DEG2RAD93
- #define DEG2RAD (PI/180.0f)94
-#endif95
-96
-#ifndef RAD2DEG97
- #define RAD2DEG (180.0f/PI)98
-#endif99
-100
-// Get float vector for Matrix101
-#ifndef MatrixToFloat102
- #define MatrixToFloat(mat) (MatrixToFloatV(mat).v)103
-#endif104
-105
-// Get float vector for Vector3106
-#ifndef Vector3ToFloat107
- #define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v)108
-#endif109
-110
-//----------------------------------------------------------------------------------111
-// Types and Structures Definition112
-//----------------------------------------------------------------------------------113
-#if !defined(RL_VECTOR2_TYPE)114
-// Vector2 type115
-typedef struct Vector2 {116
- float x;117
- float y;118
-} Vector2;119
-#define RL_VECTOR2_TYPE120
-#endif121
-122
-#if !defined(RL_VECTOR3_TYPE)123
-// Vector3 type124
-typedef struct Vector3 {125
- float x;126
- float y;127
- float z;128
-} Vector3;129
-#define RL_VECTOR3_TYPE130
-#endif131
-132
-#if !defined(RL_VECTOR4_TYPE)133
-// Vector4 type134
-typedef struct Vector4 {135
- float x;136
- float y;137
- float z;138
- float w;139
-} Vector4;140
-#define RL_VECTOR4_TYPE141
-#endif142
-143
-#if !defined(RL_QUATERNION_TYPE)144
-// Quaternion type145
-typedef Vector4 Quaternion;146
-#define RL_QUATERNION_TYPE147
-#endif148
-149
-#if !defined(RL_MATRIX_TYPE)150
-// Matrix type (OpenGL style 4x4 - right handed, column major)151
-typedef struct Matrix {152
- float m0, m4, m8, m12; // Matrix first row (4 components)153
- float m1, m5, m9, m13; // Matrix second row (4 components)154
- float m2, m6, m10, m14; // Matrix third row (4 components)155
- float m3, m7, m11, m15; // Matrix fourth row (4 components)156
-} Matrix;157
-#define RL_MATRIX_TYPE158
-#endif159
-160
-// NOTE: Helper types to be used instead of array return types for *ToFloat functions161
-typedef struct float3 {162
- float v[3];163
-} float3;164
-165
-typedef struct float16 {166
- float v[16];167
-} float16;168
-169
-#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf()170
-171
-//----------------------------------------------------------------------------------172
-// Module Functions Definition - Utils math173
-//----------------------------------------------------------------------------------174
-175
-// Clamp float value176
-RMAPI float Clamp(float value, float min, float max)177
-{178
- float result = (value < min) ? min : value;179
-180
- if (result > max) result = max;181
-182
- return result;183
-}184
-185
-// Calculate linear interpolation between two floats186
-RMAPI float Lerp(float start, float end, float amount)187
-{188
- float result = start + amount*(end - start);189
-190
- return result;191
-}192
-193
-// Normalize input value within input range194
-RMAPI float Normalize(float value, float start, float end)195
-{196
- float result = (value - start)/(end - start);197
-198
- return result;199
-}200
-201
-// Remap input value within input range to output range202
-RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)203
-{204
- float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart;205
-206
- return result;207
-}208
-209
-// Wrap input value from min to max210
-RMAPI float Wrap(float value, float min, float max)211
-{212
- float result = value - (max - min)*floorf((value - min)/(max - min));213
-214
- return result;215
-}216
-217
-// Check whether two given floats are almost equal218
-RMAPI int FloatEquals(float x, float y)219
-{220
-#if !defined(EPSILON)221
- #define EPSILON 0.000001f222
-#endif223
-224
- int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y))));225
-226
- return result;227
-}228
-229
-//----------------------------------------------------------------------------------230
-// Module Functions Definition - Vector2 math231
-//----------------------------------------------------------------------------------232
-233
-// Vector with components value 0.0f234
-RMAPI Vector2 Vector2Zero(void)235
-{236
- Vector2 result = { 0.0f, 0.0f };237
-238
- return result;239
-}240
-241
-// Vector with components value 1.0f242
-RMAPI Vector2 Vector2One(void)243
-{244
- Vector2 result = { 1.0f, 1.0f };245
-246
- return result;247
-}248
-249
-// Add two vectors (v1 + v2)250
-RMAPI Vector2 Vector2Add(Vector2 v1, Vector2 v2)251
-{252
- Vector2 result = { v1.x + v2.x, v1.y + v2.y };253
-254
- return result;255
-}256
-257
-// Add vector and float value258
-RMAPI Vector2 Vector2AddValue(Vector2 v, float add)259
-{260
- Vector2 result = { v.x + add, v.y + add };261
-262
- return result;263
-}264
-265
-// Subtract two vectors (v1 - v2)266
-RMAPI Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)267
-{268
- Vector2 result = { v1.x - v2.x, v1.y - v2.y };269
-270
- return result;271
-}272
-273
-// Subtract vector by float value274
-RMAPI Vector2 Vector2SubtractValue(Vector2 v, float sub)275
-{276
- Vector2 result = { v.x - sub, v.y - sub };277
-278
- return result;279
-}280
-281
-// Calculate vector length282
-RMAPI float Vector2Length(Vector2 v)283
-{284
- float result = sqrtf((v.x*v.x) + (v.y*v.y));285
-286
- return result;287
-}288
-289
-// Calculate vector square length290
-RMAPI float Vector2LengthSqr(Vector2 v)291
-{292
- float result = (v.x*v.x) + (v.y*v.y);293
-294
- return result;295
-}296
-297
-// Calculate two vectors dot product298
-RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2)299
-{300
- float result = (v1.x*v2.x + v1.y*v2.y);301
-302
- return result;303
-}304
-305
-// Calculate distance between two vectors306
-RMAPI float Vector2Distance(Vector2 v1, Vector2 v2)307
-{308
- float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));309
-310
- return result;311
-}312
-313
-// Calculate square distance between two vectors314
-RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)315
-{316
- float result = ((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));317
-318
- return result;319
-}320
-321
-// Calculate angle between two vectors322
-// NOTE: Angle is calculated from origin point (0, 0)323
-RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)324
-{325
- float result = 0.0f;326
-327
- float dot = v1.x*v2.x + v1.y*v2.y;328
- float det = v1.x*v2.y - v1.y*v2.x;329
-330
- result = atan2f(det, dot);331
-332
- return result;333
-}334
-335
-// Calculate angle defined by a two vectors line336
-// NOTE: Parameters need to be normalized337
-// Current implementation should be aligned with glm::angle338
-RMAPI float Vector2LineAngle(Vector2 start, Vector2 end)339
-{340
- float result = 0.0f;341
-342
- // TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior343
- result = -atan2f(end.y - start.y, end.x - start.x);344
-345
- return result;346
-}347
-348
-// Scale vector (multiply by value)349
-RMAPI Vector2 Vector2Scale(Vector2 v, float scale)350
-{351
- Vector2 result = { v.x*scale, v.y*scale };352
-353
- return result;354
-}355
-356
-// Multiply vector by vector357
-RMAPI Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)358
-{359
- Vector2 result = { v1.x*v2.x, v1.y*v2.y };360
-361
- return result;362
-}363
-364
-// Negate vector365
-RMAPI Vector2 Vector2Negate(Vector2 v)366
-{367
- Vector2 result = { -v.x, -v.y };368
-369
- return result;370
-}371
-372
-// Divide vector by vector373
-RMAPI Vector2 Vector2Divide(Vector2 v1, Vector2 v2)374
-{375
- Vector2 result = { v1.x/v2.x, v1.y/v2.y };376
-377
- return result;378
-}379
-380
-// Normalize provided vector381
-RMAPI Vector2 Vector2Normalize(Vector2 v)382
-{383
- Vector2 result = { 0 };384
- float length = sqrtf((v.x*v.x) + (v.y*v.y));385
-386
- if (length > 0)387
- {388
- float ilength = 1.0f/length;389
- result.x = v.x*ilength;390
- result.y = v.y*ilength;391
- }392
-393
- return result;394
-}395
-396
-// Transforms a Vector2 by a given Matrix397
-RMAPI Vector2 Vector2Transform(Vector2 v, Matrix mat)398
-{399
- Vector2 result = { 0 };400
-401
- float x = v.x;402
- float y = v.y;403
- float z = 0;404
-405
- result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;406
- result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;407
-408
- return result;409
-}410
-411
-// Calculate linear interpolation between two vectors412
-RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)413
-{414
- Vector2 result = { 0 };415
-416
- result.x = v1.x + amount*(v2.x - v1.x);417
- result.y = v1.y + amount*(v2.y - v1.y);418
-419
- return result;420
-}421
-422
-// Calculate reflected vector to normal423
-RMAPI Vector2 Vector2Reflect(Vector2 v, Vector2 normal)424
-{425
- Vector2 result = { 0 };426
-427
- float dotProduct = (v.x*normal.x + v.y*normal.y); // Dot product428
-429
- result.x = v.x - (2.0f*normal.x)*dotProduct;430
- result.y = v.y - (2.0f*normal.y)*dotProduct;431
-432
- return result;433
-}434
-435
-// Rotate vector by angle436
-RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)437
-{438
- Vector2 result = { 0 };439
-440
- float cosres = cosf(angle);441
- float sinres = sinf(angle);442
-443
- result.x = v.x*cosres - v.y*sinres;444
- result.y = v.x*sinres + v.y*cosres;445
-446
- return result;447
-}448
-449
-// Move Vector towards target450
-RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)451
-{452
- Vector2 result = { 0 };453
-454
- float dx = target.x - v.x;455
- float dy = target.y - v.y;456
- float value = (dx*dx) + (dy*dy);457
-458
- if ((value == 0) || ((maxDistance >= 0) && (value <= maxDistance*maxDistance))) return target;459
-460
- float dist = sqrtf(value);461
-462
- result.x = v.x + dx/dist*maxDistance;463
- result.y = v.y + dy/dist*maxDistance;464
-465
- return result;466
-}467
-468
-// Invert the given vector469
-RMAPI Vector2 Vector2Invert(Vector2 v)470
-{471
- Vector2 result = { 1.0f/v.x, 1.0f/v.y };472
-473
- return result;474
-}475
-476
-// Clamp the components of the vector between477
-// min and max values specified by the given vectors478
-RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)479
-{480
- Vector2 result = { 0 };481
-482
- result.x = fminf(max.x, fmaxf(min.x, v.x));483
- result.y = fminf(max.y, fmaxf(min.y, v.y));484
-485
- return result;486
-}487
-488
-// Clamp the magnitude of the vector between two min and max values489
-RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)490
-{491
- Vector2 result = v;492
-493
- float length = (v.x*v.x) + (v.y*v.y);494
- if (length > 0.0f)495
- {496
- length = sqrtf(length);497
-498
- float scale = 1; // By default, 1 as the neutral element.499
- if (length < min)500
- {501
- scale = min/length;502
- }503
- else if (length > max)504
- {505
- scale = max/length;506
- }507
-508
- result.x = v.x*scale;509
- result.y = v.y*scale;510
- }511
-512
- return result;513
-}514
-515
-// Check whether two given vectors are almost equal516
-RMAPI int Vector2Equals(Vector2 p, Vector2 q)517
-{518
-#if !defined(EPSILON)519
- #define EPSILON 0.000001f520
-#endif521
-522
- int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&523
- ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y)))));524
-525
- return result;526
-}527
-528
-//----------------------------------------------------------------------------------529
-// Module Functions Definition - Vector3 math530
-//----------------------------------------------------------------------------------531
-532
-// Vector with components value 0.0f533
-RMAPI Vector3 Vector3Zero(void)534
-{535
- Vector3 result = { 0.0f, 0.0f, 0.0f };536
-537
- return result;538
-}539
-540
-// Vector with components value 1.0f541
-RMAPI Vector3 Vector3One(void)542
-{543
- Vector3 result = { 1.0f, 1.0f, 1.0f };544
-545
- return result;546
-}547
-548
-// Add two vectors549
-RMAPI Vector3 Vector3Add(Vector3 v1, Vector3 v2)550
-{551
- Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };552
-553
- return result;554
-}555
-556
-// Add vector and float value557
-RMAPI Vector3 Vector3AddValue(Vector3 v, float add)558
-{559
- Vector3 result = { v.x + add, v.y + add, v.z + add };560
-561
- return result;562
-}563
-564
-// Subtract two vectors565
-RMAPI Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)566
-{567
- Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };568
-569
- return result;570
-}571
-572
-// Subtract vector by float value573
-RMAPI Vector3 Vector3SubtractValue(Vector3 v, float sub)574
-{575
- Vector3 result = { v.x - sub, v.y - sub, v.z - sub };576
-577
- return result;578
-}579
-580
-// Multiply vector by scalar581
-RMAPI Vector3 Vector3Scale(Vector3 v, float scalar)582
-{583
- Vector3 result = { v.x*scalar, v.y*scalar, v.z*scalar };584
-585
- return result;586
-}587
-588
-// Multiply vector by vector589
-RMAPI Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)590
-{591
- Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z };592
-593
- return result;594
-}595
-596
-// Calculate two vectors cross product597
-RMAPI Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)598
-{599
- Vector3 result = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };600
-601
- return result;602
-}603
-604
-// Calculate one vector perpendicular vector605
-RMAPI Vector3 Vector3Perpendicular(Vector3 v)606
-{607
- Vector3 result = { 0 };608
-609
- float min = fabsf(v.x);610
- Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};611
-612
- if (fabsf(v.y) < min)613
- {614
- min = fabsf(v.y);615
- Vector3 tmp = {0.0f, 1.0f, 0.0f};616
- cardinalAxis = tmp;617
- }618
-619
- if (fabsf(v.z) < min)620
- {621
- Vector3 tmp = {0.0f, 0.0f, 1.0f};622
- cardinalAxis = tmp;623
- }624
-625
- // Cross product between vectors626
- result.x = v.y*cardinalAxis.z - v.z*cardinalAxis.y;627
- result.y = v.z*cardinalAxis.x - v.x*cardinalAxis.z;628
- result.z = v.x*cardinalAxis.y - v.y*cardinalAxis.x;629
-630
- return result;631
-}632
-633
-// Calculate vector length634
-RMAPI float Vector3Length(const Vector3 v)635
-{636
- float result = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);637
-638
- return result;639
-}640
-641
-// Calculate vector square length642
-RMAPI float Vector3LengthSqr(const Vector3 v)643
-{644
- float result = v.x*v.x + v.y*v.y + v.z*v.z;645
-646
- return result;647
-}648
-649
-// Calculate two vectors dot product650
-RMAPI float Vector3DotProduct(Vector3 v1, Vector3 v2)651
-{652
- float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);653
-654
- return result;655
-}656
-657
-// Calculate distance between two vectors658
-RMAPI float Vector3Distance(Vector3 v1, Vector3 v2)659
-{660
- float result = 0.0f;661
-662
- float dx = v2.x - v1.x;663
- float dy = v2.y - v1.y;664
- float dz = v2.z - v1.z;665
- result = sqrtf(dx*dx + dy*dy + dz*dz);666
-667
- return result;668
-}669
-670
-// Calculate square distance between two vectors671
-RMAPI float Vector3DistanceSqr(Vector3 v1, Vector3 v2)672
-{673
- float result = 0.0f;674
-675
- float dx = v2.x - v1.x;676
- float dy = v2.y - v1.y;677
- float dz = v2.z - v1.z;678
- result = dx*dx + dy*dy + dz*dz;679
-680
- return result;681
-}682
-683
-// Calculate angle between two vectors684
-RMAPI float Vector3Angle(Vector3 v1, Vector3 v2)685
-{686
- float result = 0.0f;687
-688
- Vector3 cross = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };689
- float len = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z);690
- float dot = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);691
- result = atan2f(len, dot);692
-693
- return result;694
-}695
-696
-// Negate provided vector (invert direction)697
-RMAPI Vector3 Vector3Negate(Vector3 v)698
-{699
- Vector3 result = { -v.x, -v.y, -v.z };700
-701
- return result;702
-}703
-704
-// Divide vector by vector705
-RMAPI Vector3 Vector3Divide(Vector3 v1, Vector3 v2)706
-{707
- Vector3 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z };708
-709
- return result;710
-}711
-712
-// Normalize provided vector713
-RMAPI Vector3 Vector3Normalize(Vector3 v)714
-{715
- Vector3 result = v;716
-717
- float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);718
- if (length != 0.0f)719
- {720
- float ilength = 1.0f/length;721
-722
- result.x *= ilength;723
- result.y *= ilength;724
- result.z *= ilength;725
- }726
-727
- return result;728
-}729
-730
-//Calculate the projection of the vector v1 on to v2731
-RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)732
-{733
- Vector3 result = { 0 };734
-735
- float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);736
- float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);737
-738
- float mag = v1dv2/v2dv2;739
-740
- result.x = v2.x*mag;741
- result.y = v2.y*mag;742
- result.z = v2.z*mag;743
-744
- return result;745
-}746
-747
-//Calculate the rejection of the vector v1 on to v2748
-RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)749
-{750
- Vector3 result = { 0 };751
-752
- float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);753
- float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);754
-755
- float mag = v1dv2/v2dv2;756
-757
- result.x = v1.x - (v2.x*mag);758
- result.y = v1.y - (v2.y*mag);759
- result.z = v1.z - (v2.z*mag);760
-761
- return result;762
-}763
-764
-// Orthonormalize provided vectors765
-// Makes vectors normalized and orthogonal to each other766
-// Gram-Schmidt function implementation767
-RMAPI void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2)768
-{769
- float length = 0.0f;770
- float ilength = 0.0f;771
-772
- // Vector3Normalize(*v1);773
- Vector3 v = *v1;774
- length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);775
- if (length == 0.0f) length = 1.0f;776
- ilength = 1.0f/length;777
- v1->x *= ilength;778
- v1->y *= ilength;779
- v1->z *= ilength;780
-781
- // Vector3CrossProduct(*v1, *v2)782
- Vector3 vn1 = { v1->y*v2->z - v1->z*v2->y, v1->z*v2->x - v1->x*v2->z, v1->x*v2->y - v1->y*v2->x };783
-784
- // Vector3Normalize(vn1);785
- v = vn1;786
- length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);787
- if (length == 0.0f) length = 1.0f;788
- ilength = 1.0f/length;789
- vn1.x *= ilength;790
- vn1.y *= ilength;791
- vn1.z *= ilength;792
-793
- // Vector3CrossProduct(vn1, *v1)794
- Vector3 vn2 = { vn1.y*v1->z - vn1.z*v1->y, vn1.z*v1->x - vn1.x*v1->z, vn1.x*v1->y - vn1.y*v1->x };795
-796
- *v2 = vn2;797
-}798
-799
-// Transforms a Vector3 by a given Matrix800
-RMAPI Vector3 Vector3Transform(Vector3 v, Matrix mat)801
-{802
- Vector3 result = { 0 };803
-804
- float x = v.x;805
- float y = v.y;806
- float z = v.z;807
-808
- result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;809
- result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;810
- result.z = mat.m2*x + mat.m6*y + mat.m10*z + mat.m14;811
-812
- return result;813
-}814
-815
-// Transform a vector by quaternion rotation816
-RMAPI Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)817
-{818
- Vector3 result = { 0 };819
-820
- result.x = v.x*(q.x*q.x + q.w*q.w - q.y*q.y - q.z*q.z) + v.y*(2*q.x*q.y - 2*q.w*q.z) + v.z*(2*q.x*q.z + 2*q.w*q.y);821
- result.y = v.x*(2*q.w*q.z + 2*q.x*q.y) + v.y*(q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z) + v.z*(-2*q.w*q.x + 2*q.y*q.z);822
- result.z = v.x*(-2*q.w*q.y + 2*q.x*q.z) + v.y*(2*q.w*q.x + 2*q.y*q.z)+ v.z*(q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);823
-824
- return result;825
-}826
-827
-// Rotates a vector around an axis828
-RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle)829
-{830
- // Using Euler-Rodrigues Formula831
- // Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula832
-833
- Vector3 result = v;834
-835
- // Vector3Normalize(axis);836
- float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);837
- if (length == 0.0f) length = 1.0f;838
- float ilength = 1.0f/length;839
- axis.x *= ilength;840
- axis.y *= ilength;841
- axis.z *= ilength;842
-843
- angle /= 2.0f;844
- float a = sinf(angle);845
- float b = axis.x*a;846
- float c = axis.y*a;847
- float d = axis.z*a;848
- a = cosf(angle);849
- Vector3 w = { b, c, d };850
-851
- // Vector3CrossProduct(w, v)852
- Vector3 wv = { w.y*v.z - w.z*v.y, w.z*v.x - w.x*v.z, w.x*v.y - w.y*v.x };853
-854
- // Vector3CrossProduct(w, wv)855
- Vector3 wwv = { w.y*wv.z - w.z*wv.y, w.z*wv.x - w.x*wv.z, w.x*wv.y - w.y*wv.x };856
-857
- // Vector3Scale(wv, 2*a)858
- a *= 2;859
- wv.x *= a;860
- wv.y *= a;861
- wv.z *= a;862
-863
- // Vector3Scale(wwv, 2)864
- wwv.x *= 2;865
- wwv.y *= 2;866
- wwv.z *= 2;867
-868
- result.x += wv.x;869
- result.y += wv.y;870
- result.z += wv.z;871
-872
- result.x += wwv.x;873
- result.y += wwv.y;874
- result.z += wwv.z;875
-876
- return result;877
-}878
-879
-// Calculate linear interpolation between two vectors880
-RMAPI Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)881
-{882
- Vector3 result = { 0 };883
-884
- result.x = v1.x + amount*(v2.x - v1.x);885
- result.y = v1.y + amount*(v2.y - v1.y);886
- result.z = v1.z + amount*(v2.z - v1.z);887
-888
- return result;889
-}890
-891
-// Calculate reflected vector to normal892
-RMAPI Vector3 Vector3Reflect(Vector3 v, Vector3 normal)893
-{894
- Vector3 result = { 0 };895
-896
- // I is the original vector897
- // N is the normal of the incident plane898
- // R = I - (2*N*(DotProduct[I, N]))899
-900
- float dotProduct = (v.x*normal.x + v.y*normal.y + v.z*normal.z);901
-902
- result.x = v.x - (2.0f*normal.x)*dotProduct;903
- result.y = v.y - (2.0f*normal.y)*dotProduct;904
- result.z = v.z - (2.0f*normal.z)*dotProduct;905
-906
- return result;907
-}908
-909
-// Get min value for each pair of components910
-RMAPI Vector3 Vector3Min(Vector3 v1, Vector3 v2)911
-{912
- Vector3 result = { 0 };913
-914
- result.x = fminf(v1.x, v2.x);915
- result.y = fminf(v1.y, v2.y);916
- result.z = fminf(v1.z, v2.z);917
-918
- return result;919
-}920
-921
-// Get max value for each pair of components922
-RMAPI Vector3 Vector3Max(Vector3 v1, Vector3 v2)923
-{924
- Vector3 result = { 0 };925
-926
- result.x = fmaxf(v1.x, v2.x);927
- result.y = fmaxf(v1.y, v2.y);928
- result.z = fmaxf(v1.z, v2.z);929
-930
- return result;931
-}932
-933
-// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)934
-// NOTE: Assumes P is on the plane of the triangle935
-RMAPI Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)936
-{937
- Vector3 result = { 0 };938
-939
- Vector3 v0 = { b.x - a.x, b.y - a.y, b.z - a.z }; // Vector3Subtract(b, a)940
- Vector3 v1 = { c.x - a.x, c.y - a.y, c.z - a.z }; // Vector3Subtract(c, a)941
- Vector3 v2 = { p.x - a.x, p.y - a.y, p.z - a.z }; // Vector3Subtract(p, a)942
- float d00 = (v0.x*v0.x + v0.y*v0.y + v0.z*v0.z); // Vector3DotProduct(v0, v0)943
- float d01 = (v0.x*v1.x + v0.y*v1.y + v0.z*v1.z); // Vector3DotProduct(v0, v1)944
- float d11 = (v1.x*v1.x + v1.y*v1.y + v1.z*v1.z); // Vector3DotProduct(v1, v1)945
- float d20 = (v2.x*v0.x + v2.y*v0.y + v2.z*v0.z); // Vector3DotProduct(v2, v0)946
- float d21 = (v2.x*v1.x + v2.y*v1.y + v2.z*v1.z); // Vector3DotProduct(v2, v1)947
-948
- float denom = d00*d11 - d01*d01;949
-950
- result.y = (d11*d20 - d01*d21)/denom;951
- result.z = (d00*d21 - d01*d20)/denom;952
- result.x = 1.0f - (result.z + result.y);953
-954
- return result;955
-}956
-957
-// Projects a Vector3 from screen space into object space958
-// NOTE: We are avoiding calling other raymath functions despite available959
-RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)960
-{961
- Vector3 result = { 0 };962
-963
- // Calculate unprojected matrix (multiply view matrix by projection matrix) and invert it964
- Matrix matViewProj = { // MatrixMultiply(view, projection);965
- view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12,966
- view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13,967
- view.m0*projection.m2 + view.m1*projection.m6 + view.m2*projection.m10 + view.m3*projection.m14,968
- view.m0*projection.m3 + view.m1*projection.m7 + view.m2*projection.m11 + view.m3*projection.m15,969
- view.m4*projection.m0 + view.m5*projection.m4 + view.m6*projection.m8 + view.m7*projection.m12,970
- view.m4*projection.m1 + view.m5*projection.m5 + view.m6*projection.m9 + view.m7*projection.m13,971
- view.m4*projection.m2 + view.m5*projection.m6 + view.m6*projection.m10 + view.m7*projection.m14,972
- view.m4*projection.m3 + view.m5*projection.m7 + view.m6*projection.m11 + view.m7*projection.m15,973
- view.m8*projection.m0 + view.m9*projection.m4 + view.m10*projection.m8 + view.m11*projection.m12,974
- view.m8*projection.m1 + view.m9*projection.m5 + view.m10*projection.m9 + view.m11*projection.m13,975
- view.m8*projection.m2 + view.m9*projection.m6 + view.m10*projection.m10 + view.m11*projection.m14,976
- view.m8*projection.m3 + view.m9*projection.m7 + view.m10*projection.m11 + view.m11*projection.m15,977
- view.m12*projection.m0 + view.m13*projection.m4 + view.m14*projection.m8 + view.m15*projection.m12,978
- view.m12*projection.m1 + view.m13*projection.m5 + view.m14*projection.m9 + view.m15*projection.m13,979
- view.m12*projection.m2 + view.m13*projection.m6 + view.m14*projection.m10 + view.m15*projection.m14,980
- view.m12*projection.m3 + view.m13*projection.m7 + view.m14*projection.m11 + view.m15*projection.m15 };981
-982
- // Calculate inverted matrix -> MatrixInvert(matViewProj);983
- // Cache the matrix values (speed optimization)984
- float a00 = matViewProj.m0, a01 = matViewProj.m1, a02 = matViewProj.m2, a03 = matViewProj.m3;985
- float a10 = matViewProj.m4, a11 = matViewProj.m5, a12 = matViewProj.m6, a13 = matViewProj.m7;986
- float a20 = matViewProj.m8, a21 = matViewProj.m9, a22 = matViewProj.m10, a23 = matViewProj.m11;987
- float a30 = matViewProj.m12, a31 = matViewProj.m13, a32 = matViewProj.m14, a33 = matViewProj.m15;988
-989
- float b00 = a00*a11 - a01*a10;990
- float b01 = a00*a12 - a02*a10;991
- float b02 = a00*a13 - a03*a10;992
- float b03 = a01*a12 - a02*a11;993
- float b04 = a01*a13 - a03*a11;994
- float b05 = a02*a13 - a03*a12;995
- float b06 = a20*a31 - a21*a30;996
- float b07 = a20*a32 - a22*a30;997
- float b08 = a20*a33 - a23*a30;998
- float b09 = a21*a32 - a22*a31;999
- float b10 = a21*a33 - a23*a31;1000
- float b11 = a22*a33 - a23*a32;1001
-1002
- // Calculate the invert determinant (inlined to avoid double-caching)1003
- float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06);1004
-1005
- Matrix matViewProjInv = {1006
- (a11*b11 - a12*b10 + a13*b09)*invDet,1007
- (-a01*b11 + a02*b10 - a03*b09)*invDet,1008
- (a31*b05 - a32*b04 + a33*b03)*invDet,1009
- (-a21*b05 + a22*b04 - a23*b03)*invDet,1010
- (-a10*b11 + a12*b08 - a13*b07)*invDet,1011
- (a00*b11 - a02*b08 + a03*b07)*invDet,1012
- (-a30*b05 + a32*b02 - a33*b01)*invDet,1013
- (a20*b05 - a22*b02 + a23*b01)*invDet,1014
- (a10*b10 - a11*b08 + a13*b06)*invDet,1015
- (-a00*b10 + a01*b08 - a03*b06)*invDet,1016
- (a30*b04 - a31*b02 + a33*b00)*invDet,1017
- (-a20*b04 + a21*b02 - a23*b00)*invDet,1018
- (-a10*b09 + a11*b07 - a12*b06)*invDet,1019
- (a00*b09 - a01*b07 + a02*b06)*invDet,1020
- (-a30*b03 + a31*b01 - a32*b00)*invDet,1021
- (a20*b03 - a21*b01 + a22*b00)*invDet };1022
-1023
- // Create quaternion from source point1024
- Quaternion quat = { source.x, source.y, source.z, 1.0f };1025
-1026
- // Multiply quat point by unprojecte matrix1027
- Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv)1028
- matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w,1029
- matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w,1030
- matViewProjInv.m2*quat.x + matViewProjInv.m6*quat.y + matViewProjInv.m10*quat.z + matViewProjInv.m14*quat.w,1031
- matViewProjInv.m3*quat.x + matViewProjInv.m7*quat.y + matViewProjInv.m11*quat.z + matViewProjInv.m15*quat.w };1032
-1033
- // Normalized world points in vectors1034
- result.x = qtransformed.x/qtransformed.w;1035
- result.y = qtransformed.y/qtransformed.w;1036
- result.z = qtransformed.z/qtransformed.w;1037
-1038
- return result;1039
-}1040
-1041
-// Get Vector3 as float array1042
-RMAPI float3 Vector3ToFloatV(Vector3 v)1043
-{1044
- float3 buffer = { 0 };1045
-1046
- buffer.v[0] = v.x;1047
- buffer.v[1] = v.y;1048
- buffer.v[2] = v.z;1049
-1050
- return buffer;1051
-}1052
-1053
-// Invert the given vector1054
-RMAPI Vector3 Vector3Invert(Vector3 v)1055
-{1056
- Vector3 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z };1057
-1058
- return result;1059
-}1060
-1061
-// Clamp the components of the vector between1062
-// min and max values specified by the given vectors1063
-RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max)1064
-{1065
- Vector3 result = { 0 };1066
-1067
- result.x = fminf(max.x, fmaxf(min.x, v.x));1068
- result.y = fminf(max.y, fmaxf(min.y, v.y));1069
- result.z = fminf(max.z, fmaxf(min.z, v.z));1070
-1071
- return result;1072
-}1073
-1074
-// Clamp the magnitude of the vector between two values1075
-RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)1076
-{1077
- Vector3 result = v;1078
-1079
- float length = (v.x*v.x) + (v.y*v.y) + (v.z*v.z);1080
- if (length > 0.0f)1081
- {1082
- length = sqrtf(length);1083
-1084
- float scale = 1; // By default, 1 as the neutral element.1085
- if (length < min)1086
- {1087
- scale = min/length;1088
- }1089
- else if (length > max)1090
- {1091
- scale = max/length;1092
- }1093
-1094
- result.x = v.x*scale;1095
- result.y = v.y*scale;1096
- result.z = v.z*scale;1097
- }1098
-1099
- return result;1100
-}1101
-1102
-// Check whether two given vectors are almost equal1103
-RMAPI int Vector3Equals(Vector3 p, Vector3 q)1104
-{1105
-#if !defined(EPSILON)1106
- #define EPSILON 0.000001f1107
-#endif1108
-1109
- int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&1110
- ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&1111
- ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z)))));1112
-1113
- return result;1114
-}1115
-1116
-// Compute the direction of a refracted ray1117
-// v: normalized direction of the incoming ray1118
-// n: normalized normal vector of the interface of two optical media1119
-// r: ratio of the refractive index of the medium from where the ray comes1120
-// to the refractive index of the medium on the other side of the surface1121
-RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r)1122
-{1123
- Vector3 result = { 0 };1124
-1125
- float dot = v.x*n.x + v.y*n.y + v.z*n.z;1126
- float d = 1.0f - r*r*(1.0f - dot*dot);1127
-1128
- if (d >= 0.0f)1129
- {1130
- d = sqrtf(d);1131
- v.x = r*v.x - (r*dot + d)*n.x;1132
- v.y = r*v.y - (r*dot + d)*n.y;1133
- v.z = r*v.z - (r*dot + d)*n.z;1134
-1135
- result = v;1136
- }1137
-1138
- return result;1139
-}1140
-1141
-//----------------------------------------------------------------------------------1142
-// Module Functions Definition - Matrix math1143
-//----------------------------------------------------------------------------------1144
-1145
-// Compute matrix determinant1146
-RMAPI float MatrixDeterminant(Matrix mat)1147
-{1148
- float result = 0.0f;1149
-1150
- // Cache the matrix values (speed optimization)1151
- float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;1152
- float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;1153
- float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;1154
- float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;1155
-1156
- result = a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 +1157
- a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 +1158
- a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 +1159
- a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 +1160
- a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 +1161
- a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33;1162
-1163
- return result;1164
-}1165
-1166
-// Get the trace of the matrix (sum of the values along the diagonal)1167
-RMAPI float MatrixTrace(Matrix mat)1168
-{1169
- float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15);1170
-1171
- return result;1172
-}1173
-1174
-// Transposes provided matrix1175
-RMAPI Matrix MatrixTranspose(Matrix mat)1176
-{1177
- Matrix result = { 0 };1178
-1179
- result.m0 = mat.m0;1180
- result.m1 = mat.m4;1181
- result.m2 = mat.m8;1182
- result.m3 = mat.m12;1183
- result.m4 = mat.m1;1184
- result.m5 = mat.m5;1185
- result.m6 = mat.m9;1186
- result.m7 = mat.m13;1187
- result.m8 = mat.m2;1188
- result.m9 = mat.m6;1189
- result.m10 = mat.m10;1190
- result.m11 = mat.m14;1191
- result.m12 = mat.m3;1192
- result.m13 = mat.m7;1193
- result.m14 = mat.m11;1194
- result.m15 = mat.m15;1195
-1196
- return result;1197
-}1198
-1199
-// Invert provided matrix1200
-RMAPI Matrix MatrixInvert(Matrix mat)1201
-{1202
- Matrix result = { 0 };1203
-1204
- // Cache the matrix values (speed optimization)1205
- float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;1206
- float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;1207
- float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;1208
- float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;1209
-1210
- float b00 = a00*a11 - a01*a10;1211
- float b01 = a00*a12 - a02*a10;1212
- float b02 = a00*a13 - a03*a10;1213
- float b03 = a01*a12 - a02*a11;1214
- float b04 = a01*a13 - a03*a11;1215
- float b05 = a02*a13 - a03*a12;1216
- float b06 = a20*a31 - a21*a30;1217
- float b07 = a20*a32 - a22*a30;1218
- float b08 = a20*a33 - a23*a30;1219
- float b09 = a21*a32 - a22*a31;1220
- float b10 = a21*a33 - a23*a31;1221
- float b11 = a22*a33 - a23*a32;1222
-1223
- // Calculate the invert determinant (inlined to avoid double-caching)1224
- float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06);1225
-1226
- result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet;1227
- result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet;1228
- result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet;1229
- result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet;1230
- result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet;1231
- result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet;1232
- result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet;1233
- result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet;1234
- result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet;1235
- result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet;1236
- result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet;1237
- result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet;1238
- result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet;1239
- result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet;1240
- result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet;1241
- result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet;1242
-1243
- return result;1244
-}1245
-1246
-// Get identity matrix1247
-RMAPI Matrix MatrixIdentity(void)1248
-{1249
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1250
- 0.0f, 1.0f, 0.0f, 0.0f,1251
- 0.0f, 0.0f, 1.0f, 0.0f,1252
- 0.0f, 0.0f, 0.0f, 1.0f };1253
-1254
- return result;1255
-}1256
-1257
-// Add two matrices1258
-RMAPI Matrix MatrixAdd(Matrix left, Matrix right)1259
-{1260
- Matrix result = { 0 };1261
-1262
- result.m0 = left.m0 + right.m0;1263
- result.m1 = left.m1 + right.m1;1264
- result.m2 = left.m2 + right.m2;1265
- result.m3 = left.m3 + right.m3;1266
- result.m4 = left.m4 + right.m4;1267
- result.m5 = left.m5 + right.m5;1268
- result.m6 = left.m6 + right.m6;1269
- result.m7 = left.m7 + right.m7;1270
- result.m8 = left.m8 + right.m8;1271
- result.m9 = left.m9 + right.m9;1272
- result.m10 = left.m10 + right.m10;1273
- result.m11 = left.m11 + right.m11;1274
- result.m12 = left.m12 + right.m12;1275
- result.m13 = left.m13 + right.m13;1276
- result.m14 = left.m14 + right.m14;1277
- result.m15 = left.m15 + right.m15;1278
-1279
- return result;1280
-}1281
-1282
-// Subtract two matrices (left - right)1283
-RMAPI Matrix MatrixSubtract(Matrix left, Matrix right)1284
-{1285
- Matrix result = { 0 };1286
-1287
- result.m0 = left.m0 - right.m0;1288
- result.m1 = left.m1 - right.m1;1289
- result.m2 = left.m2 - right.m2;1290
- result.m3 = left.m3 - right.m3;1291
- result.m4 = left.m4 - right.m4;1292
- result.m5 = left.m5 - right.m5;1293
- result.m6 = left.m6 - right.m6;1294
- result.m7 = left.m7 - right.m7;1295
- result.m8 = left.m8 - right.m8;1296
- result.m9 = left.m9 - right.m9;1297
- result.m10 = left.m10 - right.m10;1298
- result.m11 = left.m11 - right.m11;1299
- result.m12 = left.m12 - right.m12;1300
- result.m13 = left.m13 - right.m13;1301
- result.m14 = left.m14 - right.m14;1302
- result.m15 = left.m15 - right.m15;1303
-1304
- return result;1305
-}1306
-1307
-// Get two matrix multiplication1308
-// NOTE: When multiplying matrices... the order matters!1309
-RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)1310
-{1311
- Matrix result = { 0 };1312
-1313
- result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12;1314
- result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13;1315
- result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14;1316
- result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15;1317
- result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12;1318
- result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13;1319
- result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14;1320
- result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15;1321
- result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12;1322
- result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13;1323
- result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14;1324
- result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15;1325
- result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12;1326
- result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13;1327
- result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14;1328
- result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15;1329
-1330
- return result;1331
-}1332
-1333
-// Get translation matrix1334
-RMAPI Matrix MatrixTranslate(float x, float y, float z)1335
-{1336
- Matrix result = { 1.0f, 0.0f, 0.0f, x,1337
- 0.0f, 1.0f, 0.0f, y,1338
- 0.0f, 0.0f, 1.0f, z,1339
- 0.0f, 0.0f, 0.0f, 1.0f };1340
-1341
- return result;1342
-}1343
-1344
-// Create rotation matrix from axis and angle1345
-// NOTE: Angle should be provided in radians1346
-RMAPI Matrix MatrixRotate(Vector3 axis, float angle)1347
-{1348
- Matrix result = { 0 };1349
-1350
- float x = axis.x, y = axis.y, z = axis.z;1351
-1352
- float lengthSquared = x*x + y*y + z*z;1353
-1354
- if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f))1355
- {1356
- float ilength = 1.0f/sqrtf(lengthSquared);1357
- x *= ilength;1358
- y *= ilength;1359
- z *= ilength;1360
- }1361
-1362
- float sinres = sinf(angle);1363
- float cosres = cosf(angle);1364
- float t = 1.0f - cosres;1365
-1366
- result.m0 = x*x*t + cosres;1367
- result.m1 = y*x*t + z*sinres;1368
- result.m2 = z*x*t - y*sinres;1369
- result.m3 = 0.0f;1370
-1371
- result.m4 = x*y*t - z*sinres;1372
- result.m5 = y*y*t + cosres;1373
- result.m6 = z*y*t + x*sinres;1374
- result.m7 = 0.0f;1375
-1376
- result.m8 = x*z*t + y*sinres;1377
- result.m9 = y*z*t - x*sinres;1378
- result.m10 = z*z*t + cosres;1379
- result.m11 = 0.0f;1380
-1381
- result.m12 = 0.0f;1382
- result.m13 = 0.0f;1383
- result.m14 = 0.0f;1384
- result.m15 = 1.0f;1385
-1386
- return result;1387
-}1388
-1389
-// Get x-rotation matrix1390
-// NOTE: Angle must be provided in radians1391
-RMAPI Matrix MatrixRotateX(float angle)1392
-{1393
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1394
- 0.0f, 1.0f, 0.0f, 0.0f,1395
- 0.0f, 0.0f, 1.0f, 0.0f,1396
- 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1397
-1398
- float cosres = cosf(angle);1399
- float sinres = sinf(angle);1400
-1401
- result.m5 = cosres;1402
- result.m6 = sinres;1403
- result.m9 = -sinres;1404
- result.m10 = cosres;1405
-1406
- return result;1407
-}1408
-1409
-// Get y-rotation matrix1410
-// NOTE: Angle must be provided in radians1411
-RMAPI Matrix MatrixRotateY(float angle)1412
-{1413
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1414
- 0.0f, 1.0f, 0.0f, 0.0f,1415
- 0.0f, 0.0f, 1.0f, 0.0f,1416
- 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1417
-1418
- float cosres = cosf(angle);1419
- float sinres = sinf(angle);1420
-1421
- result.m0 = cosres;1422
- result.m2 = -sinres;1423
- result.m8 = sinres;1424
- result.m10 = cosres;1425
-1426
- return result;1427
-}1428
-1429
-// Get z-rotation matrix1430
-// NOTE: Angle must be provided in radians1431
-RMAPI Matrix MatrixRotateZ(float angle)1432
-{1433
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1434
- 0.0f, 1.0f, 0.0f, 0.0f,1435
- 0.0f, 0.0f, 1.0f, 0.0f,1436
- 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1437
-1438
- float cosres = cosf(angle);1439
- float sinres = sinf(angle);1440
-1441
- result.m0 = cosres;1442
- result.m1 = sinres;1443
- result.m4 = -sinres;1444
- result.m5 = cosres;1445
-1446
- return result;1447
-}1448
-1449
-1450
-// Get xyz-rotation matrix1451
-// NOTE: Angle must be provided in radians1452
-RMAPI Matrix MatrixRotateXYZ(Vector3 angle)1453
-{1454
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,1455
- 0.0f, 1.0f, 0.0f, 0.0f,1456
- 0.0f, 0.0f, 1.0f, 0.0f,1457
- 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()1458
-1459
- float cosz = cosf(-angle.z);1460
- float sinz = sinf(-angle.z);1461
- float cosy = cosf(-angle.y);1462
- float siny = sinf(-angle.y);1463
- float cosx = cosf(-angle.x);1464
- float sinx = sinf(-angle.x);1465
-1466
- result.m0 = cosz*cosy;1467
- result.m1 = (cosz*siny*sinx) - (sinz*cosx);1468
- result.m2 = (cosz*siny*cosx) + (sinz*sinx);1469
-1470
- result.m4 = sinz*cosy;1471
- result.m5 = (sinz*siny*sinx) + (cosz*cosx);1472
- result.m6 = (sinz*siny*cosx) - (cosz*sinx);1473
-1474
- result.m8 = -siny;1475
- result.m9 = cosy*sinx;1476
- result.m10= cosy*cosx;1477
-1478
- return result;1479
-}1480
-1481
-// Get zyx-rotation matrix1482
-// NOTE: Angle must be provided in radians1483
-RMAPI Matrix MatrixRotateZYX(Vector3 angle)1484
-{1485
- Matrix result = { 0 };1486
-1487
- float cz = cosf(angle.z);1488
- float sz = sinf(angle.z);1489
- float cy = cosf(angle.y);1490
- float sy = sinf(angle.y);1491
- float cx = cosf(angle.x);1492
- float sx = sinf(angle.x);1493
-1494
- result.m0 = cz*cy;1495
- result.m4 = cz*sy*sx - cx*sz;1496
- result.m8 = sz*sx + cz*cx*sy;1497
- result.m12 = 0;1498
-1499
- result.m1 = cy*sz;1500
- result.m5 = cz*cx + sz*sy*sx;1501
- result.m9 = cx*sz*sy - cz*sx;1502
- result.m13 = 0;1503
-1504
- result.m2 = -sy;1505
- result.m6 = cy*sx;1506
- result.m10 = cy*cx;1507
- result.m14 = 0;1508
-1509
- result.m3 = 0;1510
- result.m7 = 0;1511
- result.m11 = 0;1512
- result.m15 = 1;1513
-1514
- return result;1515
-}1516
-1517
-// Get scaling matrix1518
-RMAPI Matrix MatrixScale(float x, float y, float z)1519
-{1520
- Matrix result = { x, 0.0f, 0.0f, 0.0f,1521
- 0.0f, y, 0.0f, 0.0f,1522
- 0.0f, 0.0f, z, 0.0f,1523
- 0.0f, 0.0f, 0.0f, 1.0f };1524
-1525
- return result;1526
-}1527
-1528
-// Get perspective projection matrix1529
-RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)1530
-{1531
- Matrix result = { 0 };1532
-1533
- float rl = (float)(right - left);1534
- float tb = (float)(top - bottom);1535
- float fn = (float)(far - near);1536
-1537
- result.m0 = ((float)near*2.0f)/rl;1538
- result.m1 = 0.0f;1539
- result.m2 = 0.0f;1540
- result.m3 = 0.0f;1541
-1542
- result.m4 = 0.0f;1543
- result.m5 = ((float)near*2.0f)/tb;1544
- result.m6 = 0.0f;1545
- result.m7 = 0.0f;1546
-1547
- result.m8 = ((float)right + (float)left)/rl;1548
- result.m9 = ((float)top + (float)bottom)/tb;1549
- result.m10 = -((float)far + (float)near)/fn;1550
- result.m11 = -1.0f;1551
-1552
- result.m12 = 0.0f;1553
- result.m13 = 0.0f;1554
- result.m14 = -((float)far*(float)near*2.0f)/fn;1555
- result.m15 = 0.0f;1556
-1557
- return result;1558
-}1559
-1560
-// Get perspective projection matrix1561
-// NOTE: Fovy angle must be provided in radians1562
-RMAPI Matrix MatrixPerspective(double fovY, double aspect, double nearPlane, double farPlane)1563
-{1564
- Matrix result = { 0 };1565
-1566
- double top = nearPlane*tan(fovY*0.5);1567
- double bottom = -top;1568
- double right = top*aspect;1569
- double left = -right;1570
-1571
- // MatrixFrustum(-right, right, -top, top, near, far);1572
- float rl = (float)(right - left);1573
- float tb = (float)(top - bottom);1574
- float fn = (float)(farPlane - nearPlane);1575
-1576
- result.m0 = ((float)nearPlane*2.0f)/rl;1577
- result.m5 = ((float)nearPlane*2.0f)/tb;1578
- result.m8 = ((float)right + (float)left)/rl;1579
- result.m9 = ((float)top + (float)bottom)/tb;1580
- result.m10 = -((float)farPlane + (float)nearPlane)/fn;1581
- result.m11 = -1.0f;1582
- result.m14 = -((float)farPlane*(float)nearPlane*2.0f)/fn;1583
-1584
- return result;1585
-}1586
-1587
-// Get orthographic projection matrix1588
-RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double nearPlane, double farPlane)1589
-{1590
- Matrix result = { 0 };1591
-1592
- float rl = (float)(right - left);1593
- float tb = (float)(top - bottom);1594
- float fn = (float)(farPlane - nearPlane);1595
-1596
- result.m0 = 2.0f/rl;1597
- result.m1 = 0.0f;1598
- result.m2 = 0.0f;1599
- result.m3 = 0.0f;1600
- result.m4 = 0.0f;1601
- result.m5 = 2.0f/tb;1602
- result.m6 = 0.0f;1603
- result.m7 = 0.0f;1604
- result.m8 = 0.0f;1605
- result.m9 = 0.0f;1606
- result.m10 = -2.0f/fn;1607
- result.m11 = 0.0f;1608
- result.m12 = -((float)left + (float)right)/rl;1609
- result.m13 = -((float)top + (float)bottom)/tb;1610
- result.m14 = -((float)farPlane + (float)nearPlane)/fn;1611
- result.m15 = 1.0f;1612
-1613
- return result;1614
-}1615
-1616
-// Get camera look-at matrix (view matrix)1617
-RMAPI Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)1618
-{1619
- Matrix result = { 0 };1620
-1621
- float length = 0.0f;1622
- float ilength = 0.0f;1623
-1624
- // Vector3Subtract(eye, target)1625
- Vector3 vz = { eye.x - target.x, eye.y - target.y, eye.z - target.z };1626
-1627
- // Vector3Normalize(vz)1628
- Vector3 v = vz;1629
- length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);1630
- if (length == 0.0f) length = 1.0f;1631
- ilength = 1.0f/length;1632
- vz.x *= ilength;1633
- vz.y *= ilength;1634
- vz.z *= ilength;1635
-1636
- // Vector3CrossProduct(up, vz)1637
- Vector3 vx = { up.y*vz.z - up.z*vz.y, up.z*vz.x - up.x*vz.z, up.x*vz.y - up.y*vz.x };1638
-1639
- // Vector3Normalize(x)1640
- v = vx;1641
- length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);1642
- if (length == 0.0f) length = 1.0f;1643
- ilength = 1.0f/length;1644
- vx.x *= ilength;1645
- vx.y *= ilength;1646
- vx.z *= ilength;1647
-1648
- // Vector3CrossProduct(vz, vx)1649
- Vector3 vy = { vz.y*vx.z - vz.z*vx.y, vz.z*vx.x - vz.x*vx.z, vz.x*vx.y - vz.y*vx.x };1650
-1651
- result.m0 = vx.x;1652
- result.m1 = vy.x;1653
- result.m2 = vz.x;1654
- result.m3 = 0.0f;1655
- result.m4 = vx.y;1656
- result.m5 = vy.y;1657
- result.m6 = vz.y;1658
- result.m7 = 0.0f;1659
- result.m8 = vx.z;1660
- result.m9 = vy.z;1661
- result.m10 = vz.z;1662
- result.m11 = 0.0f;1663
- result.m12 = -(vx.x*eye.x + vx.y*eye.y + vx.z*eye.z); // Vector3DotProduct(vx, eye)1664
- result.m13 = -(vy.x*eye.x + vy.y*eye.y + vy.z*eye.z); // Vector3DotProduct(vy, eye)1665
- result.m14 = -(vz.x*eye.x + vz.y*eye.y + vz.z*eye.z); // Vector3DotProduct(vz, eye)1666
- result.m15 = 1.0f;1667
-1668
- return result;1669
-}1670
-1671
-// Get float array of matrix data1672
-RMAPI float16 MatrixToFloatV(Matrix mat)1673
-{1674
- float16 result = { 0 };1675
-1676
- result.v[0] = mat.m0;1677
- result.v[1] = mat.m1;1678
- result.v[2] = mat.m2;1679
- result.v[3] = mat.m3;1680
- result.v[4] = mat.m4;1681
- result.v[5] = mat.m5;1682
- result.v[6] = mat.m6;1683
- result.v[7] = mat.m7;1684
- result.v[8] = mat.m8;1685
- result.v[9] = mat.m9;1686
- result.v[10] = mat.m10;1687
- result.v[11] = mat.m11;1688
- result.v[12] = mat.m12;1689
- result.v[13] = mat.m13;1690
- result.v[14] = mat.m14;1691
- result.v[15] = mat.m15;1692
-1693
- return result;1694
-}1695
-1696
-//----------------------------------------------------------------------------------1697
-// Module Functions Definition - Quaternion math1698
-//----------------------------------------------------------------------------------1699
-1700
-// Add two quaternions1701
-RMAPI Quaternion QuaternionAdd(Quaternion q1, Quaternion q2)1702
-{1703
- Quaternion result = {q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w};1704
-1705
- return result;1706
-}1707
-1708
-// Add quaternion and float value1709
-RMAPI Quaternion QuaternionAddValue(Quaternion q, float add)1710
-{1711
- Quaternion result = {q.x + add, q.y + add, q.z + add, q.w + add};1712
-1713
- return result;1714
-}1715
-1716
-// Subtract two quaternions1717
-RMAPI Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2)1718
-{1719
- Quaternion result = {q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w};1720
-1721
- return result;1722
-}1723
-1724
-// Subtract quaternion and float value1725
-RMAPI Quaternion QuaternionSubtractValue(Quaternion q, float sub)1726
-{1727
- Quaternion result = {q.x - sub, q.y - sub, q.z - sub, q.w - sub};1728
-1729
- return result;1730
-}1731
-1732
-// Get identity quaternion1733
-RMAPI Quaternion QuaternionIdentity(void)1734
-{1735
- Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };1736
-1737
- return result;1738
-}1739
-1740
-// Computes the length of a quaternion1741
-RMAPI float QuaternionLength(Quaternion q)1742
-{1743
- float result = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1744
-1745
- return result;1746
-}1747
-1748
-// Normalize provided quaternion1749
-RMAPI Quaternion QuaternionNormalize(Quaternion q)1750
-{1751
- Quaternion result = { 0 };1752
-1753
- float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1754
- if (length == 0.0f) length = 1.0f;1755
- float ilength = 1.0f/length;1756
-1757
- result.x = q.x*ilength;1758
- result.y = q.y*ilength;1759
- result.z = q.z*ilength;1760
- result.w = q.w*ilength;1761
-1762
- return result;1763
-}1764
-1765
-// Invert provided quaternion1766
-RMAPI Quaternion QuaternionInvert(Quaternion q)1767
-{1768
- Quaternion result = q;1769
-1770
- float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;1771
-1772
- if (lengthSq != 0.0f)1773
- {1774
- float invLength = 1.0f/lengthSq;1775
-1776
- result.x *= -invLength;1777
- result.y *= -invLength;1778
- result.z *= -invLength;1779
- result.w *= invLength;1780
- }1781
-1782
- return result;1783
-}1784
-1785
-// Calculate two quaternion multiplication1786
-RMAPI Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2)1787
-{1788
- Quaternion result = { 0 };1789
-1790
- float qax = q1.x, qay = q1.y, qaz = q1.z, qaw = q1.w;1791
- float qbx = q2.x, qby = q2.y, qbz = q2.z, qbw = q2.w;1792
-1793
- result.x = qax*qbw + qaw*qbx + qay*qbz - qaz*qby;1794
- result.y = qay*qbw + qaw*qby + qaz*qbx - qax*qbz;1795
- result.z = qaz*qbw + qaw*qbz + qax*qby - qay*qbx;1796
- result.w = qaw*qbw - qax*qbx - qay*qby - qaz*qbz;1797
-1798
- return result;1799
-}1800
-1801
-// Scale quaternion by float value1802
-RMAPI Quaternion QuaternionScale(Quaternion q, float mul)1803
-{1804
- Quaternion result = { 0 };1805
-1806
- result.x = q.x*mul;1807
- result.y = q.y*mul;1808
- result.z = q.z*mul;1809
- result.w = q.w*mul;1810
-1811
- return result;1812
-}1813
-1814
-// Divide two quaternions1815
-RMAPI Quaternion QuaternionDivide(Quaternion q1, Quaternion q2)1816
-{1817
- Quaternion result = { q1.x/q2.x, q1.y/q2.y, q1.z/q2.z, q1.w/q2.w };1818
-1819
- return result;1820
-}1821
-1822
-// Calculate linear interpolation between two quaternions1823
-RMAPI Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)1824
-{1825
- Quaternion result = { 0 };1826
-1827
- result.x = q1.x + amount*(q2.x - q1.x);1828
- result.y = q1.y + amount*(q2.y - q1.y);1829
- result.z = q1.z + amount*(q2.z - q1.z);1830
- result.w = q1.w + amount*(q2.w - q1.w);1831
-1832
- return result;1833
-}1834
-1835
-// Calculate slerp-optimized interpolation between two quaternions1836
-RMAPI Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)1837
-{1838
- Quaternion result = { 0 };1839
-1840
- // QuaternionLerp(q1, q2, amount)1841
- result.x = q1.x + amount*(q2.x - q1.x);1842
- result.y = q1.y + amount*(q2.y - q1.y);1843
- result.z = q1.z + amount*(q2.z - q1.z);1844
- result.w = q1.w + amount*(q2.w - q1.w);1845
-1846
- // QuaternionNormalize(q);1847
- Quaternion q = result;1848
- float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1849
- if (length == 0.0f) length = 1.0f;1850
- float ilength = 1.0f/length;1851
-1852
- result.x = q.x*ilength;1853
- result.y = q.y*ilength;1854
- result.z = q.z*ilength;1855
- result.w = q.w*ilength;1856
-1857
- return result;1858
-}1859
-1860
-// Calculates spherical linear interpolation between two quaternions1861
-RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)1862
-{1863
- Quaternion result = { 0 };1864
-1865
-#if !defined(EPSILON)1866
- #define EPSILON 0.000001f1867
-#endif1868
-1869
- float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w;1870
-1871
- if (cosHalfTheta < 0)1872
- {1873
- q2.x = -q2.x; q2.y = -q2.y; q2.z = -q2.z; q2.w = -q2.w;1874
- cosHalfTheta = -cosHalfTheta;1875
- }1876
-1877
- if (fabsf(cosHalfTheta) >= 1.0f) result = q1;1878
- else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);1879
- else1880
- {1881
- float halfTheta = acosf(cosHalfTheta);1882
- float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta);1883
-1884
- if (fabsf(sinHalfTheta) < EPSILON)1885
- {1886
- result.x = (q1.x*0.5f + q2.x*0.5f);1887
- result.y = (q1.y*0.5f + q2.y*0.5f);1888
- result.z = (q1.z*0.5f + q2.z*0.5f);1889
- result.w = (q1.w*0.5f + q2.w*0.5f);1890
- }1891
- else1892
- {1893
- float ratioA = sinf((1 - amount)*halfTheta)/sinHalfTheta;1894
- float ratioB = sinf(amount*halfTheta)/sinHalfTheta;1895
-1896
- result.x = (q1.x*ratioA + q2.x*ratioB);1897
- result.y = (q1.y*ratioA + q2.y*ratioB);1898
- result.z = (q1.z*ratioA + q2.z*ratioB);1899
- result.w = (q1.w*ratioA + q2.w*ratioB);1900
- }1901
- }1902
-1903
- return result;1904
-}1905
-1906
-// Calculate quaternion based on the rotation from one vector to another1907
-RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)1908
-{1909
- Quaternion result = { 0 };1910
-1911
- float cos2Theta = (from.x*to.x + from.y*to.y + from.z*to.z); // Vector3DotProduct(from, to)1912
- Vector3 cross = { from.y*to.z - from.z*to.y, from.z*to.x - from.x*to.z, from.x*to.y - from.y*to.x }; // Vector3CrossProduct(from, to)1913
-1914
- result.x = cross.x;1915
- result.y = cross.y;1916
- result.z = cross.z;1917
- result.w = 1.0f + cos2Theta;1918
-1919
- // QuaternionNormalize(q);1920
- // NOTE: Normalize to essentially nlerp the original and identity to 0.51921
- Quaternion q = result;1922
- float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);1923
- if (length == 0.0f) length = 1.0f;1924
- float ilength = 1.0f/length;1925
-1926
- result.x = q.x*ilength;1927
- result.y = q.y*ilength;1928
- result.z = q.z*ilength;1929
- result.w = q.w*ilength;1930
-1931
- return result;1932
-}1933
-1934
-// Get a quaternion for a given rotation matrix1935
-RMAPI Quaternion QuaternionFromMatrix(Matrix mat)1936
-{1937
- Quaternion result = { 0 };1938
-1939
- float fourWSquaredMinus1 = mat.m0 + mat.m5 + mat.m10;1940
- float fourXSquaredMinus1 = mat.m0 - mat.m5 - mat.m10;1941
- float fourYSquaredMinus1 = mat.m5 - mat.m0 - mat.m10;1942
- float fourZSquaredMinus1 = mat.m10 - mat.m0 - mat.m5;1943
-1944
- int biggestIndex = 0;1945
- float fourBiggestSquaredMinus1 = fourWSquaredMinus1;1946
- if (fourXSquaredMinus1 > fourBiggestSquaredMinus1)1947
- {1948
- fourBiggestSquaredMinus1 = fourXSquaredMinus1;1949
- biggestIndex = 1;1950
- }1951
-1952
- if (fourYSquaredMinus1 > fourBiggestSquaredMinus1)1953
- {1954
- fourBiggestSquaredMinus1 = fourYSquaredMinus1;1955
- biggestIndex = 2;1956
- }1957
-1958
- if (fourZSquaredMinus1 > fourBiggestSquaredMinus1)1959
- {1960
- fourBiggestSquaredMinus1 = fourZSquaredMinus1;1961
- biggestIndex = 3;1962
- }1963
-1964
- float biggestVal = sqrtf(fourBiggestSquaredMinus1 + 1.0f)*0.5f;1965
- float mult = 0.25f/biggestVal;1966
-1967
- switch (biggestIndex)1968
- {1969
- case 0:1970
- result.w = biggestVal;1971
- result.x = (mat.m6 - mat.m9)*mult;1972
- result.y = (mat.m8 - mat.m2)*mult;1973
- result.z = (mat.m1 - mat.m4)*mult;1974
- break;1975
- case 1:1976
- result.x = biggestVal;1977
- result.w = (mat.m6 - mat.m9)*mult;1978
- result.y = (mat.m1 + mat.m4)*mult;1979
- result.z = (mat.m8 + mat.m2)*mult;1980
- break;1981
- case 2:1982
- result.y = biggestVal;1983
- result.w = (mat.m8 - mat.m2)*mult;1984
- result.x = (mat.m1 + mat.m4)*mult;1985
- result.z = (mat.m6 + mat.m9)*mult;1986
- break;1987
- case 3:1988
- result.z = biggestVal;1989
- result.w = (mat.m1 - mat.m4)*mult;1990
- result.x = (mat.m8 + mat.m2)*mult;1991
- result.y = (mat.m6 + mat.m9)*mult;1992
- break;1993
- }1994
-1995
- return result;1996
-}1997
-1998
-// Get a matrix for a given quaternion1999
-RMAPI Matrix QuaternionToMatrix(Quaternion q)2000
-{2001
- Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,2002
- 0.0f, 1.0f, 0.0f, 0.0f,2003
- 0.0f, 0.0f, 1.0f, 0.0f,2004
- 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()2005
-2006
- float a2 = q.x*q.x;2007
- float b2 = q.y*q.y;2008
- float c2 = q.z*q.z;2009
- float ac = q.x*q.z;2010
- float ab = q.x*q.y;2011
- float bc = q.y*q.z;2012
- float ad = q.w*q.x;2013
- float bd = q.w*q.y;2014
- float cd = q.w*q.z;2015
-2016
- result.m0 = 1 - 2*(b2 + c2);2017
- result.m1 = 2*(ab + cd);2018
- result.m2 = 2*(ac - bd);2019
-2020
- result.m4 = 2*(ab - cd);2021
- result.m5 = 1 - 2*(a2 + c2);2022
- result.m6 = 2*(bc + ad);2023
-2024
- result.m8 = 2*(ac + bd);2025
- result.m9 = 2*(bc - ad);2026
- result.m10 = 1 - 2*(a2 + b2);2027
-2028
- return result;2029
-}2030
-2031
-// Get rotation quaternion for an angle and axis2032
-// NOTE: Angle must be provided in radians2033
-RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)2034
-{2035
- Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };2036
-2037
- float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);2038
-2039
- if (axisLength != 0.0f)2040
- {2041
- angle *= 0.5f;2042
-2043
- float length = 0.0f;2044
- float ilength = 0.0f;2045
-2046
- // Vector3Normalize(axis)2047
- Vector3 v = axis;2048
- length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);2049
- if (length == 0.0f) length = 1.0f;2050
- ilength = 1.0f/length;2051
- axis.x *= ilength;2052
- axis.y *= ilength;2053
- axis.z *= ilength;2054
-2055
- float sinres = sinf(angle);2056
- float cosres = cosf(angle);2057
-2058
- result.x = axis.x*sinres;2059
- result.y = axis.y*sinres;2060
- result.z = axis.z*sinres;2061
- result.w = cosres;2062
-2063
- // QuaternionNormalize(q);2064
- Quaternion q = result;2065
- length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);2066
- if (length == 0.0f) length = 1.0f;2067
- ilength = 1.0f/length;2068
- result.x = q.x*ilength;2069
- result.y = q.y*ilength;2070
- result.z = q.z*ilength;2071
- result.w = q.w*ilength;2072
- }2073
-2074
- return result;2075
-}2076
-2077
-// Get the rotation angle and axis for a given quaternion2078
-RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)2079
-{2080
- if (fabsf(q.w) > 1.0f)2081
- {2082
- // QuaternionNormalize(q);2083
- float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);2084
- if (length == 0.0f) length = 1.0f;2085
- float ilength = 1.0f/length;2086
-2087
- q.x = q.x*ilength;2088
- q.y = q.y*ilength;2089
- q.z = q.z*ilength;2090
- q.w = q.w*ilength;2091
- }2092
-2093
- Vector3 resAxis = { 0.0f, 0.0f, 0.0f };2094
- float resAngle = 2.0f*acosf(q.w);2095
- float den = sqrtf(1.0f - q.w*q.w);2096
-2097
- if (den > EPSILON)2098
- {2099
- resAxis.x = q.x/den;2100
- resAxis.y = q.y/den;2101
- resAxis.z = q.z/den;2102
- }2103
- else2104
- {2105
- // This occurs when the angle is zero.2106
- // Not a problem: just set an arbitrary normalized axis.2107
- resAxis.x = 1.0f;2108
- }2109
-2110
- *outAxis = resAxis;2111
- *outAngle = resAngle;2112
-}2113
-2114
-// Get the quaternion equivalent to Euler angles2115
-// NOTE: Rotation order is ZYX2116
-RMAPI Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)2117
-{2118
- Quaternion result = { 0 };2119
-2120
- float x0 = cosf(pitch*0.5f);2121
- float x1 = sinf(pitch*0.5f);2122
- float y0 = cosf(yaw*0.5f);2123
- float y1 = sinf(yaw*0.5f);2124
- float z0 = cosf(roll*0.5f);2125
- float z1 = sinf(roll*0.5f);2126
-2127
- result.x = x1*y0*z0 - x0*y1*z1;2128
- result.y = x0*y1*z0 + x1*y0*z1;2129
- result.z = x0*y0*z1 - x1*y1*z0;2130
- result.w = x0*y0*z0 + x1*y1*z1;2131
-2132
- return result;2133
-}2134
-2135
-// Get the Euler angles equivalent to quaternion (roll, pitch, yaw)2136
-// NOTE: Angles are returned in a Vector3 struct in radians2137
-RMAPI Vector3 QuaternionToEuler(Quaternion q)2138
-{2139
- Vector3 result = { 0 };2140
-2141
- // Roll (x-axis rotation)2142
- float x0 = 2.0f*(q.w*q.x + q.y*q.z);2143
- float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y);2144
- result.x = atan2f(x0, x1);2145
-2146
- // Pitch (y-axis rotation)2147
- float y0 = 2.0f*(q.w*q.y - q.z*q.x);2148
- y0 = y0 > 1.0f ? 1.0f : y0;2149
- y0 = y0 < -1.0f ? -1.0f : y0;2150
- result.y = asinf(y0);2151
-2152
- // Yaw (z-axis rotation)2153
- float z0 = 2.0f*(q.w*q.z + q.x*q.y);2154
- float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z);2155
- result.z = atan2f(z0, z1);2156
-2157
- return result;2158
-}2159
-2160
-// Transform a quaternion given a transformation matrix2161
-RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat)2162
-{2163
- Quaternion result = { 0 };2164
-2165
- result.x = mat.m0*q.x + mat.m4*q.y + mat.m8*q.z + mat.m12*q.w;2166
- result.y = mat.m1*q.x + mat.m5*q.y + mat.m9*q.z + mat.m13*q.w;2167
- result.z = mat.m2*q.x + mat.m6*q.y + mat.m10*q.z + mat.m14*q.w;2168
- result.w = mat.m3*q.x + mat.m7*q.y + mat.m11*q.z + mat.m15*q.w;2169
-2170
- return result;2171
-}2172
-2173
-// Check whether two given quaternions are almost equal2174
-RMAPI int QuaternionEquals(Quaternion p, Quaternion q)2175
-{2176
-#if !defined(EPSILON)2177
- #define EPSILON 0.000001f2178
-#endif2179
-2180
- int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&2181
- ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&2182
- ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&2183
- ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) ||2184
- (((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&2185
- ((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&2186
- ((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&2187
- ((fabsf(p.w + q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w))))));2188
-2189
- return result;2190
-}2191
-2192
-#endif // RAYMATH_H
diff --git a/src/main.c b/src/main.c
index fb6de3a..6f0d221 100644
--- a/src/main.c
+++ b/src/main.c
1
@@ -1,13 +1,17 @@2
#include <stdio.h>3
#include <stdlib.h>4
#include <signal.h>5
-#include <execinfo.h>6
#include <unistd.h>7
#include <time.h>9
-#include "game.h"10
-#include "const.h"11
-#include "libs/raylib.h"12
+#include "../include/game.h"13
+#include "../include/const.h"14
+#include "../lib/raylib.h"15
+16
+#if defined(PLATFORM_WEB)17
+ #include <emscripten/emscripten.h>18
+#else19
+#include <execinfo.h>21
void handle_segfault(int signal) {22
void *list[10];23
@@ -16,24 +20,35 @@ void handle_segfault(int signal) {24
backtrace_symbols_fd(list, size, STDERR_FILENO);25
exit(1);26
}27
+#endif28
+29
+game_t *game = NULL;30
+31
+void do_update(void) {32
+ game_update(game);33
+ game_draw(game);34
+}36
int main(void) {37
printf("PID: %d\n", getpid());38
time_t t;39
srand((unsigned) time(&t));40
- struct sigaction sigint_action;41
- sigint_action.sa_handler = handle_segfault;42
- sigint_action.sa_flags = 0;43
- sigemptyset(&sigint_action.sa_mask);44
- sigaction(SIGSEGV, &sigint_action, NULL);45
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Freezo");46
- game_t *game = game_create();47
+ game = game_create();48
SetTargetFPS(60);49
SetExitKey(0);50
- while (!game->quit && !WindowShouldClose()) {51
- game_update(game);52
- game_draw(game);53
- }54
+ #if defined(PLATFORM_WEB)55
+ emscripten_set_main_loop(do_update, 0, 1);56
+ #else57
+ struct sigaction sigint_action;58
+ sigint_action.sa_handler = handle_segfault;59
+ sigint_action.sa_flags = 0;60
+ sigemptyset(&sigint_action.sa_mask);61
+ sigaction(SIGSEGV, &sigint_action, NULL);62
+ while (!game->quit && !WindowShouldClose()) {63
+ do_update();64
+ }65
+ #endif66
CloseWindow();67
game_free(game);68
return 0;
diff --git a/src/menu.c b/src/menu.c
index 7217dd3..09f6716 100644
--- a/src/menu.c
+++ b/src/menu.c
1
@@ -1,11 +1,11 @@2
#include <stdlib.h>4
-#include "libs/raylib.h"5
-#include "menu.h"6
-#include "util.h"7
-#include "const.h"8
-#include "game.h"9
-#include "level.h"10
+#include "../lib/raylib.h"11
+#include "../include/menu.h"12
+#include "../include/util.h"13
+#include "../include/const.h"14
+#include "../include/game.h"15
+#include "../include/level.h"17
menu_t *menu_create(void) {18
menu_t *menu = malloc(sizeof(menu_t));19
@@ -16,6 +16,9 @@ menu_t *menu_create(void) {20
void menu_update(menu_t *menu, game_t *game) {21
UNUSED(menu);22
UNUSED(game);23
+ if (IsKeyPressed(KEY_ESCAPE)) {24
+ game->state = STATE_GAME;25
+ }26
if (IsKeyPressed(KEY_W)) {27
if (menu->idx > 0) {28
menu->idx--;
diff --git a/src/menu.h b/src/menu.h
deleted file mode 100644
index cd4cbb9..0000000
--- a/src/menu.h
+++ /dev/null
1
@@ -1,14 +0,0 @@2
-#pragma once3
-4
-typedef struct Menu menu_t;5
-6
-#include "game.h"7
-8
-struct Menu {9
- int idx;10
-};11
-12
-menu_t *menu_create(void);13
-void menu_update(menu_t *menu, game_t *game);14
-void menu_draw(menu_t *menu, game_t *game);15
-void menu_free(menu_t *menu);
diff --git a/src/player.c b/src/player.c
index 4391c9f..08b38f2 100644
--- a/src/player.c
+++ b/src/player.c
1
@@ -1,12 +1,12 @@2
#include <stdlib.h>3
#include <math.h>5
-#include "player.h"6
-#include "const.h"7
-#include "tile.h"8
-#include "util.h"9
-#include "entity.h"10
-#include "effect.h"11
+#include "../include/player.h"12
+#include "../include/const.h"13
+#include "../include/tile.h"14
+#include "../include/util.h"15
+#include "../include/entity.h"16
+#include "../include/effect.h"18
player_t *player_create(pos_t pos) {19
player_t *player = malloc(sizeof(player_t));20
@@ -23,8 +23,8 @@ player_t *player_create(pos_t pos) {21
.fall_height = 0.0,22
.held_enemy = NULL,23
.moving = false,24
- .timer_walking = timer_create(9, 4),25
- .timer_sneaking = timer_create(9, 8),26
+ .timer_walking = fz_timer_create(9, 4),27
+ .timer_sneaking = fz_timer_create(9, 8),28
.target_entity = NULL,29
.shooting_distance = PLAYER_SHOOTING_RANGE,30
};31
@@ -356,20 +356,20 @@ void player_update(player_t *player, game_t *game) {32
}33
// update timer34
if (player->on_ground && player->moving) {35
- timer_update(player->timer_walking);36
- timer_update(player->timer_sneaking);37
+ fz_timer_update(player->timer_walking);38
+ fz_timer_update(player->timer_sneaking);39
}40
else {41
- timer_reset(player->timer_walking);42
- timer_reset(player->timer_sneaking);43
+ fz_timer_reset(player->timer_walking);44
+ fz_timer_reset(player->timer_sneaking);45
}46
}48
void player_draw(player_t *player, game_t *game) {49
pos_t pos = pos_snap(player->pos);50
int frame = (player->sneaking || player->shooting)51
- ? timer_get(player->timer_sneaking)52
- : timer_get(player->timer_walking);53
+ ? fz_timer_get(player->timer_sneaking)54
+ : fz_timer_get(player->timer_walking);55
if (player->damage_timer / 4 % 2 == 0) {56
if (player->sneaking) {57
if (player->dir > 0) {58
@@ -400,7 +400,7 @@ void player_draw(player_t *player, game_t *game) {59
}61
void player_free(player_t *player) {62
- timer_free(player->timer_walking);63
- timer_free(player->timer_sneaking);64
+ fz_timer_free(player->timer_walking);65
+ fz_timer_free(player->timer_sneaking);66
free(player);67
}
diff --git a/src/player.h b/src/player.h
deleted file mode 100644
index 3a2ee9c..0000000
--- a/src/player.h
+++ /dev/null
1
@@ -1,32 +0,0 @@2
-#pragma once3
-4
-typedef struct Player player_t;5
-6
-#include "util.h"7
-#include "enemy.h"8
-#include "game.h"9
-#include "entity.h"10
-11
-struct Player {12
- pos_t pos;13
- int health;14
- bool on_ground;15
- float velocity;16
- float gravity;17
- int dir;18
- bool sneaking;19
- bool shooting;20
- int damage_timer;21
- float fall_height;22
- enemy_t *held_enemy;23
- bool moving;24
- timer_t *timer_walking;25
- timer_t *timer_sneaking;26
- entity_t *target_entity;27
- float shooting_distance;28
-};29
-30
-player_t *player_create(pos_t pos);31
-void player_update(player_t *player, game_t *game);32
-void player_draw(player_t *player, game_t *game);33
-void player_free(player_t *player);
diff --git a/src/tile.c b/src/tile.c
index 9ac095f..b0aa979 100644
--- a/src/tile.c
+++ b/src/tile.c
1
@@ -1,9 +1,9 @@2
#include <stdlib.h>4
-#include "entity.h"5
-#include "tile.h"6
-#include "const.h"7
-#include "util.h"8
+#include "../include/entity.h"9
+#include "../include/tile.h"10
+#include "../include/const.h"11
+#include "../include/util.h"13
/* ########################################################################## */14
/* # Tile # */
diff --git a/src/tile.h b/src/tile.h
deleted file mode 100644
index 11b4976..0000000
--- a/src/tile.h
+++ /dev/null
1
@@ -1,31 +0,0 @@2
-#pragma once3
-4
-typedef struct Tile tile_t;5
-6
-#include "util.h"7
-#include "game.h"8
-9
-typedef enum {10
- TILE_AIR,11
- TILE_WOOD_PLATFORM,12
- TILE_STONE_JOINT,13
- TILE_STONE_WALL,14
- TILE_GRASS,15
- TILE_STONE,16
- TILE_SNOW,17
- TILE_SAND,18
-} tile_e;19
-20
-struct Tile {21
- pos_t pos;22
- tile_e type;23
-};24
-25
-tile_t *tile_create(pos_t pos, tile_e type);26
-void tile_update(tile_t *tile, game_t *game);27
-void tile_draw(tile_t *tile, game_t *game);28
-tile_t *tile_get(game_t *game, int x, int y);29
-bool tile_ground(tile_t *tile);30
-bool tile_solid(tile_t *tile);31
-bool tile_wall(tile_t *tile);32
-void tile_free(tile_t *tile);
diff --git a/src/util.c b/src/util.c
index a26987f..81a9aac 100644
--- a/src/util.c
+++ b/src/util.c
1
@@ -1,22 +1,22 @@2
#include <stdlib.h>3
#include <string.h>5
-#include "util.h"6
-#include "const.h"7
+#include "../include/util.h"8
+#include "../include/const.h"10
-timer_t *timer_create(int frames, int step) {11
- timer_t *timer = malloc(sizeof(timer_t));12
+fz_timer_t *fz_timer_create(int frames, int step) {13
+ fz_timer_t *timer = malloc(sizeof(fz_timer_t));14
timer->frames = step * frames;15
timer->count = 0;16
timer->step = step;17
return timer;18
}20
-bool timer_check(timer_t *timer) {21
+bool fz_timer_check(fz_timer_t *timer) {22
return timer->count == 0;23
}25
-void timer_update(timer_t *timer) {26
+void fz_timer_update(fz_timer_t *timer) {27
if (timer->count >= timer->frames) {28
timer->count = 0;29
}30
@@ -25,15 +25,15 @@ void timer_update(timer_t *timer) {31
}32
}34
-void timer_reset(timer_t *timer) {35
+void fz_timer_reset(fz_timer_t *timer) {36
timer->count = 0;37
}39
-int timer_get(timer_t *timer) {40
+int fz_timer_get(fz_timer_t *timer) {41
return timer->count / timer->step;42
}44
-void timer_free(timer_t *timer) {45
+void fz_timer_free(fz_timer_t *timer) {46
free(timer);47
}
diff --git a/src/util.h b/src/util.h
deleted file mode 100644
index 3b7b2b0..0000000
--- a/src/util.h
+++ /dev/null
1
@@ -1,42 +0,0 @@2
-#pragma once3
-4
-#include <stdbool.h>5
-6
-#include "libs/raylib.h"7
-8
-#define UNUSED(x) (void)(x)9
-10
-typedef Vector2 pos_t;11
-typedef Rectangle rect_t;12
-typedef struct Timer timer_t;13
-14
-#include "game.h"15
-16
-struct Timer {17
- int frames;18
- int count;19
- int step;20
-};21
-22
-timer_t *timer_create(int frames, int step);23
-bool timer_check(timer_t *timer);24
-void timer_update(timer_t *timer);25
-void timer_reset(timer_t *timer);26
-int timer_get(timer_t *timer);27
-void timer_free(timer_t *timer);28
-29
-pos_t pos_snap(pos_t vec);30
-31
-rect_t rect_from_pos(pos_t pos, int width, int height);32
-bool rect_collide(rect_t a, rect_t b);33
-34
-Texture texture_load(char *filename, int scale);35
-Rectangle texture_rect(int x, int y, int width, int height);36
-37
-typedef enum {38
- TEXT_ALIGNMENT_LEFT,39
- TEXT_ALIGNMENT_RIGHT,40
- TEXT_ALIGNMENT_CENTER,41
-} text_alignment_e;42
-43
-void text_draw(pos_t pos, char *text, text_alignment_e alignment, game_t *game);