Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

1076 Zeilen
64 KiB

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