kota's memex

core

Window-related functions

// Initialize window and OpenGL context
void InitWindow(int width, int height, const char *title);

// Check if KEY_ESCAPE pressed or Close icon pressed
bool WindowShouldClose(void);

// Close window and unload OpenGL context
void CloseWindow(void);

// Check if window has been initialized successfully
bool IsWindowReady(void);

// Check if window is currently fullscreen
bool IsWindowFullscreen(void);

// Check if window is currently hidden (only PLATFORM_DESKTOP)
bool IsWindowHidden(void);

// Check if window is currently minimized (only PLATFORM_DESKTOP)
bool IsWindowMinimized(void);

// Check if window is currently maximized (only PLATFORM_DESKTOP)
bool IsWindowMaximized(void);

// Check if window is currently focused (only PLATFORM_DESKTOP)
bool IsWindowFocused(void);

// Check if window has been resized last frame
bool IsWindowResized(void);

// Check if one specific window flag is enabled
bool IsWindowState(unsigned int flag);

// Set window configuration state using flags (only PLATFORM_DESKTOP)
void SetWindowState(unsigned int flags);

// Clear window configuration state flags
void ClearWindowState(unsigned int flags);

// Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
void ToggleFullscreen(void);

// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void);

// Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
void MinimizeWindow(void);

// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void);

// Set icon for window (only PLATFORM_DESKTOP)
void SetWindowIcon(Image image);

// Set title for window (only PLATFORM_DESKTOP)
void SetWindowTitle(const char *title);

// Set window position on screen (only PLATFORM_DESKTOP)
void SetWindowPosition(int x, int y);

// Set monitor for the current window (fullscreen mode)
void SetWindowMonitor(int monitor);

// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
void SetWindowMinSize(int width, int height);

// Set window dimensions
void SetWindowSize(int width, int height);

// Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
void SetWindowOpacity(float opacity);

// Get native window handle
void *GetWindowHandle(void);

// Get current screen width
int GetScreenWidth(void);

// Get current screen height
int GetScreenHeight(void);

// Get current render width (it considers HiDPI)
int GetRenderWidth(void);

// Get current render height (it considers HiDPI)
int GetRenderHeight(void);

// Get number of connected monitors
int GetMonitorCount(void);

// Get current connected monitor
int GetCurrentMonitor(void);

// Get specified monitor position
Vector2 GetMonitorPosition(int monitor);

// Get specified monitor width (current video mode used by monitor)
int GetMonitorWidth(int monitor);

// Get specified monitor height (current video mode used by monitor)
int GetMonitorHeight(int monitor);

// Get specified monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor);

// Get specified monitor physical height in millimetres
int GetMonitorPhysicalHeight(int monitor);

// Get specified monitor refresh rate
int GetMonitorRefreshRate(int monitor);

// Get window position XY on monitor
Vector2 GetWindowPosition(void);

// Get window scale DPI factor
Vector2 GetWindowScaleDPI(void);

// Get the human-readable, UTF-8 encoded name of the primary monitor
const char *GetMonitorName(int monitor);

// Set clipboard text content
void SetClipboardText(const char *text);

// Get clipboard text content
const char *GetClipboardText(void);

// Enable waiting for events on EndDrawing(), no automatic event polling
void EnableEventWaiting(void);

// Disable waiting for events on EndDrawing(), automatic events polling
void DisableEventWaiting(void);

Custom frame control functions

NOTE: Those functions are intended for advance users that want full control over the frame processing. By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents(). To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL.

// Swap back buffer with front buffer (screen drawing)
void SwapScreenBuffer(void);

// Register all input events
void PollInputEvents(void);

// Wait for some time (halt program execution)
void WaitTime(double seconds);

Cursor-related functions

// Shows cursor
void ShowCursor(void);

// Hides cursor
void HideCursor(void);

// Check if cursor is not visible
bool IsCursorHidden(void);

// Enables cursor (unlock cursor)
void EnableCursor(void);

// Disables cursor (lock cursor)
void DisableCursor(void);

// Check if cursor is on the screen
bool IsCursorOnScreen(void);

Drawing-related functions

// Set background color (framebuffer clear color)
void ClearBackground(Color color);

// Setup canvas (framebuffer) to start drawing
void BeginDrawing(void);

// End canvas drawing and swap buffers (double buffering)
void EndDrawing(void);

// Begin 2D mode with custom camera (2D)
void BeginMode2D(Camera2D camera);

// Ends 2D mode with custom camera
void EndMode2D(void);

// Begin 3D mode with custom camera (3D)
void BeginMode3D(Camera3D camera);

// Ends 3D mode and returns to default 2D orthographic mode
void EndMode3D(void);

// Begin drawing to render texture
void BeginTextureMode(RenderTexture2D target);

// Ends drawing to render texture
void EndTextureMode(void);

// Begin custom shader drawing
void BeginShaderMode(Shader shader);

// End custom shader drawing (use default shader)
void EndShaderMode(void);

