2014-09-17 00:51:31 +04:00
/**********************************************************************************************
2014-09-03 18:51:28 +04:00
*
2016-03-27 19:32:36 +03:00
* raylib 1.5 .0 ( www . raylib . com )
2014-09-03 18:51:28 +04:00
*
2014-01-23 15:36:18 +04:00
* A simple and easy - to - use library to learn videogames programming
2013-11-19 02:38:44 +04:00
*
2013-11-23 16:30:54 +04:00
* Features :
* Library written in plain C code ( C99 )
* Uses C # PascalCase / camelCase notation
2016-01-23 14:37:42 +03:00
* Hardware accelerated with OpenGL ( 1.1 , 3.3 or ES2 )
2014-03-25 15:40:35 +04:00
* Unique OpenGL abstraction layer [ rlgl ]
2016-01-23 14:37:42 +03:00
* Powerful fonts module with SpriteFonts support ( including AngelCode fonts and TTF )
* Multiple textures support , including compressed formats and mipmaps generation
2014-03-25 15:40:35 +04:00
* Basic 3 d support for Shapes , Models , Heightmaps and Billboards
* Powerful math module for Vector and Matrix operations [ raymath ]
2014-09-19 14:34:25 +04:00
* Audio loading and playing with streaming support ( WAV and OGG )
2014-12-31 21:25:39 +03:00
* Multiplatform support , including Android devices , Raspberry Pi and HTML5
2014-09-03 18:51:28 +04:00
*
2013-11-23 16:30:54 +04:00
* Used external libs :
* GLFW3 ( www . glfw . org ) for window / context management and input
2016-01-23 15:22:13 +03:00
* GLAD for OpenGL extensions loading ( 3.3 Core profile , only PLATFORM_DESKTOP )
2013-11-23 16:30:54 +04:00
* stb_image ( Sean Barret ) for images loading ( JPEG , PNG , BMP , TGA , PSD , GIF , HDR , PIC )
2014-04-19 18:36:49 +04:00
* stb_image_write ( Sean Barret ) for image writting ( PNG )
* stb_vorbis ( Sean Barret ) for ogg audio loading
2016-01-23 14:37:42 +03:00
* stb_truetype ( Sean Barret ) for ttf fonts loading
2013-11-23 16:30:54 +04:00
* OpenAL Soft for audio device / context management
2014-01-23 15:36:18 +04:00
* tinfl for data decompression ( DEFLATE algorithm )
2013-11-19 02:38:44 +04:00
*
2013-11-23 16:30:54 +04:00
* Some design decisions :
2016-01-23 14:37:42 +03:00
* 32 bit Colors - All defined color are always RGBA ( struct Color is 4 byte )
2013-11-23 16:30:54 +04:00
* One custom default font is loaded automatically when InitWindow ( )
2016-01-23 14:37:42 +03:00
* If using OpenGL 3.3 or ES2 , several vertex buffers ( VAO / VBO ) are created to manage lines - triangles - quads
* If using OpenGL 3.3 or ES2 , two default shaders are loaded automatically ( internally defined )
2014-01-23 15:36:18 +04:00
*
2016-01-23 14:37:42 +03:00
* - - LICENSE - -
2013-11-19 02:38:44 +04:00
*
2014-09-03 18:51:28 +04:00
* raylib is licensed under an unmodified zlib / libpng license , which is an OSI - certified ,
2013-11-23 16:30:54 +04:00
* BSD - like license that allows static linking with closed source software :
2014-09-03 18:51:28 +04:00
*
2015-07-29 22:45:28 +03:00
* Copyright ( c ) 2013 Ramon Santamaria ( @ raysan5 )
2014-09-03 18:51:28 +04:00
*
* This software is provided " as-is " , without any express or implied warranty . In no event
2013-11-23 16:30:54 +04:00
* will the authors be held liable for any damages arising from the use of this software .
2013-11-19 02:38:44 +04:00
*
2014-09-03 18:51:28 +04:00
* Permission is granted to anyone to use this software for any purpose , including commercial
2013-11-23 16:30:54 +04:00
* applications , and to alter it and redistribute it freely , subject to the following restrictions :
2013-11-19 02:38:44 +04:00
*
2014-09-03 18:51:28 +04:00
* 1. The origin of this software must not be misrepresented ; you must not claim that you
* wrote the original software . If you use this software in a product , an acknowledgment
2013-11-23 16:30:54 +04:00
* in the product documentation would be appreciated but is not required .
2013-11-19 02:38:44 +04:00
*
2013-11-23 16:30:54 +04:00
* 2. Altered source versions must be plainly marked as such , and must not be misrepresented
* as being the original software .
2013-11-19 02:38:44 +04:00
*
2013-11-23 16:30:54 +04:00
* 3. This notice may not be removed or altered from any source distribution .
2013-11-19 02:38:44 +04:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef RAYLIB_H
2014-04-19 18:36:49 +04:00
# define RAYLIB_H
2014-04-09 22:25:26 +04:00
2014-09-17 00:51:31 +04:00
// Choose your platform here or just define it at compile time: -DPLATFORM_DESKTOP
//#define PLATFORM_DESKTOP // Windows, Linux or OSX
//#define PLATFORM_ANDROID // Android device
//#define PLATFORM_RPI // Raspberry Pi
2014-12-31 20:03:32 +03:00
//#define PLATFORM_WEB // HTML5 (emscripten, asm.js)
2014-09-17 00:51:31 +04:00
2014-10-17 23:11:58 +04:00
// Security check in case no PLATFORM_* defined
2014-12-15 03:08:30 +03:00
# if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEB)
2014-10-17 23:11:58 +04:00
# define PLATFORM_DESKTOP
# endif
2014-09-17 00:51:31 +04:00
# if defined(PLATFORM_ANDROID)
2016-01-03 15:01:21 +03:00
typedef struct android_app ; // Define android_app struct (android_native_app_glue.h)
2014-09-17 00:51:31 +04:00
# endif
2013-11-19 02:38:44 +04:00
//----------------------------------------------------------------------------------
// Some basic Defines
//----------------------------------------------------------------------------------
# ifndef PI
2015-05-05 00:46:31 +03:00
# define PI 3.14159265358979323846
2013-11-19 02:38:44 +04:00
# endif
2016-02-03 19:45:28 +03:00
# define DEG2RAD (PI / 180.0f)
# define RAD2DEG (180.0f / PI)
2013-11-19 02:38:44 +04:00
2014-10-17 23:11:58 +04:00
// raylib Config Flags
# define FLAG_FULLSCREEN_MODE 1
# define FLAG_SHOW_LOGO 2
# define FLAG_SHOW_MOUSE_CURSOR 4
# define FLAG_CENTERED_MODE 8
# define FLAG_MSAA_4X_HINT 16
2015-01-21 02:13:17 +03:00
# define FLAG_VSYNC_HINT 32
2014-10-17 23:11:58 +04:00
2015-02-02 02:57:08 +03:00
// Keyboard Function Keys
2013-11-19 02:38:44 +04:00
# define KEY_SPACE 32
# define KEY_ESCAPE 256
# define KEY_ENTER 257
2014-01-29 00:21:29 +04:00
# define KEY_BACKSPACE 259
2013-11-19 02:38:44 +04:00
# define KEY_RIGHT 262
# define KEY_LEFT 263
# define KEY_DOWN 264
# define KEY_UP 265
# define KEY_F1 290
# define KEY_F2 291
# define KEY_F3 292
# define KEY_F4 293
# define KEY_F5 294
# define KEY_F6 295
# define KEY_F7 296
# define KEY_F8 297
# define KEY_F9 298
# define KEY_F10 299
2016-02-19 21:57:25 +03:00
# define KEY_F11 300
# define KEY_F12 301
2013-11-19 02:38:44 +04:00
# define KEY_LEFT_SHIFT 340
# define KEY_LEFT_CONTROL 341
# define KEY_LEFT_ALT 342
# define KEY_RIGHT_SHIFT 344
# define KEY_RIGHT_CONTROL 345
# define KEY_RIGHT_ALT 346
2016-02-13 21:14:22 +03:00
// Keyboard Alpha Numeric Keys
2015-10-26 10:21:52 +03:00
# define KEY_ZERO 48
# define KEY_ONE 49
# define KEY_TWO 50
# define KEY_THREE 51
# define KEY_FOUR 52
# define KEY_FIVE 53
# define KEY_SIX 54
# define KEY_SEVEN 55
# define KEY_EIGHT 56
# define KEY_NINE 57
# define KEY_A 65
# define KEY_B 66
# define KEY_C 67
# define KEY_D 68
# define KEY_E 69
# define KEY_F 70
# define KEY_G 71
# define KEY_H 72
# define KEY_I 73
# define KEY_J 74
# define KEY_K 75
# define KEY_L 76
# define KEY_M 77
# define KEY_N 78
# define KEY_O 79
# define KEY_P 80
# define KEY_Q 81
# define KEY_R 82
# define KEY_S 83
# define KEY_T 84
# define KEY_U 85
# define KEY_V 86
# define KEY_W 87
# define KEY_X 88
# define KEY_Y 89
# define KEY_Z 90
2013-11-19 02:38:44 +04:00
// Mouse Buttons
2013-11-23 16:30:54 +04:00
# define MOUSE_LEFT_BUTTON 0
2015-11-05 15:42:18 +03:00
# if defined(PLATFORM_WEB)
# define MOUSE_RIGHT_BUTTON 2
# define MOUSE_MIDDLE_BUTTON 1
# else
# define MOUSE_RIGHT_BUTTON 1
# define MOUSE_MIDDLE_BUTTON 2
# endif
2013-11-19 02:38:44 +04:00
2016-02-12 21:02:23 +03:00
// Touch points registered
# define MAX_TOUCH_POINTS 2
2013-11-19 02:38:44 +04:00
// Gamepad Number
2013-11-23 16:30:54 +04:00
# define GAMEPAD_PLAYER1 0
# define GAMEPAD_PLAYER2 1
2016-03-17 14:54:36 +03:00
# define GAMEPAD_PLAYER3 2 // Not supported
# define GAMEPAD_PLAYER4 3 // Not supported
2013-11-19 02:38:44 +04:00
// Gamepad Buttons
// NOTE: Adjusted for a PS3 USB Controller
2014-09-17 00:51:31 +04:00
# define GAMEPAD_BUTTON_A 2
# define GAMEPAD_BUTTON_B 1
# define GAMEPAD_BUTTON_X 3
# define GAMEPAD_BUTTON_Y 4
# define GAMEPAD_BUTTON_R1 7
# define GAMEPAD_BUTTON_R2 5
# define GAMEPAD_BUTTON_L1 6
# define GAMEPAD_BUTTON_L2 8
# define GAMEPAD_BUTTON_SELECT 9
# define GAMEPAD_BUTTON_START 10
2013-11-19 02:38:44 +04:00
2016-03-16 19:52:09 +03:00
// Xbox360 USB Controller Buttons
# define GAMEPAD_XBOX_BUTTON_A 0
# define GAMEPAD_XBOX_BUTTON_B 1
# define GAMEPAD_XBOX_BUTTON_X 2
# define GAMEPAD_XBOX_BUTTON_Y 3
# define GAMEPAD_XBOX_BUTTON_LB 4
# define GAMEPAD_XBOX_BUTTON_RB 5
# define GAMEPAD_XBOX_BUTTON_SELECT 6
# define GAMEPAD_XBOX_BUTTON_START 7
# if defined(PLATFORM_RPI)
2016-03-17 14:54:36 +03:00
# define GAMEPAD_XBOX_AXIS_DPAD_X 7
# define GAMEPAD_XBOX_AXIS_DPAD_Y 6
2016-03-16 19:52:09 +03:00
# define GAMEPAD_XBOX_AXIS_RIGHT_X 3
# define GAMEPAD_XBOX_AXIS_RIGHT_Y 4
# define GAMEPAD_XBOX_AXIS_LT 2
# define GAMEPAD_XBOX_AXIS_RT 5
# else
# define GAMEPAD_XBOX_BUTTON_UP 10
# define GAMEPAD_XBOX_BUTTON_DOWN 12
# define GAMEPAD_XBOX_BUTTON_LEFT 13
# define GAMEPAD_XBOX_BUTTON_RIGHT 11
# define GAMEPAD_XBOX_AXIS_RIGHT_X 4
# define GAMEPAD_XBOX_AXIS_RIGHT_Y 3
# define GAMEPAD_XBOX_AXIS_LT_RT 2
# endif
# define GAMEPAD_XBOX_AXIS_LEFT_X 0
# define GAMEPAD_XBOX_AXIS_LEFT_Y 1
2013-11-19 02:38:44 +04:00
2016-01-04 23:00:20 +03:00
// Android Physic Buttons
# define ANDROID_BACK 4
# define ANDROID_MENU 82
# define ANDROID_VOLUME_UP 24
# define ANDROID_VOLUME_DOWN 25
2013-11-19 02:38:44 +04:00
// Some Basic Colors
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
2013-11-23 16:30:54 +04:00
# define LIGHTGRAY (Color){ 200, 200, 200, 255 } // Light Gray
# define GRAY (Color){ 130, 130, 130, 255 } // Gray
# define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
# define YELLOW (Color){ 253, 249, 0, 255 } // Yellow
# define GOLD (Color){ 255, 203, 0, 255 } // Gold
# define ORANGE (Color){ 255, 161, 0, 255 } // Orange
# define PINK (Color){ 255, 109, 194, 255 } // Pink
# define RED (Color){ 230, 41, 55, 255 } // Red
# define MAROON (Color){ 190, 33, 55, 255 } // Maroon
# define GREEN (Color){ 0, 228, 48, 255 } // Green
# define LIME (Color){ 0, 158, 47, 255 } // Lime
# define DARKGREEN (Color){ 0, 117, 44, 255 } // Dark Green
# define SKYBLUE (Color){ 102, 191, 255, 255 } // Sky Blue
# define BLUE (Color){ 0, 121, 241, 255 } // Blue
# define DARKBLUE (Color){ 0, 82, 172, 255 } // Dark Blue
# define PURPLE (Color){ 200, 122, 255, 255 } // Purple
# define VIOLET (Color){ 135, 60, 190, 255 } // Violet
# define DARKPURPLE (Color){ 112, 31, 126, 255 } // Dark Purple
# define BEIGE (Color){ 211, 176, 131, 255 } // Beige
# define BROWN (Color){ 127, 106, 79, 255 } // Brown
# define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown
# define WHITE (Color){ 255, 255, 255, 255 } // White
# define BLACK (Color){ 0, 0, 0, 255 } // Black
# define BLANK (Color){ 0, 0, 0, 0 } // Blank (Transparent)
# define MAGENTA (Color){ 255, 0, 255, 255 } // Magenta
# define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
2013-11-19 02:38:44 +04:00
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
2015-02-03 00:06:50 +03:00
# ifndef __cplusplus
2013-11-19 02:38:44 +04:00
// Boolean type
2016-04-27 10:02:11 +03:00
# ifndef true
typedef enum { false , true } bool ;
# endif
2015-02-03 00:06:50 +03:00
# endif
2016-04-30 09:00:12 +03:00
typedef enum { silence , mono , stereo } channel_t ;
typedef enum { mixA , mixB , mixC , mixD } mix_t ; // Used for mixing/muxing up to four diferent audio streams
2013-11-19 02:38:44 +04:00
2014-11-23 23:58:17 +03:00
// byte type
typedef unsigned char byte ;
2014-04-09 22:25:26 +04:00
// Vector2 type
typedef struct Vector2 {
float x ;
float y ;
} Vector2 ;
// Vector3 type
typedef struct Vector3 {
float x ;
float y ;
float z ;
} Vector3 ;
2015-04-06 15:02:29 +03:00
// Matrix type (OpenGL style 4x4 - right handed, column major)
typedef struct Matrix {
float m0 , m4 , m8 , m12 ;
float m1 , m5 , m9 , m13 ;
float m2 , m6 , m10 , m14 ;
float m3 , m7 , m11 , m15 ;
} Matrix ;
2013-11-19 02:38:44 +04:00
// Color type, RGBA (32bit)
typedef struct Color {
2013-11-23 16:30:54 +04:00
unsigned char r ;
unsigned char g ;
unsigned char b ;
unsigned char a ;
2013-11-19 02:38:44 +04:00
} Color ;
// Rectangle type
typedef struct Rectangle {
2013-11-23 16:30:54 +04:00
int x ;
int y ;
int width ;
int height ;
2013-11-19 02:38:44 +04:00
} Rectangle ;
// Image type, bpp always RGBA (32bit)
// NOTE: Data stored in CPU memory (RAM)
typedef struct Image {
2015-05-05 00:46:31 +03:00
void * data ; // Image raw data
int width ; // Image base width
int height ; // Image base height
int mipmaps ; // Mipmap levels, 1 by default
int format ; // Data format (TextureFormat)
2013-11-19 02:38:44 +04:00
} Image ;
// Texture2D type, bpp always RGBA (32bit)
// NOTE: Data stored in GPU memory
typedef struct Texture2D {
2015-05-05 00:46:31 +03:00
unsigned int id ; // OpenGL texture id
int width ; // Texture base width
int height ; // Texture base height
int mipmaps ; // Mipmap levels, 1 by default
int format ; // Data format (TextureFormat)
2013-11-19 02:38:44 +04:00
} Texture2D ;
2016-03-30 21:09:16 +03:00
// RenderTexture2D type, for texture rendering
typedef struct RenderTexture2D {
unsigned int id ; // Render texture (fbo) id
Texture2D texture ; // Color buffer attachment texture
Texture2D depth ; // Depth buffer attachment texture
} RenderTexture2D ;
2014-04-19 18:36:49 +04:00
// SpriteFont type, includes texture and charSet array data
2013-11-19 02:38:44 +04:00
typedef struct SpriteFont {
2015-08-30 18:45:05 +03:00
Texture2D texture ; // Font texture
int size ; // Base size (default chars height)
int numChars ; // Number of characters
int * charValues ; // Characters values array
Rectangle * charRecs ; // Characters rectangles within the texture
2016-01-02 12:45:51 +03:00
Vector2 * charOffsets ; // Characters offsets (on drawing)
int * charAdvanceX ; // Characters x advance (on drawing)
2013-11-19 02:38:44 +04:00
} SpriteFont ;
2014-04-19 18:36:49 +04:00
// Camera type, defines a camera position/orientation in 3d space
typedef struct Camera {
2016-03-05 15:05:45 +03:00
Vector3 position ; // Camera position
Vector3 target ; // Camera target it looks-at
Vector3 up ; // Camera up vector (rotation over its axis)
float fovy ; // Field-Of-View apperture in Y (degrees)
2014-04-19 18:36:49 +04:00
} Camera ;
2016-03-05 17:40:08 +03:00
// Camera2D type, defines a 2d camera
typedef struct Camera2D {
2016-03-27 19:32:36 +03:00
Vector2 offset ; // Camera offset (displacement from target)
Vector2 target ; // Camera target (for rotation and zoom)
2016-03-05 17:40:08 +03:00
float rotation ; // Camera rotation in degrees
float zoom ; // Camera zoom (scaling), should be 1.0f by default
} Camera2D ;
2016-01-18 15:36:18 +03:00
// Bounding box type
typedef struct BoundingBox {
Vector3 min ;
Vector3 max ;
} BoundingBox ;
2014-04-19 18:36:49 +04:00
// Vertex data definning a mesh
2016-01-18 15:36:18 +03:00
typedef struct Mesh {
int vertexCount ; // num vertices
float * vertices ; // vertex position (XYZ - 3 components per vertex)
float * texcoords ; // vertex texture coordinates (UV - 2 components per vertex)
float * texcoords2 ; // vertex second texture coordinates (useful for lightmaps)
float * normals ; // vertex normals (XYZ - 3 components per vertex)
float * tangents ; // vertex tangents (XYZ - 3 components per vertex)
unsigned char * colors ; // vertex colors (RGBA - 4 components per vertex)
BoundingBox bounds ; // mesh limits defined by min and max points
unsigned int vaoId ; // OpenGL Vertex Array Object id
unsigned int vboId [ 6 ] ; // OpenGL Vertex Buffer Objects id (6 types of vertex data)
} Mesh ;
2014-04-19 18:36:49 +04:00
2015-08-30 18:45:05 +03:00
// Shader type (generic shader)
2015-03-01 18:00:52 +03:00
typedef struct Shader {
2016-03-27 19:32:36 +03:00
unsigned int id ; // Shader program id
2015-06-16 11:52:26 +03:00
2015-03-01 18:00:52 +03:00
// Variable attributes
2015-07-13 19:20:16 +03:00
int vertexLoc ; // Vertex attribute location point (vertex shader)
int texcoordLoc ; // Texcoord attribute location point (vertex shader)
int normalLoc ; // Normal attribute location point (vertex shader)
int colorLoc ; // Color attibute location point (vertex shader)
2015-04-06 15:02:29 +03:00
2015-03-01 18:00:52 +03:00
// Uniforms
2016-01-13 19:13:28 +03:00
int mvpLoc ; // ModelView-Projection matrix uniform location point (vertex shader)
2015-07-13 19:20:16 +03:00
int tintColorLoc ; // Color uniform location point (fragment shader)
2015-06-16 11:52:26 +03:00
int mapDiffuseLoc ; // Diffuse map texture uniform location point (fragment shader)
int mapNormalLoc ; // Normal map texture uniform location point (fragment shader)
int mapSpecularLoc ; // Specular map texture uniform location point (fragment shader)
2015-03-01 18:00:52 +03:00
} Shader ;
2016-01-25 15:54:09 +03:00
// Material type
typedef struct Material {
2016-03-06 04:05:16 +03:00
Shader shader ; // Standard shader (supports 3 map types: diffuse, normal, specular)
2016-01-25 15:54:09 +03:00
2016-03-06 04:05:16 +03:00
Texture2D texDiffuse ; // Diffuse texture
Texture2D texNormal ; // Normal texture
Texture2D texSpecular ; // Specular texture
2016-01-25 15:54:09 +03:00
2016-03-06 04:05:16 +03:00
Color colDiffuse ; // Diffuse color
Color colAmbient ; // Ambient color
Color colSpecular ; // Specular color
2016-01-25 15:54:09 +03:00
2016-03-06 04:05:16 +03:00
float glossiness ; // Glossiness level
float normalDepth ; // Normal map depth
2016-01-25 15:54:09 +03:00
} Material ;
2014-04-09 22:25:26 +04:00
// 3d Model type
2016-01-25 15:54:09 +03:00
// TODO: Replace shader/testure by material
2014-04-19 18:36:49 +04:00
typedef struct Model {
2016-03-27 19:32:36 +03:00
Mesh mesh ; // Vertex data buffers (RAM and VRAM)
Matrix transform ; // Local transform matrix
Material material ; // Shader and textures data
2014-04-19 18:36:49 +04:00
} Model ;
2013-11-19 02:38:44 +04:00
2015-03-02 22:52:58 +03:00
// Ray type (useful for raycast)
typedef struct Ray {
Vector3 position ;
Vector3 direction ;
} Ray ;
2014-04-09 22:25:26 +04:00
// Sound source type
2013-11-19 02:38:44 +04:00
typedef struct Sound {
2013-11-23 16:30:54 +04:00
unsigned int source ;
unsigned int buffer ;
2013-11-19 02:38:44 +04:00
} Sound ;
2014-12-15 03:08:30 +03:00
// Wave type, defines audio wave data
typedef struct Wave {
void * data ; // Buffer data pointer
unsigned int dataSize ; // Data size in bytes
2016-03-27 19:32:36 +03:00
unsigned int sampleRate ; // Samples per second to be played
short bitsPerSample ; // Sample size in bits
2014-12-15 03:08:30 +03:00
short channels ;
} Wave ;
2016-04-30 09:00:12 +03:00
// Audio Context, used to create custom audio streams that are not bound to a sound file. There can be
// no more than 4 concurrent audio contexts in use. This is due to each active context being tied to
// a dedicated mix channel.
typedef struct AudioContext {
unsigned short sampleRate ; // default is 48000
unsigned char bitsPerSample ; // 16 is default
mix_t mixChannel ; // 0-3 or mixA-mixD, each mix channel can receive up to one dedicated audio stream
channel_t channels ; // 1=mono, 2=stereo
} AudioContext ;
2015-05-05 00:46:31 +03:00
// Texture formats
// NOTE: Support depends on OpenGL version and platform
2015-04-06 15:02:29 +03:00
typedef enum {
UNCOMPRESSED_GRAYSCALE = 1 , // 8 bit per pixel (no alpha)
2015-05-05 00:46:31 +03:00
UNCOMPRESSED_GRAY_ALPHA , // 16 bpp (2 channels)
2015-04-06 15:02:29 +03:00
UNCOMPRESSED_R5G6B5 , // 16 bpp
UNCOMPRESSED_R8G8B8 , // 24 bpp
UNCOMPRESSED_R5G5B5A1 , // 16 bpp (1 bit alpha)
UNCOMPRESSED_R4G4B4A4 , // 16 bpp (4 bit alpha)
UNCOMPRESSED_R8G8B8A8 , // 32 bpp
COMPRESSED_DXT1_RGB , // 4 bpp (no alpha)
COMPRESSED_DXT1_RGBA , // 4 bpp (1 bit alpha)
COMPRESSED_DXT3_RGBA , // 8 bpp
COMPRESSED_DXT5_RGBA , // 8 bpp
COMPRESSED_ETC1_RGB , // 4 bpp
COMPRESSED_ETC2_RGB , // 4 bpp
COMPRESSED_ETC2_EAC_RGBA , // 8 bpp
2015-04-13 21:15:28 +03:00
COMPRESSED_PVRT_RGB , // 4 bpp
COMPRESSED_PVRT_RGBA , // 4 bpp
2015-05-05 00:46:31 +03:00
COMPRESSED_ASTC_4x4_RGBA , // 8 bpp
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
2015-04-06 15:02:29 +03:00
} TextureFormat ;
2015-08-07 18:24:28 +03:00
// Color blending modes (pre-defined)
typedef enum { BLEND_ALPHA = 0 , BLEND_ADDITIVE , BLEND_MULTIPLIED } BlendMode ;
2015-05-05 00:46:31 +03:00
// Gestures type
2015-07-05 19:21:01 +03:00
// NOTE: It could be used as flags to enable only some gestures
2015-05-05 00:46:31 +03:00
typedef enum {
2016-02-02 18:43:42 +03:00
GESTURE_NONE = 0 ,
GESTURE_TAP = 1 ,
GESTURE_DOUBLETAP = 2 ,
GESTURE_HOLD = 4 ,
GESTURE_DRAG = 8 ,
GESTURE_SWIPE_RIGHT = 16 ,
GESTURE_SWIPE_LEFT = 32 ,
GESTURE_SWIPE_UP = 64 ,
GESTURE_SWIPE_DOWN = 128 ,
GESTURE_PINCH_IN = 256 ,
GESTURE_PINCH_OUT = 512
2015-05-05 00:46:31 +03:00
} Gestures ;
2016-02-12 21:02:23 +03:00
// Touch action (fingers or mouse)
2016-01-03 15:01:21 +03:00
typedef enum { TOUCH_UP , TOUCH_DOWN , TOUCH_MOVE } TouchAction ;
// Gesture events
2016-02-12 21:02:23 +03:00
// NOTE: MAX_TOUCH_POINTS fixed to 2
2016-03-27 19:32:36 +03:00
typedef struct GestureEvent {
2016-01-03 15:01:21 +03:00
int touchAction ;
int pointCount ;
2016-02-12 21:02:23 +03:00
int pointerId [ MAX_TOUCH_POINTS ] ;
Vector2 position [ MAX_TOUCH_POINTS ] ;
2016-01-03 15:01:21 +03:00
} GestureEvent ;
2015-07-29 22:45:28 +03:00
// Camera system modes
typedef enum { CAMERA_CUSTOM = 0 , CAMERA_FREE , CAMERA_ORBITAL , CAMERA_FIRST_PERSON , CAMERA_THIRD_PERSON } CameraMode ;
2016-03-16 14:48:30 +03:00
typedef enum { COLLIDER_CIRCLE , COLLIDER_RECTANGLE } ColliderType ;
2015-12-21 23:12:35 +03:00
typedef struct Transform {
Vector2 position ;
2016-03-23 17:50:41 +03:00
float rotation ; // Radians (not used)
Vector2 scale ; // Just for rectangle physic objects, for circle physic objects use collider radius and keep scale as { 0, 0 }
2015-12-21 23:12:35 +03:00
} Transform ;
typedef struct Rigidbody {
2016-03-05 19:05:02 +03:00
bool enabled ; // Acts as kinematic state (collisions are calculated anyway)
2015-12-21 23:12:35 +03:00
float mass ;
Vector2 acceleration ;
Vector2 velocity ;
bool applyGravity ;
2016-03-05 19:05:02 +03:00
bool isGrounded ;
float friction ; // Normalized value
2016-03-16 14:48:30 +03:00
float bounciness ;
2015-12-21 23:12:35 +03:00
} Rigidbody ;
typedef struct Collider {
bool enabled ;
ColliderType type ;
2016-03-16 14:48:30 +03:00
Rectangle bounds ; // Used for COLLIDER_RECTANGLE
int radius ; // Used for COLLIDER_CIRCLE
2015-12-21 23:12:35 +03:00
} Collider ;
2016-03-05 19:05:02 +03:00
typedef struct PhysicObject {
unsigned int id ;
Transform transform ;
Rigidbody rigidbody ;
Collider collider ;
bool enabled ;
} PhysicObject ;
2013-11-19 02:38:44 +04:00
# ifdef __cplusplus
2013-11-23 16:30:54 +04:00
extern " C " { // Prevents name mangling of functions
2013-11-19 02:38:44 +04:00
# endif
//------------------------------------------------------------------------------------
// Global Variables Definition
//------------------------------------------------------------------------------------
// It's lonely here...
//------------------------------------------------------------------------------------
// Window and Graphics Device Functions (Module: core)
//------------------------------------------------------------------------------------
2014-09-17 00:51:31 +04:00
# if defined(PLATFORM_ANDROID)
2015-07-29 22:45:28 +03:00
void InitWindow ( int width , int height , struct android_app * state ) ; // Init Android Activity and OpenGL Graphics
2014-12-31 20:03:32 +03:00
# elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
2014-09-17 00:51:31 +04:00
void InitWindow ( int width , int height , const char * title ) ; // Initialize Window and OpenGL Graphics
# endif
2014-09-03 19:06:10 +04:00
void CloseWindow ( void ) ; // Close Window and Terminate Context
bool WindowShouldClose ( void ) ; // Detect if KEY_ESCAPE pressed or Close icon pressed
2015-07-29 22:45:28 +03:00
bool IsWindowMinimized ( void ) ; // Detect if window has been minimized (or lost focus)
2014-09-17 00:51:31 +04:00
void ToggleFullscreen ( void ) ; // Fullscreen toggle (only PLATFORM_DESKTOP)
int GetScreenWidth ( void ) ; // Get current screen width
int GetScreenHeight ( void ) ; // Get current screen height
2013-11-19 02:38:44 +04:00
2016-04-17 12:19:32 +03:00
void ShowCursor ( void ) ; // Shows cursor
void HideCursor ( void ) ; // Hides cursor
bool IsCursorHidden ( void ) ; // Returns true if cursor is not visible
void EnableCursor ( void ) ; // Enables cursor
void DisableCursor ( void ) ; // Disables cursor
2014-01-23 15:36:18 +04:00
void ClearBackground ( Color color ) ; // Sets Background Color
2014-09-03 19:06:10 +04:00
void BeginDrawing ( void ) ; // Setup drawing canvas to start drawing
2016-03-05 17:40:08 +03:00
void BeginDrawingEx ( Camera2D camera ) ; // Setup drawing canvas with 2d camera
2014-09-03 19:06:10 +04:00
void EndDrawing ( void ) ; // End canvas drawing and Swap Buffers (Double Buffering)
2013-11-19 02:38:44 +04:00
2016-01-25 15:54:09 +03:00
void Begin3dMode ( Camera camera ) ; // Initializes 3D mode for drawing (Camera setup)
2014-09-03 19:06:10 +04:00
void End3dMode ( void ) ; // Ends 3D mode and returns to default 2D orthographic mode
2016-03-30 21:09:16 +03:00
void BeginTextureMode ( RenderTexture2D target ) ; // Initializes render texture for drawing
void EndTextureMode ( void ) ; // Ends drawing to render texture
2013-11-19 02:38:44 +04:00
2016-01-11 17:59:26 +03:00
Ray GetMouseRay ( Vector2 mousePosition , Camera camera ) ; // Returns a ray trace from mouse position
Vector2 WorldToScreen ( Vector3 position , Camera camera ) ; // Returns the screen space position from a 3d world space position
2016-01-25 15:54:09 +03:00
Matrix GetCameraMatrix ( Camera camera ) ; // Returns camera transform matrix (view matrix)
2015-08-30 18:45:05 +03:00
2014-01-23 15:36:18 +04:00
void SetTargetFPS ( int fps ) ; // Set target FPS (maximum)
2014-09-03 19:06:10 +04:00
float GetFPS ( void ) ; // Returns current FPS
float GetFrameTime ( void ) ; // Returns time in seconds for one frame
2013-11-19 02:38:44 +04:00
2014-01-23 15:36:18 +04:00
Color GetColor ( int hexValue ) ; // Returns a Color struct from hexadecimal value
int GetHexValue ( Color color ) ; // Returns hexadecimal value for a Color
2016-01-11 15:29:55 +03:00
float * ColorToFloat ( Color color ) ; // Converts Color to float array and normalizes
2016-01-20 20:20:05 +03:00
float * VectorToFloat ( Vector3 vec ) ; // Converts Vector3 to float array
float * MatrixToFloat ( Matrix mat ) ; // Converts Matrix to float array
2013-11-19 02:38:44 +04:00
2014-01-23 15:36:18 +04:00
int GetRandomValue ( int min , int max ) ; // Returns a random value between min and max (both included)
2014-09-17 00:51:31 +04:00
Color Fade ( Color color , float alpha ) ; // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
2013-12-19 15:08:06 +04:00
2015-08-30 18:45:05 +03:00
void SetConfigFlags ( char flags ) ; // Setup some window configuration flags
2014-12-31 20:03:32 +03:00
void ShowLogo ( void ) ; // Activates raylib logo at startup (can be done with flags)
2014-07-23 02:06:24 +04:00
2015-07-29 22:45:28 +03:00
bool IsFileDropped ( void ) ; // Check if a file have been dropped into window
char * * GetDroppedFiles ( int * count ) ; // Retrieve dropped files into window
void ClearDroppedFiles ( void ) ; // Clear dropped files paths buffer
2016-01-04 17:12:34 +03:00
void StorageSaveValue ( int position , int value ) ; // Storage save integer value (to defined position)
int StorageLoadValue ( int position ) ; // Storage load integer value (from defined position)
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Input Handling Functions (Module: core)
//------------------------------------------------------------------------------------
2014-12-15 03:08:30 +03:00
# if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
2013-11-28 22:59:56 +04:00
bool IsKeyPressed ( int key ) ; // Detect if a key has been pressed once
bool IsKeyDown ( int key ) ; // Detect if a key is being pressed
bool IsKeyReleased ( int key ) ; // Detect if a key has been released once
bool IsKeyUp ( int key ) ; // Detect if a key is NOT being pressed
2015-01-18 12:57:30 +03:00
int GetKeyPressed ( void ) ; // Get latest key pressed
2016-04-17 12:19:32 +03:00
void SetExitKey ( int key ) ; // Set a custom key to exit program (default is ESC)
bool IsGamepadAvailable ( int gamepad ) ; // Detect if a gamepad is available
float GetGamepadAxisMovement ( int gamepad , int axis ) ; // Return axis movement value for a gamepad axis
bool IsGamepadButtonPressed ( int gamepad , int button ) ; // Detect if a gamepad button has been pressed once
bool IsGamepadButtonDown ( int gamepad , int button ) ; // Detect if a gamepad button is being pressed
bool IsGamepadButtonReleased ( int gamepad , int button ) ; // Detect if a gamepad button has been released once
bool IsGamepadButtonUp ( int gamepad , int button ) ; // Detect if a gamepad button is NOT being pressed
# endif
2013-11-28 22:59:56 +04:00
bool IsMouseButtonPressed ( int button ) ; // Detect if a mouse button has been pressed once
bool IsMouseButtonDown ( int button ) ; // Detect if a mouse button is being pressed
bool IsMouseButtonReleased ( int button ) ; // Detect if a mouse button has been released once
bool IsMouseButtonUp ( int button ) ; // Detect if a mouse button is NOT being pressed
2014-09-03 19:06:10 +04:00
int GetMouseX ( void ) ; // Returns mouse position X
int GetMouseY ( void ) ; // Returns mouse position Y
Vector2 GetMousePosition ( void ) ; // Returns mouse position XY
2014-12-09 15:21:55 +03:00
void SetMousePosition ( Vector2 position ) ; // Set mouse position XY
2014-09-03 19:06:10 +04:00
int GetMouseWheelMove ( void ) ; // Returns mouse wheel movement Y
2015-02-26 15:52:03 +03:00
2016-02-10 12:31:06 +03:00
int GetTouchX ( void ) ; // Returns touch position X for touch point 0 (relative to screen size)
int GetTouchY ( void ) ; // Returns touch position Y for touch point 0 (relative to screen size)
2016-02-10 13:24:02 +03:00
Vector2 GetTouchPosition ( int index ) ; // Returns touch position XY for a touch point index (relative to screen size)
2016-01-24 21:17:08 +03:00
# if defined(PLATFORM_ANDROID)
2016-01-04 23:00:20 +03:00
bool IsButtonPressed ( int button ) ; // Detect if an android physic button has been pressed
bool IsButtonDown ( int button ) ; // Detect if an android physic button is being pressed
2016-01-05 15:58:20 +03:00
bool IsButtonReleased ( int button ) ; // Detect if an android physic button has been released
2016-01-24 21:17:08 +03:00
# endif
2015-07-29 22:45:28 +03:00
2015-10-30 13:30:32 +03:00
//------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: gestures)
//------------------------------------------------------------------------------------
2016-02-17 15:00:48 +03:00
void ProcessGestureEvent ( GestureEvent event ) ; // Process gesture event and translate it into gestures
2016-04-17 12:19:32 +03:00
void UpdateGestures ( void ) ; // Update gestures detected (called automatically in PollInputEvents())
2016-04-17 12:36:40 +03:00
bool IsGestureDetected ( int gesture ) ; // Check if a gesture have been detected
int GetGestureDetected ( void ) ; // Get latest detected gesture
2015-07-29 22:45:28 +03:00
void SetGesturesEnabled ( unsigned int gestureFlags ) ; // Enable a set of gestures using flags
2016-02-17 15:00:48 +03:00
int GetTouchPointsCount ( void ) ; // Get touch points count
2015-07-29 22:45:28 +03:00
2016-02-17 15:00:48 +03:00
float GetGestureHoldDuration ( void ) ; // Get gesture hold time in milliseconds
2015-07-29 22:45:28 +03:00
Vector2 GetGestureDragVector ( void ) ; // Get gesture drag vector
2016-02-17 15:00:48 +03:00
float GetGestureDragAngle ( void ) ; // Get gesture drag angle
Vector2 GetGesturePinchVector ( void ) ; // Get gesture pinch delta
2015-07-29 22:45:28 +03:00
float GetGesturePinchAngle ( void ) ; // Get gesture pinch angle
2013-11-19 02:38:44 +04:00
2015-07-29 22:45:28 +03:00
//------------------------------------------------------------------------------------
// Camera System Functions (Module: camera)
//------------------------------------------------------------------------------------
void SetCameraMode ( int mode ) ; // Set camera mode (multiple camera modes available)
2015-08-30 18:45:05 +03:00
void UpdateCamera ( Camera * camera ) ; // Update camera (player position is ignored)
void UpdateCameraPlayer ( Camera * camera , Vector3 * position ) ; // Update camera and player position (1st person and 3rd person cameras)
2015-07-29 22:45:28 +03:00
2015-08-28 15:14:29 +03:00
void SetCameraPosition ( Vector3 position ) ; // Set internal camera position
void SetCameraTarget ( Vector3 target ) ; // Set internal camera target
2016-03-05 15:05:45 +03:00
void SetCameraFovy ( float fovy ) ; // Set internal camera field-of-view-y
2015-07-29 22:45:28 +03:00
void SetCameraPanControl ( int panKey ) ; // Set camera pan key to combine with mouse movement (free camera)
void SetCameraAltControl ( int altKey ) ; // Set camera alt key to combine with mouse movement (free camera)
void SetCameraSmoothZoomControl ( int szKey ) ; // Set camera smooth zoom key to combine with mouse (free camera)
2015-08-28 15:14:29 +03:00
void SetCameraMoveControls ( int frontKey , int backKey ,
int leftKey , int rightKey ,
int upKey , int downKey ) ; // Set camera move controls (1st person and 3rd person cameras)
2015-07-29 22:45:28 +03:00
void SetCameraMouseSensitivity ( float sensitivity ) ; // Set camera mouse sensitivity (1st person and 3rd person cameras)
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Basic Shapes Drawing Functions (Module: shapes)
//------------------------------------------------------------------------------------
2013-11-23 16:30:54 +04:00
void DrawPixel ( int posX , int posY , Color color ) ; // Draw a pixel
void DrawPixelV ( Vector2 position , Color color ) ; // Draw a pixel (Vector version)
void DrawLine ( int startPosX , int startPosY , int endPosX , int endPosY , Color color ) ; // Draw a line
void DrawLineV ( Vector2 startPos , Vector2 endPos , Color color ) ; // Draw a line (Vector version)
void DrawCircle ( int centerX , int centerY , float radius , Color color ) ; // Draw a color-filled circle
void DrawCircleGradient ( int centerX , int centerY , float radius , Color color1 , Color color2 ) ; // Draw a gradient-filled circle
void DrawCircleV ( Vector2 center , float radius , Color color ) ; // Draw a color-filled circle (Vector version)
void DrawCircleLines ( int centerX , int centerY , float radius , Color color ) ; // Draw circle outline
void DrawRectangle ( int posX , int posY , int width , int height , Color color ) ; // Draw a color-filled rectangle
void DrawRectangleRec ( Rectangle rec , Color color ) ; // Draw a color-filled rectangle
void DrawRectangleGradient ( int posX , int posY , int width , int height , Color color1 , Color color2 ) ; // Draw a gradient-filled rectangle
void DrawRectangleV ( Vector2 position , Vector2 size , Color color ) ; // Draw a color-filled rectangle (Vector version)
void DrawRectangleLines ( int posX , int posY , int width , int height , Color color ) ; // Draw rectangle outline
void DrawTriangle ( Vector2 v1 , Vector2 v2 , Vector2 v3 , Color color ) ; // Draw a color-filled triangle
void DrawTriangleLines ( Vector2 v1 , Vector2 v2 , Vector2 v3 , Color color ) ; // Draw triangle outline
2013-12-19 15:08:06 +04:00
void DrawPoly ( Vector2 center , int sides , float radius , float rotation , Color color ) ; // Draw a regular polygon (Vector version)
void DrawPolyEx ( Vector2 * points , int numPoints , Color color ) ; // Draw a closed polygon defined by points
void DrawPolyExLines ( Vector2 * points , int numPoints , Color color ) ; // Draw polygon lines
2013-11-19 02:38:44 +04:00
2013-11-30 21:12:40 +04:00
bool CheckCollisionRecs ( Rectangle rec1 , Rectangle rec2 ) ; // Check collision between two rectangles
bool CheckCollisionCircles ( Vector2 center1 , float radius1 , Vector2 center2 , float radius2 ) ; // Check collision between two circles
bool CheckCollisionCircleRec ( Vector2 center , float radius , Rectangle rec ) ; // Check collision between circle and rectangle
Rectangle GetCollisionRec ( Rectangle rec1 , Rectangle rec2 ) ; // Get collision rectangle for two rectangles collision
2013-12-19 15:27:28 +04:00
bool CheckCollisionPointRec ( Vector2 point , Rectangle rec ) ; // Check if point is inside rectangle
bool CheckCollisionPointCircle ( Vector2 point , Vector2 center , float radius ) ; // Check if point is inside circle
bool CheckCollisionPointTriangle ( Vector2 point , Vector2 p1 , Vector2 p2 , Vector2 p3 ) ; // Check if point is inside a triangle
2013-11-30 21:12:40 +04:00
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Texture Loading and Drawing Functions (Module: textures)
//------------------------------------------------------------------------------------
2013-11-23 16:30:54 +04:00
Image LoadImage ( const char * fileName ) ; // Load an image into CPU memory (RAM)
2015-07-05 19:21:01 +03:00
Image LoadImageEx ( Color * pixels , int width , int height ) ; // Load image data from Color array data (RGBA - 32bit)
2015-07-13 19:20:16 +03:00
Image LoadImageRaw ( const char * fileName , int width , int height , int format , int headerSize ) ; // Load image data from RAW file
2014-01-23 15:36:18 +04:00
Image LoadImageFromRES ( const char * rresName , int resId ) ; // Load an image from rRES file (raylib Resource)
2013-11-23 16:30:54 +04:00
Texture2D LoadTexture ( const char * fileName ) ; // Load an image as texture into GPU memory
2015-11-04 20:33:46 +03:00
Texture2D LoadTextureEx ( void * data , int width , int height , int textureFormat ) ; // Load a texture from raw data into GPU memory
2014-01-23 15:36:18 +04:00
Texture2D LoadTextureFromRES ( const char * rresName , int resId ) ; // Load an image as texture from rRES file (raylib Resource)
2015-08-30 18:45:05 +03:00
Texture2D LoadTextureFromImage ( Image image ) ; // Load a texture from image data
2016-03-30 21:09:16 +03:00
RenderTexture2D LoadRenderTexture ( int width , int height ) ; // Load a texture to be used for rendering
2014-01-23 15:36:18 +04:00
void UnloadImage ( Image image ) ; // Unload image from CPU memory (RAM)
2013-11-23 16:30:54 +04:00
void UnloadTexture ( Texture2D texture ) ; // Unload texture from GPU memory
2016-03-30 21:09:16 +03:00
void UnloadRenderTexture ( RenderTexture2D target ) ; // Unload render texture from GPU memory
2015-07-13 19:20:16 +03:00
Color * GetImageData ( Image image ) ; // Get pixel data from image as a Color struct array
Image GetTextureData ( Texture2D texture ) ; // Get pixel data from GPU texture and return an Image
2015-10-25 02:50:15 +03:00
void ImageToPOT ( Image * image , Color fillColor ) ; // Convert image to POT (power-of-two)
void ImageFormat ( Image * image , int newFormat ) ; // Convert image data to desired format
2015-12-30 15:32:41 +03:00
void ImageDither ( Image * image , int rBpp , int gBpp , int bBpp , int aBpp ) ; // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
2015-10-06 18:30:03 +03:00
Image ImageCopy ( Image image ) ; // Create an image duplicate (useful for transformations)
void ImageCrop ( Image * image , Rectangle crop ) ; // Crop an image to a defined rectangle
void ImageResize ( Image * image , int newWidth , int newHeight ) ; // Resize and image (bilinear filtering)
2016-03-02 21:22:55 +03:00
void ImageResizeNN ( Image * image , int newWidth , int newHeight ) ; // Resize and image (Nearest-Neighbor scaling algorithm)
2015-10-25 02:50:15 +03:00
Image ImageText ( const char * text , int fontSize , Color color ) ; // Create an image from text (default font)
Image ImageTextEx ( SpriteFont font , const char * text , int fontSize , int spacing , Color tint ) ; // Create an image from text (custom sprite font)
2016-03-06 21:28:58 +03:00
void ImageDraw ( Image * dst , Image src , Rectangle srcRec , Rectangle dstRec ) ; // Draw a source image within a destination image
void ImageDrawText ( Image * dst , Vector2 position , const char * text , int fontSize , Color color ) ; // Draw text (default font) within an image (destination)
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)
2015-10-25 02:50:15 +03:00
void ImageFlipVertical ( Image * image ) ; // Flip image vertically
void ImageFlipHorizontal ( Image * image ) ; // Flip image horizontally
void ImageColorTint ( Image * image , Color color ) ; // Modify image color: tint
void ImageColorInvert ( Image * image ) ; // Modify image color: invert
2016-02-21 18:19:31 +03:00
void ImageColorGrayscale ( Image * image ) ; // Modify image color: grayscale
2015-10-25 02:50:15 +03:00
void ImageColorContrast ( Image * image , float contrast ) ; // Modify image color: contrast (-100 to 100)
void ImageColorBrightness ( Image * image , int brightness ) ; // Modify image color: brightness (-255 to 255)
2015-07-05 19:21:01 +03:00
void GenTextureMipmaps ( Texture2D texture ) ; // Generate GPU mipmaps for a texture
2015-11-04 20:33:46 +03:00
void UpdateTexture ( Texture2D texture , void * pixels ) ; // Update GPU texture with new data
2014-01-23 15:36:18 +04:00
2013-11-23 16:30:54 +04:00
void DrawTexture ( Texture2D texture , int posX , int posY , Color tint ) ; // Draw a Texture2D
2014-03-16 23:59:02 +04:00
void DrawTextureV ( Texture2D texture , Vector2 position , Color tint ) ; // Draw a Texture2D with position defined as Vector2
2013-11-23 16:30:54 +04:00
void DrawTextureEx ( Texture2D texture , Vector2 position , float rotation , float scale , Color tint ) ; // Draw a Texture2D with extended parameters
2013-11-28 22:59:56 +04:00
void DrawTextureRec ( Texture2D texture , Rectangle sourceRec , Vector2 position , Color tint ) ; // Draw a part of a texture defined by a rectangle
2014-01-23 15:36:18 +04:00
void DrawTexturePro ( Texture2D texture , Rectangle sourceRec , Rectangle destRec , Vector2 origin , // Draw a part of a texture defined by a rectangle with 'pro' parameters
2014-09-03 18:51:28 +04:00
float rotation , Color tint ) ;
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Font Loading and Text Drawing Functions (Module: text)
//------------------------------------------------------------------------------------
2014-09-03 19:06:10 +04:00
SpriteFont GetDefaultFont ( void ) ; // Get the default SpriteFont
2013-11-23 16:30:54 +04:00
SpriteFont LoadSpriteFont ( const char * fileName ) ; // Load a SpriteFont image into GPU memory
void UnloadSpriteFont ( SpriteFont spriteFont ) ; // Unload SpriteFont from GPU memory
2014-04-19 18:36:49 +04:00
2013-11-28 22:59:56 +04:00
void DrawText ( const char * text , int posX , int posY , int fontSize , Color color ) ; // Draw text (using default font)
2014-01-23 15:36:18 +04:00
void DrawTextEx ( SpriteFont spriteFont , const char * text , Vector2 position , // Draw text using SpriteFont and additional parameters
int fontSize , int spacing , Color tint ) ;
2013-11-28 22:59:56 +04:00
int MeasureText ( const char * text , int fontSize ) ; // Measure string width for default font
2013-11-23 16:30:54 +04:00
Vector2 MeasureTextEx ( SpriteFont spriteFont , const char * text , int fontSize , int spacing ) ; // Measure string size for SpriteFont
2015-08-30 18:45:05 +03:00
2013-11-28 22:59:56 +04:00
void DrawFPS ( int posX , int posY ) ; // Shows current FPS on top-left corner
2013-11-23 16:30:54 +04:00
const char * FormatText ( const char * text , . . . ) ; // Formatting of text with variables to 'embed'
2015-12-30 15:32:41 +03:00
const char * SubText ( const char * text , int position , int length ) ; // Get a piece of a text string
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Basic 3d Shapes Drawing Functions (Module: models)
//------------------------------------------------------------------------------------
2013-11-23 16:30:54 +04:00
void DrawCube ( Vector3 position , float width , float height , float lenght , Color color ) ; // Draw cube
void DrawCubeV ( Vector3 position , Vector3 size , Color color ) ; // Draw cube (Vector version)
void DrawCubeWires ( Vector3 position , float width , float height , float lenght , Color color ) ; // Draw cube wires
2014-04-04 22:11:57 +04:00
void DrawCubeTexture ( Texture2D texture , Vector3 position , float width , float height , float lenght , Color color ) ; // Draw cube textured
2013-11-23 16:30:54 +04:00
void DrawSphere ( Vector3 centerPos , float radius , Color color ) ; // Draw sphere
void DrawSphereEx ( Vector3 centerPos , float radius , int rings , int slices , Color color ) ; // Draw sphere with extended parameters
2014-04-04 22:11:57 +04:00
void DrawSphereWires ( Vector3 centerPos , float radius , int rings , int slices , Color color ) ; // Draw sphere wires
2013-11-23 16:30:54 +04:00
void DrawCylinder ( Vector3 position , float radiusTop , float radiusBottom , float height , int slices , Color color ) ; // Draw a cylinder/cone
void DrawCylinderWires ( Vector3 position , float radiusTop , float radiusBottom , float height , int slices , Color color ) ; // Draw a cylinder/cone wires
2015-04-06 15:02:29 +03:00
void DrawPlane ( Vector3 centerPos , Vector2 size , Color color ) ; // Draw a plane XZ
void DrawRay ( Ray ray , Color color ) ; // Draw a ray line
2013-11-23 16:30:54 +04:00
void DrawGrid ( int slices , float spacing ) ; // Draw a grid (centered at (0, 0, 0))
2014-04-04 22:11:57 +04:00
void DrawGizmo ( Vector3 position ) ; // Draw simple gizmo
2013-11-19 02:38:44 +04:00
//DrawTorus(), DrawTeapot() are useless...
//------------------------------------------------------------------------------------
// Model 3d Loading and Drawing Functions (Module: models)
//------------------------------------------------------------------------------------
2013-11-23 16:30:54 +04:00
Model LoadModel ( const char * fileName ) ; // Load a 3d model (.OBJ)
2016-03-05 18:17:54 +03:00
Model LoadModelEx ( Mesh data ) ; // Load a 3d model (from mesh data)
2014-01-23 15:36:18 +04:00
//Model LoadModelFromRES(const char *rresName, int resId); // TODO: Load a 3d model from rRES file (raylib Resource)
2016-02-11 17:51:04 +03:00
Model LoadHeightmap ( Image heightmap , Vector3 size ) ; // Load a heightmap image as a 3d model
2014-12-31 20:03:32 +03:00
Model LoadCubicmap ( Image cubicmap ) ; // Load a map image as a 3d model (cubes based)
2013-11-23 16:30:54 +04:00
void UnloadModel ( Model model ) ; // Unload 3d model from memory
2014-04-19 18:36:49 +04:00
void SetModelTexture ( Model * model , Texture2D texture ) ; // Link a texture to a model
void DrawModel ( Model model , Vector3 position , float scale , Color tint ) ; // Draw a model (with texture if set)
2016-02-02 20:41:01 +03:00
void DrawModelEx ( Model model , Vector3 position , Vector3 rotationAxis , float rotationAngle , Vector3 scale , Color tint ) ; // Draw a model with extended parameters
2014-04-19 18:36:49 +04:00
void DrawModelWires ( Model model , Vector3 position , float scale , Color color ) ; // Draw a model wires (with texture if set)
2016-03-06 04:05:16 +03:00
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
2016-03-01 22:54:02 +03:00
void DrawBoundingBox ( BoundingBox box , Color color ) ; // Draw bounding box (wires)
2014-04-19 18:36:49 +04:00
2014-03-16 23:59:02 +04:00
void DrawBillboard ( Camera camera , Texture2D texture , Vector3 center , float size , Color tint ) ; // Draw a billboard texture
2014-09-03 18:51:28 +04:00
void DrawBillboardRec ( Camera camera , Texture2D texture , Rectangle sourceRec , Vector3 center , float size , Color tint ) ; // Draw a billboard texture defined by sourceRec
2013-11-19 02:38:44 +04:00
2016-03-01 22:54:02 +03:00
BoundingBox CalculateBoundingBox ( Mesh mesh ) ; // Calculate mesh bounding box limits
2015-07-13 19:20:16 +03:00
bool CheckCollisionSpheres ( Vector3 centerA , float radiusA , Vector3 centerB , float radiusB ) ; // Detect collision between two spheres
2016-03-01 22:54:02 +03:00
bool CheckCollisionBoxes ( BoundingBox box1 , BoundingBox box2 ) ; // Detect collision between two bounding boxes
bool CheckCollisionBoxSphere ( BoundingBox box , Vector3 centerSphere , float radiusSphere ) ; // Detect collision between box and sphere
2016-01-20 21:28:47 +03:00
bool CheckCollisionRaySphere ( Ray ray , Vector3 spherePosition , float sphereRadius ) ; // Detect collision between ray and sphere
bool CheckCollisionRaySphereEx ( Ray ray , Vector3 spherePosition , float sphereRadius , Vector3 * collisionPoint ) ; // Detect collision between ray and sphere with extended parameters and collision point detection
2016-03-01 22:54:02 +03:00
bool CheckCollisionRayBox ( Ray ray , BoundingBox box ) ; // Detect collision between ray and box
2015-09-02 03:41:55 +03:00
Vector3 ResolveCollisionCubicmap ( Image cubicmap , Vector3 mapPosition , Vector3 * playerPosition , float radius ) ; // Detect collision of player radius with cubicmap
// NOTE: Return the normal vector of the impacted surface
2015-08-30 18:45:05 +03:00
//------------------------------------------------------------------------------------
// Shaders System Functions (Module: rlgl)
// NOTE: This functions are useless when using OpenGL 1.1
//------------------------------------------------------------------------------------
Shader LoadShader ( char * vsFileName , char * fsFileName ) ; // Load a custom shader and bind default locations
unsigned int LoadShaderProgram ( char * vShaderStr , char * fShaderStr ) ; // Load custom shaders strings and return program id
void UnloadShader ( Shader shader ) ; // Unload a custom shader from memory
void SetCustomShader ( Shader shader ) ; // Set custom shader to be used in batch draw
void SetDefaultShader ( void ) ; // Set default shader to be used in batch draw
void SetModelShader ( Model * model , Shader shader ) ; // Link a shader to a model
int GetShaderLocation ( Shader shader , const char * uniformName ) ; // Get shader uniform location
void SetShaderValue ( Shader shader , int uniformLoc , float * value , int size ) ; // Set shader uniform value (float)
void SetShaderValuei ( Shader shader , int uniformLoc , int * value , int size ) ; // Set shader uniform value (int)
2016-02-12 21:02:23 +03:00
void SetShaderValueMatrix ( Shader shader , int uniformLoc , Matrix mat ) ; // Set shader uniform value (matrix 4x4)
2016-03-06 04:05:16 +03:00
//void SetShaderMapDiffuse(Shader *shader, Texture2D texture); // Default diffuse shader map texture assignment
//void SetShaderMapNormal(Shader *shader, const char *uniformName, Texture2D texture); // Normal map texture shader assignment
//void SetShaderMapSpecular(Shader *shader, const char *uniformName, Texture2D texture); // Specular map texture shader assignment
//void SetShaderMap(Shader *shader, int mapLocation, Texture2D texture, int textureUnit); // TODO: Generic shader map assignment
2015-08-30 18:45:05 +03:00
void SetBlendMode ( int mode ) ; // Set blending mode (alpha, additive, multiplied)
2015-12-21 23:12:35 +03:00
//----------------------------------------------------------------------------------
2016-03-05 19:05:02 +03:00
// Physics System Functions (Module: physac)
2015-12-21 23:12:35 +03:00
//----------------------------------------------------------------------------------
2016-03-16 14:48:30 +03:00
void InitPhysics ( Vector2 gravity ) ; // Initializes pointers array (just pointers, fixed size)
2016-03-05 19:05:02 +03:00
void UpdatePhysics ( ) ; // Update physic objects, calculating physic behaviours and collisions detection
void ClosePhysics ( ) ; // Unitialize all physic objects and empty the objects pool
2015-12-21 23:12:35 +03:00
2016-03-05 19:05:02 +03:00
PhysicObject * CreatePhysicObject ( Vector2 position , float rotation , Vector2 scale ) ; // Create a new physic object dinamically, initialize it and add to pool
void DestroyPhysicObject ( PhysicObject * pObj ) ; // Destroy a specific physic object and take it out of the list
2015-12-21 23:12:35 +03:00
2016-03-16 14:48:30 +03:00
void ApplyForce ( PhysicObject * pObj , Vector2 force ) ; // Apply directional force to a physic object
void ApplyForceAtPosition ( Vector2 position , float force , float radius ) ; // Apply radial force to all physic objects in range
2016-03-05 19:05:02 +03:00
Rectangle TransformToRectangle ( Transform transform ) ; // Convert Transform data type to Rectangle (position and scale)
void DrawPhysicObjectInfo ( PhysicObject * pObj , Vector2 position , int fontSize ) ; // Draw physic object information at screen position
2015-12-21 23:12:35 +03:00
2013-11-19 02:38:44 +04:00
//------------------------------------------------------------------------------------
// Audio Loading and Playing Functions (Module: audio)
//------------------------------------------------------------------------------------
2014-09-03 19:06:10 +04:00
void InitAudioDevice ( void ) ; // Initialize audio device and context
void CloseAudioDevice ( void ) ; // Close the audio device and context (and music stream)
2016-04-30 09:00:12 +03:00
bool AudioDeviceReady ( void ) ; // True if call to InitAudioDevice() was successful and CloseAudioDevice() has not been called yet
// Audio contexts are for outputing custom audio waveforms, This will shut down any other sound sources currently playing
// The mix_t is what mix channel you want to operate on, mixA->mixD are the ones available. Each mix channel can only be used one at a time.
// exmple usage is InitAudioContext(48000, 16, mixA, stereo);
AudioContext * InitAudioContext ( unsigned short sampleRate , unsigned char bitsPerSample , mix_t mixChannel , channel_t channels ) ;
void CloseAudioContext ( AudioContext * ctx ) ; // Frees audio context
2014-04-19 18:36:49 +04:00
2013-11-23 16:30:54 +04:00
Sound LoadSound ( char * fileName ) ; // Load sound to memory
2014-12-31 20:03:32 +03:00
Sound LoadSoundFromWave ( Wave wave ) ; // Load sound to memory from wave data
2014-01-23 15:36:18 +04:00
Sound LoadSoundFromRES ( const char * rresName , int resId ) ; // Load sound to memory from rRES file (raylib Resource)
2013-11-23 16:30:54 +04:00
void UnloadSound ( Sound sound ) ; // Unload sound
void PlaySound ( Sound sound ) ; // Play a sound
void PauseSound ( Sound sound ) ; // Pause a sound
void StopSound ( Sound sound ) ; // Stop playing a sound
2014-04-09 22:25:26 +04:00
bool SoundIsPlaying ( Sound sound ) ; // Check if a sound is currently playing
2014-04-19 18:36:49 +04:00
void SetSoundVolume ( Sound sound , float volume ) ; // Set volume for a sound (1.0 is max level)
void SetSoundPitch ( Sound sound , float pitch ) ; // Set pitch for a sound (1.0 is base level)
void PlayMusicStream ( char * fileName ) ; // Start music playing (open stream)
2015-07-29 22:45:28 +03:00
void UpdateMusicStream ( void ) ; // Updates buffers for music streaming
2014-09-03 19:06:10 +04:00
void StopMusicStream ( void ) ; // Stop music playing (close stream)
void PauseMusicStream ( void ) ; // Pause music playing
2014-09-17 00:51:31 +04:00
void ResumeMusicStream ( void ) ; // Resume playing paused music
2014-09-03 19:06:10 +04:00
bool MusicIsPlaying ( void ) ; // Check if music is playing
2014-04-19 18:36:49 +04:00
void SetMusicVolume ( float volume ) ; // Set volume for music (1.0 is max level)
2014-09-03 19:06:10 +04:00
float GetMusicTimeLength ( void ) ; // Get current music time length (in seconds)
float GetMusicTimePlayed ( void ) ; // Get current music time played (in seconds)
2013-11-23 16:30:54 +04:00
2013-11-19 02:38:44 +04:00
# ifdef __cplusplus
}
# endif
2013-11-19 03:09:52 +04:00
# endif // RAYLIB_H