A Simple and Easy-To-Use Library To Enjoy Videogames Programming
A Simple and Easy-To-Use Library To Enjoy Videogames Programming
module: core
// Window-related functions
void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
void CloseWindow(void); // Close window and unload OpenGL context
bool IsWindowReady(void); // Check if window has been initialized successfully
bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
bool IsWindowResized(void); // Check if window has been resized
bool IsWindowHidden(void); // Check if window is currently hidden
bool IsWindowFullscreen(void); // Check if window is currently fullscreen
void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
void UnhideWindow(void); // Show the window
void HideWindow(void); // Hide the window
void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
void SetWindowSize(int width, int height); // Set window dimensions
void *GetWindowHandle(void); // Get native window handle
int GetScreenWidth(void); // Get current screen width
int GetScreenHeight(void); // Get current screen height
int GetMonitorCount(void); // Get number of connected monitors
int GetMonitorWidth(int monitor); // Get primary monitor width
int GetMonitorHeight(int monitor); // Get primary monitor height
int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres
Vector2 GetWindowPosition(void); // Get window position XY on monitor
const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
const char *GetClipboardText(void); // Get clipboard text content
void SetClipboardText(const char *text); // Set clipboard text content
// Cursor-related functions
void ShowCursor(void); // Shows cursor
void HideCursor(void); // Hides cursor
bool IsCursorHidden(void); // Check if cursor is not visible
void EnableCursor(void); // Enables cursor (unlock cursor)
void DisableCursor(void); // Disables cursor (lock cursor)
// Drawing-related functions
void ClearBackground(Color color); // Set background color (framebuffer clear color)
void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D)
void EndMode2D(void); // Ends 2D mode with custom camera
void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D)
void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode
void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
void EndTextureMode(void); // Ends drawing to render texture
void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)
void EndScissorMode(void); // End scissor mode
// Screen-space-related functions
Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix
Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
Vector2 GetWorldToScreenEx(Vector3 position, Camera camera,int width, int height); // Returns size position for a 3d world space position
Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position
Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position
// Timing-related functions
void SetTargetFPS(int fps); // Set target FPS (maximum)
int GetFPS(void); // Returns current FPS
float GetFrameTime(void); // Returns time in seconds for last frame drawn
double GetTime(void); // Returns elapsed time in seconds since InitWindow()
// Color-related functions
int ColorToInt(Color color); // Returns hexadecimal value for a Color
Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1]
Color ColorFromNormalized(Vector4 normalized); // Returns color from normalized values [0..1]
Vector3 ColorToHSV(Color color); // Returns HSV values for a Color
Color ColorFromHSV(Vector3 hsv); // Returns a Color from HSV values
Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
// Misc. functions
void SetConfigFlags(unsigned int flags); // Setup window configuration flags (view FLAGS)
void SetTraceLogLevel(int logType); // Set the current threshold (minimum) log level
void SetTraceLogExit(int logType); // Set the exit threshold (minimum) log level
void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging
void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)
void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorythm)
unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorythm)
void OpenURL(const char *url); // Open URL with default system browser (if available)
//------------------------------------------------------------------------------------
// Input Handling Functions
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: gestures)
//------------------------------------------------------------------------------------
void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
bool IsGestureDetected(int gesture); // Check if a gesture have been detected
int GetGestureDetected(void); // Get latest detected gesture
int GetTouchPointsCount(void); // Get touch points count
float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
Vector2 GetGestureDragVector(void); // Get gesture drag vector
float GetGestureDragAngle(void); // Get gesture drag angle
Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
float GetGesturePinchAngle(void); // Get gesture pinch angle
//------------------------------------------------------------------------------------
// Camera System Functions (Module: camera)
//------------------------------------------------------------------------------------
void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
void UpdateCamera(Camera *camera); // Update camera position for selected mode
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)
void SetCameraMoveControls(int frontKey, int backKey,
int rightKey, int leftKey,
int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
module: shapes
module: textures
module: text
// Text strings management functions (no utf8 strings, only byte chars)
// NOTE: Some strings allocate memory internally for returned strings, just be careful!
int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied
bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal
unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style)
const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string
char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (memory must be freed!)
char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (memory must be freed!)
const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter
const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings
void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor!
int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string
const char *TextToUpper(const char *text); // Get upper case version of provided string
const char *TextToLower(const char *text); // Get lower case version of provided string
const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string
int TextToInteger(const char *text); // Get integer value from text (negative values not supported)
char *TextToUtf8(int *codepoints, int length); // Encode text codepoint into utf8 text (memory must be freed!)
// VR control functions
void InitVrSimulator(void); // Init VR simulator for selected device parameters
void CloseVrSimulator(void); // Close VR simulator for current device
void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters
bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
void ToggleVrMode(void); // Enable/Disable VR experience
void BeginVrDrawing(void); // Begin VR simulator stereo rendering
void EndVrDrawing(void); // End VR simulator stereo rendering
module: audio
structs colors
struct Vector2; // Vector2 type // Custom raylib color palette for amazing visuals
struct Vector3; // Vector3 type #define LIGHTGRAY (Color){ 200, 200, 200, 255 } // Light Gray
struct Vector4; // Vector4 type #define GRAY (Color){ 130, 130, 130, 255 } // Gray
struct Quaternion; // Quaternion type #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
struct Matrix; // Matrix type (OpenGL style 4x4) #define YELLOW (Color){ 253, 249, 0, 255 } // Yellow
struct Color; // Color type, RGBA (32bit) #define GOLD (Color){ 255, 203, 0, 255 } // Gold
struct Rectangle; // Rectangle type #define ORANGE (Color){ 255, 161, 0, 255 } // Orange
#define PINK (Color){ 255, 109, 194, 255 } // Pink
struct Image; // Image type (multiple pixel formats supported) #define RED (Color){ 230, 41, 55, 255 } // Red
// NOTE: Data stored in CPU memory (RAM) #define MAROON (Color){ 190, 33, 55, 255 } // Maroon
struct Texture; // Texture type (multiple internal formats supported) #define GREEN (Color){ 0, 228, 48, 255 } // Green
// NOTE: Data stored in GPU memory (VRAM) #define LIME (Color){ 0, 158, 47, 255 } // Lime
struct RenderTexture; // RenderTexture type, for texture rendering #define DARKGREEN (Color){ 0, 117, 44, 255 } // Dark Green
struct NPatchInfo; // N-Patch layout info #define SKYBLUE (Color){ 102, 191, 255, 255 } // Sky Blue
struct CharInfo; // Font character info #define BLUE (Color){ 0, 121, 241, 255 } // Blue
struct Font; // Font type, includes texture and chars data #define DARKBLUE (Color){ 0, 82, 172, 255 } // Dark Blue
#define PURPLE (Color){ 200, 122, 255, 255 } // Purple
struct Camera; // Camera type, defines 3d camera position/orientation #define VIOLET (Color){ 135, 60, 190, 255 } // Violet
struct Camera2D; // Camera2D type, defines a 2d camera #define DARKPURPLE (Color){ 112, 31, 126, 255 } // Dark Purple
struct Mesh; // Vertex data definning a mesh #define BEIGE (Color){ 211, 176, 131, 255 } // Beige
struct Shader; // Shader type (generic shader) #define BROWN (Color){ 127, 106, 79, 255 } // Brown
struct MaterialMap; // Material texture map #define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown
struct Material; // Material type
struct Model; // Basic 3d Model type #define WHITE (Color){ 255, 255, 255, 255 } // White
struct Transform; // Transformation (used for bones) #define BLACK (Color){ 0, 0, 0, 255 } // Black
struct BoneInfo; // Bone information #define BLANK (Color){ 0, 0, 0, 0 } // Transparent
struct ModelAnimation; // Model animation data (bones and frames) #define MAGENTA (Color){ 255, 0, 255, 255 } // Magenta
struct Ray; // Ray type (useful for raycast) #define RAYWHITE (Color){ 245, 245, 245, 255 } // Ray White
struct RayHitInfo; // Raycast hit information
struct BoundingBox; // Bounding box type for 3d mesh
raylib quick reference card - Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)