// Begin blending mode (alpha, additive, multiplied, subtract, custom)
void BeginBlendMode(int mode);

// End blending mode (reset to default: alpha blending)
void EndBlendMode(void);

// Begin scissor mode (define screen area for following drawing)
void BeginScissorMode(int x, int y, int width, int height);

// End scissor mode
void EndScissorMode(void);

// Begin stereo rendering (requires VR simulator)
void BeginVrStereoMode(VrStereoConfig config);

// End stereo rendering (requires VR simulator)
void EndVrStereoMode(void);

// Load VR stereo config for VR simulator device parameters
VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device);

// Unload VR stereo config
void UnloadVrStereoConfig(VrStereoConfig config);

Shader management functions

NOTE: Shader functionality is not available on OpenGL 1.1

// Load shader from files and bind default locations
Shader LoadShader(const char *vsFileName, const char *fsFileName);

// Load shader from code strings and bind default locations
Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode);

// Get shader uniform location
int GetShaderLocation(Shader shader, const char *uniformName);

// Get shader attribute location
int GetShaderLocationAttrib(Shader shader, const char *attribName);

// Set shader uniform value
void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType);

// Set shader uniform value vector
void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count);

// Set shader uniform value (matrix 4x4)
void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat);

// Set shader uniform value for texture (sampler2d)
void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture);

// Unload shader from GPU memory (VRAM)
void UnloadShader(Shader shader);

Screen-space-related functions

// Get a ray trace from mouse position
Ray GetMouseRay(Vector2 mousePosition, Camera camera);

// Get camera transform matrix (view matrix)
Matrix GetCameraMatrix(Camera camera);

// Get camera 2d transform matrix
Matrix GetCameraMatrix2D(Camera2D camera);

// Get the screen space position for a 3d world space position
Vector2 GetWorldToScreen(Vector3 position, Camera camera);

// Get the world space position for a 2d camera screen space position
Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera);

// Get size position for a 3d world space position
Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height);

// Get the screen space position for a 2d camera world space position
Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera);

Timing-related functions

// Set target FPS (maximum)
void SetTargetFPS(int fps);

// Get current FPS
int GetFPS(void);

// Get time in seconds for last frame drawn (delta time)
float GetFrameTime(void);

// Get elapsed time in seconds since InitWindow()
double GetTime(void);

Misc. functions

// Get a random value between min and max (both included)
int GetRandomValue(int min, int max);

// Set the seed for the random number generator
void SetRandomSeed(unsigned int seed);

// Takes a screenshot of current screen (filename extension defines format)
void TakeScreenshot(const char *fileName);

// Setup init configuration flags (view FLAGS)
void SetConfigFlags(unsigned int flags);

// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
void TraceLog(int logLevel, const char *text, ...);

// Set the current threshold (minimum) log level
void SetTraceLogLevel(int logLevel);

// Internal memory allocator
void *MemAlloc(int size);

// Internal memory reallocator
void *MemRealloc(void *ptr, int size);

// Internal memory free
void MemFree(void *ptr);

// Open URL with default system browser (if available)
void OpenURL(const char *url);

Set custom callbacks

WARNING: Callbacks setup is intended for advance users

// Set custom trace log
void SetTraceLogCallback(TraceLogCallback callback);

// Set custom file binary data loader
void SetLoadFileDataCallback(LoadFileDataCallback callback);

// Set custom file binary data saver
void SetSaveFileDataCallback(SaveFileDataCallback callback);

// Set custom file text data loader
void SetLoadFileTextCallback(LoadFileTextCallback callback);

// Set custom file text data saver
void SetSaveFileTextCallback(SaveFileTextCallback callback);

Files management functions

// Load file data as byte array (read)
unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead);

// Unload file data allocated by LoadFileData()
void UnloadFileData(unsigned char *data);

// Save data to file from byte array (write), returns true on success
bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite);

// Export data to code (.h), returns true on success
bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName);

// Load text data from file (read), returns a '\0' terminated string
char *LoadFileText(const char *fileName);

// Unload file text data allocated by LoadFileText()
void UnloadFileText(char *text);

// Save text data to file (write), string must be '\0' terminated, returns true on success
bool SaveFileText(const char *fileName, char *text);

// Check if file exists
bool FileExists(const char *fileName);

// Check if a directory path exists
bool DirectoryExists(const char *dirPath);

// Check file extension (including point: .png, .wav)
bool IsFileExtension(const char *fileName, const char *ext);

// Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
int GetFileLength(const char *fileName);

// Get pointer to extension for a filename string (includes dot: '.png')
const char *GetFileExtension(const char *fileName);

// Get pointer to filename for a path string
const char *GetFileName(const char *filePath);

// Get filename string without extension (uses static string)
const char *GetFileNameWithoutExt(const char *filePath);

// Get full path for a given fileName with path (uses static string)
const char *GetDirectoryPath(const char *filePath);

// Get previous directory path for a given path (uses static string)
const char *GetPrevDirectoryPath(const char *dirPath);

