From e056446750bff6db15842aea662f18a322052d8c Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 9 Nov 2023 21:24:58 +0200 Subject: Organized core functions. --- API.md | 740 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 370 insertions(+), 370 deletions(-) (limited to 'API.md') diff --git a/API.md b/API.md index 7c5ba1b..e6dceb8 100644 --- a/API.md +++ b/API.md @@ -3508,7 +3508,7 @@ GLFW event cursor enter/leave --- -## Core - Window +## Core - Window-related functions --- @@ -3746,159 +3746,117 @@ Get clipboard text content --- -## Core - Timing +## Core - Cursor-related functions --- -> RL.SetTargetFPS( int fps ) - -Set target FPS (maximum) - ---- - -> FPS = RL.GetFPS() - -Get current FPS - -- Success return int - ---- - -> delta = RL.GetFrameTime() - -Get time in seconds for last frame drawn (Delta time) +> RL.ShowCursor() -- Success return float +Shows cursor --- -> time = RL.GetTime() - -Get elapsed time in seconds since InitWindow() +> RL.HideCursor() -- Success return float +Hides cursor --- -## Core - Misc - ---- +> hidden = RL.IsCursorHidden() -> RL.TakeScreenshot( string fileName ) +Check if cursor is not visible -Takes a screenshot of current screen (filename extension defines format) +- Success return bool --- -> RL.SetConfigFlags( int flags ) +> RL.EnableCursor() -Setup init configuration flags (view FLAGS) +Enables cursor (unlock cursor) --- -> RL.TraceLog( int logLevel, string text ) +> RL.DisableCursor() -Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +Disables cursor (lock cursor) --- -> RL.SetTraceLogLevel( int logLevel ) - -Set the current threshold (minimum) log level - ---- +> onSreen = RL.IsCursorOnScreen() -> RL.SetLogLevelInvalid( int logLevel ) +Check if cursor is on the screen -Set the log level for bad function calls and invalid data formats. +- Success return bool --- -> logLevel = RL.GetLogLevelInvalid() - -Get the log level for bad function calls and invalid data formats. - -- Success return int +## Core - Drawing-related functions --- -> RL.OpenURL( string url ) +> RL.ClearBackground( Color color ) -Open URL with default system browser (If available) +Set background color (framebuffer clear color) --- -> enabled = RL.IsGCUnloadEnabled() - -Check if Lua garbage collection is set to unload object data - -- Success return bool - ---- +> RL.BeginDrawing() -## Core - Cursor +Setup canvas (framebuffer) to start drawing --- -> RL.ShowCursor() +> RL.EndDrawing() -Shows cursor +End canvas drawing and swap buffers (double buffering) --- -> RL.HideCursor() +> RL.BeginMode2D( camera2D camera ) -Hides cursor +Begin 2D mode with custom camera (2D) --- -> hidden = RL.IsCursorHidden() - -Check if cursor is not visible +> RL.EndMode2D() -- Success return bool +Ends 2D mode with custom camera --- -> RL.EnableCursor() +> RL.BeginMode3D( camera3D camera ) -Enables cursor (unlock cursor) +Begin 3D mode with custom camera (3D) --- -> RL.DisableCursor() +> RL.EndMode3D() -Disables cursor (lock cursor) +Ends 3D mode and returns to default 2D orthographic mode --- -> onSreen = RL.IsCursorOnScreen() - -Check if cursor is on the screen - -- Success return bool - ---- +> RL.BeginTextureMode( RenderTexture target ) -## Core - Drawing +Begin drawing to render texture --- -> RL.ClearBackground( Color color ) +> RL.EndTextureMode() -Set background color (framebuffer clear color) +Ends drawing to render texture --- -> RL.BeginDrawing() +> RL.BeginShaderMode( Shader shader ) -Setup canvas (framebuffer) to start drawing +Begin custom shader drawing --- -> RL.EndDrawing() +> RL.EndShaderMode() -End canvas drawing and swap buffers (double buffering) +End custom shader drawing (use default shader) --- @@ -3926,7 +3884,7 @@ End scissor mode --- -## Core - Shader +## Core - Shader management functions --- @@ -3958,18 +3916,6 @@ Check if a shader is ready --- -> RL.BeginShaderMode( Shader shader ) - -Begin custom shader drawing - ---- - -> RL.EndShaderMode() - -End custom shader drawing (use default shader) - ---- - > location = RL.GetShaderLocation( Shader shader, string uniformName ) Get shader uniform location @@ -4032,515 +3978,665 @@ Unload shader from GPU memory (VRAM) --- -## Core - Input-related Keyboard +## Core - Screen-space-related functions --- -> pressed = RL.IsKeyPressed( int key ) +> ray = RL.GetMouseRay( Vector2 mousePosition, Camera3D camera ) -Detect if a key has been pressed once +Get a ray trace from mouse position -- Success return bool +- Success return Ray --- -> pressed = RL.IsKeyDown( int key ) +> matrix = RL.GetCameraMatrix( Camera3D camera ) -Detect if a key is being pressed +Get camera transform matrix (view matrix) -- Success return bool +- Success return Matrix --- -> released = RL.IsKeyReleased( int key ) +> matrix = RL.GetCameraMatrix2D( Camera2D camera ) -Detect if a key has been released once +Get camera 2d transform matrix -- Success return bool +- Success return Matrix --- -> released = RL.IsKeyUp( int key ) +> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera ) -Check if a key is NOT being pressed +Get the screen space position for a 3d world space position -- Success return bool +- Success return Vector2 --- -> keycode = RL.GetKeyPressed() +> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size ) -Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty +Get size position for a 3d world space position -- Success return int +- Success return Vector2 --- -> unicode = RL.GetCharPressed() +> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera ) -Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty +Get the screen space position for a 2d camera world space position + +- Success return Vector2 + +--- + +> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera ) + +Get the world space position for a 2d camera screen space position + +- Success return Vector2 + +--- + +## Core - Timing-related functions + +--- + +> RL.SetTargetFPS( int fps ) + +Set target FPS (maximum) + +--- + +> FPS = RL.GetFPS() + +Get current FPS - Success return int --- -> RL.SetExitKey( int key ) +> delta = RL.GetFrameTime() -Set a custom key to exit program (default is ESC) +Get time in seconds for last frame drawn (Delta time) + +- Success return float --- -> keyName = RL.GetKeyName( int key, int scancode ) +> time = RL.GetTime() -This function returns the name of the specified printable key, encoded as UTF-8. -This is typically the character that key would produce without any modifier keys, -intended for displaying key bindings to the user. For dead keys, it is typically -the diacritic it would add to a character. +Get elapsed time in seconds since InitWindow() -Do not use this function for text input. You will break text input for many -languages even if it happens to work for yours. +- Success return float -If the key is KEY_UNKNOWN, the scancode is used to identify the key, -otherwise the scancode is ignored. If you specify a non-printable key, -or KEY_UNKNOWN and a scancode that maps to a non-printable key, -this function returns nil but does not emit an error. +--- -- Success return string or nil +## Core - Misc --- -> scancode = RL.GetKeyScancode( int key ) +> RL.TakeScreenshot( string fileName ) -This function returns the platform-specific scancode of the specified key. -If the key is KEY_UNKNOWN or does not exist on the keyboard this method will return -1. +Takes a screenshot of current screen (filename extension defines format) + +--- + +> RL.SetConfigFlags( int flags ) + +Setup init configuration flags (view FLAGS) + +--- + +> RL.TraceLog( int logLevel, string text ) + +Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) + +--- + +> RL.SetTraceLogLevel( int logLevel ) + +Set the current threshold (minimum) log level + +--- + +> RL.SetLogLevelInvalid( int logLevel ) + +Set the log level for bad function calls and invalid data formats. + +--- + +> logLevel = RL.GetLogLevelInvalid() + +Get the log level for bad function calls and invalid data formats. - Success return int --- -## Core - Input-related Gamepad +> RL.OpenURL( string url ) + +Open URL with default system browser (If available) --- -> available = RL.IsGamepadAvailable( int gamepad ) +> enabled = RL.IsGCUnloadEnabled() -Detect if a gamepad is available +Check if Lua garbage collection is set to unload object data - Success return bool --- -> pressed = RL.IsGamepadButtonPressed( int gamepad, int button ) +## Core - Files management functions -Detect if a gamepad button has been pressed once +--- + +> path = RL.GetBasePath() + +Return game directory (where main.lua is located) + +- Success return string + +--- + +> fileExists = RL.FileExists( string fileName ) + +Check if file exists - Success return bool --- -> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) +> dirExists = RL.DirectoryExists( string dirPath ) -Detect if a gamepad button is being pressed +Check if a directory path exists - Success return bool --- -> released = RL.IsGamepadButtonReleased( int gamepad, int button ) +> hasFileExtension = RL.IsFileExtension( string fileName, string ext ) -Detect if a gamepad button has been released once +Check file extension (Including point: .png, .wav) - Success return bool --- -> count = RL.GetGamepadAxisCount( int gamepad ) +> length = RL.GetFileLength( string fileName ) -Return gamepad axis count for a gamepad +Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) - Success return int --- -> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) +> extension = RL.GetFileExtension( string fileName ) -Return axis movement value for a gamepad axis +Get pointer to extension for a filename string (Includes dot: '.png') -- Success return float +- Success return string --- -> name = RL.GetGamepadName( int gamepad ) +> fileName = RL.GetFileName( string filePath ) -Return gamepad internal name id +Get pointer to filename for a path string - Success return string --- -## Core - Input-related Mouse +> fileName = RL.GetFileNameWithoutExt( string filePath ) + +Get filename string without extension (Uses static string) + +- Success return string --- -> pressed = RL.IsMouseButtonPressed( int button ) +> filePath = RL.GetDirectoryPath( string filePath ) -Detect if a mouse button has been pressed once +Get full path for a given fileName with path (Uses static string) -- Success return bool +- Success return string --- -> pressed = RL.IsMouseButtonDown( int button ) +> directory = RL.GetPrevDirectoryPath( string dirPath ) -Detect if a mouse button is being pressed +Get previous directory path for a given path (Uses static string) + +- Success return string + +--- + +> directory = RL.GetWorkingDirectory() + +Get current working directory (Uses static string) + +- Success return string + +--- + +> fileNames = RL.LoadDirectoryFiles( string dirPath ) + +Load directory filepaths + +- Success return string{} + +--- + +> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs ) + +Load directory filepaths with extension filtering and recursive directory scan + +- Success return string{} + +--- + +> success = RL.ChangeDirectory( string directory ) + +Change working directory, return true on success - Success return bool --- -> released = RL.IsMouseButtonReleased( int button ) +> isFile = RL.IsPathFile( string path ) -Detect if a mouse button has been released once +Check if a given path is a file or a directory - Success return bool --- -> released = RL.IsMouseButtonUp( int button ) +> iSFileDropped = RL.IsFileDropped() -Check if a mouse button is NOT being pressed +Check if a file has been dropped into window - Success return bool --- -> position = RL.GetMousePosition() +> files = RL.LoadDroppedFiles() -Returns mouse position +Load dropped filepaths -- Success return Vector2 +- Success return string{} --- -> position = RL.GetMouseDelta() +> time = RL.GetFileModTime( string fileName ) -Get mouse delta between frames +Get file modification time (Last write time) -- Success return Vector2 +- Success return int --- -> RL.SetMousePosition( Vector2 position ) +## Core - Compression/Encoding functionality -Set mouse position XY +--- + +> compData = RL.CompressData( Buffer buffer ) + +Compress data (DEFLATE algorithm) + +- Success return Buffer --- -> RL.SetMouseOffset( Vector2 offset ) +> decompData = RL.DecompressData( Buffer compData ) -Set mouse offset +Decompress data (DEFLATE algorithm). + +- Success Buffer --- -> RL.SetMouseScale( Vector2 scale ) +> encodedData, outputSize = RL.EncodeDataBase64( string data ) -Set mouse scaling +Encode data to Base64 string + +- Success return string, int --- -> movement = RL.GetMouseWheelMove() +> decodedData, outputSize = RL.DecodeDataBase64( string data ) -Returns mouse wheel movement Y +Decode Base64 string data -- Success return float +- Success return string, int --- -> RL.SetMouseCursor( int cursor ) +## Core - Input-related functions: keyboard -Set mouse cursor +--- + +> pressed = RL.IsKeyPressed( int key ) + +Detect if a key has been pressed once + +- Success return bool --- -## Core - Input-related Touch +> pressed = RL.IsKeyDown( int key ) + +Detect if a key is being pressed + +- Success return bool --- -> position = RL.GetTouchPosition( int index ) +> released = RL.IsKeyReleased( int key ) -Get touch position XY for a touch point index (relative to screen size) +Detect if a key has been released once -- Success return Vector2 +- Success return bool --- -> id = RL.GetTouchPointId( int index ) +> released = RL.IsKeyUp( int key ) -Get touch point identifier for given index +Check if a key is NOT being pressed -- Success return int +- Success return bool --- -> count = RL.GetTouchPointCount() +> keycode = RL.GetKeyPressed() -Get touch point identifier for given index +Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty - Success return int --- -## Core - Input-related Gestures +> unicode = RL.GetCharPressed() + +Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty + +- Success return int --- -> RL.SetGesturesEnabled( unsigned int flags ) +> RL.SetExitKey( int key ) -Enable a set of gestures using flags +Set a custom key to exit program (default is ESC) --- -> detected = RL.IsGestureDetected( int gesture ) +> keyName = RL.GetKeyName( int key, int scancode ) -Check if a gesture have been detected +This function returns the name of the specified printable key, encoded as UTF-8. +This is typically the character that key would produce without any modifier keys, +intended for displaying key bindings to the user. For dead keys, it is typically +the diacritic it would add to a character. -- Success return bool +Do not use this function for text input. You will break text input for many +languages even if it happens to work for yours. + +If the key is KEY_UNKNOWN, the scancode is used to identify the key, +otherwise the scancode is ignored. If you specify a non-printable key, +or KEY_UNKNOWN and a scancode that maps to a non-printable key, +this function returns nil but does not emit an error. + +- Success return string or nil --- -> gesture = RL.GetGestureDetected() +> scancode = RL.GetKeyScancode( int key ) -Get latest detected gesture +This function returns the platform-specific scancode of the specified key. +If the key is KEY_UNKNOWN or does not exist on the keyboard this method will return -1. - Success return int --- -> time = RL.GetGestureHoldDuration() +## Core - Input-related functions: gamepads + +--- + +> available = RL.IsGamepadAvailable( int gamepad ) + +Detect if a gamepad is available + +- Success return bool + +--- + +> pressed = RL.IsGamepadButtonPressed( int gamepad, int button ) -Get gesture hold time in milliseconds +Detect if a gamepad button has been pressed once -- Success return float +- Success return bool --- -> vector = RL.GetGestureDragVector() +> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) -Get gesture drag vector +Detect if a gamepad button is being pressed -- Success return Vector2 +- Success return bool --- -> angle = RL.GetGestureDragAngle() +> released = RL.IsGamepadButtonReleased( int gamepad, int button ) -Get gesture drag angle +Detect if a gamepad button has been released once -- Success return float +- Success return bool --- -> vector = RL.GetGesturePinchVector() +> count = RL.GetGamepadAxisCount( int gamepad ) -Get gesture pinch delta +Return gamepad axis count for a gamepad -- Success return Vector2 +- Success return int --- -> angle = RL.GetGesturePinchAngle() +> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) -Get gesture pinch angle +Return axis movement value for a gamepad axis - Success return float --- -## Core - File +> name = RL.GetGamepadName( int gamepad ) ---- +Return gamepad internal name id -> path = RL.GetBasePath() +- Success return string -Return game directory (where main.lua is located) +--- -- Success return string +## Core - Input-related functions: mouse --- -> fileExists = RL.FileExists( string fileName ) +> pressed = RL.IsMouseButtonPressed( int button ) -Check if file exists +Detect if a mouse button has been pressed once - Success return bool --- -> dirExists = RL.DirectoryExists( string dirPath ) +> pressed = RL.IsMouseButtonDown( int button ) -Check if a directory path exists +Detect if a mouse button is being pressed - Success return bool --- -> hasFileExtension = RL.IsFileExtension( string fileName, string ext ) +> released = RL.IsMouseButtonReleased( int button ) -Check file extension (Including point: .png, .wav) +Detect if a mouse button has been released once - Success return bool --- -> length = RL.GetFileLength( string fileName ) +> released = RL.IsMouseButtonUp( int button ) -Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) +Check if a mouse button is NOT being pressed -- Success return int +- Success return bool --- -> extension = RL.GetFileExtension( string fileName ) +> position = RL.GetMousePosition() -Get pointer to extension for a filename string (Includes dot: '.png') +Returns mouse position -- Success return string +- Success return Vector2 --- -> fileName = RL.GetFileName( string filePath ) +> position = RL.GetMouseDelta() -Get pointer to filename for a path string +Get mouse delta between frames -- Success return string +- Success return Vector2 --- -> fileName = RL.GetFileNameWithoutExt( string filePath ) - -Get filename string without extension (Uses static string) +> RL.SetMousePosition( Vector2 position ) -- Success return string +Set mouse position XY --- -> filePath = RL.GetDirectoryPath( string filePath ) - -Get full path for a given fileName with path (Uses static string) +> RL.SetMouseOffset( Vector2 offset ) -- Success return string +Set mouse offset --- -> directory = RL.GetPrevDirectoryPath( string dirPath ) - -Get previous directory path for a given path (Uses static string) +> RL.SetMouseScale( Vector2 scale ) -- Success return string +Set mouse scaling --- -> directory = RL.GetWorkingDirectory() +> movement = RL.GetMouseWheelMove() -Get current working directory (Uses static string) +Returns mouse wheel movement Y -- Success return string +- Success return float --- -> fileNames = RL.LoadDirectoryFiles( string dirPath ) +> RL.SetMouseCursor( int cursor ) -Load directory filepaths +Set mouse cursor -- Success return string{} +--- + +## Core - Input-related functions: touch --- -> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs ) +> position = RL.GetTouchPosition( int index ) -Load directory filepaths with extension filtering and recursive directory scan +Get touch position XY for a touch point index (relative to screen size) -- Success return string{} +- Success return Vector2 --- -> success = RL.ChangeDirectory( string directory ) +> id = RL.GetTouchPointId( int index ) -Change working directory, return true on success +Get touch point identifier for given index -- Success return bool +- Success return int --- -> isFile = RL.IsPathFile( string path ) +> count = RL.GetTouchPointCount() -Check if a given path is a file or a directory +Get touch point identifier for given index -- Success return bool +- Success return int --- -> iSFileDropped = RL.IsFileDropped() +## Core - Input-related functions: gestures -Check if a file has been dropped into window +--- -- Success return bool +> RL.SetGesturesEnabled( unsigned int flags ) + +Enable a set of gestures using flags --- -> files = RL.LoadDroppedFiles() +> detected = RL.IsGestureDetected( int gesture ) -Load dropped filepaths +Check if a gesture have been detected -- Success return string{} +- Success return bool --- -> time = RL.GetFileModTime( string fileName ) +> gesture = RL.GetGestureDetected() -Get file modification time (Last write time) +Get latest detected gesture - Success return int --- -## Core - Compression/Encoding functionality +> time = RL.GetGestureHoldDuration() + +Get gesture hold time in milliseconds + +- Success return float --- -> compData = RL.CompressData( Buffer buffer ) +> vector = RL.GetGestureDragVector() -Compress data (DEFLATE algorithm) +Get gesture drag vector -- Success return Buffer +- Success return Vector2 --- -> decompData = RL.DecompressData( Buffer compData ) +> angle = RL.GetGestureDragAngle() -Decompress data (DEFLATE algorithm). +Get gesture drag angle -- Success Buffer +- Success return float --- -> encodedData, outputSize = RL.EncodeDataBase64( string data ) +> vector = RL.GetGesturePinchVector() -Encode data to Base64 string +Get gesture pinch delta -- Success return string, int +- Success return Vector2 --- -> decodedData, outputSize = RL.DecodeDataBase64( string data ) +> angle = RL.GetGesturePinchAngle() -Decode Base64 string data +Get gesture pinch angle -- Success return string, int +- Success return float --- -## Core - Camera2D +## Core - Camera2D System functions --- @@ -4552,18 +4648,6 @@ Return camera2D set to default configuration --- -> RL.BeginMode2D( camera2D camera ) - -Begin 2D mode with custom camera (2D) - ---- - -> RL.EndMode2D() - -Ends 2D mode with custom camera - ---- - > RL.SetCamera2DTarget( camera2D camera, Vector2 target ) Set camera target (rotation and zoom origin) @@ -4620,7 +4704,7 @@ Get camera2D zoom --- -## Core - Camera3D +## Core - Camera3D System functions --- @@ -4632,18 +4716,6 @@ Return camera3D id set to default configuration --- -> RL.BeginMode3D( camera3D camera ) - -Begin 3D mode with custom camera (3D) - ---- - -> RL.EndMode3D() - -Ends 3D mode and returns to default 2D orthographic mode - ---- - > RL.SetCamera3DPosition( camera3D camera, Vector3 position ) Set camera position (Remember to call "RL.UpdateCamera3D()" to apply changes) @@ -4818,67 +4890,7 @@ Update camera movement, movement/rotation values should be provided by user --- -## Core - Screen-space - ---- - -> ray = RL.GetMouseRay( Vector2 mousePosition, Camera3D camera ) - -Get a ray trace from mouse position - -- Success return Ray - ---- - -> matrix = RL.GetCameraMatrix( Camera3D camera ) - -Get camera transform matrix (view matrix) - -- Success return Matrix - ---- - -> matrix = RL.GetCameraMatrix2D( Camera2D camera ) - -Get camera 2d transform matrix - -- Success return Matrix - ---- - -> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera ) - -Get the screen space position for a 3d world space position - -- Success return Vector2 - ---- - -> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size ) - -Get size position for a 3d world space position - -- Success return Vector2 - ---- - -> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera ) - -Get the screen space position for a 2d camera world space position - -- Success return Vector2 - ---- - -> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera ) - -Get the world space position for a 2d camera screen space position - -- Success return Vector2 - ---- - -## Core - Buffer +## Core - Buffer management functions --- @@ -5758,18 +5770,6 @@ Draws a texture (or part of it) that stretches or shrinks nicely --- -> RL.BeginTextureMode( RenderTexture target ) - -Begin drawing to render texture - ---- - -> RL.EndTextureMode() - -Ends drawing to render texture - ---- - ## Textures - Texture Configuration --- -- cgit v1.2.3