You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1016 lines
62 KiB

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