1 | /********************************************************************************************** |
2 | * |
3 | * raylib - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) |
4 | * |
5 | * FEATURES: |
6 | * - NO external dependencies, all required libraries included with raylib |
7 | * - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly, MacOS, UWP, Android, Raspberry Pi, HTML5. |
8 | * - Written in plain C code (C99) in PascalCase/camelCase notation |
9 | * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile) |
10 | * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] |
11 | * - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts) |
12 | * - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) |
13 | * - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! |
14 | * - Flexible Materials system, supporting classic maps and PBR maps |
15 | * - Skeletal Animation support (CPU bones-based animation) |
16 | * - Shaders support, including Model shaders and Postprocessing shaders |
17 | * - Powerful math module for Vector, Matrix and Quaternion operations: [raymath] |
18 | * - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) |
19 | * - VR stereo rendering with configurable HMD device parameters |
20 | * - Bindings to multiple programming languages available! |
21 | * |
22 | * NOTES: |
23 | * One custom font is loaded by default when InitWindow() [core] |
24 | * If using OpenGL 3.3 or ES2, one default shader is loaded automatically (internally defined) [rlgl] |
25 | * If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads |
26 | * |
27 | * DEPENDENCIES (included): |
28 | * [core] rglfw (github.com/glfw/glfw) for window/context management and input (only PLATFORM_DESKTOP) |
29 | * [rlgl] glad (github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (only PLATFORM_DESKTOP) |
30 | * [raudio] miniaudio (github.com/dr-soft/miniaudio) for audio device/context management |
31 | * |
32 | * OPTIONAL DEPENDENCIES (included): |
33 | * [core] rgif (Charlie Tangora, Ramon Santamaria) for GIF recording |
34 | * [textures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) |
35 | * [textures] stb_image_write (Sean Barret) for image writting (BMP, TGA, PNG, JPG) |
36 | * [textures] stb_image_resize (Sean Barret) for image resizing algorithms |
37 | * [textures] stb_perlin (Sean Barret) for Perlin noise image generation |
38 | * [text] stb_truetype (Sean Barret) for ttf fonts loading |
39 | * [text] stb_rect_pack (Sean Barret) for rectangles packing |
40 | * [models] par_shapes (Philip Rideout) for parametric 3d shapes generation |
41 | * [models] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL) |
42 | * [models] cgltf (Johannes Kuhlmann) for models loading (glTF) |
43 | * [raudio] stb_vorbis (Sean Barret) for OGG audio loading |
44 | * [raudio] dr_flac (David Reid) for FLAC audio file loading |
45 | * [raudio] dr_mp3 (David Reid) for MP3 audio file loading |
46 | * [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading |
47 | * [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading |
48 | * |
49 | * |
50 | * LICENSE: zlib/libpng |
51 | * |
52 | * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, |
53 | * BSD-like license that allows static linking with closed source software: |
54 | * |
55 | * Copyright (c) 2013-2020 Ramon Santamaria (@raysan5) |
56 | * |
57 | * This software is provided "as-is", without any express or implied warranty. In no event |
58 | * will the authors be held liable for any damages arising from the use of this software. |
59 | * |
60 | * Permission is granted to anyone to use this software for any purpose, including commercial |
61 | * applications, and to alter it and redistribute it freely, subject to the following restrictions: |
62 | * |
63 | * 1. The origin of this software must not be misrepresented; you must not claim that you |
64 | * wrote the original software. If you use this software in a product, an acknowledgment |
65 | * in the product documentation would be appreciated but is not required. |
66 | * |
67 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented |
68 | * as being the original software. |
69 | * |
70 | * 3. This notice may not be removed or altered from any source distribution. |
71 | * |
72 | **********************************************************************************************/ |
73 | |
74 | #ifndef RAYLIB_H |
75 | #define RAYLIB_H |
76 | |
77 | #include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback |
78 | |
79 | #if defined(_WIN32) |
80 | // Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll |
81 | #if defined(BUILD_LIBTYPE_SHARED) |
82 | #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll) |
83 | #elif defined(USE_LIBTYPE_SHARED) |
84 | #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) |
85 | #else |
86 | #define RLAPI // We are building or using raylib as a static library |
87 | #endif |
88 | #else |
89 | #define RLAPI // We are building or using raylib as a static library (or Linux shared library) |
90 | #endif |
91 | |
92 | //---------------------------------------------------------------------------------- |
93 | // Some basic Defines |
94 | //---------------------------------------------------------------------------------- |
95 | #ifndef PI |
96 | #define PI 3.14159265358979323846f |
97 | #endif |
98 | |
99 | #define DEG2RAD (PI/180.0f) |
100 | #define RAD2DEG (180.0f/PI) |
101 | |
102 | #define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported |
103 | |
104 | // Allow custom memory allocators |
105 | #ifndef RL_MALLOC |
106 | #define RL_MALLOC(sz) malloc(sz) |
107 | #endif |
108 | #ifndef RL_CALLOC |
109 | #define RL_CALLOC(n,sz) calloc(n,sz) |
110 | #endif |
111 | #ifndef RL_REALLOC |
112 | #define RL_REALLOC(ptr,sz) realloc(ptr,sz) |
113 | #endif |
114 | #ifndef RL_FREE |
115 | #define RL_FREE(ptr) free(ptr) |
116 | #endif |
117 | |
118 | // NOTE: MSC C++ compiler does not support compound literals (C99 feature) |
119 | // Plain structures in C++ (without constructors) can be initialized from { } initializers. |
120 | #if defined(__cplusplus) |
121 | #define CLITERAL(type) type |
122 | #else |
123 | #define CLITERAL(type) (type) |
124 | #endif |
125 | |
126 | // Some Basic Colors |
127 | // NOTE: Custom raylib color palette for amazing visuals on WHITE background |
128 | #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray |
129 | #define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray |
130 | #define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray |
131 | #define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow |
132 | #define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold |
133 | #define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange |
134 | #define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink |
135 | #define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red |
136 | #define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon |
137 | #define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green |
138 | #define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime |
139 | #define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green |
140 | #define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue |
141 | #define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue |
142 | #define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue |
143 | #define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple |
144 | #define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet |
145 | #define DARKPURPLE CLITERAL(Color){ 112, 31, 126, 255 } // Dark Purple |
146 | #define BEIGE CLITERAL(Color){ 211, 176, 131, 255 } // Beige |
147 | #define BROWN CLITERAL(Color){ 127, 106, 79, 255 } // Brown |
148 | #define DARKBROWN CLITERAL(Color){ 76, 63, 47, 255 } // Dark Brown |
149 | |
150 | #define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White |
151 | #define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black |
152 | #define BLANK CLITERAL(Color){ 0, 0, 0, 0 } // Blank (Transparent) |
153 | #define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta |
154 | #define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo) |
155 | |
156 | // Temporal hack to avoid breaking old codebases using |
157 | // deprecated raylib implementation of these functions |
158 | #define FormatText TextFormat |
159 | #define SubText TextSubtext |
160 | #define ShowWindow UnhideWindow |
161 | #define LoadText LoadFileText |
162 | |
163 | //---------------------------------------------------------------------------------- |
164 | // Structures Definition |
165 | //---------------------------------------------------------------------------------- |
166 | // Boolean type |
167 | #if defined(__STDC__) && __STDC_VERSION__ >= 199901L |
168 | #include <stdbool.h> |
169 | #elif !defined(__cplusplus) && !defined(bool) |
170 | typedef enum { false, true } bool; |
171 | #endif |
172 | |
173 | // Vector2 type |
174 | typedef struct Vector2 { |
175 | float x; |
176 | float y; |
177 | } Vector2; |
178 | |
179 | // Vector3 type |
180 | typedef struct Vector3 { |
181 | float x; |
182 | float y; |
183 | float z; |
184 | } Vector3; |
185 | |
186 | // Vector4 type |
187 | typedef struct Vector4 { |
188 | float x; |
189 | float y; |
190 | float z; |
191 | float w; |
192 | } Vector4; |
193 | |
194 | // Quaternion type, same as Vector4 |
195 | typedef Vector4 Quaternion; |
196 | |
197 | // Matrix type (OpenGL style 4x4 - right handed, column major) |
198 | typedef struct Matrix { |
199 | float m0, m4, m8, m12; |
200 | float m1, m5, m9, m13; |
201 | float m2, m6, m10, m14; |
202 | float m3, m7, m11, m15; |
203 | } Matrix; |
204 | |
205 | // Color type, RGBA (32bit) |
206 | typedef struct Color { |
207 | unsigned char r; |
208 | unsigned char g; |
209 | unsigned char b; |
210 | unsigned char a; |
211 | } Color; |
212 | |
213 | // Rectangle type |
214 | typedef struct Rectangle { |
215 | float x; |
216 | float y; |
217 | float width; |
218 | float height; |
219 | } Rectangle; |
220 | |
221 | // Image type, bpp always RGBA (32bit) |
222 | // NOTE: Data stored in CPU memory (RAM) |
223 | typedef struct Image { |
224 | void *data; // Image raw data |
225 | int width; // Image base width |
226 | int height; // Image base height |
227 | int mipmaps; // Mipmap levels, 1 by default |
228 | int format; // Data format (PixelFormat type) |
229 | } Image; |
230 | |
231 | // Texture2D type |
232 | // NOTE: Data stored in GPU memory |
233 | typedef struct Texture2D { |
234 | unsigned int id; // OpenGL texture id |
235 | int width; // Texture base width |
236 | int height; // Texture base height |
237 | int mipmaps; // Mipmap levels, 1 by default |
238 | int format; // Data format (PixelFormat type) |
239 | } Texture2D; |
240 | |
241 | // Texture type, same as Texture2D |
242 | typedef Texture2D Texture; |
243 | |
244 | // TextureCubemap type, actually, same as Texture2D |
245 | typedef Texture2D TextureCubemap; |
246 | |
247 | // RenderTexture2D type, for texture rendering |
248 | typedef struct RenderTexture2D { |
249 | unsigned int id; // OpenGL Framebuffer Object (FBO) id |
250 | Texture2D texture; // Color buffer attachment texture |
251 | Texture2D depth; // Depth buffer attachment texture |
252 | bool depthTexture; // Track if depth attachment is a texture or renderbuffer |
253 | } RenderTexture2D; |
254 | |
255 | // RenderTexture type, same as RenderTexture2D |
256 | typedef RenderTexture2D RenderTexture; |
257 | |
258 | // N-Patch layout info |
259 | typedef struct NPatchInfo { |
260 | Rectangle sourceRec; // Region in the texture |
261 | int left; // left border offset |
262 | int top; // top border offset |
263 | int right; // right border offset |
264 | int bottom; // bottom border offset |
265 | int type; // layout of the n-patch: 3x3, 1x3 or 3x1 |
266 | } NPatchInfo; |
267 | |
268 | // Font character info |
269 | typedef struct CharInfo { |
270 | int value; // Character value (Unicode) |
271 | int offsetX; // Character offset X when drawing |
272 | int offsetY; // Character offset Y when drawing |
273 | int advanceX; // Character advance position X |
274 | Image image; // Character image data |
275 | } CharInfo; |
276 | |
277 | // Font type, includes texture and charSet array data |
278 | typedef struct Font { |
279 | int baseSize; // Base size (default chars height) |
280 | int charsCount; // Number of characters |
281 | Texture2D texture; // Characters texture atlas |
282 | Rectangle *recs; // Characters rectangles in texture |
283 | CharInfo *chars; // Characters info data |
284 | } Font; |
285 | |
286 | #define SpriteFont Font // SpriteFont type fallback, defaults to Font |
287 | |
288 | // Camera type, defines a camera position/orientation in 3d space |
289 | typedef struct Camera3D { |
290 | Vector3 position; // Camera position |
291 | Vector3 target; // Camera target it looks-at |
292 | Vector3 up; // Camera up vector (rotation over its axis) |
293 | float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic |
294 | int type; // Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC |
295 | } Camera3D; |
296 | |
297 | typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D |
298 | |
299 | // Camera2D type, defines a 2d camera |
300 | typedef struct Camera2D { |
301 | Vector2 offset; // Camera offset (displacement from target) |
302 | Vector2 target; // Camera target (rotation and zoom origin) |
303 | float rotation; // Camera rotation in degrees |
304 | float zoom; // Camera zoom (scaling), should be 1.0f by default |
305 | } Camera2D; |
306 | |
307 | // Vertex data definning a mesh |
308 | // NOTE: Data stored in CPU memory (and GPU) |
309 | typedef struct Mesh { |
310 | int vertexCount; // Number of vertices stored in arrays |
311 | int triangleCount; // Number of triangles stored (indexed or not) |
312 | |
313 | // Default vertex data |
314 | float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) |
315 | float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) |
316 | float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) |
317 | float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) |
318 | float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) |
319 | unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) |
320 | unsigned short *indices;// Vertex indices (in case vertex data comes indexed) |
321 | |
322 | // Animation vertex data |
323 | float *animVertices; // Animated vertex positions (after bones transformations) |
324 | float *animNormals; // Animated normals (after bones transformations) |
325 | int *boneIds; // Vertex bone ids, up to 4 bones influence by vertex (skinning) |
326 | float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning) |
327 | |
328 | // OpenGL identifiers |
329 | unsigned int vaoId; // OpenGL Vertex Array Object id |
330 | unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data) |
331 | } Mesh; |
332 | |
333 | // Shader type (generic) |
334 | typedef struct Shader { |
335 | unsigned int id; // Shader program id |
336 | int *locs; // Shader locations array (MAX_SHADER_LOCATIONS) |
337 | } Shader; |
338 | |
339 | // Material texture map |
340 | typedef struct MaterialMap { |
341 | Texture2D texture; // Material map texture |
342 | Color color; // Material map color |
343 | float value; // Material map value |
344 | } MaterialMap; |
345 | |
346 | // Material type (generic) |
347 | typedef struct Material { |
348 | Shader shader; // Material shader |
349 | MaterialMap *maps; // Material maps array (MAX_MATERIAL_MAPS) |
350 | float *params; // Material generic parameters (if required) |
351 | } Material; |
352 | |
353 | // Transformation properties |
354 | typedef struct Transform { |
355 | Vector3 translation; // Translation |
356 | Quaternion rotation; // Rotation |
357 | Vector3 scale; // Scale |
358 | } Transform; |
359 | |
360 | // Bone information |
361 | typedef struct BoneInfo { |
362 | char name[32]; // Bone name |
363 | int parent; // Bone parent |
364 | } BoneInfo; |
365 | |
366 | // Model type |
367 | typedef struct Model { |
368 | Matrix transform; // Local transform matrix |
369 | |
370 | int meshCount; // Number of meshes |
371 | Mesh *meshes; // Meshes array |
372 | |
373 | int materialCount; // Number of materials |
374 | Material *materials; // Materials array |
375 | int *meshMaterial; // Mesh material number |
376 | |
377 | // Animation data |
378 | int boneCount; // Number of bones |
379 | BoneInfo *bones; // Bones information (skeleton) |
380 | Transform *bindPose; // Bones base transformation (pose) |
381 | } Model; |
382 | |
383 | // Model animation |
384 | typedef struct ModelAnimation { |
385 | int boneCount; // Number of bones |
386 | BoneInfo *bones; // Bones information (skeleton) |
387 | |
388 | int frameCount; // Number of animation frames |
389 | Transform **framePoses; // Poses array by frame |
390 | } ModelAnimation; |
391 | |
392 | // Ray type (useful for raycast) |
393 | typedef struct Ray { |
394 | Vector3 position; // Ray position (origin) |
395 | Vector3 direction; // Ray direction |
396 | } Ray; |
397 | |
398 | // Raycast hit information |
399 | typedef struct RayHitInfo { |
400 | bool hit; // Did the ray hit something? |
401 | float distance; // Distance to nearest hit |
402 | Vector3 position; // Position of nearest hit |
403 | Vector3 normal; // Surface normal of hit |
404 | } RayHitInfo; |
405 | |
406 | // Bounding box type |
407 | typedef struct BoundingBox { |
408 | Vector3 min; // Minimum vertex box-corner |
409 | Vector3 max; // Maximum vertex box-corner |
410 | } BoundingBox; |
411 | |
412 | // Wave type, defines audio wave data |
413 | typedef struct Wave { |
414 | unsigned int sampleCount; // Total number of samples |
415 | unsigned int sampleRate; // Frequency (samples per second) |
416 | unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) |
417 | unsigned int channels; // Number of channels (1-mono, 2-stereo) |
418 | void *data; // Buffer data pointer |
419 | } Wave; |
420 | |
421 | typedef struct rAudioBuffer rAudioBuffer; |
422 | |
423 | // Audio stream type |
424 | // NOTE: Useful to create custom audio streams not bound to a specific file |
425 | typedef struct AudioStream { |
426 | unsigned int sampleRate; // Frequency (samples per second) |
427 | unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) |
428 | unsigned int channels; // Number of channels (1-mono, 2-stereo) |
429 | |
430 | rAudioBuffer *buffer; // Pointer to internal data used by the audio system |
431 | } AudioStream; |
432 | |
433 | // Sound source type |
434 | typedef struct Sound { |
435 | unsigned int sampleCount; // Total number of samples |
436 | AudioStream stream; // Audio stream |
437 | } Sound; |
438 | |
439 | // Music stream type (audio file streaming from memory) |
440 | // NOTE: Anything longer than ~10 seconds should be streamed |
441 | typedef struct Music { |
442 | int ctxType; // Type of music context (audio filetype) |
443 | void *ctxData; // Audio context data, depends on type |
444 | |
445 | unsigned int sampleCount; // Total number of samples |
446 | unsigned int loopCount; // Loops count (times music will play), 0 means infinite loop |
447 | |
448 | AudioStream stream; // Audio stream |
449 | } Music; |
450 | |
451 | // Head-Mounted-Display device parameters |
452 | typedef struct VrDeviceInfo { |
453 | int hResolution; // HMD horizontal resolution in pixels |
454 | int vResolution; // HMD vertical resolution in pixels |
455 | float hScreenSize; // HMD horizontal size in meters |
456 | float vScreenSize; // HMD vertical size in meters |
457 | float vScreenCenter; // HMD screen center in meters |
458 | float eyeToScreenDistance; // HMD distance between eye and display in meters |
459 | float lensSeparationDistance; // HMD lens separation distance in meters |
460 | float interpupillaryDistance; // HMD IPD (distance between pupils) in meters |
461 | float lensDistortionValues[4]; // HMD lens distortion constant parameters |
462 | float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters |
463 | } VrDeviceInfo; |
464 | |
465 | //---------------------------------------------------------------------------------- |
466 | // Enumerators Definition |
467 | //---------------------------------------------------------------------------------- |
468 | // System config flags |
469 | // NOTE: Used for bit masks |
470 | typedef enum { |
471 | FLAG_RESERVED = 1, // Reserved |
472 | FLAG_FULLSCREEN_MODE = 2, // Set to run program in fullscreen |
473 | FLAG_WINDOW_RESIZABLE = 4, // Set to allow resizable window |
474 | FLAG_WINDOW_UNDECORATED = 8, // Set to disable window decoration (frame and buttons) |
475 | FLAG_WINDOW_TRANSPARENT = 16, // Set to allow transparent window |
476 | FLAG_WINDOW_HIDDEN = 128, // Set to create the window initially hidden |
477 | FLAG_WINDOW_ALWAYS_RUN = 256, // Set to allow windows running while minimized |
478 | FLAG_MSAA_4X_HINT = 32, // Set to try enabling MSAA 4X |
479 | FLAG_VSYNC_HINT = 64 // Set to try enabling V-Sync on GPU |
480 | } ConfigFlag; |
481 | |
482 | // Trace log type |
483 | typedef enum { |
484 | LOG_ALL = 0, // Display all logs |
485 | LOG_TRACE, |
486 | LOG_DEBUG, |
487 | LOG_INFO, |
488 | LOG_WARNING, |
489 | LOG_ERROR, |
490 | LOG_FATAL, |
491 | LOG_NONE // Disable logging |
492 | } TraceLogType; |
493 | |
494 | // Keyboard keys |
495 | typedef enum { |
496 | // Alphanumeric keys |
497 | KEY_APOSTROPHE = 39, |
498 | KEY_COMMA = 44, |
499 | KEY_MINUS = 45, |
500 | KEY_PERIOD = 46, |
501 | KEY_SLASH = 47, |
502 | KEY_ZERO = 48, |
503 | KEY_ONE = 49, |
504 | KEY_TWO = 50, |
505 | KEY_THREE = 51, |
506 | KEY_FOUR = 52, |
507 | KEY_FIVE = 53, |
508 | KEY_SIX = 54, |
509 | KEY_SEVEN = 55, |
510 | KEY_EIGHT = 56, |
511 | KEY_NINE = 57, |
512 | KEY_SEMICOLON = 59, |
513 | KEY_EQUAL = 61, |
514 | KEY_A = 65, |
515 | KEY_B = 66, |
516 | KEY_C = 67, |
517 | KEY_D = 68, |
518 | KEY_E = 69, |
519 | KEY_F = 70, |
520 | KEY_G = 71, |
521 | KEY_H = 72, |
522 | KEY_I = 73, |
523 | KEY_J = 74, |
524 | KEY_K = 75, |
525 | KEY_L = 76, |
526 | KEY_M = 77, |
527 | KEY_N = 78, |
528 | KEY_O = 79, |
529 | KEY_P = 80, |
530 | KEY_Q = 81, |
531 | KEY_R = 82, |
532 | KEY_S = 83, |
533 | KEY_T = 84, |
534 | KEY_U = 85, |
535 | KEY_V = 86, |
536 | KEY_W = 87, |
537 | KEY_X = 88, |
538 | KEY_Y = 89, |
539 | KEY_Z = 90, |
540 | |
541 | // Function keys |
542 | KEY_SPACE = 32, |
543 | KEY_ESCAPE = 256, |
544 | KEY_ENTER = 257, |
545 | KEY_TAB = 258, |
546 | KEY_BACKSPACE = 259, |
547 | KEY_INSERT = 260, |
548 | KEY_DELETE = 261, |
549 | KEY_RIGHT = 262, |
550 | KEY_LEFT = 263, |
551 | KEY_DOWN = 264, |
552 | KEY_UP = 265, |
553 | KEY_PAGE_UP = 266, |
554 | KEY_PAGE_DOWN = 267, |
555 | KEY_HOME = 268, |
556 | KEY_END = 269, |
557 | KEY_CAPS_LOCK = 280, |
558 | KEY_SCROLL_LOCK = 281, |
559 | KEY_NUM_LOCK = 282, |
560 | KEY_PRINT_SCREEN = 283, |
561 | KEY_PAUSE = 284, |
562 | KEY_F1 = 290, |
563 | KEY_F2 = 291, |
564 | KEY_F3 = 292, |
565 | KEY_F4 = 293, |
566 | KEY_F5 = 294, |
567 | KEY_F6 = 295, |
568 | KEY_F7 = 296, |
569 | KEY_F8 = 297, |
570 | KEY_F9 = 298, |
571 | KEY_F10 = 299, |
572 | KEY_F11 = 300, |
573 | KEY_F12 = 301, |
574 | KEY_LEFT_SHIFT = 340, |
575 | KEY_LEFT_CONTROL = 341, |
576 | KEY_LEFT_ALT = 342, |
577 | KEY_LEFT_SUPER = 343, |
578 | KEY_RIGHT_SHIFT = 344, |
579 | KEY_RIGHT_CONTROL = 345, |
580 | KEY_RIGHT_ALT = 346, |
581 | KEY_RIGHT_SUPER = 347, |
582 | = 348, |
583 | KEY_LEFT_BRACKET = 91, |
584 | KEY_BACKSLASH = 92, |
585 | KEY_RIGHT_BRACKET = 93, |
586 | KEY_GRAVE = 96, |
587 | |
588 | // Keypad keys |
589 | KEY_KP_0 = 320, |
590 | KEY_KP_1 = 321, |
591 | KEY_KP_2 = 322, |
592 | KEY_KP_3 = 323, |
593 | KEY_KP_4 = 324, |
594 | KEY_KP_5 = 325, |
595 | KEY_KP_6 = 326, |
596 | KEY_KP_7 = 327, |
597 | KEY_KP_8 = 328, |
598 | KEY_KP_9 = 329, |
599 | KEY_KP_DECIMAL = 330, |
600 | KEY_KP_DIVIDE = 331, |
601 | KEY_KP_MULTIPLY = 332, |
602 | KEY_KP_SUBTRACT = 333, |
603 | KEY_KP_ADD = 334, |
604 | KEY_KP_ENTER = 335, |
605 | KEY_KP_EQUAL = 336 |
606 | } KeyboardKey; |
607 | |
608 | // Android buttons |
609 | typedef enum { |
610 | KEY_BACK = 4, |
611 | = 82, |
612 | KEY_VOLUME_UP = 24, |
613 | KEY_VOLUME_DOWN = 25 |
614 | } AndroidButton; |
615 | |
616 | // Mouse buttons |
617 | typedef enum { |
618 | MOUSE_LEFT_BUTTON = 0, |
619 | MOUSE_RIGHT_BUTTON = 1, |
620 | MOUSE_MIDDLE_BUTTON = 2 |
621 | } MouseButton; |
622 | |
623 | // Gamepad number |
624 | typedef enum { |
625 | GAMEPAD_PLAYER1 = 0, |
626 | GAMEPAD_PLAYER2 = 1, |
627 | GAMEPAD_PLAYER3 = 2, |
628 | GAMEPAD_PLAYER4 = 3 |
629 | } GamepadNumber; |
630 | |
631 | // Gamepad Buttons |
632 | typedef enum { |
633 | // This is here just for error checking |
634 | GAMEPAD_BUTTON_UNKNOWN = 0, |
635 | |
636 | // This is normally a DPAD |
637 | GAMEPAD_BUTTON_LEFT_FACE_UP, |
638 | GAMEPAD_BUTTON_LEFT_FACE_RIGHT, |
639 | GAMEPAD_BUTTON_LEFT_FACE_DOWN, |
640 | GAMEPAD_BUTTON_LEFT_FACE_LEFT, |
641 | |
642 | // This normally corresponds with PlayStation and Xbox controllers |
643 | // XBOX: [Y,X,A,B] |
644 | // PS3: [Triangle,Square,Cross,Circle] |
645 | // No support for 6 button controllers though.. |
646 | GAMEPAD_BUTTON_RIGHT_FACE_UP, |
647 | GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, |
648 | GAMEPAD_BUTTON_RIGHT_FACE_DOWN, |
649 | GAMEPAD_BUTTON_RIGHT_FACE_LEFT, |
650 | |
651 | // Triggers |
652 | GAMEPAD_BUTTON_LEFT_TRIGGER_1, |
653 | GAMEPAD_BUTTON_LEFT_TRIGGER_2, |
654 | GAMEPAD_BUTTON_RIGHT_TRIGGER_1, |
655 | GAMEPAD_BUTTON_RIGHT_TRIGGER_2, |
656 | |
657 | // These are buttons in the center of the gamepad |
658 | GAMEPAD_BUTTON_MIDDLE_LEFT, //PS3 Select |
659 | GAMEPAD_BUTTON_MIDDLE, //PS Button/XBOX Button |
660 | GAMEPAD_BUTTON_MIDDLE_RIGHT, //PS3 Start |
661 | |
662 | // These are the joystick press in buttons |
663 | GAMEPAD_BUTTON_LEFT_THUMB, |
664 | GAMEPAD_BUTTON_RIGHT_THUMB |
665 | } GamepadButton; |
666 | |
667 | typedef enum { |
668 | // This is here just for error checking |
669 | GAMEPAD_AXIS_UNKNOWN = 0, |
670 | |
671 | // Left stick |
672 | GAMEPAD_AXIS_LEFT_X, |
673 | GAMEPAD_AXIS_LEFT_Y, |
674 | |
675 | // Right stick |
676 | GAMEPAD_AXIS_RIGHT_X, |
677 | GAMEPAD_AXIS_RIGHT_Y, |
678 | |
679 | // Pressure levels for the back triggers |
680 | GAMEPAD_AXIS_LEFT_TRIGGER, // [1..-1] (pressure-level) |
681 | GAMEPAD_AXIS_RIGHT_TRIGGER // [1..-1] (pressure-level) |
682 | } GamepadAxis; |
683 | |
684 | // Shader location point type |
685 | typedef enum { |
686 | LOC_VERTEX_POSITION = 0, |
687 | LOC_VERTEX_TEXCOORD01, |
688 | LOC_VERTEX_TEXCOORD02, |
689 | LOC_VERTEX_NORMAL, |
690 | LOC_VERTEX_TANGENT, |
691 | LOC_VERTEX_COLOR, |
692 | LOC_MATRIX_MVP, |
693 | LOC_MATRIX_MODEL, |
694 | LOC_MATRIX_VIEW, |
695 | LOC_MATRIX_PROJECTION, |
696 | LOC_VECTOR_VIEW, |
697 | LOC_COLOR_DIFFUSE, |
698 | LOC_COLOR_SPECULAR, |
699 | LOC_COLOR_AMBIENT, |
700 | LOC_MAP_ALBEDO, // LOC_MAP_DIFFUSE |
701 | LOC_MAP_METALNESS, // LOC_MAP_SPECULAR |
702 | LOC_MAP_NORMAL, |
703 | LOC_MAP_ROUGHNESS, |
704 | LOC_MAP_OCCLUSION, |
705 | LOC_MAP_EMISSION, |
706 | LOC_MAP_HEIGHT, |
707 | LOC_MAP_CUBEMAP, |
708 | LOC_MAP_IRRADIANCE, |
709 | LOC_MAP_PREFILTER, |
710 | LOC_MAP_BRDF |
711 | } ShaderLocationIndex; |
712 | |
713 | #define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO |
714 | #define LOC_MAP_SPECULAR LOC_MAP_METALNESS |
715 | |
716 | // Shader uniform data types |
717 | typedef enum { |
718 | UNIFORM_FLOAT = 0, |
719 | UNIFORM_VEC2, |
720 | UNIFORM_VEC3, |
721 | UNIFORM_VEC4, |
722 | UNIFORM_INT, |
723 | UNIFORM_IVEC2, |
724 | UNIFORM_IVEC3, |
725 | UNIFORM_IVEC4, |
726 | UNIFORM_SAMPLER2D |
727 | } ShaderUniformDataType; |
728 | |
729 | // Material map type |
730 | typedef enum { |
731 | MAP_ALBEDO = 0, // MAP_DIFFUSE |
732 | MAP_METALNESS = 1, // MAP_SPECULAR |
733 | MAP_NORMAL = 2, |
734 | MAP_ROUGHNESS = 3, |
735 | MAP_OCCLUSION, |
736 | MAP_EMISSION, |
737 | MAP_HEIGHT, |
738 | MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP |
739 | MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP |
740 | MAP_PREFILTER, // NOTE: Uses GL_TEXTURE_CUBE_MAP |
741 | MAP_BRDF |
742 | } MaterialMapType; |
743 | |
744 | #define MAP_DIFFUSE MAP_ALBEDO |
745 | #define MAP_SPECULAR MAP_METALNESS |
746 | |
747 | // Pixel formats |
748 | // NOTE: Support depends on OpenGL version and platform |
749 | typedef enum { |
750 | UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) |
751 | UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) |
752 | UNCOMPRESSED_R5G6B5, // 16 bpp |
753 | UNCOMPRESSED_R8G8B8, // 24 bpp |
754 | UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) |
755 | UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) |
756 | UNCOMPRESSED_R8G8B8A8, // 32 bpp |
757 | UNCOMPRESSED_R32, // 32 bpp (1 channel - float) |
758 | UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) |
759 | UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) |
760 | COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) |
761 | COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) |
762 | COMPRESSED_DXT3_RGBA, // 8 bpp |
763 | COMPRESSED_DXT5_RGBA, // 8 bpp |
764 | COMPRESSED_ETC1_RGB, // 4 bpp |
765 | COMPRESSED_ETC2_RGB, // 4 bpp |
766 | COMPRESSED_ETC2_EAC_RGBA, // 8 bpp |
767 | COMPRESSED_PVRT_RGB, // 4 bpp |
768 | COMPRESSED_PVRT_RGBA, // 4 bpp |
769 | COMPRESSED_ASTC_4x4_RGBA, // 8 bpp |
770 | COMPRESSED_ASTC_8x8_RGBA // 2 bpp |
771 | } PixelFormat; |
772 | |
773 | // Texture parameters: filter mode |
774 | // NOTE 1: Filtering considers mipmaps if available in the texture |
775 | // NOTE 2: Filter is accordingly set for minification and magnification |
776 | typedef enum { |
777 | FILTER_POINT = 0, // No filter, just pixel aproximation |
778 | FILTER_BILINEAR, // Linear filtering |
779 | FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) |
780 | FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x |
781 | FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x |
782 | FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x |
783 | } TextureFilterMode; |
784 | |
785 | // Cubemap layout type |
786 | typedef enum { |
787 | CUBEMAP_AUTO_DETECT = 0, // Automatically detect layout type |
788 | CUBEMAP_LINE_VERTICAL, // Layout is defined by a vertical line with faces |
789 | CUBEMAP_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces |
790 | CUBEMAP_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces |
791 | CUBEMAP_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces |
792 | CUBEMAP_PANORAMA // Layout is defined by a panorama image (equirectangular map) |
793 | } CubemapLayoutType; |
794 | |
795 | // Texture parameters: wrap mode |
796 | typedef enum { |
797 | WRAP_REPEAT = 0, // Repeats texture in tiled mode |
798 | WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode |
799 | WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode |
800 | WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode |
801 | } TextureWrapMode; |
802 | |
803 | // Font type, defines generation method |
804 | typedef enum { |
805 | FONT_DEFAULT = 0, // Default font generation, anti-aliased |
806 | FONT_BITMAP, // Bitmap font generation, no anti-aliasing |
807 | FONT_SDF // SDF font generation, requires external shader |
808 | } FontType; |
809 | |
810 | // Color blending modes (pre-defined) |
811 | typedef enum { |
812 | BLEND_ALPHA = 0, // Blend textures considering alpha (default) |
813 | BLEND_ADDITIVE, // Blend textures adding colors |
814 | BLEND_MULTIPLIED // Blend textures multiplying colors |
815 | } BlendMode; |
816 | |
817 | // Gestures type |
818 | // NOTE: It could be used as flags to enable only some gestures |
819 | typedef enum { |
820 | GESTURE_NONE = 0, |
821 | GESTURE_TAP = 1, |
822 | GESTURE_DOUBLETAP = 2, |
823 | GESTURE_HOLD = 4, |
824 | GESTURE_DRAG = 8, |
825 | GESTURE_SWIPE_RIGHT = 16, |
826 | GESTURE_SWIPE_LEFT = 32, |
827 | GESTURE_SWIPE_UP = 64, |
828 | GESTURE_SWIPE_DOWN = 128, |
829 | GESTURE_PINCH_IN = 256, |
830 | GESTURE_PINCH_OUT = 512 |
831 | } GestureType; |
832 | |
833 | // Camera system modes |
834 | typedef enum { |
835 | CAMERA_CUSTOM = 0, |
836 | CAMERA_FREE, |
837 | CAMERA_ORBITAL, |
838 | CAMERA_FIRST_PERSON, |
839 | CAMERA_THIRD_PERSON |
840 | } CameraMode; |
841 | |
842 | // Camera projection modes |
843 | typedef enum { |
844 | CAMERA_PERSPECTIVE = 0, |
845 | CAMERA_ORTHOGRAPHIC |
846 | } CameraType; |
847 | |
848 | // Type of n-patch |
849 | typedef enum { |
850 | NPT_9PATCH = 0, // Npatch defined by 3x3 tiles |
851 | NPT_3PATCH_VERTICAL, // Npatch defined by 1x3 tiles |
852 | NPT_3PATCH_HORIZONTAL // Npatch defined by 3x1 tiles |
853 | } NPatchType; |
854 | |
855 | // Callbacks to be implemented by users |
856 | typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); |
857 | |
858 | #if defined(__cplusplus) |
859 | extern "C" { // Prevents name mangling of functions |
860 | #endif |
861 | |
862 | //------------------------------------------------------------------------------------ |
863 | // Global Variables Definition |
864 | //------------------------------------------------------------------------------------ |
865 | // It's lonely here... |
866 | |
867 | //------------------------------------------------------------------------------------ |
868 | // Window and Graphics Device Functions (Module: core) |
869 | //------------------------------------------------------------------------------------ |
870 | |
871 | // Window-related functions |
872 | RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context |
873 | RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed |
874 | RLAPI void CloseWindow(void); // Close window and unload OpenGL context |
875 | RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully |
876 | RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) |
877 | RLAPI bool IsWindowResized(void); // Check if window has been resized |
878 | RLAPI bool IsWindowHidden(void); // Check if window is currently hidden |
879 | RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen |
880 | RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) |
881 | RLAPI void UnhideWindow(void); // Show the window |
882 | RLAPI void HideWindow(void); // Hide the window |
883 | RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) |
884 | RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP) |
885 | RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) |
886 | RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) |
887 | RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) |
888 | RLAPI void SetWindowSize(int width, int height); // Set window dimensions |
889 | RLAPI void *GetWindowHandle(void); // Get native window handle |
890 | RLAPI int GetScreenWidth(void); // Get current screen width |
891 | RLAPI int GetScreenHeight(void); // Get current screen height |
892 | RLAPI int GetMonitorCount(void); // Get number of connected monitors |
893 | RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width |
894 | RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height |
895 | RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres |
896 | RLAPI int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres |
897 | RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor |
898 | RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor |
899 | RLAPI const char *GetClipboardText(void); // Get clipboard text content |
900 | RLAPI void SetClipboardText(const char *text); // Set clipboard text content |
901 | |
902 | // Cursor-related functions |
903 | RLAPI void ShowCursor(void); // Shows cursor |
904 | RLAPI void HideCursor(void); // Hides cursor |
905 | RLAPI bool IsCursorHidden(void); // Check if cursor is not visible |
906 | RLAPI void EnableCursor(void); // Enables cursor (unlock cursor) |
907 | RLAPI void DisableCursor(void); // Disables cursor (lock cursor) |
908 | |
909 | // Drawing-related functions |
910 | RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color) |
911 | RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing |
912 | RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) |
913 | RLAPI void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D) |
914 | RLAPI void EndMode2D(void); // Ends 2D mode with custom camera |
915 | RLAPI void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D) |
916 | RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode |
917 | RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing |
918 | RLAPI void EndTextureMode(void); // Ends drawing to render texture |
919 | RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) |
920 | RLAPI void EndScissorMode(void); // End scissor mode |
921 | |
922 | // Screen-space-related functions |
923 | RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position |
924 | RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) |
925 | RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix |
926 | RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position |
927 | RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Returns size position for a 3d world space position |
928 | RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position |
929 | RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position |
930 | |
931 | // Timing-related functions |
932 | RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum) |
933 | RLAPI int GetFPS(void); // Returns current FPS |
934 | RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn |
935 | RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow() |
936 | |
937 | // Color-related functions |
938 | RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color |
939 | RLAPI Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1] |
940 | RLAPI Color ColorFromNormalized(Vector4 normalized); // Returns color from normalized values [0..1] |
941 | RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color |
942 | RLAPI Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values |
943 | RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value |
944 | RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f |
945 | |
946 | // Misc. functions |
947 | RLAPI void SetConfigFlags(unsigned int flags); // Setup window configuration flags (view FLAGS) |
948 | RLAPI void SetTraceLogLevel(int logType); // Set the current threshold (minimum) log level |
949 | RLAPI void SetTraceLogExit(int logType); // Set the exit threshold (minimum) log level |
950 | RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging |
951 | RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) |
952 | RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) |
953 | RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) |
954 | |
955 | // Files management functions |
956 | RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) |
957 | RLAPI void SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write) |
958 | RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string |
959 | RLAPI void SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated |
960 | RLAPI bool FileExists(const char *fileName); // Check if file exists |
961 | RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension |
962 | RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists |
963 | RLAPI const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string |
964 | RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string |
965 | RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string) |
966 | RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string) |
967 | RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string) |
968 | RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string) |
969 | RLAPI char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenames in a directory path (memory should be freed) |
970 | RLAPI void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) |
971 | RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success |
972 | RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window |
973 | RLAPI char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) |
974 | RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) |
975 | RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) |
976 | |
977 | RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm) |
978 | RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm) |
979 | |
980 | // Persistent storage management |
981 | RLAPI void SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position) |
982 | RLAPI int LoadStorageValue(unsigned int position); // Load integer value from storage file (from defined position) |
983 | |
984 | RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available) |
985 | |
986 | //------------------------------------------------------------------------------------ |
987 | // Input Handling Functions (Module: core) |
988 | //------------------------------------------------------------------------------------ |
989 | |
990 | // Input-related functions: keyboard |
991 | RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once |
992 | RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed |
993 | RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once |
994 | RLAPI bool IsKeyUp(int key); // Detect if a key is NOT being pressed |
995 | RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) |
996 | RLAPI int GetKeyPressed(void); // Get key pressed, call it multiple times for chars queued |
997 | |
998 | // Input-related functions: gamepads |
999 | RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available |
1000 | RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available) |
1001 | RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id |
1002 | RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once |
1003 | RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed |
1004 | RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once |
1005 | RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed |
1006 | RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed |
1007 | RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad |
1008 | RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis |
1009 | |
1010 | // Input-related functions: mouse |
1011 | RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once |
1012 | RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed |
1013 | RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once |
1014 | RLAPI bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed |
1015 | RLAPI int GetMouseX(void); // Returns mouse position X |
1016 | RLAPI int GetMouseY(void); // Returns mouse position Y |
1017 | RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY |
1018 | RLAPI void SetMousePosition(int x, int y); // Set mouse position XY |
1019 | RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset |
1020 | RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling |
1021 | RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y |
1022 | |
1023 | // Input-related functions: touch |
1024 | RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size) |
1025 | RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size) |
1026 | RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size) |
1027 | |
1028 | //------------------------------------------------------------------------------------ |
1029 | // Gestures and Touch Handling Functions (Module: gestures) |
1030 | //------------------------------------------------------------------------------------ |
1031 | RLAPI void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags |
1032 | RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected |
1033 | RLAPI int GetGestureDetected(void); // Get latest detected gesture |
1034 | RLAPI int GetTouchPointsCount(void); // Get touch points count |
1035 | RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds |
1036 | RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector |
1037 | RLAPI float GetGestureDragAngle(void); // Get gesture drag angle |
1038 | RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta |
1039 | RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle |
1040 | |
1041 | //------------------------------------------------------------------------------------ |
1042 | // Camera System Functions (Module: camera) |
1043 | //------------------------------------------------------------------------------------ |
1044 | RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) |
1045 | RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode |
1046 | |
1047 | RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) |
1048 | RLAPI void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera) |
1049 | RLAPI void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera) |
1050 | RLAPI void SetCameraMoveControls(int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras) |
1051 | |
1052 | //------------------------------------------------------------------------------------ |
1053 | // Basic Shapes Drawing Functions (Module: shapes) |
1054 | //------------------------------------------------------------------------------------ |
1055 | |
1056 | // Basic shapes drawing functions |
1057 | RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel |
1058 | RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) |
1059 | RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line |
1060 | RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) |
1061 | RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness |
1062 | RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out |
1063 | RLAPI void DrawLineStrip(Vector2 *points, int numPoints, Color color); // Draw lines sequence |
1064 | RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle |
1065 | RLAPI void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); // Draw a piece of a circle |
1066 | RLAPI void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); // Draw circle sector outline |
1067 | RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle |
1068 | RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) |
1069 | RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline |
1070 | RLAPI void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse |
1071 | RLAPI void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); // Draw ellipse outline |
1072 | RLAPI void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring |
1073 | RLAPI void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); // Draw ring outline |
1074 | RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle |
1075 | RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) |
1076 | RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle |
1077 | RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters |
1078 | RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle |
1079 | RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle |
1080 | RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors |
1081 | RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline |
1082 | RLAPI void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color); // Draw rectangle outline with extended parameters |
1083 | RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); // Draw rectangle with rounded edges |
1084 | RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color); // Draw rectangle with rounded edges outline |
1085 | RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) |
1086 | RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline (vertex in counter-clockwise order!) |
1087 | RLAPI void DrawTriangleFan(Vector2 *points, int numPoints, Color color); // Draw a triangle fan defined by points (first vertex is the center) |
1088 | RLAPI void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color); // Draw a triangle strip defined by points |
1089 | RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) |
1090 | RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides |
1091 | |
1092 | // Basic shapes collision detection functions |
1093 | RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles |
1094 | RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles |
1095 | RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle |
1096 | RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision |
1097 | RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle |
1098 | RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle |
1099 | RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle |
1100 | |
1101 | //------------------------------------------------------------------------------------ |
1102 | // Texture Loading and Drawing Functions (Module: textures) |
1103 | //------------------------------------------------------------------------------------ |
1104 | |
1105 | // Image loading functions |
1106 | // NOTE: This functions do not require GPU access |
1107 | RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) |
1108 | RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit) |
1109 | RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int ); // Load image from RAW file data |
1110 | RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM) |
1111 | RLAPI void ExportImage(Image image, const char *fileName); // Export image data to file |
1112 | RLAPI void ExportImageAsCode(Image image, const char *fileName); // Export image as code file defining an array of bytes |
1113 | RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array |
1114 | RLAPI Vector4 *GetImageDataNormalized(Image image); // Get pixel data from image as Vector4 array (float normalized) |
1115 | |
1116 | // Image generation functions |
1117 | RLAPI Image GenImageColor(int width, int height, Color color); // Generate image: plain color |
1118 | RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient |
1119 | RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient |
1120 | RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient |
1121 | RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked |
1122 | RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise |
1123 | RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise |
1124 | RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells |
1125 | |
1126 | // Image manipulation functions |
1127 | RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) |
1128 | RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece |
1129 | RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) |
1130 | RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) |
1131 | RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) |
1132 | RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format |
1133 | RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image |
1134 | RLAPI void ImageAlphaClear(Image *image, Color color, float threshold); // Clear alpha channel to desired color |
1135 | RLAPI void ImageAlphaCrop(Image *image, float threshold); // Crop image depending on alpha value |
1136 | RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel |
1137 | RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle |
1138 | RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm) |
1139 | RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm) |
1140 | RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color color); // Resize canvas and fill with color |
1141 | RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image |
1142 | RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) |
1143 | RLAPI void ImageFlipVertical(Image *image); // Flip image vertically |
1144 | RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally |
1145 | RLAPI void ImageRotateCW(Image *image); // Rotate image clockwise 90deg |
1146 | RLAPI void ImageRotateCCW(Image *image); // Rotate image counter-clockwise 90deg |
1147 | RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint |
1148 | RLAPI void ImageColorInvert(Image *image); // Modify image color: invert |
1149 | RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale |
1150 | RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) |
1151 | RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) |
1152 | RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color |
1153 | RLAPI Color *(Image image, int maxPaletteSize, int *); // Extract color palette from image to maximum size (memory should be freed) |
1154 | RLAPI Rectangle GetImageAlphaBorder(Image image, float threshold); // Get image alpha border rectangle |
1155 | |
1156 | // Image drawing functions |
1157 | // NOTE: Image software-rendering functions (CPU) |
1158 | RLAPI void ImageClearBackground(Image *dst, Color color); // Clear image background with given color |
1159 | RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color); // Draw pixel within an image |
1160 | RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version) |
1161 | RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image |
1162 | RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version) |
1163 | RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle within an image |
1164 | RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw circle within an image (Vector version) |
1165 | RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image |
1166 | RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version) |
1167 | RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image |
1168 | RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image |
1169 | 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) |
1170 | 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) |
1171 | 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) |
1172 | |
1173 | // Texture loading functions |
1174 | // NOTE: These functions require GPU access |
1175 | RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM) |
1176 | RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data |
1177 | RLAPI TextureCubemap LoadTextureCubemap(Image image, int layoutType); // Load cubemap from image, multiple image cubemap layouts supported |
1178 | RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer) |
1179 | RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM) |
1180 | RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM) |
1181 | RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data |
1182 | RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image |
1183 | RLAPI Image GetScreenData(void); // Get pixel data from screen buffer and return an Image (screenshot) |
1184 | |
1185 | // Texture configuration functions |
1186 | RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture |
1187 | RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode |
1188 | RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode |
1189 | |
1190 | // Texture drawing functions |
1191 | RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D |
1192 | RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 |
1193 | RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters |
1194 | RLAPI void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle |
1195 | RLAPI void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters |
1196 | RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters |
1197 | RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely |
1198 | |
1199 | // Image/Texture misc functions |
1200 | RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture) |
1201 | |
1202 | //------------------------------------------------------------------------------------ |
1203 | // Font Loading and Text Drawing Functions (Module: text) |
1204 | //------------------------------------------------------------------------------------ |
1205 | |
1206 | // Font loading/unloading functions |
1207 | RLAPI Font GetFontDefault(void); // Get the default Font |
1208 | RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM) |
1209 | RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters |
1210 | RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style) |
1211 | RLAPI CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use |
1212 | RLAPI Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info |
1213 | RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM) |
1214 | |
1215 | // Text drawing functions |
1216 | RLAPI void DrawFPS(int posX, int posY); // Shows current FPS |
1217 | RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) |
1218 | RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters |
1219 | RLAPI void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits |
1220 | RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, |
1221 | int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection |
1222 | RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint); // Draw one character (codepoint) |
1223 | |
1224 | // Text misc. functions |
1225 | RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font |
1226 | RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font |
1227 | RLAPI int GetGlyphIndex(Font font, int codepoint); // Get index position for a unicode character on font |
1228 | |
1229 | // Text strings management functions (no utf8 strings, only byte chars) |
1230 | // NOTE: Some strings allocate memory internally for returned strings, just be careful! |
1231 | RLAPI int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied |
1232 | RLAPI bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal |
1233 | RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending |
1234 | RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style) |
1235 | RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string |
1236 | RLAPI char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (memory must be freed!) |
1237 | RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (memory must be freed!) |
1238 | RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter |
1239 | RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings |
1240 | RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! |
1241 | RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string |
1242 | RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string |
1243 | RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string |
1244 | RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string |
1245 | RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) |
1246 | RLAPI char *TextToUtf8(int *codepoints, int length); // Encode text codepoint into utf8 text (memory must be freed!) |
1247 | |
1248 | // UTF8 text strings management functions |
1249 | RLAPI int *GetCodepoints(const char *text, int *count); // Get all codepoints in a string, codepoints count returned by parameters |
1250 | RLAPI int GetCodepointsCount(const char *text); // Get total number of characters (codepoints) in a UTF8 encoded string |
1251 | RLAPI int GetNextCodepoint(const char *text, int *bytesProcessed); // Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure |
1252 | RLAPI const char *CodepointToUtf8(int codepoint, int *byteLength); // Encode codepoint into utf8 text (char array length returned as parameter) |
1253 | |
1254 | //------------------------------------------------------------------------------------ |
1255 | // Basic 3d Shapes Drawing Functions (Module: models) |
1256 | //------------------------------------------------------------------------------------ |
1257 | |
1258 | // Basic geometric 3D shapes drawing functions |
1259 | RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space |
1260 | RLAPI void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line |
1261 | RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space |
1262 | RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube |
1263 | RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) |
1264 | RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires |
1265 | RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version) |
1266 | RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured |
1267 | RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere |
1268 | RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters |
1269 | RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires |
1270 | RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone |
1271 | RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires |
1272 | RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ |
1273 | RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line |
1274 | RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) |
1275 | RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo |
1276 | //DrawTorus(), DrawTeapot() could be useful? |
1277 | |
1278 | //------------------------------------------------------------------------------------ |
1279 | // Model 3d Loading and Drawing Functions (Module: models) |
1280 | //------------------------------------------------------------------------------------ |
1281 | |
1282 | // Model loading/unloading functions |
1283 | RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials) |
1284 | RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material) |
1285 | RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM) |
1286 | |
1287 | // Mesh loading/unloading functions |
1288 | RLAPI Mesh *LoadMeshes(const char *fileName, int *meshCount); // Load meshes from model file |
1289 | RLAPI void ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file |
1290 | RLAPI void UnloadMesh(Mesh mesh); // Unload mesh from memory (RAM and/or VRAM) |
1291 | |
1292 | // Material loading/unloading functions |
1293 | RLAPI Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file |
1294 | RLAPI Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) |
1295 | RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM) |
1296 | RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) |
1297 | RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh |
1298 | |
1299 | // Model animations loading/unloading functions |
1300 | RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount); // Load model animations from file |
1301 | RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose |
1302 | RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data |
1303 | RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match |
1304 | |
1305 | // Mesh generation functions |
1306 | RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh |
1307 | RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) |
1308 | RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh |
1309 | RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere) |
1310 | RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap) |
1311 | RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh |
1312 | RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh |
1313 | RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh |
1314 | RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data |
1315 | RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data |
1316 | |
1317 | // Mesh manipulation functions |
1318 | RLAPI BoundingBox MeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits |
1319 | RLAPI void MeshTangents(Mesh *mesh); // Compute mesh tangents |
1320 | RLAPI void MeshBinormals(Mesh *mesh); // Compute mesh binormals |
1321 | |
1322 | // Model drawing functions |
1323 | RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) |
1324 | RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters |
1325 | RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set) |
1326 | 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 parameters |
1327 | RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) |
1328 | RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture |
1329 | RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec |
1330 | |
1331 | // Collision detection functions |
1332 | RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres |
1333 | RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes |
1334 | RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere |
1335 | RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius); // Detect collision between ray and sphere |
1336 | RLAPI bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *collisionPoint); // Detect collision between ray and sphere, returns collision point |
1337 | RLAPI bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box |
1338 | RLAPI RayHitInfo GetCollisionRayModel(Ray ray, Model model); // Get collision info between ray and model |
1339 | RLAPI RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle |
1340 | RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Get collision info between ray and ground plane (Y-normal plane) |
1341 | |
1342 | //------------------------------------------------------------------------------------ |
1343 | // Shaders System Functions (Module: rlgl) |
1344 | // NOTE: This functions are useless when using OpenGL 1.1 |
1345 | //------------------------------------------------------------------------------------ |
1346 | |
1347 | // Shader loading/unloading functions |
1348 | RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations |
1349 | RLAPI Shader LoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations |
1350 | RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) |
1351 | |
1352 | RLAPI Shader GetShaderDefault(void); // Get default shader |
1353 | RLAPI Texture2D GetTextureDefault(void); // Get default texture |
1354 | RLAPI Texture2D GetShapesTexture(void); // Get texture to draw shapes |
1355 | RLAPI Rectangle GetShapesTextureRec(void); // Get texture rectangle to draw shapes |
1356 | RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Define default texture used to draw shapes |
1357 | |
1358 | // Shader configuration functions |
1359 | RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location |
1360 | RLAPI void SetShaderValue(Shader shader, int uniformLoc, const void *value, int uniformType); // Set shader uniform value |
1361 | RLAPI void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int uniformType, int count); // Set shader uniform value vector |
1362 | RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4) |
1363 | RLAPI void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture); // Set shader uniform value for texture |
1364 | RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix) |
1365 | RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix) |
1366 | RLAPI Matrix GetMatrixModelview(void); // Get internal modelview matrix |
1367 | RLAPI Matrix GetMatrixProjection(void); // Get internal projection matrix |
1368 | |
1369 | // Texture maps generation (PBR) |
1370 | // NOTE: Required shaders should be provided |
1371 | RLAPI Texture2D GenTextureCubemap(Shader shader, Texture2D map, int size); // Generate cubemap texture from 2D texture |
1372 | RLAPI Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data |
1373 | RLAPI Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data |
1374 | RLAPI Texture2D GenTextureBRDF(Shader shader, int size); // Generate BRDF texture |
1375 | |
1376 | // Shading begin/end functions |
1377 | RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing |
1378 | RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader) |
1379 | RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) |
1380 | RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending) |
1381 | |
1382 | // VR control functions |
1383 | RLAPI void InitVrSimulator(void); // Init VR simulator for selected device parameters |
1384 | RLAPI void CloseVrSimulator(void); // Close VR simulator for current device |
1385 | RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera |
1386 | RLAPI void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters |
1387 | RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready |
1388 | RLAPI void ToggleVrMode(void); // Enable/Disable VR experience |
1389 | RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering |
1390 | RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering |
1391 | |
1392 | //------------------------------------------------------------------------------------ |
1393 | // Audio Loading and Playing Functions (Module: audio) |
1394 | //------------------------------------------------------------------------------------ |
1395 | |
1396 | // Audio device management functions |
1397 | RLAPI void InitAudioDevice(void); // Initialize audio device and context |
1398 | RLAPI void CloseAudioDevice(void); // Close the audio device and context |
1399 | RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully |
1400 | RLAPI void SetMasterVolume(float volume); // Set master volume (listener) |
1401 | |
1402 | // Wave/Sound loading/unloading functions |
1403 | RLAPI Wave LoadWave(const char *fileName); // Load wave data from file |
1404 | RLAPI Sound LoadSound(const char *fileName); // Load sound from file |
1405 | RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data |
1406 | RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data |
1407 | RLAPI void UnloadWave(Wave wave); // Unload wave data |
1408 | RLAPI void UnloadSound(Sound sound); // Unload sound |
1409 | RLAPI void ExportWave(Wave wave, const char *fileName); // Export wave data to file |
1410 | RLAPI void ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h) |
1411 | |
1412 | // Wave/Sound management functions |
1413 | RLAPI void PlaySound(Sound sound); // Play a sound |
1414 | RLAPI void StopSound(Sound sound); // Stop playing a sound |
1415 | RLAPI void PauseSound(Sound sound); // Pause a sound |
1416 | RLAPI void ResumeSound(Sound sound); // Resume a paused sound |
1417 | RLAPI void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool) |
1418 | RLAPI void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool) |
1419 | RLAPI int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel |
1420 | RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing |
1421 | RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) |
1422 | RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) |
1423 | RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format |
1424 | RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave |
1425 | RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range |
1426 | RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array |
1427 | |
1428 | // Music management functions |
1429 | RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file |
1430 | RLAPI void UnloadMusicStream(Music music); // Unload music stream |
1431 | RLAPI void PlayMusicStream(Music music); // Start music playing |
1432 | RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming |
1433 | RLAPI void StopMusicStream(Music music); // Stop music playing |
1434 | RLAPI void PauseMusicStream(Music music); // Pause music playing |
1435 | RLAPI void ResumeMusicStream(Music music); // Resume playing paused music |
1436 | RLAPI bool IsMusicPlaying(Music music); // Check if music is playing |
1437 | RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) |
1438 | RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level) |
1439 | RLAPI void SetMusicLoopCount(Music music, int count); // Set music loop count (loop repeats) |
1440 | RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds) |
1441 | RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) |
1442 | |
1443 | // AudioStream management functions |
1444 | RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data) |
1445 | RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data |
1446 | RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory |
1447 | RLAPI bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill |
1448 | RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream |
1449 | RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream |
1450 | RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream |
1451 | RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing |
1452 | RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream |
1453 | RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level) |
1454 | RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level) |
1455 | RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams |
1456 | |
1457 | //------------------------------------------------------------------------------------ |
1458 | // Network (Module: network) |
1459 | //------------------------------------------------------------------------------------ |
1460 | |
1461 | // IN PROGRESS: Check rnet.h for reference |
1462 | |
1463 | #if defined(__cplusplus) |
1464 | } |
1465 | #endif |
1466 | |
1467 | #endif // RAYLIB_H |
1468 | |