raylib.h 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. /**********************************************************************************************
  2. *
  3. * raylib 1.5.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 C# 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 (WAV, OGG, XM, MOD)
  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. *
  23. * Used external libs:
  24. * GLFW3 (www.glfw.org) for window/context management and input
  25. * GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP)
  26. * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA, PSD, GIF, HDR, PIC)
  27. * stb_image_write (Sean Barret) for image writting (PNG)
  28. * stb_vorbis (Sean Barret) for ogg audio loading
  29. * stb_truetype (Sean Barret) for ttf fonts loading
  30. * jar_xm (Joshua Reisenauer) for XM audio module loading
  31. * jar_mod (Joshua Reisenauer) for MOD audio module loading
  32. * OpenAL Soft for audio device/context management
  33. * tinfl for data decompression (DEFLATE algorithm)
  34. *
  35. * Some design decisions:
  36. * 32bit Colors - All defined color are always RGBA (struct Color is 4 byte)
  37. * One custom default font is loaded automatically when InitWindow()
  38. * If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads
  39. * If using OpenGL 3.3 or ES2, two default shaders are loaded automatically (internally defined)
  40. *
  41. * -- LICENSE --
  42. *
  43. * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  44. * BSD-like license that allows static linking with closed source software:
  45. *
  46. * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
  47. *
  48. * This software is provided "as-is", without any express or implied warranty. In no event
  49. * will the authors be held liable for any damages arising from the use of this software.
  50. *
  51. * Permission is granted to anyone to use this software for any purpose, including commercial
  52. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  53. *
  54. * 1. The origin of this software must not be misrepresented; you must not claim that you
  55. * wrote the original software. If you use this software in a product, an acknowledgment
  56. * in the product documentation would be appreciated but is not required.
  57. *
  58. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  59. * as being the original software.
  60. *
  61. * 3. This notice may not be removed or altered from any source distribution.
  62. *
  63. **********************************************************************************************/
  64. #ifndef RAYLIB_H
  65. #define RAYLIB_H
  66. // Choose your platform here or just define it at compile time: -DPLATFORM_DESKTOP
  67. //#define PLATFORM_DESKTOP // Windows, Linux or OSX
  68. //#define PLATFORM_ANDROID // Android device
  69. //#define PLATFORM_RPI // Raspberry Pi
  70. //#define PLATFORM_WEB // HTML5 (emscripten, asm.js)
  71. //#define RLGL_OCULUS_SUPPORT // Oculus Rift CV1 (complementary to PLATFORM_DESKTOP)
  72. // Security check in case no PLATFORM_* defined
  73. #if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEB)
  74. #define PLATFORM_DESKTOP
  75. #endif
  76. #if defined(PLATFORM_ANDROID)
  77. typedef struct android_app; // Define android_app struct (android_native_app_glue.h)
  78. #endif
  79. //----------------------------------------------------------------------------------
  80. // Some basic Defines
  81. //----------------------------------------------------------------------------------
  82. #ifndef PI
  83. #define PI 3.14159265358979323846
  84. #endif
  85. #define DEG2RAD (PI/180.0f)
  86. #define RAD2DEG (180.0f/PI)
  87. // raylib Config Flags
  88. #define FLAG_FULLSCREEN_MODE 1
  89. #define FLAG_SHOW_LOGO 2
  90. #define FLAG_SHOW_MOUSE_CURSOR 4
  91. #define FLAG_CENTERED_MODE 8
  92. #define FLAG_MSAA_4X_HINT 16
  93. #define FLAG_VSYNC_HINT 32
  94. // Keyboard Function Keys
  95. #define KEY_SPACE 32
  96. #define KEY_ESCAPE 256
  97. #define KEY_ENTER 257
  98. #define KEY_BACKSPACE 259
  99. #define KEY_RIGHT 262
  100. #define KEY_LEFT 263
  101. #define KEY_DOWN 264
  102. #define KEY_UP 265
  103. #define KEY_F1 290
  104. #define KEY_F2 291
  105. #define KEY_F3 292
  106. #define KEY_F4 293
  107. #define KEY_F5 294
  108. #define KEY_F6 295
  109. #define KEY_F7 296
  110. #define KEY_F8 297
  111. #define KEY_F9 298
  112. #define KEY_F10 299
  113. #define KEY_F11 300
  114. #define KEY_F12 301
  115. #define KEY_LEFT_SHIFT 340
  116. #define KEY_LEFT_CONTROL 341
  117. #define KEY_LEFT_ALT 342
  118. #define KEY_RIGHT_SHIFT 344
  119. #define KEY_RIGHT_CONTROL 345
  120. #define KEY_RIGHT_ALT 346
  121. // Keyboard Alpha Numeric Keys
  122. #define KEY_ZERO 48
  123. #define KEY_ONE 49
  124. #define KEY_TWO 50
  125. #define KEY_THREE 51
  126. #define KEY_FOUR 52
  127. #define KEY_FIVE 53
  128. #define KEY_SIX 54
  129. #define KEY_SEVEN 55
  130. #define KEY_EIGHT 56
  131. #define KEY_NINE 57
  132. #define KEY_A 65
  133. #define KEY_B 66
  134. #define KEY_C 67
  135. #define KEY_D 68
  136. #define KEY_E 69
  137. #define KEY_F 70
  138. #define KEY_G 71
  139. #define KEY_H 72
  140. #define KEY_I 73
  141. #define KEY_J 74
  142. #define KEY_K 75
  143. #define KEY_L 76
  144. #define KEY_M 77
  145. #define KEY_N 78
  146. #define KEY_O 79
  147. #define KEY_P 80
  148. #define KEY_Q 81
  149. #define KEY_R 82
  150. #define KEY_S 83
  151. #define KEY_T 84
  152. #define KEY_U 85
  153. #define KEY_V 86
  154. #define KEY_W 87
  155. #define KEY_X 88
  156. #define KEY_Y 89
  157. #define KEY_Z 90
  158. // Mouse Buttons
  159. #define MOUSE_LEFT_BUTTON 0
  160. #if defined(PLATFORM_WEB)
  161. #define MOUSE_RIGHT_BUTTON 2
  162. #define MOUSE_MIDDLE_BUTTON 1
  163. #else
  164. #define MOUSE_RIGHT_BUTTON 1
  165. #define MOUSE_MIDDLE_BUTTON 2
  166. #endif
  167. // Touch points registered
  168. #define MAX_TOUCH_POINTS 2
  169. // Gamepad Number
  170. #define GAMEPAD_PLAYER1 0
  171. #define GAMEPAD_PLAYER2 1
  172. #define GAMEPAD_PLAYER3 2 // Not supported
  173. #define GAMEPAD_PLAYER4 3 // Not supported
  174. // Gamepad Buttons
  175. // NOTE: Adjusted for a PS3 USB Controller
  176. #define GAMEPAD_BUTTON_A 2
  177. #define GAMEPAD_BUTTON_B 1
  178. #define GAMEPAD_BUTTON_X 3
  179. #define GAMEPAD_BUTTON_Y 4
  180. #define GAMEPAD_BUTTON_R1 7
  181. #define GAMEPAD_BUTTON_R2 5
  182. #define GAMEPAD_BUTTON_L1 6
  183. #define GAMEPAD_BUTTON_L2 8
  184. #define GAMEPAD_BUTTON_SELECT 9
  185. #define GAMEPAD_BUTTON_START 10
  186. // Xbox360 USB Controller Buttons
  187. #define GAMEPAD_XBOX_BUTTON_A 0
  188. #define GAMEPAD_XBOX_BUTTON_B 1
  189. #define GAMEPAD_XBOX_BUTTON_X 2
  190. #define GAMEPAD_XBOX_BUTTON_Y 3
  191. #define GAMEPAD_XBOX_BUTTON_LB 4
  192. #define GAMEPAD_XBOX_BUTTON_RB 5
  193. #define GAMEPAD_XBOX_BUTTON_SELECT 6
  194. #define GAMEPAD_XBOX_BUTTON_START 7
  195. #if defined(PLATFORM_RPI)
  196. #define GAMEPAD_XBOX_AXIS_DPAD_X 7
  197. #define GAMEPAD_XBOX_AXIS_DPAD_Y 6
  198. #define GAMEPAD_XBOX_AXIS_RIGHT_X 3
  199. #define GAMEPAD_XBOX_AXIS_RIGHT_Y 4
  200. #define GAMEPAD_XBOX_AXIS_LT 2
  201. #define GAMEPAD_XBOX_AXIS_RT 5
  202. #else
  203. #define GAMEPAD_XBOX_BUTTON_UP 10
  204. #define GAMEPAD_XBOX_BUTTON_DOWN 12
  205. #define GAMEPAD_XBOX_BUTTON_LEFT 13
  206. #define GAMEPAD_XBOX_BUTTON_RIGHT 11
  207. #define GAMEPAD_XBOX_AXIS_RIGHT_X 4
  208. #define GAMEPAD_XBOX_AXIS_RIGHT_Y 3
  209. #define GAMEPAD_XBOX_AXIS_LT_RT 2
  210. #endif
  211. #define GAMEPAD_XBOX_AXIS_LEFT_X 0
  212. #define GAMEPAD_XBOX_AXIS_LEFT_Y 1
  213. // Android Physic Buttons
  214. #define ANDROID_BACK 4
  215. #define ANDROID_MENU 82
  216. #define ANDROID_VOLUME_UP 24
  217. #define ANDROID_VOLUME_DOWN 25
  218. // Some Basic Colors
  219. // NOTE: Custom raylib color palette for amazing visuals on WHITE background
  220. #define LIGHTGRAY (Color){ 200, 200, 200, 255 } // Light Gray
  221. #define GRAY (Color){ 130, 130, 130, 255 } // Gray
  222. #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
  223. #define YELLOW (Color){ 253, 249, 0, 255 } // Yellow
  224. #define GOLD (Color){ 255, 203, 0, 255 } // Gold
  225. #define ORANGE (Color){ 255, 161, 0, 255 } // Orange
  226. #define PINK (Color){ 255, 109, 194, 255 } // Pink
  227. #define RED (Color){ 230, 41, 55, 255 } // Red
  228. #define MAROON (Color){ 190, 33, 55, 255 } // Maroon
  229. #define GREEN (Color){ 0, 228, 48, 255 } // Green
  230. #define LIME (Color){ 0, 158, 47, 255 } // Lime
  231. #define DARKGREEN (Color){ 0, 117, 44, 255 } // Dark Green
  232. #define SKYBLUE (Color){ 102, 191, 255, 255 } // Sky Blue
  233. #define BLUE (Color){ 0, 121, 241, 255 } // Blue
  234. #define DARKBLUE (Color){ 0, 82, 172, 255 } // Dark Blue
  235. #define PURPLE (Color){ 200, 122, 255, 255 } // Purple
  236. #define VIOLET (Color){ 135, 60, 190, 255 } // Violet
  237. #define DARKPURPLE (Color){ 112, 31, 126, 255 } // Dark Purple
  238. #define BEIGE (Color){ 211, 176, 131, 255 } // Beige
  239. #define BROWN (Color){ 127, 106, 79, 255 } // Brown
  240. #define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown
  241. #define WHITE (Color){ 255, 255, 255, 255 } // White
  242. #define BLACK (Color){ 0, 0, 0, 255 } // Black
  243. #define BLANK (Color){ 0, 0, 0, 0 } // Blank (Transparent)
  244. #define MAGENTA (Color){ 255, 0, 255, 255 } // Magenta
  245. #define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
  246. //----------------------------------------------------------------------------------
  247. // Types and Structures Definition
  248. //----------------------------------------------------------------------------------
  249. #ifndef __cplusplus
  250. // Boolean type
  251. #ifndef __APPLE__
  252. #if !defined(_STDBOOL_H)
  253. typedef enum { false, true } bool;
  254. #define _STDBOOL_H
  255. #endif
  256. #else
  257. #include <stdbool.h>
  258. #endif
  259. #endif
  260. // byte type
  261. typedef unsigned char byte;
  262. // Vector2 type
  263. typedef struct Vector2 {
  264. float x;
  265. float y;
  266. } Vector2;
  267. // Vector3 type
  268. typedef struct Vector3 {
  269. float x;
  270. float y;
  271. float z;
  272. } Vector3;
  273. // Matrix type (OpenGL style 4x4 - right handed, column major)
  274. typedef struct Matrix {
  275. float m0, m4, m8, m12;
  276. float m1, m5, m9, m13;
  277. float m2, m6, m10, m14;
  278. float m3, m7, m11, m15;
  279. } Matrix;
  280. // Color type, RGBA (32bit)
  281. typedef struct Color {
  282. unsigned char r;
  283. unsigned char g;
  284. unsigned char b;
  285. unsigned char a;
  286. } Color;
  287. // Rectangle type
  288. typedef struct Rectangle {
  289. int x;
  290. int y;
  291. int width;
  292. int height;
  293. } Rectangle;
  294. // Image type, bpp always RGBA (32bit)
  295. // NOTE: Data stored in CPU memory (RAM)
  296. typedef struct Image {
  297. void *data; // Image raw data
  298. int width; // Image base width
  299. int height; // Image base height
  300. int mipmaps; // Mipmap levels, 1 by default
  301. int format; // Data format (TextureFormat)
  302. } Image;
  303. // Texture2D type, bpp always RGBA (32bit)
  304. // NOTE: Data stored in GPU memory
  305. typedef struct Texture2D {
  306. unsigned int id; // OpenGL texture id
  307. int width; // Texture base width
  308. int height; // Texture base height
  309. int mipmaps; // Mipmap levels, 1 by default
  310. int format; // Data format (TextureFormat)
  311. } Texture2D;
  312. // RenderTexture2D type, for texture rendering
  313. typedef struct RenderTexture2D {
  314. unsigned int id; // Render texture (fbo) id
  315. Texture2D texture; // Color buffer attachment texture
  316. Texture2D depth; // Depth buffer attachment texture
  317. } RenderTexture2D;
  318. // SpriteFont type, includes texture and charSet array data
  319. typedef struct SpriteFont {
  320. Texture2D texture; // Font texture
  321. int size; // Base size (default chars height)
  322. int numChars; // Number of characters
  323. int *charValues; // Characters values array
  324. Rectangle *charRecs; // Characters rectangles within the texture
  325. Vector2 *charOffsets; // Characters offsets (on drawing)
  326. int *charAdvanceX; // Characters x advance (on drawing)
  327. } SpriteFont;
  328. // Camera type, defines a camera position/orientation in 3d space
  329. typedef struct Camera {
  330. Vector3 position; // Camera position
  331. Vector3 target; // Camera target it looks-at
  332. Vector3 up; // Camera up vector (rotation over its axis)
  333. float fovy; // Camera field-of-view apperture in Y (degrees)
  334. } Camera;
  335. // Camera2D type, defines a 2d camera
  336. typedef struct Camera2D {
  337. Vector2 offset; // Camera offset (displacement from target)
  338. Vector2 target; // Camera target (rotation and zoom origin)
  339. float rotation; // Camera rotation in degrees
  340. float zoom; // Camera zoom (scaling), should be 1.0f by default
  341. } Camera2D;
  342. // Bounding box type
  343. typedef struct BoundingBox {
  344. Vector3 min; // minimum vertex box-corner
  345. Vector3 max; // maximum vertex box-corner
  346. } BoundingBox;
  347. // Vertex data definning a mesh
  348. typedef struct Mesh {
  349. int vertexCount; // number of vertices stored in arrays
  350. int triangleCount; // number of triangles stored (indexed or not)
  351. float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
  352. float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
  353. float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
  354. float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
  355. float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
  356. unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
  357. unsigned short *indices;// vertex indices (in case vertex data comes indexed)
  358. unsigned int vaoId; // OpenGL Vertex Array Object id
  359. unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
  360. } Mesh;
  361. // Shader type (generic shader)
  362. typedef struct Shader {
  363. unsigned int id; // Shader program id
  364. // Vertex attributes locations (default locations)
  365. int vertexLoc; // Vertex attribute location point (default-location = 0)
  366. int texcoordLoc; // Texcoord attribute location point (default-location = 1)
  367. int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
  368. int normalLoc; // Normal attribute location point (default-location = 2)
  369. int tangentLoc; // Tangent attribute location point (default-location = 4)
  370. int colorLoc; // Color attibute location point (default-location = 3)
  371. // Uniform locations
  372. int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
  373. int tintColorLoc; // Diffuse color uniform location point (fragment shader)
  374. // Texture map locations (generic for any kind of map)
  375. int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
  376. int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
  377. int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
  378. } Shader;
  379. // Material type
  380. typedef struct Material {
  381. Shader shader; // Standard shader (supports 3 map textures)
  382. Texture2D texDiffuse; // Diffuse texture (binded to shader mapTexture0Loc)
  383. Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc)
  384. Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc)
  385. Color colDiffuse; // Diffuse color
  386. Color colAmbient; // Ambient color
  387. Color colSpecular; // Specular color
  388. float glossiness; // Glossiness level (Ranges from 0 to 1000)
  389. } Material;
  390. // Model type
  391. typedef struct Model {
  392. Mesh mesh; // Vertex data buffers (RAM and VRAM)
  393. Matrix transform; // Local transform matrix
  394. Material material; // Shader and textures data
  395. } Model;
  396. // Light type
  397. typedef struct LightData {
  398. unsigned int id; // Light unique id
  399. bool enabled; // Light enabled
  400. int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
  401. Vector3 position; // Light position
  402. Vector3 target; // Light target: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
  403. float radius; // Light attenuation radius light intensity reduced with distance (world distance)
  404. Color diffuse; // Light diffuse color
  405. float intensity; // Light intensity level
  406. float coneAngle; // Light cone max angle: LIGHT_SPOT
  407. } LightData, *Light;
  408. // Light types
  409. typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType;
  410. // Ray type (useful for raycast)
  411. typedef struct Ray {
  412. Vector3 position; // Ray position (origin)
  413. Vector3 direction; // Ray direction
  414. } Ray;
  415. // Sound source type
  416. typedef struct Sound {
  417. unsigned int source; // Sound audio source id
  418. unsigned int buffer; // Sound audio buffer id
  419. } Sound;
  420. // Wave type, defines audio wave data
  421. typedef struct Wave {
  422. void *data; // Buffer data pointer
  423. unsigned int dataSize; // Data size in bytes
  424. unsigned int sampleRate; // Samples per second to be played
  425. short bitsPerSample; // Sample size in bits
  426. short channels;
  427. } Wave;
  428. // Texture formats
  429. // NOTE: Support depends on OpenGL version and platform
  430. typedef enum {
  431. UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
  432. UNCOMPRESSED_GRAY_ALPHA, // 16 bpp (2 channels)
  433. UNCOMPRESSED_R5G6B5, // 16 bpp
  434. UNCOMPRESSED_R8G8B8, // 24 bpp
  435. UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
  436. UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
  437. UNCOMPRESSED_R8G8B8A8, // 32 bpp
  438. COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
  439. COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
  440. COMPRESSED_DXT3_RGBA, // 8 bpp
  441. COMPRESSED_DXT5_RGBA, // 8 bpp
  442. COMPRESSED_ETC1_RGB, // 4 bpp
  443. COMPRESSED_ETC2_RGB, // 4 bpp
  444. COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
  445. COMPRESSED_PVRT_RGB, // 4 bpp
  446. COMPRESSED_PVRT_RGBA, // 4 bpp
  447. COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
  448. COMPRESSED_ASTC_8x8_RGBA // 2 bpp
  449. } TextureFormat;
  450. // Color blending modes (pre-defined)
  451. typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
  452. // Gestures type
  453. // NOTE: It could be used as flags to enable only some gestures
  454. typedef enum {
  455. GESTURE_NONE = 0,
  456. GESTURE_TAP = 1,
  457. GESTURE_DOUBLETAP = 2,
  458. GESTURE_HOLD = 4,
  459. GESTURE_DRAG = 8,
  460. GESTURE_SWIPE_RIGHT = 16,
  461. GESTURE_SWIPE_LEFT = 32,
  462. GESTURE_SWIPE_UP = 64,
  463. GESTURE_SWIPE_DOWN = 128,
  464. GESTURE_PINCH_IN = 256,
  465. GESTURE_PINCH_OUT = 512
  466. } Gestures;
  467. // Touch action (fingers or mouse)
  468. typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
  469. // Gesture events
  470. // NOTE: MAX_TOUCH_POINTS fixed to 2
  471. typedef struct GestureEvent {
  472. int touchAction;
  473. int pointCount;
  474. int pointerId[MAX_TOUCH_POINTS];
  475. Vector2 position[MAX_TOUCH_POINTS];
  476. } GestureEvent;
  477. // Camera system modes
  478. typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode;
  479. // Head Mounted Display devices
  480. typedef enum {
  481. HMD_DEFAULT_DEVICE = 0,
  482. HMD_OCULUS_RIFT_DK2,
  483. HMD_OCULUS_RIFT_CV1,
  484. HMD_VALVE_HTC_VIVE,
  485. HMD_SAMSUNG_GEAR_VR,
  486. HMD_GOOGLE_CARDBOARD,
  487. HMD_SONY_PLAYSTATION_VR,
  488. HMD_RAZER_OSVR,
  489. HMD_FOVE_VR,
  490. } VrDevice;
  491. #ifdef __cplusplus
  492. extern "C" { // Prevents name mangling of functions
  493. #endif
  494. //------------------------------------------------------------------------------------
  495. // Global Variables Definition
  496. //------------------------------------------------------------------------------------
  497. // It's lonely here...
  498. //------------------------------------------------------------------------------------
  499. // Window and Graphics Device Functions (Module: core)
  500. //------------------------------------------------------------------------------------
  501. #if defined(PLATFORM_ANDROID)
  502. void InitWindow(int width, int height, struct android_app *state); // Init Android Activity and OpenGL Graphics
  503. #elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
  504. void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
  505. #endif
  506. void CloseWindow(void); // Close Window and Terminate Context
  507. bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed
  508. bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus)
  509. void ToggleFullscreen(void); // Fullscreen toggle (only PLATFORM_DESKTOP)
  510. int GetScreenWidth(void); // Get current screen width
  511. int GetScreenHeight(void); // Get current screen height
  512. void ShowCursor(void); // Shows cursor
  513. void HideCursor(void); // Hides cursor
  514. bool IsCursorHidden(void); // Returns true if cursor is not visible
  515. void EnableCursor(void); // Enables cursor
  516. void DisableCursor(void); // Disables cursor
  517. void ClearBackground(Color color); // Sets Background Color
  518. void BeginDrawing(void); // Setup drawing canvas to start drawing
  519. void EndDrawing(void); // End canvas drawing and Swap Buffers (Double Buffering)
  520. void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera
  521. void End2dMode(void); // Ends 2D mode custom camera usage
  522. void Begin3dMode(Camera camera); // Initializes 3D mode for drawing (Camera setup)
  523. void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
  524. void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
  525. void EndTextureMode(void); // Ends drawing to render texture
  526. Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
  527. Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position from a 3d world space position
  528. Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
  529. void SetTargetFPS(int fps); // Set target FPS (maximum)
  530. float GetFPS(void); // Returns current FPS
  531. float GetFrameTime(void); // Returns time in seconds for one frame
  532. Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
  533. int GetHexValue(Color color); // Returns hexadecimal value for a Color
  534. float *ColorToFloat(Color color); // Converts Color to float array and normalizes
  535. float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
  536. float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
  537. int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
  538. Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  539. void SetConfigFlags(char flags); // Setup some window configuration flags
  540. void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
  541. bool IsFileDropped(void); // Check if a file have been dropped into window
  542. char **GetDroppedFiles(int *count); // Retrieve dropped files into window
  543. void ClearDroppedFiles(void); // Clear dropped files paths buffer
  544. void StorageSaveValue(int position, int value); // Storage save integer value (to defined position)
  545. int StorageLoadValue(int position); // Storage load integer value (from defined position)
  546. //------------------------------------------------------------------------------------
  547. // Input Handling Functions (Module: core)
  548. //------------------------------------------------------------------------------------
  549. #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
  550. bool IsKeyPressed(int key); // Detect if a key has been pressed once
  551. bool IsKeyDown(int key); // Detect if a key is being pressed
  552. bool IsKeyReleased(int key); // Detect if a key has been released once
  553. bool IsKeyUp(int key); // Detect if a key is NOT being pressed
  554. int GetKeyPressed(void); // Get latest key pressed
  555. void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
  556. bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
  557. float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
  558. bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
  559. bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
  560. bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
  561. bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
  562. #endif
  563. bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
  564. bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
  565. bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
  566. bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
  567. int GetMouseX(void); // Returns mouse position X
  568. int GetMouseY(void); // Returns mouse position Y
  569. Vector2 GetMousePosition(void); // Returns mouse position XY
  570. void SetMousePosition(Vector2 position); // Set mouse position XY
  571. int GetMouseWheelMove(void); // Returns mouse wheel movement Y
  572. int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
  573. int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
  574. Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
  575. #if defined(PLATFORM_ANDROID)
  576. bool IsButtonPressed(int button); // Detect if an android physic button has been pressed
  577. bool IsButtonDown(int button); // Detect if an android physic button is being pressed
  578. bool IsButtonReleased(int button); // Detect if an android physic button has been released
  579. #endif
  580. //------------------------------------------------------------------------------------
  581. // Gestures and Touch Handling Functions (Module: gestures)
  582. //------------------------------------------------------------------------------------
  583. void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
  584. bool IsGestureDetected(int gesture); // Check if a gesture have been detected
  585. void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
  586. void UpdateGestures(void); // Update gestures detected (called automatically in PollInputEvents())
  587. int GetTouchPointsCount(void); // Get touch points count
  588. int GetGestureDetected(void); // Get latest detected gesture
  589. float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
  590. Vector2 GetGestureDragVector(void); // Get gesture drag vector
  591. float GetGestureDragAngle(void); // Get gesture drag angle
  592. Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
  593. float GetGesturePinchAngle(void); // Get gesture pinch angle
  594. //------------------------------------------------------------------------------------
  595. // Camera System Functions (Module: camera)
  596. //------------------------------------------------------------------------------------
  597. void SetCameraMode(int mode); // Set camera mode (multiple camera modes available)
  598. void UpdateCamera(Camera *camera); // Update camera (player position is ignored)
  599. void UpdateCameraPlayer(Camera *camera, Vector3 *position); // Update camera and player position (1st person and 3rd person cameras)
  600. void SetCameraPosition(Vector3 position); // Set internal camera position
  601. void SetCameraTarget(Vector3 target); // Set internal camera target
  602. void SetCameraFovy(float fovy); // Set internal camera field-of-view-y
  603. void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
  604. void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
  605. void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
  606. void SetCameraMoveControls(int frontKey, int backKey,
  607. int leftKey, int rightKey,
  608. int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
  609. void SetCameraMouseSensitivity(float sensitivity); // Set camera mouse sensitivity (1st person and 3rd person cameras)
  610. //------------------------------------------------------------------------------------
  611. // Basic Shapes Drawing Functions (Module: shapes)
  612. //------------------------------------------------------------------------------------
  613. void DrawPixel(int posX, int posY, Color color); // Draw a pixel
  614. void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
  615. void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
  616. void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
  617. void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
  618. void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
  619. void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
  620. void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
  621. void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
  622. void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
  623. void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
  624. void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
  625. void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
  626. void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
  627. void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
  628. void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
  629. void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
  630. void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
  631. bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
  632. bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
  633. bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
  634. Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision
  635. bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
  636. bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
  637. bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle
  638. //------------------------------------------------------------------------------------
  639. // Texture Loading and Drawing Functions (Module: textures)
  640. //------------------------------------------------------------------------------------
  641. Image LoadImage(const char *fileName); // Load an image into CPU memory (RAM)
  642. Image LoadImageEx(Color *pixels, int width, int height); // Load image data from Color array data (RGBA - 32bit)
  643. Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image data from RAW file
  644. Image LoadImageFromRES(const char *rresName, int resId); // Load an image from rRES file (raylib Resource)
  645. Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory
  646. Texture2D LoadTextureEx(void *data, int width, int height, int textureFormat); // Load a texture from raw data into GPU memory
  647. Texture2D LoadTextureFromRES(const char *rresName, int resId); // Load an image as texture from rRES file (raylib Resource)
  648. Texture2D LoadTextureFromImage(Image image); // Load a texture from image data
  649. RenderTexture2D LoadRenderTexture(int width, int height); // Load a texture to be used for rendering
  650. void UnloadImage(Image image); // Unload image from CPU memory (RAM)
  651. void UnloadTexture(Texture2D texture); // Unload texture from GPU memory
  652. void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory
  653. Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
  654. Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
  655. void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
  656. void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
  657. void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
  658. Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
  659. void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
  660. void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering)
  661. void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm)
  662. Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
  663. Image ImageTextEx(SpriteFont font, const char *text, int fontSize, int spacing, Color tint); // Create an image from text (custom sprite font)
  664. void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image
  665. void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination)
  666. void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, int fontSize, int spacing, Color color); // Draw text (custom sprite font) within an image (destination)
  667. void ImageFlipVertical(Image *image); // Flip image vertically
  668. void ImageFlipHorizontal(Image *image); // Flip image horizontally
  669. void ImageColorTint(Image *image, Color color); // Modify image color: tint
  670. void ImageColorInvert(Image *image); // Modify image color: invert
  671. void ImageColorGrayscale(Image *image); // Modify image color: grayscale
  672. void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
  673. void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
  674. void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture
  675. void UpdateTexture(Texture2D texture, void *pixels); // Update GPU texture with new data
  676. void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
  677. void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
  678. void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
  679. void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
  680. void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, // Draw a part of a texture defined by a rectangle with 'pro' parameters
  681. float rotation, Color tint);
  682. //------------------------------------------------------------------------------------
  683. // Font Loading and Text Drawing Functions (Module: text)
  684. //------------------------------------------------------------------------------------
  685. SpriteFont GetDefaultFont(void); // Get the default SpriteFont
  686. SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory
  687. void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory
  688. void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
  689. void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
  690. int fontSize, int spacing, Color tint);
  691. int MeasureText(const char *text, int fontSize); // Measure string width for default font
  692. Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int spacing); // Measure string size for SpriteFont
  693. void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner
  694. const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
  695. const char *SubText(const char *text, int position, int length); // Get a piece of a text string
  696. //------------------------------------------------------------------------------------
  697. // Basic 3d Shapes Drawing Functions (Module: models)
  698. //------------------------------------------------------------------------------------
  699. void DrawCube(Vector3 position, float width, float height, float lenght, Color color); // Draw cube
  700. void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
  701. void DrawCubeWires(Vector3 position, float width, float height, float lenght, Color color); // Draw cube wires
  702. void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float lenght, Color color); // Draw cube textured
  703. void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
  704. void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
  705. void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
  706. void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
  707. void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
  708. void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
  709. void DrawRay(Ray ray, Color color); // Draw a ray line
  710. void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
  711. void DrawGizmo(Vector3 position); // Draw simple gizmo
  712. void DrawLight(Light light); // Draw light in 3D world
  713. void Draw3DLine(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
  714. void Draw3DCircle(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space
  715. //DrawTorus(), DrawTeapot() are useless...
  716. //------------------------------------------------------------------------------------
  717. // Model 3d Loading and Drawing Functions (Module: models)
  718. //------------------------------------------------------------------------------------
  719. Model LoadModel(const char *fileName); // Load a 3d model (.OBJ)
  720. Model LoadModelEx(Mesh data, bool dynamic); // Load a 3d model (from mesh data)
  721. Model LoadModelFromRES(const char *rresName, int resId); // Load a 3d model from rRES file (raylib Resource)
  722. Model LoadHeightmap(Image heightmap, Vector3 size); // Load a heightmap image as a 3d model
  723. Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based)
  724. void UnloadModel(Model model); // Unload 3d model from memory
  725. Material LoadMaterial(const char *fileName); // Load material data (from file)
  726. Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
  727. Material LoadStandardMaterial(void); // Load standard material (uses material attributes and lighting shader)
  728. void UnloadMaterial(Material material); // Unload material textures from VRAM
  729. void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
  730. void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
  731. void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
  732. void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
  733. void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
  734. void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
  735. void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
  736. BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
  737. bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
  738. bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
  739. bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
  740. bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere
  741. bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere with extended parameters and collision point detection
  742. bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box
  743. Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
  744. // NOTE: Return the normal vector of the impacted surface
  745. //------------------------------------------------------------------------------------
  746. // Shaders System Functions (Module: rlgl)
  747. // NOTE: This functions are useless when using OpenGL 1.1
  748. //------------------------------------------------------------------------------------
  749. Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
  750. void UnloadShader(Shader shader); // Unload a custom shader from memory
  751. Shader GetDefaultShader(void); // Get default shader
  752. Shader GetStandardShader(void); // Get standard shader
  753. Texture2D GetDefaultTexture(void); // Get default texture
  754. int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
  755. void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
  756. void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
  757. void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
  758. void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
  759. void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
  760. void BeginShaderMode(Shader shader); // Begin custom shader drawing
  761. void EndShaderMode(void); // End custom shader drawing (use default shader)
  762. void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
  763. void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
  764. Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
  765. void DestroyLight(Light light); // Destroy a light and take it out of the list
  766. //------------------------------------------------------------------------------------
  767. // VR experience Functions (Module: rlgl)
  768. // NOTE: This functions are useless when using OpenGL 1.1
  769. //------------------------------------------------------------------------------------
  770. void InitVrDevice(int vdDevice); // Init VR device
  771. void CloseVrDevice(void); // Close VR device
  772. void UpdateVrTracking(void); // Update VR tracking (position and orientation)
  773. void BeginVrDrawing(void); // Begin VR drawing configuration
  774. void EndVrDrawing(void); // End VR drawing process (and desktop mirror)
  775. bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready
  776. void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
  777. //------------------------------------------------------------------------------------
  778. // Audio Loading and Playing Functions (Module: audio)
  779. //------------------------------------------------------------------------------------
  780. void InitAudioDevice(void); // Initialize audio device and context
  781. void CloseAudioDevice(void); // Close the audio device and context (and music stream)
  782. bool IsAudioDeviceReady(void); // True if call to InitAudioDevice() was successful and CloseAudioDevice() has not been called yet
  783. Sound LoadSound(char *fileName); // Load sound to memory
  784. Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
  785. Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
  786. void UnloadSound(Sound sound); // Unload sound
  787. void PlaySound(Sound sound); // Play a sound
  788. void PauseSound(Sound sound); // Pause a sound
  789. void StopSound(Sound sound); // Stop playing a sound
  790. bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
  791. void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
  792. void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
  793. int PlayMusicStream(int index, char *fileName); // Start music playing (open stream)
  794. void UpdateMusicStream(int index); // Updates buffers for music streaming
  795. void StopMusicStream(int index); // Stop music playing (close stream)
  796. void PauseMusicStream(int index); // Pause music playing
  797. void ResumeMusicStream(int index); // Resume playing paused music
  798. bool IsMusicPlaying(int index); // Check if music is playing
  799. void SetMusicVolume(int index, float volume); // Set volume for music (1.0 is max level)
  800. void SetMusicPitch(int index, float pitch); // Set pitch for a music (1.0 is base level)
  801. float GetMusicTimeLength(int index); // Get current music time length (in seconds)
  802. float GetMusicTimePlayed(int index); // Get current music time played (in seconds)
  803. int GetMusicStreamCount(void); // Get number of streams loaded
  804. #ifdef __cplusplus
  805. }
  806. #endif
  807. #endif // RAYLIB_H