raylib.h 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  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. #if !defined(_STDBOOL_H)
  252. typedef enum { false, true } bool;
  253. #define _STDBOOL_H
  254. #endif
  255. #endif
  256. // byte type
  257. typedef unsigned char byte;
  258. // Vector2 type
  259. typedef struct Vector2 {
  260. float x;
  261. float y;
  262. } Vector2;
  263. // Vector3 type
  264. typedef struct Vector3 {
  265. float x;
  266. float y;
  267. float z;
  268. } Vector3;
  269. // Matrix type (OpenGL style 4x4 - right handed, column major)
  270. typedef struct Matrix {
  271. float m0, m4, m8, m12;
  272. float m1, m5, m9, m13;
  273. float m2, m6, m10, m14;
  274. float m3, m7, m11, m15;
  275. } Matrix;
  276. // Color type, RGBA (32bit)
  277. typedef struct Color {
  278. unsigned char r;
  279. unsigned char g;
  280. unsigned char b;
  281. unsigned char a;
  282. } Color;
  283. // Rectangle type
  284. typedef struct Rectangle {
  285. int x;
  286. int y;
  287. int width;
  288. int height;
  289. } Rectangle;
  290. // Image type, bpp always RGBA (32bit)
  291. // NOTE: Data stored in CPU memory (RAM)
  292. typedef struct Image {
  293. void *data; // Image raw data
  294. int width; // Image base width
  295. int height; // Image base height
  296. int mipmaps; // Mipmap levels, 1 by default
  297. int format; // Data format (TextureFormat)
  298. } Image;
  299. // Texture2D type, bpp always RGBA (32bit)
  300. // NOTE: Data stored in GPU memory
  301. typedef struct Texture2D {
  302. unsigned int id; // OpenGL texture id
  303. int width; // Texture base width
  304. int height; // Texture base height
  305. int mipmaps; // Mipmap levels, 1 by default
  306. int format; // Data format (TextureFormat)
  307. } Texture2D;
  308. // RenderTexture2D type, for texture rendering
  309. typedef struct RenderTexture2D {
  310. unsigned int id; // Render texture (fbo) id
  311. Texture2D texture; // Color buffer attachment texture
  312. Texture2D depth; // Depth buffer attachment texture
  313. } RenderTexture2D;
  314. // SpriteFont type, includes texture and charSet array data
  315. typedef struct SpriteFont {
  316. Texture2D texture; // Font texture
  317. int size; // Base size (default chars height)
  318. int numChars; // Number of characters
  319. int *charValues; // Characters values array
  320. Rectangle *charRecs; // Characters rectangles within the texture
  321. Vector2 *charOffsets; // Characters offsets (on drawing)
  322. int *charAdvanceX; // Characters x advance (on drawing)
  323. } SpriteFont;
  324. // Camera type, defines a camera position/orientation in 3d space
  325. typedef struct Camera {
  326. Vector3 position; // Camera position
  327. Vector3 target; // Camera target it looks-at
  328. Vector3 up; // Camera up vector (rotation over its axis)
  329. float fovy; // Camera field-of-view apperture in Y (degrees)
  330. } Camera;
  331. // Camera2D type, defines a 2d camera
  332. typedef struct Camera2D {
  333. Vector2 offset; // Camera offset (displacement from target)
  334. Vector2 target; // Camera target (rotation and zoom origin)
  335. float rotation; // Camera rotation in degrees
  336. float zoom; // Camera zoom (scaling), should be 1.0f by default
  337. } Camera2D;
  338. // Bounding box type
  339. typedef struct BoundingBox {
  340. Vector3 min; // minimum vertex box-corner
  341. Vector3 max; // maximum vertex box-corner
  342. } BoundingBox;
  343. // Vertex data definning a mesh
  344. typedef struct Mesh {
  345. int vertexCount; // number of vertices stored in arrays
  346. int triangleCount; // number of triangles stored (indexed or not)
  347. float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
  348. float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
  349. float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
  350. float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
  351. float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
  352. unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
  353. unsigned short *indices;// vertex indices (in case vertex data comes indexed)
  354. unsigned int vaoId; // OpenGL Vertex Array Object id
  355. unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
  356. } Mesh;
  357. // Shader type (generic shader)
  358. typedef struct Shader {
  359. unsigned int id; // Shader program id
  360. // Vertex attributes locations (default locations)
  361. int vertexLoc; // Vertex attribute location point (default-location = 0)
  362. int texcoordLoc; // Texcoord attribute location point (default-location = 1)
  363. int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
  364. int normalLoc; // Normal attribute location point (default-location = 2)
  365. int tangentLoc; // Tangent attribute location point (default-location = 4)
  366. int colorLoc; // Color attibute location point (default-location = 3)
  367. // Uniform locations
  368. int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
  369. int tintColorLoc; // Diffuse color uniform location point (fragment shader)
  370. // Texture map locations (generic for any kind of map)
  371. int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
  372. int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
  373. int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
  374. } Shader;
  375. // Material type
  376. typedef struct Material {
  377. Shader shader; // Standard shader (supports 3 map textures)
  378. Texture2D texDiffuse; // Diffuse texture (binded to shader mapTexture0Loc)
  379. Texture2D texNormal; // Normal texture (binded to shader mapTexture1Loc)
  380. Texture2D texSpecular; // Specular texture (binded to shader mapTexture2Loc)
  381. Color colDiffuse; // Diffuse color
  382. Color colAmbient; // Ambient color
  383. Color colSpecular; // Specular color
  384. float glossiness; // Glossiness level (Ranges from 0 to 1000)
  385. } Material;
  386. // Model type
  387. typedef struct Model {
  388. Mesh mesh; // Vertex data buffers (RAM and VRAM)
  389. Matrix transform; // Local transform matrix
  390. Material material; // Shader and textures data
  391. } Model;
  392. // Light type
  393. typedef struct LightData {
  394. unsigned int id; // Light unique id
  395. bool enabled; // Light enabled
  396. int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
  397. Vector3 position; // Light position
  398. Vector3 target; // Light target: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
  399. float radius; // Light attenuation radius light intensity reduced with distance (world distance)
  400. Color diffuse; // Light diffuse color
  401. float intensity; // Light intensity level
  402. float coneAngle; // Light cone max angle: LIGHT_SPOT
  403. } LightData, *Light;
  404. // Light types
  405. typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType;
  406. // Ray type (useful for raycast)
  407. typedef struct Ray {
  408. Vector3 position; // Ray position (origin)
  409. Vector3 direction; // Ray direction
  410. } Ray;
  411. // Sound source type
  412. typedef struct Sound {
  413. unsigned int source; // Sound audio source id
  414. unsigned int buffer; // Sound audio buffer id
  415. } Sound;
  416. // Wave type, defines audio wave data
  417. typedef struct Wave {
  418. void *data; // Buffer data pointer
  419. unsigned int dataSize; // Data size in bytes
  420. unsigned int sampleRate; // Samples per second to be played
  421. short bitsPerSample; // Sample size in bits
  422. short channels;
  423. } Wave;
  424. // Texture formats
  425. // NOTE: Support depends on OpenGL version and platform
  426. typedef enum {
  427. UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
  428. UNCOMPRESSED_GRAY_ALPHA, // 16 bpp (2 channels)
  429. UNCOMPRESSED_R5G6B5, // 16 bpp
  430. UNCOMPRESSED_R8G8B8, // 24 bpp
  431. UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
  432. UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
  433. UNCOMPRESSED_R8G8B8A8, // 32 bpp
  434. COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
  435. COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
  436. COMPRESSED_DXT3_RGBA, // 8 bpp
  437. COMPRESSED_DXT5_RGBA, // 8 bpp
  438. COMPRESSED_ETC1_RGB, // 4 bpp
  439. COMPRESSED_ETC2_RGB, // 4 bpp
  440. COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
  441. COMPRESSED_PVRT_RGB, // 4 bpp
  442. COMPRESSED_PVRT_RGBA, // 4 bpp
  443. COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
  444. COMPRESSED_ASTC_8x8_RGBA // 2 bpp
  445. } TextureFormat;
  446. // Color blending modes (pre-defined)
  447. typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
  448. // Gestures type
  449. // NOTE: It could be used as flags to enable only some gestures
  450. typedef enum {
  451. GESTURE_NONE = 0,
  452. GESTURE_TAP = 1,
  453. GESTURE_DOUBLETAP = 2,
  454. GESTURE_HOLD = 4,
  455. GESTURE_DRAG = 8,
  456. GESTURE_SWIPE_RIGHT = 16,
  457. GESTURE_SWIPE_LEFT = 32,
  458. GESTURE_SWIPE_UP = 64,
  459. GESTURE_SWIPE_DOWN = 128,
  460. GESTURE_PINCH_IN = 256,
  461. GESTURE_PINCH_OUT = 512
  462. } Gestures;
  463. // Touch action (fingers or mouse)
  464. typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
  465. // Gesture events
  466. // NOTE: MAX_TOUCH_POINTS fixed to 2
  467. typedef struct GestureEvent {
  468. int touchAction;
  469. int pointCount;
  470. int pointerId[MAX_TOUCH_POINTS];
  471. Vector2 position[MAX_TOUCH_POINTS];
  472. } GestureEvent;
  473. // Camera system modes
  474. typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode;
  475. // Head Mounted Display devices
  476. typedef enum {
  477. HMD_DEFAULT_DEVICE = 0,
  478. HMD_OCULUS_RIFT_DK2,
  479. HMD_OCULUS_RIFT_CV1,
  480. HMD_VALVE_HTC_VIVE,
  481. HMD_SAMSUNG_GEAR_VR,
  482. HMD_GOOGLE_CARDBOARD,
  483. HMD_SONY_PLAYSTATION_VR,
  484. HMD_RAZER_OSVR,
  485. HMD_FOVE_VR,
  486. } VrDevice;
  487. #ifdef __cplusplus
  488. extern "C" { // Prevents name mangling of functions
  489. #endif
  490. //------------------------------------------------------------------------------------
  491. // Global Variables Definition
  492. //------------------------------------------------------------------------------------
  493. // It's lonely here...
  494. //------------------------------------------------------------------------------------
  495. // Window and Graphics Device Functions (Module: core)
  496. //------------------------------------------------------------------------------------
  497. #if defined(PLATFORM_ANDROID)
  498. void InitWindow(int width, int height, struct android_app *state); // Init Android Activity and OpenGL Graphics
  499. #elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
  500. void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
  501. #endif
  502. void CloseWindow(void); // Close Window and Terminate Context
  503. bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed
  504. bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus)
  505. void ToggleFullscreen(void); // Fullscreen toggle (only PLATFORM_DESKTOP)
  506. int GetScreenWidth(void); // Get current screen width
  507. int GetScreenHeight(void); // Get current screen height
  508. void ShowCursor(void); // Shows cursor
  509. void HideCursor(void); // Hides cursor
  510. bool IsCursorHidden(void); // Returns true if cursor is not visible
  511. void EnableCursor(void); // Enables cursor
  512. void DisableCursor(void); // Disables cursor
  513. void ClearBackground(Color color); // Sets Background Color
  514. void BeginDrawing(void); // Setup drawing canvas to start drawing
  515. void EndDrawing(void); // End canvas drawing and Swap Buffers (Double Buffering)
  516. void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera
  517. void End2dMode(void); // Ends 2D mode custom camera usage
  518. void Begin3dMode(Camera camera); // Initializes 3D mode for drawing (Camera setup)
  519. void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
  520. void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
  521. void EndTextureMode(void); // Ends drawing to render texture
  522. Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
  523. Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position from a 3d world space position
  524. Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
  525. void SetTargetFPS(int fps); // Set target FPS (maximum)
  526. float GetFPS(void); // Returns current FPS
  527. float GetFrameTime(void); // Returns time in seconds for one frame
  528. Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
  529. int GetHexValue(Color color); // Returns hexadecimal value for a Color
  530. float *ColorToFloat(Color color); // Converts Color to float array and normalizes
  531. float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
  532. float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
  533. int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
  534. Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
  535. void SetConfigFlags(char flags); // Setup some window configuration flags
  536. void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
  537. bool IsFileDropped(void); // Check if a file have been dropped into window
  538. char **GetDroppedFiles(int *count); // Retrieve dropped files into window
  539. void ClearDroppedFiles(void); // Clear dropped files paths buffer
  540. void StorageSaveValue(int position, int value); // Storage save integer value (to defined position)
  541. int StorageLoadValue(int position); // Storage load integer value (from defined position)
  542. //------------------------------------------------------------------------------------
  543. // Input Handling Functions (Module: core)
  544. //------------------------------------------------------------------------------------
  545. #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
  546. bool IsKeyPressed(int key); // Detect if a key has been pressed once
  547. bool IsKeyDown(int key); // Detect if a key is being pressed
  548. bool IsKeyReleased(int key); // Detect if a key has been released once
  549. bool IsKeyUp(int key); // Detect if a key is NOT being pressed
  550. int GetKeyPressed(void); // Get latest key pressed
  551. void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
  552. bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
  553. float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
  554. bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
  555. bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
  556. bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
  557. bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
  558. #endif
  559. bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
  560. bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
  561. bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
  562. bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed
  563. int GetMouseX(void); // Returns mouse position X
  564. int GetMouseY(void); // Returns mouse position Y
  565. Vector2 GetMousePosition(void); // Returns mouse position XY
  566. void SetMousePosition(Vector2 position); // Set mouse position XY
  567. int GetMouseWheelMove(void); // Returns mouse wheel movement Y
  568. int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
  569. int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
  570. Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
  571. #if defined(PLATFORM_ANDROID)
  572. bool IsButtonPressed(int button); // Detect if an android physic button has been pressed
  573. bool IsButtonDown(int button); // Detect if an android physic button is being pressed
  574. bool IsButtonReleased(int button); // Detect if an android physic button has been released
  575. #endif
  576. //------------------------------------------------------------------------------------
  577. // Gestures and Touch Handling Functions (Module: gestures)
  578. //------------------------------------------------------------------------------------
  579. void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
  580. bool IsGestureDetected(int gesture); // Check if a gesture have been detected
  581. void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
  582. void UpdateGestures(void); // Update gestures detected (called automatically in PollInputEvents())
  583. int GetTouchPointsCount(void); // Get touch points count
  584. int GetGestureDetected(void); // Get latest detected gesture
  585. float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
  586. Vector2 GetGestureDragVector(void); // Get gesture drag vector
  587. float GetGestureDragAngle(void); // Get gesture drag angle
  588. Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
  589. float GetGesturePinchAngle(void); // Get gesture pinch angle
  590. //------------------------------------------------------------------------------------
  591. // Camera System Functions (Module: camera)
  592. //------------------------------------------------------------------------------------
  593. void SetCameraMode(int mode); // Set camera mode (multiple camera modes available)
  594. void UpdateCamera(Camera *camera); // Update camera (player position is ignored)
  595. void UpdateCameraPlayer(Camera *camera, Vector3 *position); // Update camera and player position (1st person and 3rd person cameras)
  596. void SetCameraPosition(Vector3 position); // Set internal camera position
  597. void SetCameraTarget(Vector3 target); // Set internal camera target
  598. void SetCameraFovy(float fovy); // Set internal camera field-of-view-y
  599. void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
  600. void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
  601. void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
  602. void SetCameraMoveControls(int frontKey, int backKey,
  603. int leftKey, int rightKey,
  604. int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
  605. void SetCameraMouseSensitivity(float sensitivity); // Set camera mouse sensitivity (1st person and 3rd person cameras)
  606. //------------------------------------------------------------------------------------
  607. // Basic Shapes Drawing Functions (Module: shapes)
  608. //------------------------------------------------------------------------------------
  609. void DrawPixel(int posX, int posY, Color color); // Draw a pixel
  610. void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
  611. void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
  612. void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
  613. void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
  614. void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
  615. void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
  616. void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
  617. void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
  618. void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
  619. void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
  620. void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
  621. void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
  622. void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
  623. void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
  624. void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
  625. void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
  626. void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
  627. bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
  628. bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
  629. bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
  630. Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision
  631. bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
  632. bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle
  633. bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle
  634. //------------------------------------------------------------------------------------
  635. // Texture Loading and Drawing Functions (Module: textures)
  636. //------------------------------------------------------------------------------------
  637. Image LoadImage(const char *fileName); // Load an image into CPU memory (RAM)
  638. Image LoadImageEx(Color *pixels, int width, int height); // Load image data from Color array data (RGBA - 32bit)
  639. Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image data from RAW file
  640. Image LoadImageFromRES(const char *rresName, int resId); // Load an image from rRES file (raylib Resource)
  641. Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory
  642. Texture2D LoadTextureEx(void *data, int width, int height, int textureFormat); // Load a texture from raw data into GPU memory
  643. Texture2D LoadTextureFromRES(const char *rresName, int resId); // Load an image as texture from rRES file (raylib Resource)
  644. Texture2D LoadTextureFromImage(Image image); // Load a texture from image data
  645. RenderTexture2D LoadRenderTexture(int width, int height); // Load a texture to be used for rendering
  646. void UnloadImage(Image image); // Unload image from CPU memory (RAM)
  647. void UnloadTexture(Texture2D texture); // Unload texture from GPU memory
  648. void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory
  649. Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
  650. Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
  651. void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
  652. void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
  653. void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
  654. Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
  655. void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
  656. void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering)
  657. void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm)
  658. Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
  659. Image ImageTextEx(SpriteFont font, const char *text, int fontSize, int spacing, Color tint); // Create an image from text (custom sprite font)
  660. void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image
  661. void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination)
  662. 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)
  663. void ImageFlipVertical(Image *image); // Flip image vertically
  664. void ImageFlipHorizontal(Image *image); // Flip image horizontally
  665. void ImageColorTint(Image *image, Color color); // Modify image color: tint
  666. void ImageColorInvert(Image *image); // Modify image color: invert
  667. void ImageColorGrayscale(Image *image); // Modify image color: grayscale
  668. void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
  669. void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
  670. void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture
  671. void UpdateTexture(Texture2D texture, void *pixels); // Update GPU texture with new data
  672. void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
  673. void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
  674. void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
  675. void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
  676. void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, // Draw a part of a texture defined by a rectangle with 'pro' parameters
  677. float rotation, Color tint);
  678. //------------------------------------------------------------------------------------
  679. // Font Loading and Text Drawing Functions (Module: text)
  680. //------------------------------------------------------------------------------------
  681. SpriteFont GetDefaultFont(void); // Get the default SpriteFont
  682. SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory
  683. void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory
  684. void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
  685. void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
  686. int fontSize, int spacing, Color tint);
  687. int MeasureText(const char *text, int fontSize); // Measure string width for default font
  688. Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int spacing); // Measure string size for SpriteFont
  689. void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner
  690. const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
  691. const char *SubText(const char *text, int position, int length); // Get a piece of a text string
  692. //------------------------------------------------------------------------------------
  693. // Basic 3d Shapes Drawing Functions (Module: models)
  694. //------------------------------------------------------------------------------------
  695. void DrawCube(Vector3 position, float width, float height, float lenght, Color color); // Draw cube
  696. void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
  697. void DrawCubeWires(Vector3 position, float width, float height, float lenght, Color color); // Draw cube wires
  698. void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float lenght, Color color); // Draw cube textured
  699. void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
  700. void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
  701. void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
  702. void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
  703. void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
  704. void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
  705. void DrawRay(Ray ray, Color color); // Draw a ray line
  706. void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
  707. void DrawGizmo(Vector3 position); // Draw simple gizmo
  708. void DrawLight(Light light); // Draw light in 3D world
  709. void Draw3DLine(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
  710. void Draw3DCircle(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space
  711. //DrawTorus(), DrawTeapot() are useless...
  712. //------------------------------------------------------------------------------------
  713. // Model 3d Loading and Drawing Functions (Module: models)
  714. //------------------------------------------------------------------------------------
  715. Model LoadModel(const char *fileName); // Load a 3d model (.OBJ)
  716. Model LoadModelEx(Mesh data, bool dynamic); // Load a 3d model (from mesh data)
  717. Model LoadModelFromRES(const char *rresName, int resId); // Load a 3d model from rRES file (raylib Resource)
  718. Model LoadHeightmap(Image heightmap, Vector3 size); // Load a heightmap image as a 3d model
  719. Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based)
  720. void UnloadModel(Model model); // Unload 3d model from memory
  721. Material LoadMaterial(const char *fileName); // Load material data (from file)
  722. Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
  723. Material LoadStandardMaterial(void); // Load standard material (uses material attributes and lighting shader)
  724. void UnloadMaterial(Material material); // Unload material textures from VRAM
  725. void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
  726. void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
  727. void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set)
  728. 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
  729. void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
  730. void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
  731. void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
  732. BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
  733. bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
  734. bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
  735. bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
  736. bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere
  737. bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere with extended parameters and collision point detection
  738. bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box
  739. Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
  740. // NOTE: Return the normal vector of the impacted surface
  741. //------------------------------------------------------------------------------------
  742. // Shaders System Functions (Module: rlgl)
  743. // NOTE: This functions are useless when using OpenGL 1.1
  744. //------------------------------------------------------------------------------------
  745. Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
  746. void UnloadShader(Shader shader); // Unload a custom shader from memory
  747. Shader GetDefaultShader(void); // Get default shader
  748. Shader GetStandardShader(void); // Get standard shader
  749. Texture2D GetDefaultTexture(void); // Get default texture
  750. int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
  751. void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
  752. void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
  753. void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
  754. void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
  755. void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
  756. void BeginShaderMode(Shader shader); // Begin custom shader drawing
  757. void EndShaderMode(void); // End custom shader drawing (use default shader)
  758. void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
  759. void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
  760. Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
  761. void DestroyLight(Light light); // Destroy a light and take it out of the list
  762. //------------------------------------------------------------------------------------
  763. // VR experience Functions (Module: rlgl)
  764. // NOTE: This functions are useless when using OpenGL 1.1
  765. //------------------------------------------------------------------------------------
  766. void InitVrDevice(int vdDevice); // Init VR device
  767. void CloseVrDevice(void); // Close VR device
  768. void UpdateVrTracking(void); // Update VR tracking (position and orientation)
  769. void BeginVrDrawing(void); // Begin VR drawing configuration
  770. void EndVrDrawing(void); // End VR drawing process (and desktop mirror)
  771. bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready
  772. void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
  773. //------------------------------------------------------------------------------------
  774. // Audio Loading and Playing Functions (Module: audio)
  775. //------------------------------------------------------------------------------------
  776. void InitAudioDevice(void); // Initialize audio device and context
  777. void CloseAudioDevice(void); // Close the audio device and context (and music stream)
  778. bool IsAudioDeviceReady(void); // True if call to InitAudioDevice() was successful and CloseAudioDevice() has not been called yet
  779. Sound LoadSound(char *fileName); // Load sound to memory
  780. Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
  781. Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
  782. void UnloadSound(Sound sound); // Unload sound
  783. void PlaySound(Sound sound); // Play a sound
  784. void PauseSound(Sound sound); // Pause a sound
  785. void StopSound(Sound sound); // Stop playing a sound
  786. bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
  787. void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
  788. void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
  789. int PlayMusicStream(int index, char *fileName); // Start music playing (open stream)
  790. void UpdateMusicStream(int index); // Updates buffers for music streaming
  791. void StopMusicStream(int index); // Stop music playing (close stream)
  792. void PauseMusicStream(int index); // Pause music playing
  793. void ResumeMusicStream(int index); // Resume playing paused music
  794. bool IsMusicPlaying(int index); // Check if music is playing
  795. void SetMusicVolume(int index, float volume); // Set volume for music (1.0 is max level)
  796. void SetMusicPitch(int index, float pitch); // Set pitch for a music (1.0 is base level)
  797. float GetMusicTimeLength(int index); // Get current music time length (in seconds)
  798. float GetMusicTimePlayed(int index); // Get current music time played (in seconds)
  799. int GetMusicStreamCount(void); // Get number of streams loaded
  800. #ifdef __cplusplus
  801. }
  802. #endif
  803. #endif // RAYLIB_H