1084 lines
65 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib v1.8.0
  4. *
  5. * A simple and easy-to-use library to learn videogames programming (www.raylib.com)
  6. *
  7. * FEATURES:
  8. * - Library written in plain C code (C99)
  9. * - Multiple platforms supported: Windows, Linux, Mac, Android, Raspberry Pi, HTML5.
  10. * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0)
  11. * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
  12. * - Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF)
  13. * - Multiple textures support, including compressed formats and mipmaps generation
  14. * - Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
  15. * - Powerful math module for Vector2, Vector3, Matrix and Quaternion operations: [raymath]
  16. * - Audio loading and playing with streaming support and mixing channels: [audio]
  17. * - VR stereo rendering support with configurable HMD device parameters
  18. * - Minimal external dependencies (GLFW3, OpenGL, OpenAL)
  19. * - Complete bindings for Lua, Go and Pascal
  20. *
  21. * NOTES:
  22. * 32bit Colors - Any defined Color is always RGBA (4 byte)
  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:
  28. * GLFW3 (www.glfw.org) for window/context management and input [core]
  29. * GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
  30. * OpenAL Soft for audio device/context management [audio]
  31. *
  32. * OPTIONAL DEPENDENCIES:
  33. * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures]
  34. * stb_image_write (Sean Barret) for image writting (PNG) [utils]
  35. * stb_truetype (Sean Barret) for ttf fonts loading [text]
  36. * stb_vorbis (Sean Barret) for ogg audio loading [audio]
  37. * jar_xm (Joshua Reisenauer) for XM audio module loading [audio]
  38. * jar_mod (Joshua Reisenauer) for MOD audio module loading [audio]
  39. * dr_flac (David Reid) for FLAC audio file loading [audio]
  40. * tinfl for data decompression (DEFLATE algorithm) [rres]
  41. *
  42. *
  43. * LICENSE: zlib/libpng
  44. *
  45. * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  46. * BSD-like license that allows static linking with closed source software:
  47. *
  48. * Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
  49. *
  50. * This software is provided "as-is", without any express or implied warranty. In no event
  51. * will the authors be held liable for any damages arising from the use of this software.
  52. *
  53. * Permission is granted to anyone to use this software for any purpose, including commercial
  54. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  55. *
  56. * 1. The origin of this software must not be misrepresented; you must not claim that you
  57. * wrote the original software. If you use this software in a product, an acknowledgment
  58. * in the product documentation would be appreciated but is not required.
  59. *
  60. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  61. * as being the original software.
  62. *
  63. * 3. This notice may not be removed or altered from any source distribution.
  64. *
  65. **********************************************************************************************/
  66. #ifndef RAYLIB_H
  67. #define RAYLIB_H
  68. // Choose your platform here or just define it at compile time: -DPLATFORM_DESKTOP
  69. //#define PLATFORM_DESKTOP // Windows, Linux or OSX
  70. //#define PLATFORM_ANDROID // Android device
  71. //#define PLATFORM_RPI // Raspberry Pi
  72. //#define PLATFORM_WEB // HTML5 (emscripten, asm.js)
  73. // Security check in case no PLATFORM_* defined
  74. #if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEB)
  75. #define PLATFORM_DESKTOP
  76. #endif
  77. #if defined(_WIN32) && defined(BUILDING_DLL)
  78. #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL
  79. #elif defined(_WIN32) && defined(RAYLIB_DLL)
  80. #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 DLL
  81. #else
  82. #define RLAPI // We are building or using raylib as a static library (or Linux shared library)
  83. #endif
  84. //----------------------------------------------------------------------------------
  85. // Some basic Defines
  86. //----------------------------------------------------------------------------------
  87. #ifndef PI
  88. #define PI 3.14159265358979323846f
  89. #endif
  90. #define DEG2RAD (PI/180.0f)
  91. #define RAD2DEG (180.0f/PI)
  92. // raylib Config Flags
  93. #define FLAG_SHOW_LOGO 1 // Set to show raylib logo at startup
  94. #define FLAG_FULLSCREEN_MODE 2 // Set to run program in fullscreen
  95. #define FLAG_WINDOW_RESIZABLE 4 // Set to allow resizable window
  96. #define FLAG_WINDOW_DECORATED 8 // Set to show window decoration (frame and buttons)
  97. #define FLAG_WINDOW_TRANSPARENT 16 // Set to allow transparent window
  98. #define FLAG_MSAA_4X_HINT 32 // Set to try enabling MSAA 4X
  99. #define FLAG_VSYNC_HINT 64 // Set to try enabling V-Sync on GPU
  100. // Keyboard Function Keys
  101. #define KEY_SPACE 32
  102. #define KEY_ESCAPE 256
  103. #define KEY_ENTER 257
  104. #define KEY_BACKSPACE 259
  105. #define KEY_RIGHT 262
  106. #define KEY_LEFT 263
  107. #define KEY_DOWN 264
  108. #define KEY_UP 265
  109. #define KEY_F1 290
  110. #define KEY_F2 291
  111. #define KEY_F3 292
  112. #define KEY_F4 293
  113. #define KEY_F5 294
  114. #define KEY_F6 295
  115. #define KEY_F7 296
  116. #define KEY_F8 297
  117. #define KEY_F9 298
  118. #define KEY_F10 299
  119. #define KEY_F11 300
  120. #define KEY_F12 301
  121. #define KEY_LEFT_SHIFT 340
  122. #define KEY_LEFT_CONTROL 341
  123. #define KEY_LEFT_ALT 342
  124. #define KEY_RIGHT_SHIFT 344
  125. #define KEY_RIGHT_CONTROL 345
  126. #define KEY_RIGHT_ALT 346
  127. // Keyboard Alpha Numeric Keys
  128. #define KEY_ZERO 48
  129. #define KEY_ONE 49
  130. #define KEY_TWO 50
  131. #define KEY_THREE 51
  132. #define KEY_FOUR 52
  133. #define KEY_FIVE 53
  134. #define KEY_SIX 54
  135. #define KEY_SEVEN 55
  136. #define KEY_EIGHT 56
  137. #define KEY_NINE 57
  138. #define KEY_A 65
  139. #define KEY_B 66
  140. #define KEY_C 67
  141. #define KEY_D 68
  142. #define KEY_E 69
  143. #define KEY_F 70
  144. #define KEY_G 71
  145. #define KEY_H 72
  146. #define KEY_I 73
  147. #define KEY_J 74
  148. #define KEY_K 75
  149. #define KEY_L 76
  150. #define KEY_M 77
  151. #define KEY_N 78
  152. #define KEY_O 79
  153. #define KEY_P 80
  154. #define KEY_Q 81
  155. #define KEY_R 82
  156. #define KEY_S 83
  157. #define KEY_T 84
  158. #define KEY_U 85
  159. #define KEY_V 86
  160. #define KEY_W 87
  161. #define KEY_X 88
  162. #define KEY_Y 89
  163. #define KEY_Z 90
  164. #if defined(PLATFORM_ANDROID)
  165. // Android Physical Buttons
  166. #define KEY_BACK 4
  167. #define KEY_MENU 82
  168. #define KEY_VOLUME_UP 24
  169. #define KEY_VOLUME_DOWN 25
  170. #endif
  171. // Mouse Buttons
  172. #define MOUSE_LEFT_BUTTON 0
  173. #define MOUSE_RIGHT_BUTTON 1
  174. #define MOUSE_MIDDLE_BUTTON 2
  175. // Touch points registered
  176. #define MAX_TOUCH_POINTS 2
  177. // Gamepad Number
  178. #define GAMEPAD_PLAYER1 0
  179. #define GAMEPAD_PLAYER2 1
  180. #define GAMEPAD_PLAYER3 2
  181. #define GAMEPAD_PLAYER4 3
  182. // Gamepad Buttons/Axis
  183. // PS3 USB Controller Buttons
  184. #define GAMEPAD_PS3_BUTTON_TRIANGLE 0
  185. #define GAMEPAD_PS3_BUTTON_CIRCLE 1
  186. #define GAMEPAD_PS3_BUTTON_CROSS 2
  187. #define GAMEPAD_PS3_BUTTON_SQUARE 3
  188. #define GAMEPAD_PS3_BUTTON_L1 6
  189. #define GAMEPAD_PS3_BUTTON_R1 7
  190. #define GAMEPAD_PS3_BUTTON_L2 4
  191. #define GAMEPAD_PS3_BUTTON_R2 5
  192. #define GAMEPAD_PS3_BUTTON_START 8
  193. #define GAMEPAD_PS3_BUTTON_SELECT 9
  194. #define GAMEPAD_PS3_BUTTON_UP 24
  195. #define GAMEPAD_PS3_BUTTON_RIGHT 25
  196. #define GAMEPAD_PS3_BUTTON_DOWN 26
  197. #define GAMEPAD_PS3_BUTTON_LEFT 27
  198. #define GAMEPAD_PS3_BUTTON_PS 12
  199. // PS3 USB Controller Axis
  200. #define GAMEPAD_PS3_AXIS_LEFT_X 0
  201. #define GAMEPAD_PS3_AXIS_LEFT_Y 1
  202. #define GAMEPAD_PS3_AXIS_RIGHT_X 2
  203. #define GAMEPAD_PS3_AXIS_RIGHT_Y 5
  204. #define GAMEPAD_PS3_AXIS_L2 3 // [1..-1] (pressure-level)
  205. #define GAMEPAD_PS3_AXIS_R2 4 // [1..-1] (pressure-level)
  206. // Xbox360 USB Controller Buttons
  207. #define GAMEPAD_XBOX_BUTTON_A 0
  208. #define GAMEPAD_XBOX_BUTTON_B 1
  209. #define GAMEPAD_XBOX_BUTTON_X 2
  210. #define GAMEPAD_XBOX_BUTTON_Y 3
  211. #define GAMEPAD_XBOX_BUTTON_LB 4
  212. #define GAMEPAD_XBOX_BUTTON_RB 5
  213. #define GAMEPAD_XBOX_BUTTON_SELECT 6
  214. #define GAMEPAD_XBOX_BUTTON_START 7
  215. #define GAMEPAD_XBOX_BUTTON_UP 10
  216. #define GAMEPAD_XBOX_BUTTON_RIGHT 11
  217. #define GAMEPAD_XBOX_BUTTON_DOWN 12
  218. #define GAMEPAD_XBOX_BUTTON_LEFT 13
  219. #define GAMEPAD_XBOX_BUTTON_HOME 8
  220. // Xbox360 USB Controller Axis
  221. // NOTE: For Raspberry Pi, axis must be reconfigured
  222. #if defined(PLATFORM_RPI)
  223. #define GAMEPAD_XBOX_AXIS_LEFT_X 0 // [-1..1] (left->right)
  224. #define GAMEPAD_XBOX_AXIS_LEFT_Y 1 // [-1..1] (up->down)
  225. #define GAMEPAD_XBOX_AXIS_RIGHT_X 3 // [-1..1] (left->right)
  226. #define GAMEPAD_XBOX_AXIS_RIGHT_Y 4 // [-1..1] (up->down)
  227. #define GAMEPAD_XBOX_AXIS_LT 2 // [-1..1] (pressure-level)
  228. #define GAMEPAD_XBOX_AXIS_RT 5 // [-1..1] (pressure-level)
  229. #else
  230. #define GAMEPAD_XBOX_AXIS_LEFT_X 0 // [-1..1] (left->right)
  231. #define GAMEPAD_XBOX_AXIS_LEFT_Y 1 // [1..-1] (up->down)
  232. #define GAMEPAD_XBOX_AXIS_RIGHT_X 2 // [-1..1] (left->right)
  233. #define GAMEPAD_XBOX_AXIS_RIGHT_Y 3 // [1..-1] (up->down)
  234. #define GAMEPAD_XBOX_AXIS_LT 4 // [-1..1] (pressure-level)
  235. #define GAMEPAD_XBOX_AXIS_RT 5 // [-1..1] (pressure-level)
  236. #endif
  237. // NOTE: MSC C++ compiler does not support compound literals (C99 feature)
  238. // Plain structures in C++ (without constructors) can be initialized from { } initializers.
  239. #ifdef __cplusplus
  240. #define CLITERAL
  241. #else
  242. #define CLITERAL (Color)
  243. #endif
  244. // Some Basic Colors
  245. // NOTE: Custom raylib color palette for amazing visuals on WHITE background
  246. #define LIGHTGRAY CLITERAL{ 200, 200, 200, 255 } // Light Gray
  247. #define GRAY CLITERAL{ 130, 130, 130, 255 } // Gray
  248. #define DARKGRAY CLITERAL{ 80, 80, 80, 255 } // Dark Gray
  249. #define YELLOW CLITERAL{ 253, 249, 0, 255 } // Yellow
  250. #define GOLD CLITERAL{ 255, 203, 0, 255 } // Gold
  251. #define ORANGE CLITERAL{ 255, 161, 0, 255 } // Orange
  252. #define PINK CLITERAL{ 255, 109, 194, 255 } // Pink
  253. #define RED CLITERAL{ 230, 41, 55, 255 } // Red
  254. #define MAROON CLITERAL{ 190, 33, 55, 255 } // Maroon
  255. #define GREEN CLITERAL{ 0, 228, 48, 255 } // Green
  256. #define LIME CLITERAL{ 0, 158, 47, 255 } // Lime
  257. #define DARKGREEN CLITERAL{ 0, 117, 44, 255 } // Dark Green
  258. #define SKYBLUE CLITERAL{ 102, 191, 255, 255 } // Sky Blue
  259. #define BLUE CLITERAL{ 0, 121, 241, 255 } // Blue
  260. #define DARKBLUE CLITERAL{ 0, 82, 172, 255 } // Dark Blue
  261. #define PURPLE CLITERAL{ 200, 122, 255, 255 } // Purple
  262. #define VIOLET CLITERAL{ 135, 60, 190, 255 } // Violet
  263. #define DARKPURPLE CLITERAL{ 112, 31, 126, 255 } // Dark Purple
  264. #define BEIGE CLITERAL{ 211, 176, 131, 255 } // Beige
  265. #define BROWN CLITERAL{ 127, 106, 79, 255 } // Brown
  266. #define DARKBROWN CLITERAL{ 76, 63, 47, 255 } // Dark Brown
  267. #define WHITE CLITERAL{ 255, 255, 255, 255 } // White
  268. #define BLACK CLITERAL{ 0, 0, 0, 255 } // Black
  269. #define BLANK CLITERAL{ 0, 0, 0, 0 } // Blank (Transparent)
  270. #define MAGENTA CLITERAL{ 255, 0, 255, 255 } // Magenta
  271. #define RAYWHITE CLITERAL{ 245, 245, 245, 255 } // My own White (raylib logo)
  272. //----------------------------------------------------------------------------------
  273. // Structures Definition
  274. //----------------------------------------------------------------------------------
  275. #ifndef __cplusplus
  276. // Boolean type
  277. #if !defined(_STDBOOL_H) || !defined(__STDBOOL_H) // CLang uses second form
  278. typedef enum { false, true } bool;
  279. #endif
  280. #endif
  281. // Vector2 type
  282. typedef struct Vector2 {
  283. float x;
  284. float y;
  285. } Vector2;
  286. // Vector3 type
  287. typedef struct Vector3 {
  288. float x;
  289. float y;
  290. float z;
  291. } Vector3;
  292. // Matrix type (OpenGL style 4x4 - right handed, column major)
  293. typedef struct Matrix {
  294. float m0, m4, m8, m12;
  295. float m1, m5, m9, m13;
  296. float m2, m6, m10, m14;
  297. float m3, m7, m11, m15;
  298. } Matrix;
  299. // Color type, RGBA (32bit)
  300. typedef struct Color {
  301. unsigned char r;
  302. unsigned char g;
  303. unsigned char b;
  304. unsigned char a;
  305. } Color;
  306. // Rectangle type
  307. typedef struct Rectangle {
  308. int x;
  309. int y;
  310. int width;
  311. int height;
  312. } Rectangle;
  313. // Image type, bpp always RGBA (32bit)
  314. // NOTE: Data stored in CPU memory (RAM)
  315. typedef struct Image {
  316. void *data; // Image raw data
  317. int width; // Image base width
  318. int height; // Image base height
  319. int mipmaps; // Mipmap levels, 1 by default
  320. int format; // Data format (TextureFormat type)
  321. } Image;
  322. // Texture2D type
  323. // NOTE: Data stored in GPU memory
  324. typedef struct Texture2D {
  325. unsigned int id; // OpenGL texture id
  326. int width; // Texture base width
  327. int height; // Texture base height
  328. int mipmaps; // Mipmap levels, 1 by default
  329. int format; // Data format (TextureFormat type)
  330. } Texture2D;
  331. // RenderTexture2D type, for texture rendering
  332. typedef struct RenderTexture2D {
  333. unsigned int id; // OpenGL Framebuffer Object (FBO) id
  334. Texture2D texture; // Color buffer attachment texture
  335. Texture2D depth; // Depth buffer attachment texture
  336. } RenderTexture2D;
  337. // SpriteFont character info
  338. typedef struct CharInfo {
  339. int value; // Character value (Unicode)
  340. Rectangle rec; // Character rectangle in sprite font
  341. int offsetX; // Character offset X when drawing
  342. int offsetY; // Character offset Y when drawing
  343. int advanceX; // Character advance position X
  344. } CharInfo;
  345. // SpriteFont type, includes texture and charSet array data
  346. typedef struct SpriteFont {
  347. Texture2D texture; // Font texture
  348. int baseSize; // Base size (default chars height)
  349. int charsCount; // Number of characters
  350. CharInfo *chars; // Characters info data
  351. } SpriteFont;
  352. // Camera type, defines a camera position/orientation in 3d space
  353. typedef struct Camera {
  354. Vector3 position; // Camera position
  355. Vector3 target; // Camera target it looks-at
  356. Vector3 up; // Camera up vector (rotation over its axis)
  357. float fovy; // Camera field-of-view apperture in Y (degrees)
  358. } Camera;
  359. // Camera2D type, defines a 2d camera
  360. typedef struct Camera2D {
  361. Vector2 offset; // Camera offset (displacement from target)
  362. Vector2 target; // Camera target (rotation and zoom origin)
  363. float rotation; // Camera rotation in degrees
  364. float zoom; // Camera zoom (scaling), should be 1.0f by default
  365. } Camera2D;
  366. // Bounding box type
  367. typedef struct BoundingBox {
  368. Vector3 min; // minimum vertex box-corner
  369. Vector3 max; // maximum vertex box-corner
  370. } BoundingBox;
  371. // Vertex data definning a mesh
  372. typedef struct Mesh {
  373. int vertexCount; // number of vertices stored in arrays
  374. int triangleCount; // number of triangles stored (indexed or not)
  375. float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
  376. float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
  377. float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
  378. float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
  379. float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
  380. unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
  381. unsigned short *indices;// vertex indices (in case vertex data comes indexed)
  382. unsigned int vaoId; // OpenGL Vertex Array Object id
  383. unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
  384. } Mesh;
  385. // Shader type (generic shader)
  386. typedef struct Shader {
  387. unsigned int id; // Shader program id
  388. // Vertex attributes locations (default locations)
  389. int vertexLoc; // Vertex attribute location point (default-location = 0)
  390. int texcoordLoc; // Texcoord attribute location point (default-location = 1)
  391. int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
  392. int normalLoc; // Normal attribute location point (default-location = 2)
  393. int tangentLoc; // Tangent attribute location point (default-location = 4)
  394. int colorLoc; // Color attibute location point (default-location = 3)
  395. // Uniform locations
  396. int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
  397. int colDiffuseLoc; // Diffuse color uniform location point (fragment shader)
  398. int colAmbientLoc; // Ambient color uniform location point (fragment shader)
  399. int colSpecularLoc; // Specular color uniform location point (fragment shader)
  400. // Texture map locations (generic for any kind of map)
  401. int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
  402. int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
  403. int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
  404. } Shader;
  405. // Material type
  406. typedef struct Material {
  407. Shader shader; // Standard shader (supports 3 map textures)
  408. Texture2D texDiffuse; // Diffuse texture (binded to shader mapTexture0Loc)
  409. Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc)
  410. Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc)
  411. Color colDiffuse; // Diffuse color
  412. Color colAmbient; // Ambient color
  413. Color colSpecular; // Specular color
  414. float glossiness; // Glossiness level (Ranges from 0 to 1000)
  415. } Material;
  416. // Model type
  417. typedef struct Model {
  418. Mesh mesh; // Vertex data buffers (RAM and VRAM)
  419. Matrix transform; // Local transform matrix
  420. Material material; // Shader and textures data
  421. } Model;
  422. // Ray type (useful for raycast)
  423. typedef struct Ray {
  424. Vector3 position; // Ray position (origin)
  425. Vector3 direction; // Ray direction
  426. } Ray;
  427. // Raycast hit information
  428. typedef struct RayHitInfo {
  429. bool hit; // Did the ray hit something?
  430. float distance; // Distance to nearest hit
  431. Vector3 position; // Position of nearest hit
  432. Vector3 normal; // Surface normal of hit
  433. } RayHitInfo;
  434. // Wave type, defines audio wave data
  435. typedef struct Wave {
  436. unsigned int sampleCount; // Number of samples
  437. unsigned int sampleRate; // Frequency (samples per second)
  438. unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
  439. unsigned int channels; // Number of channels (1-mono, 2-stereo)
  440. void *data; // Buffer data pointer
  441. } Wave;
  442. // Sound source type
  443. typedef struct Sound {
  444. unsigned int source; // OpenAL audio source id
  445. unsigned int buffer; // OpenAL audio buffer id
  446. int format; // OpenAL audio format specifier
  447. } Sound;
  448. // Music type (file streaming from memory)
  449. // NOTE: Anything longer than ~10 seconds should be streamed
  450. typedef struct MusicData *Music;
  451. // Audio stream type
  452. // NOTE: Useful to create custom audio streams not bound to a specific file
  453. typedef struct AudioStream {
  454. unsigned int sampleRate; // Frequency (samples per second)
  455. unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
  456. unsigned int channels; // Number of channels (1-mono, 2-stereo)
  457. int format; // OpenAL audio format specifier
  458. unsigned int source; // OpenAL audio source id
  459. unsigned int buffers[2]; // OpenAL audio buffers (double buffering)
  460. } AudioStream;
  461. // rRES data returned when reading a resource,
  462. // it contains all required data for user (24 byte)
  463. typedef struct RRESData {
  464. unsigned int type; // Resource type (4 byte)
  465. unsigned int param1; // Resouce parameter 1 (4 byte)
  466. unsigned int param2; // Resouce parameter 2 (4 byte)
  467. unsigned int param3; // Resouce parameter 3 (4 byte)
  468. unsigned int param4; // Resouce parameter 4 (4 byte)
  469. void *data; // Resource data pointer (4 byte)
  470. } RRESData;
  471. // RRES type (pointer to RRESData array)
  472. typedef struct RRESData *RRES;
  473. //----------------------------------------------------------------------------------
  474. // Enumerators Definition
  475. //----------------------------------------------------------------------------------
  476. // Trace log type
  477. typedef enum {
  478. LOG_INFO = 0,
  479. LOG_WARNING,
  480. LOG_ERROR,
  481. LOG_DEBUG,
  482. LOG_OTHER
  483. } LogType;
  484. // Texture formats
  485. // NOTE: Support depends on OpenGL version and platform
  486. typedef enum {
  487. UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
  488. UNCOMPRESSED_GRAY_ALPHA, // 16 bpp (2 channels)
  489. UNCOMPRESSED_R5G6B5, // 16 bpp
  490. UNCOMPRESSED_R8G8B8, // 24 bpp
  491. UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
  492. UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
  493. UNCOMPRESSED_R8G8B8A8, // 32 bpp
  494. UNCOMPRESSED_R32G32B32, // 32 bit per channel (float) - HDR
  495. COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
  496. COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
  497. COMPRESSED_DXT3_RGBA, // 8 bpp
  498. COMPRESSED_DXT5_RGBA, // 8 bpp
  499. COMPRESSED_ETC1_RGB, // 4 bpp
  500. COMPRESSED_ETC2_RGB, // 4 bpp
  501. COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
  502. COMPRESSED_PVRT_RGB, // 4 bpp
  503. COMPRESSED_PVRT_RGBA, // 4 bpp
  504. COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
  505. COMPRESSED_ASTC_8x8_RGBA // 2 bpp
  506. } TextureFormat;
  507. // Texture parameters: filter mode
  508. // NOTE 1: Filtering considers mipmaps if available in the texture
  509. // NOTE 2: Filter is accordingly set for minification and magnification
  510. typedef enum {
  511. FILTER_POINT = 0, // No filter, just pixel aproximation
  512. FILTER_BILINEAR, // Linear filtering
  513. FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
  514. FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
  515. FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x
  516. FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
  517. } TextureFilterMode;
  518. // Texture parameters: wrap mode
  519. typedef enum {
  520. WRAP_REPEAT = 0,
  521. WRAP_CLAMP,
  522. WRAP_MIRROR
  523. } TextureWrapMode;
  524. // Color blending modes (pre-defined)
  525. typedef enum {
  526. BLEND_ALPHA = 0,
  527. BLEND_ADDITIVE,
  528. BLEND_MULTIPLIED
  529. } BlendMode;
  530. // Gestures type
  531. // NOTE: It could be used as flags to enable only some gestures
  532. typedef enum {
  533. GESTURE_NONE = 0,
  534. GESTURE_TAP = 1,
  535. GESTURE_DOUBLETAP = 2,
  536. GESTURE_HOLD = 4,
  537. GESTURE_DRAG = 8,
  538. GESTURE_SWIPE_RIGHT = 16,
  539. GESTURE_SWIPE_LEFT = 32,
  540. GESTURE_SWIPE_UP = 64,
  541. GESTURE_SWIPE_DOWN = 128,
  542. GESTURE_PINCH_IN = 256,
  543. GESTURE_PINCH_OUT = 512
  544. } Gestures;
  545. // Camera system modes
  546. typedef enum {
  547. CAMERA_CUSTOM = 0,
  548. CAMERA_FREE,
  549. CAMERA_ORBITAL,
  550. CAMERA_FIRST_PERSON,
  551. CAMERA_THIRD_PERSON
  552. } CameraMode;
  553. // Head Mounted Display devices
  554. typedef enum {
  555. HMD_DEFAULT_DEVICE = 0,
  556. HMD_OCULUS_RIFT_DK2,
  557. HMD_OCULUS_RIFT_CV1,
  558. HMD_VALVE_HTC_VIVE,
  559. HMD_SAMSUNG_GEAR_VR,
  560. HMD_GOOGLE_CARDBOARD,
  561. HMD_SONY_PLAYSTATION_VR,
  562. HMD_RAZER_OSVR,
  563. HMD_FOVE_VR,
  564. } VrDevice;
  565. // RRESData type
  566. typedef enum {
  567. RRES_TYPE_RAW = 0,
  568. RRES_TYPE_IMAGE,
  569. RRES_TYPE_WAVE,
  570. RRES_TYPE_VERTEX,
  571. RRES_TYPE_TEXT,
  572. RRES_TYPE_FONT_IMAGE,
  573. RRES_TYPE_FONT_CHARDATA, // CharInfo data array
  574. RRES_TYPE_DIRECTORY
  575. } RRESDataType;
  576. #ifdef __cplusplus
  577. extern "C" { // Prevents name mangling of functions
  578. #endif
  579. //------------------------------------------------------------------------------------
  580. // Global Variables Definition
  581. //------------------------------------------------------------------------------------
  582. // It's lonely here...
  583. //------------------------------------------------------------------------------------
  584. // Window and Graphics Device Functions (Module: core)
  585. //------------------------------------------------------------------------------------
  586. // Window-related functions
  587. #if defined(PLATFORM_ANDROID)
  588. RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
  589. #elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
  590. RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
  591. #endif
  592. RLAPI void CloseWindow(void); // Close window and unload OpenGL context
  593. RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
  594. RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
  595. RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
  596. RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
  597. RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
  598. RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
  599. RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
  600. RLAPI int GetScreenWidth(void); // Get current screen width
  601. RLAPI int GetScreenHeight(void); // Get current screen height
  602. #if !defined(PLATFORM_ANDROID)
  603. // Cursor-related functions
  604. RLAPI void ShowCursor(void); // Shows cursor
  605. RLAPI void HideCursor(void); // Hides cursor
  606. RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
  607. RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)
  608. RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
  609. #endif
  610. // Drawing-related functions
  611. RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
  612. RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
  613. RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
  614. RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
  615. RLAPI void End2dMode(void); // Ends 2D mode with custom camera
  616. RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
  617. RLAPI void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
  618. RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
  619. RLAPI void EndTextureMode(void); // Ends drawing to render texture
  620. // Screen-space-related functions
  621. RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
  622. RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
  623. RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
  624. // Timming-related functions
  625. RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
  626. RLAPI int GetFPS(void); // Returns current FPS
  627. RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
  628. // Color-related functions
  629. RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
  630. RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
  631. RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  632. RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
  633. RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
  634. RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
  635. // Misc. functions
  636. RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
  637. RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
  638. RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
  639. RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
  640. RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
  641. // Files management functions
  642. RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
  643. RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
  644. RLAPI const char *GetWorkingDirectory(void); // Get current working directory
  645. RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success
  646. RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
  647. RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
  648. RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
  649. // Persistent storage management
  650. RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
  651. RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
  652. //------------------------------------------------------------------------------------
  653. // Input Handling Functions (Module: core)
  654. //------------------------------------------------------------------------------------
  655. // Input-related functions: keyboard
  656. RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
  657. RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
  658. RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
  659. RLAPI bool IsKeyUp(int key); // Detect if a key is NOT being pressed
  660. RLAPI int GetKeyPressed(void); // Get latest key pressed
  661. RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
  662. // Input-related functions: gamepads
  663. RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
  664. RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
  665. RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
  666. RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
  667. RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
  668. RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
  669. RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
  670. RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
  671. RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
  672. RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
  673. // Input-related functions: mouse
  674. RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
  675. RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
  676. RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
  677. RLAPI bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
  678. RLAPI int GetMouseX(void); // Returns mouse position X
  679. RLAPI int GetMouseY(void); // Returns mouse position Y
  680. RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
  681. RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
  682. RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
  683. // Input-related functions: touch
  684. RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
  685. RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
  686. RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
  687. //------------------------------------------------------------------------------------
  688. // Gestures and Touch Handling Functions (Module: gestures)
  689. //------------------------------------------------------------------------------------
  690. RLAPI void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
  691. RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected
  692. RLAPI int GetGestureDetected(void); // Get latest detected gesture
  693. RLAPI int GetTouchPointsCount(void); // Get touch points count
  694. RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
  695. RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
  696. RLAPI float GetGestureDragAngle(void); // Get gesture drag angle
  697. RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
  698. RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle
  699. //------------------------------------------------------------------------------------
  700. // Camera System Functions (Module: camera)
  701. //------------------------------------------------------------------------------------
  702. RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
  703. RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
  704. RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
  705. RLAPI void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
  706. RLAPI void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
  707. RLAPI void SetCameraMoveControls(int frontKey, int backKey,
  708. int rightKey, int leftKey,
  709. int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
  710. //------------------------------------------------------------------------------------
  711. // Basic Shapes Drawing Functions (Module: shapes)
  712. //------------------------------------------------------------------------------------
  713. // Basic shapes drawing functions
  714. RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
  715. RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
  716. RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
  717. RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
  718. RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness
  719. RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out
  720. RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
  721. RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
  722. RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
  723. RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
  724. RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
  725. RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
  726. RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters
  727. RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
  728. RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
  729. RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
  730. RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
  731. RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
  732. RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
  733. RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
  734. RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
  735. // Basic shapes collision detection functions
  736. RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
  737. RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
  738. RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
  739. RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision
  740. RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
  741. RLAPI bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
  742. RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle
  743. //------------------------------------------------------------------------------------
  744. // Texture Loading and Drawing Functions (Module: textures)
  745. //------------------------------------------------------------------------------------
  746. // Image/Texture2D data loading/unloading/saving functions
  747. RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
  748. RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
  749. RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
  750. RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
  751. RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM)
  752. RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
  753. RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
  754. RLAPI void UnloadImage(Image image); // Unload image from CPU memory (RAM)
  755. RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
  756. RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
  757. RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
  758. RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
  759. RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
  760. RLAPI void SaveImageAs(const char *fileName, Image image); // Save image to a PNG file
  761. // Image manipulation functions
  762. RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
  763. RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
  764. RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
  765. RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
  766. RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
  767. RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
  768. RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering)
  769. RLAPI void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm)
  770. RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
  771. RLAPI Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing, Color tint); // Create an image from text (custom sprite font)
  772. RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image
  773. RLAPI void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination)
  774. RLAPI void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text,
  775. float fontSize, int spacing, Color color); // Draw text (custom sprite font) within an image (destination)
  776. RLAPI void ImageFlipVertical(Image *image); // Flip image vertically
  777. RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally
  778. RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint
  779. RLAPI void ImageColorInvert(Image *image); // Modify image color: invert
  780. RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
  781. RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
  782. RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
  783. // Image generation functions
  784. RLAPI Image GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient
  785. RLAPI Image GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient
  786. RLAPI Image GenImageRadialGradient(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
  787. RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
  788. RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
  789. RLAPI Image GenImagePerlinNoise(int width, int height, float scale); // Generate image: perlin noise
  790. RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells
  791. // Texture2D configuration functions
  792. RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
  793. RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
  794. RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
  795. // Texture2D drawing functions
  796. RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
  797. RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
  798. RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
  799. RLAPI void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
  800. RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, // Draw a part of a texture defined by a rectangle with 'pro' parameters
  801. float rotation, Color tint);
  802. //------------------------------------------------------------------------------------
  803. // Font Loading and Text Drawing Functions (Module: text)
  804. //------------------------------------------------------------------------------------
  805. // SpriteFont loading/unloading functions
  806. RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
  807. RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
  808. RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
  809. RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
  810. // Text drawing functions
  811. RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
  812. RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
  813. RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
  814. float fontSize, int spacing, Color tint);
  815. // Text misc. functions
  816. RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
  817. RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
  818. RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
  819. RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
  820. //------------------------------------------------------------------------------------
  821. // Basic 3d Shapes Drawing Functions (Module: models)
  822. //------------------------------------------------------------------------------------
  823. // Basic geometric 3D shapes drawing functions
  824. RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
  825. RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
  826. RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
  827. RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
  828. RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
  829. RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
  830. RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
  831. RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
  832. RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
  833. RLAPI void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
  834. RLAPI void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
  835. RLAPI void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
  836. RLAPI void DrawRay(Ray ray, Color color); // Draw a ray line
  837. RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
  838. RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo
  839. //DrawTorus(), DrawTeapot() could be useful?
  840. //------------------------------------------------------------------------------------
  841. // Model 3d Loading and Drawing Functions (Module: models)
  842. //------------------------------------------------------------------------------------
  843. // Model loading/unloading functions
  844. RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
  845. RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
  846. RLAPI Model LoadModel(const char *fileName); // Load model from file
  847. RLAPI Model LoadModelFromMesh(Mesh data, bool dynamic); // Load model from mesh data
  848. RLAPI Model LoadHeightmap(Image heightmap, Vector3 size); // Load heightmap model from image data
  849. RLAPI Model LoadCubicmap(Image cubicmap); // Load cubes-based map model from image data
  850. RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
  851. RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
  852. // Material loading/unloading functions
  853. RLAPI Material LoadMaterial(const char *fileName); // Load material from file
  854. RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
  855. RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
  856. // Model drawing functions
  857. RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
  858. RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
  859. float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
  860. RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
  861. RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
  862. float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
  863. RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
  864. RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
  865. RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
  866. Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
  867. // Collision detection functions
  868. RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
  869. RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
  870. RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
  871. RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
  872. RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere
  873. RLAPI bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius,
  874. Vector3 *collisionPoint); // Detect collision between ray and sphere, returns collision point
  875. RLAPI bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box
  876. RLAPI RayHitInfo GetCollisionRayMesh(Ray ray, Mesh *mesh); // Get collision info between ray and mesh
  877. RLAPI RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle
  878. RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Get collision info between ray and ground plane (Y-normal plane)
  879. //------------------------------------------------------------------------------------
  880. // Shaders System Functions (Module: rlgl)
  881. // NOTE: This functions are useless when using OpenGL 1.1
  882. //------------------------------------------------------------------------------------
  883. // Shader loading/unloading functions
  884. RLAPI char *LoadText(const char *fileName); // Load chars array from text file
  885. RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
  886. RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
  887. RLAPI Shader GetDefaultShader(void); // Get default shader
  888. RLAPI Texture2D GetDefaultTexture(void); // Get default texture
  889. // Shader configuration functions
  890. RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
  891. RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
  892. RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
  893. RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
  894. RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
  895. RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
  896. // Shading begin/end functions
  897. RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
  898. RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
  899. RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
  900. RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
  901. // VR control functions
  902. RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
  903. RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
  904. RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
  905. RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
  906. RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
  907. RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
  908. RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
  909. //------------------------------------------------------------------------------------
  910. // Audio Loading and Playing Functions (Module: audio)
  911. //------------------------------------------------------------------------------------
  912. // Audio device management functions
  913. RLAPI void InitAudioDevice(void); // Initialize audio device and context
  914. RLAPI void CloseAudioDevice(void); // Close the audio device and context
  915. RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
  916. RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
  917. // Wave/Sound loading/unloading functions
  918. RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
  919. RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
  920. RLAPI Sound LoadSound(const char *fileName); // Load sound from file
  921. RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
  922. RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
  923. RLAPI void UnloadWave(Wave wave); // Unload wave data
  924. RLAPI void UnloadSound(Sound sound); // Unload sound
  925. // Wave/Sound management functions
  926. RLAPI void PlaySound(Sound sound); // Play a sound
  927. RLAPI void PauseSound(Sound sound); // Pause a sound
  928. RLAPI void ResumeSound(Sound sound); // Resume a paused sound
  929. RLAPI void StopSound(Sound sound); // Stop playing a sound
  930. RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
  931. RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
  932. RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
  933. RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
  934. RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
  935. RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
  936. RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
  937. // Music management functions
  938. RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
  939. RLAPI void UnloadMusicStream(Music music); // Unload music stream
  940. RLAPI void PlayMusicStream(Music music); // Start music playing
  941. RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming
  942. RLAPI void StopMusicStream(Music music); // Stop music playing
  943. RLAPI void PauseMusicStream(Music music); // Pause music playing
  944. RLAPI void ResumeMusicStream(Music music); // Resume playing paused music
  945. RLAPI bool IsMusicPlaying(Music music); // Check if music is playing
  946. RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
  947. RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
  948. RLAPI void SetMusicLoopCount(Music music, float count); // Set music loop count (loop repeats)
  949. RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
  950. RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
  951. // AudioStream management functions
  952. RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
  953. unsigned int channels); // Init audio stream (to stream raw audio pcm data)
  954. RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
  955. RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
  956. RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
  957. RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream
  958. RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream
  959. RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream
  960. RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream
  961. #ifdef __cplusplus
  962. }
  963. #endif
  964. #endif // RAYLIB_H