// Get current working directory (uses static string)
const char *GetWorkingDirectory(void);

// Get the directory if the running application (uses static string)
const char *GetApplicationDirectory(void);

// Change working directory, return true on success
bool ChangeDirectory(const char *dir);

// Check if a given path is a file or a directory
bool IsPathFile(const char *path);

// Load directory filepaths
FilePathList LoadDirectoryFiles(const char *dirPath);

// Load directory filepaths with extension filtering and recursive directory scan
FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);

// Unload filepaths
void UnloadDirectoryFiles(FilePathList files);

// Check if a file has been dropped into window
bool IsFileDropped(void);

// Load dropped filepaths
FilePathList LoadDroppedFiles(void);

// Unload dropped filepaths
void UnloadDroppedFiles(FilePathList files);

// Get file modification time (last write time)
long GetFileModTime(const char *fileName);

Compression/Encoding functionality

// Compress data (DEFLATE algorithm), memory must be MemFree()
unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize);

// Decompress data (DEFLATE algorithm), memory must be MemFree()
unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize);

// Encode data to Base64 string, memory must be MemFree()
char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize);

// Decode Base64 string data, memory must be MemFree()
unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize);

Input-related functions: keyboard

// Check if a key has been pressed once
bool IsKeyPressed(int key);

// Check if a key is being pressed
bool IsKeyDown(int key);

// Check if a key has been released once
bool IsKeyReleased(int key);

// Check if a key is NOT being pressed
bool IsKeyUp(int key);

// Set a custom key to exit program (default is ESC)
void SetExitKey(int key);

// Get key pressed (keycode), call it multiple times for keys queued, returns 0
// when the queue is empty
int GetKeyPressed(void);

// Get char pressed (unicode), call it multiple times for chars queued, returns
// 0 when the queue is empty
int GetCharPressed(void);

Input-related functions: gamepads

// Check if a gamepad is available
bool IsGamepadAvailable(int gamepad);

// Get gamepad internal name id
const char *GetGamepadName(int gamepad);

// Check if a gamepad button has been pressed once
bool IsGamepadButtonPressed(int gamepad, int button);

// Check if a gamepad button is being pressed
bool IsGamepadButtonDown(int gamepad, int button);

// Check if a gamepad button has been released once
bool IsGamepadButtonReleased(int gamepad, int button);

// Check if a gamepad button is NOT being pressed
bool IsGamepadButtonUp(int gamepad, int button);

// Get the last gamepad button pressed
int GetGamepadButtonPressed(void);

// Get gamepad axis count for a gamepad
int GetGamepadAxisCount(int gamepad);

// Get axis movement value for a gamepad axis
float GetGamepadAxisMovement(int gamepad, int axis);

// Set internal gamepad mappings (SDL_GameControllerDB)
int SetGamepadMappings(const char *mappings);

Input-related functions: mouse

// Check if a mouse button has been pressed once
bool IsMouseButtonPressed(int button);

// Check if a mouse button is being pressed
bool IsMouseButtonDown(int button);

// Check if a mouse button has been released once
bool IsMouseButtonReleased(int button);

// Check if a mouse button is NOT being pressed
bool IsMouseButtonUp(int button);

// Get mouse position X
int GetMouseX(void);

// Get mouse position Y
int GetMouseY(void);

// Get mouse position XY
Vector2 GetMousePosition(void);

// Get mouse delta between frames
Vector2 GetMouseDelta(void);

// Set mouse position XY
void SetMousePosition(int x, int y);

// Set mouse offset
void SetMouseOffset(int offsetX, int offsetY);

// Set mouse scaling
void SetMouseScale(float scaleX, float scaleY);

// Get mouse wheel movement for X or Y, whichever is larger
float GetMouseWheelMove(void);

// Get mouse wheel movement for both X and Y
Vector2 GetMouseWheelMoveV(void);

// Set mouse cursor
void SetMouseCursor(int cursor);

Input-related functions: touch

// Get touch position X for touch point 0 (relative to screen size)
int GetTouchX(void);

// Get touch position Y for touch point 0 (relative to screen size)
int GetTouchY(void);

// Get touch position XY for a touch point index (relative to screen size)
Vector2 GetTouchPosition(int index);

// Get touch point identifier for given index
int GetTouchPointId(int index);

// Get number of touch points
int GetTouchPointCount(void);

//------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: rgestures)
//------------------------------------------------------------------------------------
void SetGesturesEnabled(unsigned int flags);                // 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
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: rcamera)
//------------------------------------------------------------------------------------
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 keyPan);                       // Set camera pan key to combine with mouse movement (free camera)
void SetCameraAltControl(int keyAlt);                       // Set camera alt key to combine with mouse movement (free camera)
void SetCameraSmoothZoomControl(int keySmoothZoom);         // Set camera smooth zoom key to combine with mouse (free camera)
void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown); // Set camera move controls (1st person and 3rd person cameras)