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,7 +3746,299 @@ Get clipboard text content --- -## Core - Timing +## Core - Cursor-related functions + +--- + +> RL.ShowCursor() + +Shows cursor + +--- + +> RL.HideCursor() + +Hides cursor + +--- + +> hidden = RL.IsCursorHidden() + +Check if cursor is not visible + +- Success return bool + +--- + +> RL.EnableCursor() + +Enables cursor (unlock cursor) + +--- + +> RL.DisableCursor() + +Disables cursor (lock cursor) + +--- + +> onSreen = RL.IsCursorOnScreen() + +Check if cursor is on the screen + +- Success return bool + +--- + +## Core - Drawing-related functions + +--- + +> RL.ClearBackground( Color color ) + +Set background color (framebuffer clear color) + +--- + +> RL.BeginDrawing() + +Setup canvas (framebuffer) to start drawing + +--- + +> RL.EndDrawing() + +End canvas drawing and swap buffers (double buffering) + +--- + +> RL.BeginMode2D( camera2D camera ) + +Begin 2D mode with custom camera (2D) + +--- + +> RL.EndMode2D() + +Ends 2D mode with custom camera + +--- + +> RL.BeginMode3D( camera3D camera ) + +Begin 3D mode with custom camera (3D) + +--- + +> RL.EndMode3D() + +Ends 3D mode and returns to default 2D orthographic mode + +--- + +> RL.BeginTextureMode( RenderTexture target ) + +Begin drawing to render texture + +--- + +> RL.EndTextureMode() + +Ends drawing to render texture + +--- + +> RL.BeginShaderMode( Shader shader ) + +Begin custom shader drawing + +--- + +> RL.EndShaderMode() + +End custom shader drawing (use default shader) + +--- + +> RL.BeginBlendMode( int mode ) + +Begin blending mode (BLEND_ALPHA, BLEND_ADDITIVE, BLEND_MULTIPLIED...) + +--- + +> RL.EndBlendMode() + +End blending mode (reset to default: BLEND_ALPHA) + +--- + +> RL.BeginScissorMode( Rectangle rectange ) + +Begin scissor mode (define screen area for following drawing) + +--- + +> RL.EndScissorMode() + +End scissor mode + +--- + +## Core - Shader management functions + +--- + +> shader = RL.LoadShader( string vsFileName, string fsFileName ) + +Load shader from files and bind default locations. +NOTE: Set nil if no shader + +- Failure return nil +- Success return Shader + +--- + +> shader = RL.LoadShaderFromMemory( string vsCode, string fsCode ) + +Load shader from code strings and bind default locations +NOTE: Set nil if no shader + +- Failure return nil +- Success return Shader + +--- + +> isReady = RL.IsShaderReady( Shader shader ) + +Check if a shader is ready + +- Success return bool + +--- + +> location = RL.GetShaderLocation( Shader shader, string uniformName ) + +Get shader uniform location + +- Success return int + +--- + +> location = RL.GetShaderLocationAttrib( Shader shader, string attribName ) + +Get shader attribute location + +- Success return int + +--- + +> RL.SetShaderLocationIndex( Shader shader, int shaderLocationIndex, int location ) + +Set shader location index + +--- + +> location = RL.GetShaderLocationIndex( Shader shader, int shaderLocationIndex ) + +Get shader location index + +- Success return int + +--- + +> RL.SetShaderValueMatrix( Shader shader, int locIndex, Matrix mat ) + +Set shader uniform value (matrix 4x4) + +--- + +> RL.SetShaderValueTexture( Shader shader, int locIndex, Texture texture ) + +Set shader uniform value for texture (sampler2d) + +--- + +> RL.SetShaderValue( Shader shader, int locIndex, number{} values, int uniformType ) + +Set shader uniform value +NOTE: Even one value should be in table + +--- + +> RL.SetShaderValueV( Shader shader, int locIndex, number{} values, int uniformType, int count ) + +Set shader uniform value vector +NOTE: Even one value should be in table + +--- + +> RL.UnloadShader( Shader shader ) + +Unload shader from GPU memory (VRAM) + +--- + +## Core - Screen-space-related functions + +--- + +> 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 - Timing-related functions --- @@ -3836,527 +4128,7 @@ Check if Lua garbage collection is set to unload object data --- -## Core - Cursor - ---- - -> RL.ShowCursor() - -Shows cursor - ---- - -> RL.HideCursor() - -Hides cursor - ---- - -> hidden = RL.IsCursorHidden() - -Check if cursor is not visible - -- Success return bool - ---- - -> RL.EnableCursor() - -Enables cursor (unlock cursor) - ---- - -> RL.DisableCursor() - -Disables cursor (lock cursor) - ---- - -> onSreen = RL.IsCursorOnScreen() - -Check if cursor is on the screen - -- Success return bool - ---- - -## Core - Drawing - ---- - -> RL.ClearBackground( Color color ) - -Set background color (framebuffer clear color) - ---- - -> RL.BeginDrawing() - -Setup canvas (framebuffer) to start drawing - ---- - -> RL.EndDrawing() - -End canvas drawing and swap buffers (double buffering) - ---- - -> RL.BeginBlendMode( int mode ) - -Begin blending mode (BLEND_ALPHA, BLEND_ADDITIVE, BLEND_MULTIPLIED...) - ---- - -> RL.EndBlendMode() - -End blending mode (reset to default: BLEND_ALPHA) - ---- - -> RL.BeginScissorMode( Rectangle rectange ) - -Begin scissor mode (define screen area for following drawing) - ---- - -> RL.EndScissorMode() - -End scissor mode - ---- - -## Core - Shader - ---- - -> shader = RL.LoadShader( string vsFileName, string fsFileName ) - -Load shader from files and bind default locations. -NOTE: Set nil if no shader - -- Failure return nil -- Success return Shader - ---- - -> shader = RL.LoadShaderFromMemory( string vsCode, string fsCode ) - -Load shader from code strings and bind default locations -NOTE: Set nil if no shader - -- Failure return nil -- Success return Shader - ---- - -> isReady = RL.IsShaderReady( Shader shader ) - -Check if a shader is ready - -- Success return bool - ---- - -> 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 - -- Success return int - ---- - -> location = RL.GetShaderLocationAttrib( Shader shader, string attribName ) - -Get shader attribute location - -- Success return int - ---- - -> RL.SetShaderLocationIndex( Shader shader, int shaderLocationIndex, int location ) - -Set shader location index - ---- - -> location = RL.GetShaderLocationIndex( Shader shader, int shaderLocationIndex ) - -Get shader location index - -- Success return int - ---- - -> RL.SetShaderValueMatrix( Shader shader, int locIndex, Matrix mat ) - -Set shader uniform value (matrix 4x4) - ---- - -> RL.SetShaderValueTexture( Shader shader, int locIndex, Texture texture ) - -Set shader uniform value for texture (sampler2d) - ---- - -> RL.SetShaderValue( Shader shader, int locIndex, number{} values, int uniformType ) - -Set shader uniform value -NOTE: Even one value should be in table - ---- - -> RL.SetShaderValueV( Shader shader, int locIndex, number{} values, int uniformType, int count ) - -Set shader uniform value vector -NOTE: Even one value should be in table - ---- - -> RL.UnloadShader( Shader shader ) - -Unload shader from GPU memory (VRAM) - ---- - -## Core - Input-related Keyboard - ---- - -> pressed = RL.IsKeyPressed( int key ) - -Detect if a key has been pressed once - -- Success return bool - ---- - -> pressed = RL.IsKeyDown( int key ) - -Detect if a key is being pressed - -- Success return bool - ---- - -> released = RL.IsKeyReleased( int key ) - -Detect if a key has been released once - -- Success return bool - ---- - -> released = RL.IsKeyUp( int key ) - -Check if a key is NOT being pressed - -- Success return bool - ---- - -> keycode = RL.GetKeyPressed() - -Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty - -- Success return int - ---- - -> 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.SetExitKey( int key ) - -Set a custom key to exit program (default is ESC) - ---- - -> keyName = RL.GetKeyName( int key, int scancode ) - -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. - -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 - ---- - -> scancode = RL.GetKeyScancode( int key ) - -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 - ---- - -## Core - Input-related Gamepad - ---- - -> available = RL.IsGamepadAvailable( int gamepad ) - -Detect if a gamepad is available - -- Success return bool - ---- - -> pressed = RL.IsGamepadButtonPressed( int gamepad, int button ) - -Detect if a gamepad button has been pressed once - -- Success return bool - ---- - -> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) - -Detect if a gamepad button is being pressed - -- Success return bool - ---- - -> released = RL.IsGamepadButtonReleased( int gamepad, int button ) - -Detect if a gamepad button has been released once - -- Success return bool - ---- - -> count = RL.GetGamepadAxisCount( int gamepad ) - -Return gamepad axis count for a gamepad - -- Success return int - ---- - -> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) - -Return axis movement value for a gamepad axis - -- Success return float - ---- - -> name = RL.GetGamepadName( int gamepad ) - -Return gamepad internal name id - -- Success return string - ---- - -## Core - Input-related Mouse - ---- - -> pressed = RL.IsMouseButtonPressed( int button ) - -Detect if a mouse button has been pressed once - -- Success return bool - ---- - -> pressed = RL.IsMouseButtonDown( int button ) - -Detect if a mouse button is being pressed - -- Success return bool - ---- - -> released = RL.IsMouseButtonReleased( int button ) - -Detect if a mouse button has been released once - -- Success return bool - ---- - -> released = RL.IsMouseButtonUp( int button ) - -Check if a mouse button is NOT being pressed - -- Success return bool - ---- - -> position = RL.GetMousePosition() - -Returns mouse position - -- Success return Vector2 - ---- - -> position = RL.GetMouseDelta() - -Get mouse delta between frames - -- Success return Vector2 - ---- - -> RL.SetMousePosition( Vector2 position ) - -Set mouse position XY - ---- - -> RL.SetMouseOffset( Vector2 offset ) - -Set mouse offset - ---- - -> RL.SetMouseScale( Vector2 scale ) - -Set mouse scaling - ---- - -> movement = RL.GetMouseWheelMove() - -Returns mouse wheel movement Y - -- Success return float - ---- - -> RL.SetMouseCursor( int cursor ) - -Set mouse cursor - ---- - -## Core - Input-related Touch - ---- - -> position = RL.GetTouchPosition( int index ) - -Get touch position XY for a touch point index (relative to screen size) - -- Success return Vector2 - ---- - -> id = RL.GetTouchPointId( int index ) - -Get touch point identifier for given index - -- Success return int - ---- - -> count = RL.GetTouchPointCount() - -Get touch point identifier for given index - -- Success return int - ---- - -## Core - Input-related Gestures - ---- - -> RL.SetGesturesEnabled( unsigned int flags ) - -Enable a set of gestures using flags - ---- - -> detected = RL.IsGestureDetected( int gesture ) - -Check if a gesture have been detected - -- Success return bool - ---- - -> gesture = RL.GetGestureDetected() - -Get latest detected gesture - -- Success return int - ---- - -> time = RL.GetGestureHoldDuration() - -Get gesture hold time in milliseconds - -- Success return float - ---- - -> vector = RL.GetGestureDragVector() - -Get gesture drag vector - -- Success return Vector2 - ---- - -> angle = RL.GetGestureDragAngle() - -Get gesture drag angle - -- Success return float - ---- - -> vector = RL.GetGesturePinchVector() - -Get gesture pinch delta - -- Success return Vector2 - ---- - -> angle = RL.GetGesturePinchAngle() - -Get gesture pinch angle - -- Success return float - ---- - -## Core - File +## Core - Files management functions --- @@ -4540,7 +4312,331 @@ Decode Base64 string data --- -## Core - Camera2D +## Core - Input-related functions: keyboard + +--- + +> pressed = RL.IsKeyPressed( int key ) + +Detect if a key has been pressed once + +- Success return bool + +--- + +> pressed = RL.IsKeyDown( int key ) + +Detect if a key is being pressed + +- Success return bool + +--- + +> released = RL.IsKeyReleased( int key ) + +Detect if a key has been released once + +- Success return bool + +--- + +> released = RL.IsKeyUp( int key ) + +Check if a key is NOT being pressed + +- Success return bool + +--- + +> keycode = RL.GetKeyPressed() + +Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty + +- Success return int + +--- + +> 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.SetExitKey( int key ) + +Set a custom key to exit program (default is ESC) + +--- + +> keyName = RL.GetKeyName( int key, int scancode ) + +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. + +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 + +--- + +> scancode = RL.GetKeyScancode( int key ) + +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 + +--- + +## 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 ) + +Detect if a gamepad button has been pressed once + +- Success return bool + +--- + +> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) + +Detect if a gamepad button is being pressed + +- Success return bool + +--- + +> released = RL.IsGamepadButtonReleased( int gamepad, int button ) + +Detect if a gamepad button has been released once + +- Success return bool + +--- + +> count = RL.GetGamepadAxisCount( int gamepad ) + +Return gamepad axis count for a gamepad + +- Success return int + +--- + +> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) + +Return axis movement value for a gamepad axis + +- Success return float + +--- + +> name = RL.GetGamepadName( int gamepad ) + +Return gamepad internal name id + +- Success return string + +--- + +## Core - Input-related functions: mouse + +--- + +> pressed = RL.IsMouseButtonPressed( int button ) + +Detect if a mouse button has been pressed once + +- Success return bool + +--- + +> pressed = RL.IsMouseButtonDown( int button ) + +Detect if a mouse button is being pressed + +- Success return bool + +--- + +> released = RL.IsMouseButtonReleased( int button ) + +Detect if a mouse button has been released once + +- Success return bool + +--- + +> released = RL.IsMouseButtonUp( int button ) + +Check if a mouse button is NOT being pressed + +- Success return bool + +--- + +> position = RL.GetMousePosition() + +Returns mouse position + +- Success return Vector2 + +--- + +> position = RL.GetMouseDelta() + +Get mouse delta between frames + +- Success return Vector2 + +--- + +> RL.SetMousePosition( Vector2 position ) + +Set mouse position XY + +--- + +> RL.SetMouseOffset( Vector2 offset ) + +Set mouse offset + +--- + +> RL.SetMouseScale( Vector2 scale ) + +Set mouse scaling + +--- + +> movement = RL.GetMouseWheelMove() + +Returns mouse wheel movement Y + +- Success return float + +--- + +> RL.SetMouseCursor( int cursor ) + +Set mouse cursor + +--- + +## Core - Input-related functions: touch + +--- + +> position = RL.GetTouchPosition( int index ) + +Get touch position XY for a touch point index (relative to screen size) + +- Success return Vector2 + +--- + +> id = RL.GetTouchPointId( int index ) + +Get touch point identifier for given index + +- Success return int + +--- + +> count = RL.GetTouchPointCount() + +Get touch point identifier for given index + +- Success return int + +--- + +## Core - Input-related functions: gestures + +--- + +> RL.SetGesturesEnabled( unsigned int flags ) + +Enable a set of gestures using flags + +--- + +> detected = RL.IsGestureDetected( int gesture ) + +Check if a gesture have been detected + +- Success return bool + +--- + +> gesture = RL.GetGestureDetected() + +Get latest detected gesture + +- Success return int + +--- + +> time = RL.GetGestureHoldDuration() + +Get gesture hold time in milliseconds + +- Success return float + +--- + +> vector = RL.GetGestureDragVector() + +Get gesture drag vector + +- Success return Vector2 + +--- + +> angle = RL.GetGestureDragAngle() + +Get gesture drag angle + +- Success return float + +--- + +> vector = RL.GetGesturePinchVector() + +Get gesture pinch delta + +- Success return Vector2 + +--- + +> angle = RL.GetGesturePinchAngle() + +Get gesture pinch angle + +- Success return float + +--- + +## 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 --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 98df0a4..5ca1c59 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -1208,7 +1208,7 @@ RL.EVENT_MOUSE_CURSOR_POS=8 RL.EVENT_MOUSE_SCROLL=9 ---GLFW event cursor enter/leave RL.EVENT_CURSOR_ENTER=10 --- Core - Window +-- Core - Window-related functions ---Check if window has been initialized successfully ---- Success return bool @@ -1376,72 +1376,7 @@ function RL.SetClipboardText( text ) end ---@return any text function RL.GetClipboardText() end --- Core - Timing - ----Set target FPS (maximum) ----@param fps integer ----@return any RL.SetTargetFPS -function RL.SetTargetFPS( fps ) end - ----Get current FPS ----- Success return int ----@return any FPS -function RL.GetFPS() end - ----Get time in seconds for last frame drawn (Delta time) ----- Success return float ----@return any delta -function RL.GetFrameTime() end - ----Get elapsed time in seconds since InitWindow() ----- Success return float ----@return any time -function RL.GetTime() end - --- Core - Misc - ----Takes a screenshot of current screen (filename extension defines format) ----@param fileName string ----@return any RL.TakeScreenshot -function RL.TakeScreenshot( fileName ) end - ----Setup init configuration flags (view FLAGS) ----@param flags integer ----@return any RL.SetConfigFlags -function RL.SetConfigFlags( flags ) end - ----Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) ----@param logLevel integer ----@param text string ----@return any RL.TraceLog -function RL.TraceLog( logLevel, text ) end - ----Set the current threshold (minimum) log level ----@param logLevel integer ----@return any RL.SetTraceLogLevel -function RL.SetTraceLogLevel( logLevel ) end - ----Set the log level for bad function calls and invalid data formats. ----@param logLevel integer ----@return any RL.SetLogLevelInvalid -function RL.SetLogLevelInvalid( logLevel ) end - ----Get the log level for bad function calls and invalid data formats. ----- Success return int ----@return any logLevel -function RL.GetLogLevelInvalid() end - ----Open URL with default system browser (If available) ----@param url string ----@return any RL.OpenURL -function RL.OpenURL( url ) end - ----Check if Lua garbage collection is set to unload object data ----- Success return bool ----@return any enabled -function RL.IsGCUnloadEnabled() end - --- Core - Cursor +-- Core - Cursor-related functions ---Shows cursor ---@return any RL.ShowCursor @@ -1469,7 +1404,7 @@ function RL.DisableCursor() end ---@return any onSreen function RL.IsCursorOnScreen() end --- Core - Drawing +-- Core - Drawing-related functions ---Set background color (framebuffer clear color) ---@param color table @@ -1484,6 +1419,42 @@ function RL.BeginDrawing() end ---@return any RL.EndDrawing function RL.EndDrawing() end +---Begin 2D mode with custom camera (2D) +---@param camera any +---@return any RL.BeginMode2D +function RL.BeginMode2D( camera ) end + +---Ends 2D mode with custom camera +---@return any RL.EndMode2D +function RL.EndMode2D() end + +---Begin 3D mode with custom camera (3D) +---@param camera any +---@return any RL.BeginMode3D +function RL.BeginMode3D( camera ) end + +---Ends 3D mode and returns to default 2D orthographic mode +---@return any RL.EndMode3D +function RL.EndMode3D() end + +---Begin drawing to render texture +---@param target any +---@return any RL.BeginTextureMode +function RL.BeginTextureMode( target ) end + +---Ends drawing to render texture +---@return any RL.EndTextureMode +function RL.EndTextureMode() end + +---Begin custom shader drawing +---@param shader any +---@return any RL.BeginShaderMode +function RL.BeginShaderMode( shader ) end + +---End custom shader drawing (use default shader) +---@return any RL.EndShaderMode +function RL.EndShaderMode() end + ---Begin blending mode (BLEND_ALPHA, BLEND_ADDITIVE, BLEND_MULTIPLIED...) ---@param mode integer ---@return any RL.BeginBlendMode @@ -1502,7 +1473,7 @@ function RL.BeginScissorMode( rectange ) end ---@return any RL.EndScissorMode function RL.EndScissorMode() end --- Core - Shader +-- Core - Shader management functions ---Load shader from files and bind default locations. ---NOTE: Set nil if no shader @@ -1528,15 +1499,6 @@ function RL.LoadShaderFromMemory( vsCode, fsCode ) end ---@return any isReady function RL.IsShaderReady( shader ) end ----Begin custom shader drawing ----@param shader any ----@return any RL.BeginShaderMode -function RL.BeginShaderMode( shader ) end - ----End custom shader drawing (use default shader) ----@return any RL.EndShaderMode -function RL.EndShaderMode() end - ---Get shader uniform location ---- Success return int ---@param shader any @@ -1603,242 +1565,122 @@ function RL.SetShaderValueV( shader, locIndex, values, uniformType, count ) end ---@return any RL.UnloadShader function RL.UnloadShader( shader ) end --- Core - Input-related Keyboard +-- Core - Screen-space-related functions ----Detect if a key has been pressed once ----- Success return bool ----@param key integer ----@return any pressed -function RL.IsKeyPressed( key ) end +---Get a ray trace from mouse position +---- Success return Ray +---@param mousePosition table +---@param camera any +---@return any ray +function RL.GetMouseRay( mousePosition, camera ) end ----Detect if a key is being pressed ----- Success return bool ----@param key integer ----@return any pressed -function RL.IsKeyDown( key ) end +---Get camera transform matrix (view matrix) +---- Success return Matrix +---@param camera any +---@return any matrix +function RL.GetCameraMatrix( camera ) end ----Detect if a key has been released once ----- Success return bool ----@param key integer ----@return any released -function RL.IsKeyReleased( key ) end +---Get camera 2d transform matrix +---- Success return Matrix +---@param camera any +---@return any matrix +function RL.GetCameraMatrix2D( camera ) end ----Check if a key is NOT being pressed ----- Success return bool ----@param key integer ----@return any released -function RL.IsKeyUp( key ) end - ----Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty ----- Success return int ----@return any keycode -function RL.GetKeyPressed() end - ----Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty ----- Success return int ----@return any unicode -function RL.GetCharPressed() end - ----Set a custom key to exit program (default is ESC) ----@param key integer ----@return any RL.SetExitKey -function RL.SetExitKey( key ) end - ----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. ----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 ----@param key integer ----@param scancode integer ----@return any keyName -function RL.GetKeyName( key, scancode ) end - ----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 ----@param key integer ----@return any scancode -function RL.GetKeyScancode( key ) end - --- Core - Input-related Gamepad - ----Detect if a gamepad is available ----- Success return bool ----@param gamepad integer ----@return any available -function RL.IsGamepadAvailable( gamepad ) end - ----Detect if a gamepad button has been pressed once ----- Success return bool ----@param gamepad integer ----@param button integer ----@return any pressed -function RL.IsGamepadButtonPressed( gamepad, button ) end - ----Detect if a gamepad button is being pressed ----- Success return bool ----@param gamepad integer ----@param button integer ----@return any pressed -function RL.IsGamepadButtonDown( gamepad, button ) end - ----Detect if a gamepad button has been released once ----- Success return bool ----@param gamepad integer ----@param button integer ----@return any released -function RL.IsGamepadButtonReleased( gamepad, button ) end - ----Return gamepad axis count for a gamepad ----- Success return int ----@param gamepad integer ----@return any count -function RL.GetGamepadAxisCount( gamepad ) end - ----Return axis movement value for a gamepad axis ----- Success return float ----@param gamepad integer ----@param axis integer ----@return any value -function RL.GetGamepadAxisMovement( gamepad, axis ) end - ----Return gamepad internal name id ----- Success return string ----@param gamepad integer ----@return any name -function RL.GetGamepadName( gamepad ) end - --- Core - Input-related Mouse - ----Detect if a mouse button has been pressed once ----- Success return bool ----@param button integer ----@return any pressed -function RL.IsMouseButtonPressed( button ) end - ----Detect if a mouse button is being pressed ----- Success return bool ----@param button integer ----@return any pressed -function RL.IsMouseButtonDown( button ) end - ----Detect if a mouse button has been released once ----- Success return bool ----@param button integer ----@return any released -function RL.IsMouseButtonReleased( button ) end - ----Check if a mouse button is NOT being pressed ----- Success return bool ----@param button integer ----@return any released -function RL.IsMouseButtonUp( button ) end - ----Returns mouse position +---Get the screen space position for a 3d world space position ---- Success return Vector2 ----@return any position -function RL.GetMousePosition() end - ----Get mouse delta between frames ----- Success return Vector2 ----@return any position -function RL.GetMouseDelta() end - ----Set mouse position XY ---@param position table ----@return any RL.SetMousePosition -function RL.SetMousePosition( position ) end - ----Set mouse offset ----@param offset table ----@return any RL.SetMouseOffset -function RL.SetMouseOffset( offset ) end - ----Set mouse scaling ----@param scale table ----@return any RL.SetMouseScale -function RL.SetMouseScale( scale ) end - ----Returns mouse wheel movement Y ----- Success return float ----@return any movement -function RL.GetMouseWheelMove() end - ----Set mouse cursor ----@param cursor integer ----@return any RL.SetMouseCursor -function RL.SetMouseCursor( cursor ) end - --- Core - Input-related Touch - ----Get touch position XY for a touch point index (relative to screen size) ----- Success return Vector2 ----@param index integer +---@param camera any ---@return any position -function RL.GetTouchPosition( index ) end +function RL.GetWorldToScreen( position, camera ) end ----Get touch point identifier for given index +---Get size position for a 3d world space position +---- Success return Vector2 +---@param position table +---@param camera any +---@param size table +---@return any position +function RL.GetWorldToScreenEx( position, camera, size ) end + +---Get the screen space position for a 2d camera world space position +---- Success return Vector2 +---@param position table +---@param camera any +---@return any position +function RL.GetWorldToScreen2D( position, camera ) end + +---Get the world space position for a 2d camera screen space position +---- Success return Vector2 +---@param position table +---@param camera any +---@return any position +function RL.GetScreenToWorld2D( position, camera ) end + +-- Core - Timing-related functions + +---Set target FPS (maximum) +---@param fps integer +---@return any RL.SetTargetFPS +function RL.SetTargetFPS( fps ) end + +---Get current FPS ---- Success return int ----@param index integer ----@return any id -function RL.GetTouchPointId( index ) end +---@return any FPS +function RL.GetFPS() end ----Get touch point identifier for given index ----- Success return int ----@return any count -function RL.GetTouchPointCount() end +---Get time in seconds for last frame drawn (Delta time) +---- Success return float +---@return any delta +function RL.GetFrameTime() end --- Core - Input-related Gestures - ----Enable a set of gestures using flags ----@param int any ----@return any RL.SetGesturesEnabled -function RL.SetGesturesEnabled( int ) end - ----Check if a gesture have been detected ----- Success return bool ----@param gesture integer ----@return any detected -function RL.IsGestureDetected( gesture ) end - ----Get latest detected gesture ----- Success return int ----@return any gesture -function RL.GetGestureDetected() end - ----Get gesture hold time in milliseconds +---Get elapsed time in seconds since InitWindow() ---- Success return float ---@return any time -function RL.GetGestureHoldDuration() end +function RL.GetTime() end ----Get gesture drag vector ----- Success return Vector2 ----@return any vector -function RL.GetGestureDragVector() end +-- Core - Misc ----Get gesture drag angle ----- Success return float ----@return any angle -function RL.GetGestureDragAngle() end +---Takes a screenshot of current screen (filename extension defines format) +---@param fileName string +---@return any RL.TakeScreenshot +function RL.TakeScreenshot( fileName ) end ----Get gesture pinch delta ----- Success return Vector2 ----@return any vector -function RL.GetGesturePinchVector() end +---Setup init configuration flags (view FLAGS) +---@param flags integer +---@return any RL.SetConfigFlags +function RL.SetConfigFlags( flags ) end ----Get gesture pinch angle ----- Success return float ----@return any angle -function RL.GetGesturePinchAngle() end +---Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +---@param logLevel integer +---@param text string +---@return any RL.TraceLog +function RL.TraceLog( logLevel, text ) end --- Core - File +---Set the current threshold (minimum) log level +---@param logLevel integer +---@return any RL.SetTraceLogLevel +function RL.SetTraceLogLevel( logLevel ) end + +---Set the log level for bad function calls and invalid data formats. +---@param logLevel integer +---@return any RL.SetLogLevelInvalid +function RL.SetLogLevelInvalid( logLevel ) end + +---Get the log level for bad function calls and invalid data formats. +---- Success return int +---@return any logLevel +function RL.GetLogLevelInvalid() end + +---Open URL with default system browser (If available) +---@param url string +---@return any RL.OpenURL +function RL.OpenURL( url ) end + +---Check if Lua garbage collection is set to unload object data +---- Success return bool +---@return any enabled +function RL.IsGCUnloadEnabled() end + +-- Core - Files management functions ---Return game directory (where main.lua is located) ---- Success return string @@ -1975,22 +1817,248 @@ function RL.EncodeDataBase64( data ) end ---@return any outputSize function RL.DecodeDataBase64( data ) end --- Core - Camera2D +-- Core - Input-related functions: keyboard + +---Detect if a key has been pressed once +---- Success return bool +---@param key integer +---@return any pressed +function RL.IsKeyPressed( key ) end + +---Detect if a key is being pressed +---- Success return bool +---@param key integer +---@return any pressed +function RL.IsKeyDown( key ) end + +---Detect if a key has been released once +---- Success return bool +---@param key integer +---@return any released +function RL.IsKeyReleased( key ) end + +---Check if a key is NOT being pressed +---- Success return bool +---@param key integer +---@return any released +function RL.IsKeyUp( key ) end + +---Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty +---- Success return int +---@return any keycode +function RL.GetKeyPressed() end + +---Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty +---- Success return int +---@return any unicode +function RL.GetCharPressed() end + +---Set a custom key to exit program (default is ESC) +---@param key integer +---@return any RL.SetExitKey +function RL.SetExitKey( key ) end + +---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. +---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 +---@param key integer +---@param scancode integer +---@return any keyName +function RL.GetKeyName( key, scancode ) end + +---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 +---@param key integer +---@return any scancode +function RL.GetKeyScancode( key ) end + +-- Core - Input-related functions: gamepads + +---Detect if a gamepad is available +---- Success return bool +---@param gamepad integer +---@return any available +function RL.IsGamepadAvailable( gamepad ) end + +---Detect if a gamepad button has been pressed once +---- Success return bool +---@param gamepad integer +---@param button integer +---@return any pressed +function RL.IsGamepadButtonPressed( gamepad, button ) end + +---Detect if a gamepad button is being pressed +---- Success return bool +---@param gamepad integer +---@param button integer +---@return any pressed +function RL.IsGamepadButtonDown( gamepad, button ) end + +---Detect if a gamepad button has been released once +---- Success return bool +---@param gamepad integer +---@param button integer +---@return any released +function RL.IsGamepadButtonReleased( gamepad, button ) end + +---Return gamepad axis count for a gamepad +---- Success return int +---@param gamepad integer +---@return any count +function RL.GetGamepadAxisCount( gamepad ) end + +---Return axis movement value for a gamepad axis +---- Success return float +---@param gamepad integer +---@param axis integer +---@return any value +function RL.GetGamepadAxisMovement( gamepad, axis ) end + +---Return gamepad internal name id +---- Success return string +---@param gamepad integer +---@return any name +function RL.GetGamepadName( gamepad ) end + +-- Core - Input-related functions: mouse + +---Detect if a mouse button has been pressed once +---- Success return bool +---@param button integer +---@return any pressed +function RL.IsMouseButtonPressed( button ) end + +---Detect if a mouse button is being pressed +---- Success return bool +---@param button integer +---@return any pressed +function RL.IsMouseButtonDown( button ) end + +---Detect if a mouse button has been released once +---- Success return bool +---@param button integer +---@return any released +function RL.IsMouseButtonReleased( button ) end + +---Check if a mouse button is NOT being pressed +---- Success return bool +---@param button integer +---@return any released +function RL.IsMouseButtonUp( button ) end + +---Returns mouse position +---- Success return Vector2 +---@return any position +function RL.GetMousePosition() end + +---Get mouse delta between frames +---- Success return Vector2 +---@return any position +function RL.GetMouseDelta() end + +---Set mouse position XY +---@param position table +---@return any RL.SetMousePosition +function RL.SetMousePosition( position ) end + +---Set mouse offset +---@param offset table +---@return any RL.SetMouseOffset +function RL.SetMouseOffset( offset ) end + +---Set mouse scaling +---@param scale table +---@return any RL.SetMouseScale +function RL.SetMouseScale( scale ) end + +---Returns mouse wheel movement Y +---- Success return float +---@return any movement +function RL.GetMouseWheelMove() end + +---Set mouse cursor +---@param cursor integer +---@return any RL.SetMouseCursor +function RL.SetMouseCursor( cursor ) end + +-- Core - Input-related functions: touch + +---Get touch position XY for a touch point index (relative to screen size) +---- Success return Vector2 +---@param index integer +---@return any position +function RL.GetTouchPosition( index ) end + +---Get touch point identifier for given index +---- Success return int +---@param index integer +---@return any id +function RL.GetTouchPointId( index ) end + +---Get touch point identifier for given index +---- Success return int +---@return any count +function RL.GetTouchPointCount() end + +-- Core - Input-related functions: gestures + +---Enable a set of gestures using flags +---@param int any +---@return any RL.SetGesturesEnabled +function RL.SetGesturesEnabled( int ) end + +---Check if a gesture have been detected +---- Success return bool +---@param gesture integer +---@return any detected +function RL.IsGestureDetected( gesture ) end + +---Get latest detected gesture +---- Success return int +---@return any gesture +function RL.GetGestureDetected() end + +---Get gesture hold time in milliseconds +---- Success return float +---@return any time +function RL.GetGestureHoldDuration() end + +---Get gesture drag vector +---- Success return Vector2 +---@return any vector +function RL.GetGestureDragVector() end + +---Get gesture drag angle +---- Success return float +---@return any angle +function RL.GetGestureDragAngle() end + +---Get gesture pinch delta +---- Success return Vector2 +---@return any vector +function RL.GetGesturePinchVector() end + +---Get gesture pinch angle +---- Success return float +---@return any angle +function RL.GetGesturePinchAngle() end + +-- Core - Camera2D System functions ---Return camera2D set to default configuration ---- Success return Camera2D ---@return any camera2D function RL.CreateCamera2D() end ----Begin 2D mode with custom camera (2D) ----@param camera any ----@return any RL.BeginMode2D -function RL.BeginMode2D( camera ) end - ----Ends 2D mode with custom camera ----@return any RL.EndMode2D -function RL.EndMode2D() end - ---Set camera target (rotation and zoom origin) ---@param camera any ---@param target table @@ -2039,22 +2107,13 @@ function RL.GetCamera2DRotation( camera ) end ---@return any zoom function RL.GetCamera2DZoom( camera ) end --- Core - Camera3D +-- Core - Camera3D System functions ---Return camera3D id set to default configuration ---- Success return int ---@return any camera function RL.CreateCamera3D() end ----Begin 3D mode with custom camera (3D) ----@param camera any ----@return any RL.BeginMode3D -function RL.BeginMode3D( camera ) end - ----Ends 3D mode and returns to default 2D orthographic mode ----@return any RL.EndMode3D -function RL.EndMode3D() end - ---Set camera position (Remember to call "RL.UpdateCamera3D()" to apply changes) ---@param camera any ---@param position table @@ -2218,57 +2277,7 @@ function RL.UpdateCamera3D( camera, mode ) end ---@return any RL.UpdateCamera3DPro function RL.UpdateCamera3DPro( camera, movement, rotation, zoom ) end --- Core - Screen-space - ----Get a ray trace from mouse position ----- Success return Ray ----@param mousePosition table ----@param camera any ----@return any ray -function RL.GetMouseRay( mousePosition, camera ) end - ----Get camera transform matrix (view matrix) ----- Success return Matrix ----@param camera any ----@return any matrix -function RL.GetCameraMatrix( camera ) end - ----Get camera 2d transform matrix ----- Success return Matrix ----@param camera any ----@return any matrix -function RL.GetCameraMatrix2D( camera ) end - ----Get the screen space position for a 3d world space position ----- Success return Vector2 ----@param position table ----@param camera any ----@return any position -function RL.GetWorldToScreen( position, camera ) end - ----Get size position for a 3d world space position ----- Success return Vector2 ----@param position table ----@param camera any ----@param size table ----@return any position -function RL.GetWorldToScreenEx( position, camera, size ) end - ----Get the screen space position for a 2d camera world space position ----- Success return Vector2 ----@param position table ----@param camera any ----@return any position -function RL.GetWorldToScreen2D( position, camera ) end - ----Get the world space position for a 2d camera screen space position ----- Success return Vector2 ----@param position table ----@param camera any ----@return any position -function RL.GetScreenToWorld2D( position, camera ) end - --- Core - Buffer +-- Core - Buffer management functions ---Load Buffer. Type should be one of the Buffer types ---- Success return Buffer @@ -3167,15 +3176,6 @@ function RL.DrawTexturePro( texture, source, dest, origin, rotation, tint ) end ---@return any RL.DrawTextureNPatch function RL.DrawTextureNPatch( texture, nPatchInfo, dest, origin, rotation, tint ) end ----Begin drawing to render texture ----@param target any ----@return any RL.BeginTextureMode -function RL.BeginTextureMode( target ) end - ----Ends drawing to render texture ----@return any RL.EndTextureMode -function RL.EndTextureMode() end - -- Textures - Texture Configuration ---Generate GPU mipmaps for a texture diff --git a/changelog b/changelog index b13b598..4e48356 100644 --- a/changelog +++ b/changelog @@ -47,6 +47,7 @@ DETAILED CHANGES: - ADDED: GetModelBoundingBox. - ADDED: DrawModelWires and DrawModelWiresEx. - ADDED: LoadMaterials. + - CHANGED: Organized core functions. ------------------------------------------------------------------------ Release: ReiLua version 0.5.0 Using Raylib 4.5 diff --git a/include/core.h b/include/core.h index ad50f1b..32aa8f9 100644 --- a/include/core.h +++ b/include/core.h @@ -3,7 +3,7 @@ #include "lua_core.h" void unloadBuffer( Buffer *buffer ); -/* Window. */ +/* Window-related functions. */ int lcoreIsWindowReady( lua_State *L ); int lcoreIsWindowFullscreen( lua_State *L ); int lcoreIsWindowHidden( lua_State *L ); @@ -36,41 +36,33 @@ int lcoreGetMonitorName( lua_State *L ); int lcoreCloseWindow( lua_State *L ); int lcoreSetClipboardText( lua_State *L ); int lcoreGetClipboardText( lua_State *L ); -/* Timing. */ -int lcoreSetTargetFPS( lua_State *L ); -int lcoreGetFPS( lua_State *L ); -int lcoreGetFrameTime( lua_State *L ); -int lcoreGetTime( lua_State *L ); -/* Misc. */ -int lcoreTakeScreenshot( lua_State *L ); -int lcoreSetConfigFlags( lua_State *L ); -int lcoreTraceLog( lua_State *L ); -int lcoreSetTraceLogLevel( lua_State *L ); -int lcoreSetLogLevelInvalid( lua_State *L ); -int lcoreGetLogLevelInvalid( lua_State *L ); -int lcoreOpenURL( lua_State *L ); -int lcoreIsGCUnloadEnabled( lua_State *L ); -/* Cursor. */ +/* Cursor-related functions. */ int lcoreShowCursor( lua_State *L ); int lcoreHideCursor( lua_State *L ); int lcoreIsCursorHidden( lua_State *L ); int lcoreEnableCursor( lua_State *L ); int lcoreDisableCursor( lua_State *L ); int lcoreIsCursorOnScreen( lua_State *L ); -/* Drawing. */ +/* Drawing-related functions. */ int lcoreClearBackground( lua_State *L ); int lcoreBeginDrawing( lua_State *L ); int lcoreEndDrawing( lua_State *L ); +int lcoreBeginMode2D( lua_State *L ); +int lcoreEndMode2D( lua_State *L ); +int lcoreBeginMode3D( lua_State *L ); +int lcoreEndMode3D( lua_State *L ); +int lcoreBeginTextureMode( lua_State *L ); +int lcoreEndTextureMode( lua_State *L ); +int lcoreBeginShaderMode( lua_State *L ); +int lcoreEndShaderMode( lua_State *L ); int lcoreBeginBlendMode( lua_State *L ); int lcoreEndBlendMode( lua_State *L ); int lcoreBeginScissorMode( lua_State *L ); int lcoreEndScissorMode( lua_State *L ); -/* Shader. */ +/* Shader management functions. */ int lcoreLoadShader( lua_State *L ); int lcoreLoadShaderFromMemory( lua_State *L ); int lcoreIsShaderReady( lua_State *L ); -int lcoreBeginShaderMode( lua_State *L ); -int lcoreEndShaderMode( lua_State *L ); int lcoreGetShaderLocation( lua_State *L ); int lcoreGetShaderLocationAttrib( lua_State *L ); int lcoreSetShaderLocationIndex( lua_State *L ); @@ -80,7 +72,29 @@ int lcoreSetShaderValueTexture( lua_State *L ); int lcoreSetShaderValue( lua_State *L ); int lcoreSetShaderValueV( lua_State *L ); int lcoreUnloadShader( lua_State *L ); -/* File. */ +/* Screen-space-related functions. */ +int lcoreGetMouseRay( lua_State *L ); +int lcoreGetCameraMatrix( lua_State *L ); +int lcoreGetCameraMatrix2D( lua_State *L ); +int lcoreGetWorldToScreen( lua_State *L ); +int lcoreGetWorldToScreenEx( lua_State *L ); +int lcoreGetWorldToScreen2D( lua_State *L ); +int lcoreGetScreenToWorld2D( lua_State *L ); +/* Timing-related functions. */ +int lcoreSetTargetFPS( lua_State *L ); +int lcoreGetFPS( lua_State *L ); +int lcoreGetFrameTime( lua_State *L ); +int lcoreGetTime( lua_State *L ); +/* Misc. functions */ +int lcoreTakeScreenshot( lua_State *L ); +int lcoreSetConfigFlags( lua_State *L ); +int lcoreTraceLog( lua_State *L ); +int lcoreSetTraceLogLevel( lua_State *L ); +int lcoreSetLogLevelInvalid( lua_State *L ); +int lcoreGetLogLevelInvalid( lua_State *L ); +int lcoreOpenURL( lua_State *L ); +int lcoreIsGCUnloadEnabled( lua_State *L ); +/* Files management functions. */ int lcoreGetBasePath( lua_State *L ); int lcoreFileExists( lua_State *L ); int lcoreDirectoryExists( lua_State *L ); @@ -104,10 +118,51 @@ int lcoreCompressData( lua_State *L ); int lcoreDecompressData( lua_State *L ); int lcoreEncodeDataBase64( lua_State *L ); int lcoreDecodeDataBase64( lua_State *L ); -/* Camera2D. */ +/* Input-related functions: keyboard. */ +int lcoreIsKeyPressed( lua_State *L ); +int lcoreIsKeyDown( lua_State *L ); +int lcoreIsKeyReleased( lua_State *L ); +int lcoreIsKeyUp( lua_State *L ); +int lcoreGetKeyPressed( lua_State *L ); +int lcoreGetCharPressed( lua_State *L ); +int lcoreSetExitKey( lua_State *L ); +int lcoreGetKeyName( lua_State *L ); +int lcoreGetKeyScancode( lua_State *L ); +/* Input-related functions: gamepads. */ +int lcoreIsGamepadAvailable( lua_State *L ); +int lcoreIsGamepadButtonPressed( lua_State *L ); +int lcoreIsGamepadButtonDown( lua_State *L ); +int lcoreIsGamepadButtonReleased( lua_State *L ); +int lcoreGetGamepadAxisCount( lua_State *L ); +int lcoreGetGamepadAxisMovement( lua_State *L ); +int lcoreGetGamepadName( lua_State *L ); +/* Input-related functions: mouse. */ +int lcoreIsMouseButtonPressed( lua_State *L ); +int lcoreIsMouseButtonDown( lua_State *L ); +int lcoreIsMouseButtonReleased( lua_State *L ); +int lcoreIsMouseButtonUp( lua_State *L ); +int lcoreGetMousePosition( lua_State *L ); +int lcoreGetMouseDelta( lua_State *L ); +int lcoreSetMousePosition( lua_State *L ); +int lcoreSetMouseOffset( lua_State *L ); +int lcoreSetMouseScale( lua_State *L ); +int lcoreGetMouseWheelMove( lua_State *L ); +int lcoreSetMouseCursor( lua_State *L ); +/* Input-related functions: touch. */ +int lcoreGetTouchPosition( lua_State *L ); +int lcoreGetTouchPointId( lua_State *L ); +int lcoreGetTouchPointCount( lua_State *L ); +/* Input-related functions: gestures. */ +int lcoreSetGesturesEnabled( lua_State *L ); +int lcoreIsGestureDetected( lua_State *L ); +int lcoreGetGestureDetected( lua_State *L ); +int lcoreGetGestureHoldDuration( lua_State *L ); +int lcoreGetGestureDragVector( lua_State *L ); +int lcoreGetGestureDragAngle( lua_State *L ); +int lcoreGetGesturePinchVector( lua_State *L ); +int lcoreGetGesturePinchAngle( lua_State *L ); +/* Camera2D System functions. */ int lcoreCreateCamera2D( lua_State *L ); -int lcoreBeginMode2D( lua_State *L ); -int lcoreEndMode2D( lua_State *L ); int lcoreSetCamera2DTarget( lua_State *L ); int lcoreSetCamera2DOffset( lua_State *L ); int lcoreSetCamera2DRotation( lua_State *L ); @@ -116,10 +171,8 @@ int lcoreGetCamera2DTarget( lua_State *L ); int lcoreGetCamera2DOffset( lua_State *L ); int lcoreGetCamera2DRotation( lua_State *L ); int lcoreGetCamera2DZoom( lua_State *L ); -/* Camera3D. */ +/* Camera3D System functions. */ int lcoreCreateCamera3D( lua_State *L ); -int lcoreBeginMode3D( lua_State *L ); -int lcoreEndMode3D( lua_State *L ); int lcoreSetCamera3DPosition( lua_State *L ); int lcoreSetCamera3DTarget( lua_State *L ); int lcoreSetCamera3DUp( lua_State *L ); @@ -144,58 +197,7 @@ int lcoreGetCamera3DViewMatrix( lua_State *L ); int lcoreGetCamera3DProjectionMatrix( lua_State *L ); int lcoreUpdateCamera3D( lua_State *L ); int lcoreUpdateCamera3DPro( lua_State *L ); -/* Input-related Keyboard. */ -int lcoreIsKeyPressed( lua_State *L ); -int lcoreIsKeyDown( lua_State *L ); -int lcoreIsKeyReleased( lua_State *L ); -int lcoreIsKeyUp( lua_State *L ); -int lcoreGetKeyPressed( lua_State *L ); -int lcoreGetCharPressed( lua_State *L ); -int lcoreSetExitKey( lua_State *L ); -int lcoreGetKeyName( lua_State *L ); -int lcoreGetKeyScancode( lua_State *L ); -/* Input-related Gamepad. */ -int lcoreIsGamepadAvailable( lua_State *L ); -int lcoreIsGamepadButtonPressed( lua_State *L ); -int lcoreIsGamepadButtonDown( lua_State *L ); -int lcoreIsGamepadButtonReleased( lua_State *L ); -int lcoreGetGamepadAxisCount( lua_State *L ); -int lcoreGetGamepadAxisMovement( lua_State *L ); -int lcoreGetGamepadName( lua_State *L ); -/* Input-related Mouse. */ -int lcoreIsMouseButtonPressed( lua_State *L ); -int lcoreIsMouseButtonDown( lua_State *L ); -int lcoreIsMouseButtonReleased( lua_State *L ); -int lcoreIsMouseButtonUp( lua_State *L ); -int lcoreGetMousePosition( lua_State *L ); -int lcoreGetMouseDelta( lua_State *L ); -int lcoreSetMousePosition( lua_State *L ); -int lcoreSetMouseOffset( lua_State *L ); -int lcoreSetMouseScale( lua_State *L ); -int lcoreGetMouseWheelMove( lua_State *L ); -int lcoreSetMouseCursor( lua_State *L ); -/* Input-related Touch */ -int lcoreGetTouchPosition( lua_State *L ); -int lcoreGetTouchPointId( lua_State *L ); -int lcoreGetTouchPointCount( lua_State *L ); -/* Input-related Gestures. */ -int lcoreSetGesturesEnabled( lua_State *L ); -int lcoreIsGestureDetected( lua_State *L ); -int lcoreGetGestureDetected( lua_State *L ); -int lcoreGetGestureHoldDuration( lua_State *L ); -int lcoreGetGestureDragVector( lua_State *L ); -int lcoreGetGestureDragAngle( lua_State *L ); -int lcoreGetGesturePinchVector( lua_State *L ); -int lcoreGetGesturePinchAngle( lua_State *L ); -/* Screen-space. */ -int lcoreGetMouseRay( lua_State *L ); -int lcoreGetCameraMatrix( lua_State *L ); -int lcoreGetCameraMatrix2D( lua_State *L ); -int lcoreGetWorldToScreen( lua_State *L ); -int lcoreGetWorldToScreenEx( lua_State *L ); -int lcoreGetWorldToScreen2D( lua_State *L ); -int lcoreGetScreenToWorld2D( lua_State *L ); -/* Buffer. */ +/* Buffer management functions. */ int lcoreLoadBuffer( lua_State *L ); int lcoreUnloadBuffer( lua_State *L ); int lcoreGetBufferData( lua_State *L ); diff --git a/include/textures.h b/include/textures.h index 353026e..237dc60 100644 --- a/include/textures.h +++ b/include/textures.h @@ -81,8 +81,6 @@ int ltexturesDrawTexture( lua_State *L ); int ltexturesDrawTextureRec( lua_State *L ); int ltexturesDrawTexturePro( lua_State *L ); int ltexturesDrawTextureNPatch( lua_State *L ); -int ltexturesBeginTextureMode( lua_State *L ); -int ltexturesEndTextureMode( lua_State *L ); /* Texture Configuration. */ int ltexturesGenTextureMipmaps( lua_State *L ); int ltexturesSetTextureFilter( lua_State *L ); diff --git a/src/core.c b/src/core.c index a32b226..05af7c8 100644 --- a/src/core.c +++ b/src/core.c @@ -25,7 +25,7 @@ void unloadBuffer( Buffer *buffer ) { } /* -## Core - Window +## Core - Window-related functions */ /* @@ -467,165 +467,7 @@ int lcoreGetClipboardText( lua_State *L ) { } /* -## Core - Timing -*/ - -/* -> RL.SetTargetFPS( int fps ) - -Set target FPS (maximum) -*/ -int lcoreSetTargetFPS( lua_State *L ) { - int fps = luaL_checkinteger( L, 1 ); - - SetTargetFPS( fps ); - - return 0; -} - -/* -> FPS = RL.GetFPS() - -Get current FPS - -- Success return int -*/ -int lcoreGetFPS( lua_State *L ) { - lua_pushinteger( L, GetFPS() ); - - return 1; -} - -/* -> delta = RL.GetFrameTime() - -Get time in seconds for last frame drawn (Delta time) - -- Success return float -*/ -int lcoreGetFrameTime( lua_State *L ) { - lua_pushnumber( L, GetFrameTime() ); - - return 1; -} - -/* -> time = RL.GetTime() - -Get elapsed time in seconds since InitWindow() - -- Success return float -*/ -int lcoreGetTime( lua_State *L ) { - lua_pushnumber( L, GetTime() ); - - return 1; -} - -/* -## Core - Misc -*/ - -/* -> RL.TakeScreenshot( string fileName ) - -Takes a screenshot of current screen (filename extension defines format) -*/ -int lcoreTakeScreenshot( lua_State *L ) { - TakeScreenshot( luaL_checkstring( L, 1 ) ); - - return 0; -} - -/* -> RL.SetConfigFlags( int flags ) - -Setup init configuration flags (view FLAGS) -*/ -int lcoreSetConfigFlags( lua_State *L ) { - unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 ); - - SetConfigFlags( flag ); - - return 0; -} - -/* -> RL.TraceLog( int logLevel, string text ) - -Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) -*/ -int lcoreTraceLog( lua_State *L ) { - int logLevel = luaL_checkinteger( L, 1 ); - - TraceLog( logLevel, "%s", luaL_checkstring( L, 2 ) ); - - return 0; -} - -/* -> RL.SetTraceLogLevel( int logLevel ) - -Set the current threshold (minimum) log level -*/ -int lcoreSetTraceLogLevel( lua_State *L ) { - int logLevel = luaL_checkinteger( L, 1 ); - - SetTraceLogLevel( logLevel ); - - return 0; -} - -/* -> RL.SetLogLevelInvalid( int logLevel ) - -Set the log level for bad function calls and invalid data formats. -*/ -int lcoreSetLogLevelInvalid( lua_State *L ) { - state->logLevelInvalid = luaL_checkinteger( L, 1 ); - - return 0; -} - -/* -> logLevel = RL.GetLogLevelInvalid() - -Get the log level for bad function calls and invalid data formats. - -- Success return int -*/ -int lcoreGetLogLevelInvalid( lua_State *L ) { - lua_pushinteger( L, state->logLevelInvalid ); - - return 1; -} - -/* -> RL.OpenURL( string url ) - -Open URL with default system browser (If available) -*/ -int lcoreOpenURL( lua_State *L ) { - OpenURL( luaL_checkstring( L, 1 ) ); - - return 0; -} - -/* -> enabled = RL.IsGCUnloadEnabled() - -Check if Lua garbage collection is set to unload object data - -- Success return bool -*/ -int lcoreIsGCUnloadEnabled( lua_State *L ) { - lua_pushboolean( L, state->gcUnload ); - - return 1; -} - -/* -## Core - Cursor +## Core - Cursor-related functions */ /* @@ -699,7 +541,7 @@ int lcoreIsCursorOnScreen( lua_State *L ) { } /* -## Core - Drawing +## Core - Drawing-related functions */ /* @@ -737,6 +579,102 @@ int lcoreEndDrawing( lua_State *L ) { return 0; } +/* +> RL.BeginMode2D( camera2D camera ) + +Begin 2D mode with custom camera (2D) +*/ +int lcoreBeginMode2D( lua_State *L ) { + Camera2D *camera = uluaGetCamera2D( L, 1 ); + + BeginMode2D( *camera ); + + return 0; +} + +/* +> RL.EndMode2D() + +Ends 2D mode with custom camera +*/ +int lcoreEndMode2D( lua_State *L ) { + EndMode2D(); + + return 0; +} + +/* +> RL.BeginMode3D( camera3D camera ) + +Begin 3D mode with custom camera (3D) +*/ +int lcoreBeginMode3D( lua_State *L ) { + Camera3D *camera = uluaGetCamera3D( L, 1 ); + + BeginMode3D( *camera ); + + return 0; +} + +/* +> RL.EndMode3D() + +Ends 3D mode and returns to default 2D orthographic mode +*/ +int lcoreEndMode3D( lua_State *L ) { + EndMode3D(); + + return 0; +} + +/* +> RL.BeginTextureMode( RenderTexture target ) + +Begin drawing to render texture +*/ +int lcoreBeginTextureMode( lua_State *L ) { + RenderTexture *renderTexture = uluaGetRenderTexture( L, 1 ); + + BeginTextureMode( *renderTexture ); + + return 0; +} + +/* +> RL.EndTextureMode() + +Ends drawing to render texture +*/ +int lcoreEndTextureMode( lua_State *L ) { + EndTextureMode(); + + return 0; +} + +/* +> RL.BeginShaderMode( Shader shader ) + +Begin custom shader drawing +*/ +int lcoreBeginShaderMode( lua_State *L ) { + Shader *shader = uluaGetShader( L, 1 ); + + BeginShaderMode( *shader ); + + return 0; +} + +/* +> RL.EndShaderMode() + +End custom shader drawing (use default shader) +*/ +int lcoreEndShaderMode( lua_State *L ) { + EndShaderMode(); + + return 0; +} + /* > RL.BeginBlendMode( int mode ) @@ -786,7 +724,7 @@ int lcoreEndScissorMode( lua_State *L ) { } /* -## Core - Shader +## Core - Shader management functions */ /* @@ -853,30 +791,6 @@ int lcoreIsShaderReady( lua_State *L ) { return 1; } -/* -> RL.BeginShaderMode( Shader shader ) - -Begin custom shader drawing -*/ -int lcoreBeginShaderMode( lua_State *L ) { - Shader *shader = uluaGetShader( L, 1 ); - - BeginShaderMode( *shader ); - - return 0; -} - -/* -> RL.EndShaderMode() - -End custom shader drawing (use default shader) -*/ -int lcoreEndShaderMode( lua_State *L ) { - EndShaderMode(); - - return 0; -} - /* > location = RL.GetShaderLocation( Shader shader, string uniformName ) @@ -1067,585 +981,280 @@ int lcoreUnloadShader( lua_State *L ) { } /* -## 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 */ -int lcoreIsKeyPressed( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); +int lcoreGetMouseRay( lua_State *L ) { + Vector2 mousePosition = uluaGetVector2( L, 1 ); + Camera3D *camera = uluaGetCamera3D( L, 2 ); - lua_pushboolean( L, IsKeyPressed( key ) ); + uluaPushRay( L, GetMouseRay( mousePosition, *camera ) ); return 1; } /* -> 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 */ -int lcoreIsKeyDown( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); +int lcoreGetCameraMatrix( lua_State *L ) { + Camera3D *camera = uluaGetCamera3D( L, 1 ); - lua_pushboolean( L, IsKeyDown( key ) ); + uluaPushMatrix( L, GetCameraMatrix( *camera ) ); return 1; } /* -> 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 */ -int lcoreIsKeyReleased( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); +int lcoreGetCameraMatrix2D( lua_State *L ) { + Camera2D *camera = uluaGetCamera2D( L, 1 ); - lua_pushboolean( L, IsKeyReleased( key ) ); + uluaPushMatrix( L, GetCameraMatrix2D( *camera ) ); return 1; } /* -> released = RL.IsKeyUp( int key ) +> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera ) -Check if a key is NOT being pressed - -- Success return bool -*/ -int lcoreIsKeyUp( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsKeyUp( key ) ); - - return 1; -} - -/* -> keycode = RL.GetKeyPressed() - -Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty - -- Success return int -*/ -int lcoreGetKeyPressed( lua_State *L ) { - lua_pushinteger( L, GetKeyPressed() ); - - return 1; -} - -/* -> unicode = RL.GetCharPressed() - -Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty - -- Success return int -*/ -int lcoreGetCharPressed( lua_State *L ) { - lua_pushinteger( L, GetCharPressed() ); - - return 1; -} - -/* -> RL.SetExitKey( int key ) - -Set a custom key to exit program (default is ESC) -*/ -int lcoreSetExitKey( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); - - SetExitKey( key ); - - return 0; -} - -/* -> keyName = RL.GetKeyName( int key, int scancode ) - -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. - -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 -*/ -int lcoreGetKeyName( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); - int scancode = luaL_checkinteger( L, 2 ); - - const char *keyName = glfwGetKeyName( key, scancode ); - - if ( keyName != NULL ) { - lua_pushstring( L, keyName ); - } - else { - lua_pushnil( L ); - } - - return 1; -} - -/* -> scancode = RL.GetKeyScancode( int key ) - -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 -*/ -int lcoreGetKeyScancode( lua_State *L ) { - int key = luaL_checkinteger( L, 1 ); - - lua_pushinteger( L, glfwGetKeyScancode( key ) ); - - return 1; -} - -/* -## Core - Input-related Gamepad -*/ - -/* -> available = RL.IsGamepadAvailable( int gamepad ) - -Detect if a gamepad is available - -- Success return bool -*/ -int lcoreIsGamepadAvailable( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsGamepadAvailable( gamepad ) ); - - return 1; -} - -/* -> pressed = RL.IsGamepadButtonPressed( int gamepad, int button ) - -Detect if a gamepad button has been pressed once - -- Success return bool -*/ -int lcoreIsGamepadButtonPressed( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - int button = luaL_checkinteger( L, 2 ); - - lua_pushboolean( L, IsGamepadButtonPressed( gamepad, button ) ); - - return 1; -} - -/* -> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) - -Detect if a gamepad button is being pressed - -- Success return bool -*/ -int lcoreIsGamepadButtonDown( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - int button = luaL_checkinteger( L, 2 ); - - lua_pushboolean( L, IsGamepadButtonDown( gamepad, button ) ); - - return 1; -} - -/* -> released = RL.IsGamepadButtonReleased( int gamepad, int button ) - -Detect if a gamepad button has been released once - -- Success return bool -*/ -int lcoreIsGamepadButtonReleased( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - int button = luaL_checkinteger( L, 2 ); - - lua_pushboolean( L, IsGamepadButtonReleased( gamepad, button ) ); - - return 1; -} - -/* -> count = RL.GetGamepadAxisCount( int gamepad ) - -Return gamepad axis count for a gamepad - -- Success return int -*/ -int lcoreGetGamepadAxisCount( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - - lua_pushinteger( L, GetGamepadAxisCount( gamepad ) ); - - return 1; -} - -/* -> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) - -Return axis movement value for a gamepad axis - -- Success return float -*/ -int lcoreGetGamepadAxisMovement( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - int axis = luaL_checkinteger( L, 2 ); - - lua_pushnumber( L, GetGamepadAxisMovement( gamepad, axis ) ); - - return 1; -} - -/* -> name = RL.GetGamepadName( int gamepad ) - -Return gamepad internal name id - -- Success return string -*/ -int lcoreGetGamepadName( lua_State *L ) { - int gamepad = luaL_checkinteger( L, 1 ); - - lua_pushstring( L, GetGamepadName( gamepad ) ); - - return 1; -} - -/* -## Core - Input-related Mouse -*/ - -/* -> pressed = RL.IsMouseButtonPressed( int button ) - -Detect if a mouse button has been pressed once - -- Success return bool -*/ -int lcoreIsMouseButtonPressed( lua_State *L ) { - int button = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsMouseButtonPressed( button ) ); - - return 1; -} - -/* -> pressed = RL.IsMouseButtonDown( int button ) - -Detect if a mouse button is being pressed - -- Success return bool -*/ -int lcoreIsMouseButtonDown( lua_State *L ) { - int button = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsMouseButtonDown( button ) ); - - return 1; -} - -/* -> released = RL.IsMouseButtonReleased( int button ) - -Detect if a mouse button has been released once - -- Success return bool -*/ -int lcoreIsMouseButtonReleased( lua_State *L ) { - int button = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsMouseButtonReleased( button ) ); - - return 1; -} - -/* -> released = RL.IsMouseButtonUp( int button ) - -Check if a mouse button is NOT being pressed - -- Success return bool -*/ -int lcoreIsMouseButtonUp( lua_State *L ) { - int button = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsMouseButtonUp( button ) ); - - return 1; -} - -/* -> position = RL.GetMousePosition() - -Returns mouse position +Get the screen space position for a 3d world space position - Success return Vector2 */ -int lcoreGetMousePosition( lua_State *L ) { - uluaPushVector2( L, GetMousePosition() ); +int lcoreGetWorldToScreen( lua_State *L ) { + Vector3 position = uluaGetVector3( L, 1 ); + Camera3D *camera = uluaGetCamera3D( L, 2 ); + + uluaPushVector2( L, GetWorldToScreen( position, *camera ) ); return 1; } /* -> position = RL.GetMouseDelta() +> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size ) -Get mouse delta between frames +Get size position for a 3d world space position - Success return Vector2 */ -int lcoreGetMouseDelta( lua_State *L ) { - uluaPushVector2( L, GetMouseDelta() ); +int lcoreGetWorldToScreenEx( lua_State *L ) { + Vector3 position = uluaGetVector3( L, 1 ); + Camera3D *camera = uluaGetCamera3D( L, 2 ); + Vector2 size = uluaGetVector2( L, 3 ); + + uluaPushVector2( L, GetWorldToScreenEx( position, *camera, size.x, size.y ) ); return 1; } /* -> RL.SetMousePosition( Vector2 position ) +> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera ) -Set mouse position XY +Get the screen space position for a 2d camera world space position + +- Success return Vector2 */ -int lcoreSetMousePosition( lua_State *L ) { - Vector2 pos = uluaGetVector2( L, 1 ); +int lcoreGetWorldToScreen2D( lua_State *L ) { + Vector2 position = uluaGetVector2( L, 1 ); + Camera2D *camera = uluaGetCamera2D( L, 2 ); - SetMousePosition( pos.x, pos.y ); + uluaPushVector2( L, GetWorldToScreen2D( position, *camera ) ); + + return 1; +} + +/* +> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera ) + +Get the world space position for a 2d camera screen space position + +- Success return Vector2 +*/ +int lcoreGetScreenToWorld2D( lua_State *L ) { + Vector2 position = uluaGetVector2( L, 1 ); + Camera2D *camera = uluaGetCamera2D( L, 2 ); + + uluaPushVector2( L, GetScreenToWorld2D( position, *camera ) ); + + return 1; +} + +/* +## Core - Timing-related functions +*/ + +/* +> RL.SetTargetFPS( int fps ) + +Set target FPS (maximum) +*/ +int lcoreSetTargetFPS( lua_State *L ) { + int fps = luaL_checkinteger( L, 1 ); + + SetTargetFPS( fps ); return 0; } /* -> RL.SetMouseOffset( Vector2 offset ) +> FPS = RL.GetFPS() -Set mouse offset +Get current FPS + +- Success return int */ -int lcoreSetMouseOffset( lua_State *L ) { - Vector2 offset = uluaGetVector2( L, 1 ); +int lcoreGetFPS( lua_State *L ) { + lua_pushinteger( L, GetFPS() ); - SetMouseOffset( offset.x, offset.y ); - - return 0; + return 1; } /* -> RL.SetMouseScale( Vector2 scale ) +> delta = RL.GetFrameTime() -Set mouse scaling -*/ -int lcoreSetMouseScale( lua_State *L ) { - Vector2 scale = uluaGetVector2( L, 1 ); - - SetMouseScale( scale.x, scale.y ); - - return 0; -} - -/* -> movement = RL.GetMouseWheelMove() - -Returns mouse wheel movement Y +Get time in seconds for last frame drawn (Delta time) - Success return float */ -int lcoreGetMouseWheelMove( lua_State *L ) { - lua_pushnumber( L, GetMouseWheelMove() ); +int lcoreGetFrameTime( lua_State *L ) { + lua_pushnumber( L, GetFrameTime() ); return 1; } /* -> RL.SetMouseCursor( int cursor ) +> time = RL.GetTime() -Set mouse cursor +Get elapsed time in seconds since InitWindow() + +- Success return float */ -int lcoreSetMouseCursor( lua_State *L ) { - int cursor = luaL_checkinteger( L, 1 ); +int lcoreGetTime( lua_State *L ) { + lua_pushnumber( L, GetTime() ); - SetMouseCursor( cursor ); + return 1; +} + +/* +## Core - Misc +*/ + +/* +> RL.TakeScreenshot( string fileName ) + +Takes a screenshot of current screen (filename extension defines format) +*/ +int lcoreTakeScreenshot( lua_State *L ) { + TakeScreenshot( luaL_checkstring( L, 1 ) ); return 0; } /* -## Core - Input-related Touch +> RL.SetConfigFlags( int flags ) + +Setup init configuration flags (view FLAGS) */ +int lcoreSetConfigFlags( lua_State *L ) { + unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 ); -/* -> position = RL.GetTouchPosition( int index ) - -Get touch position XY for a touch point index (relative to screen size) - -- Success return Vector2 -*/ -int lcoreGetTouchPosition( lua_State *L ) { - int index = luaL_checkinteger( L, 1 ); - - uluaPushVector2( L, GetTouchPosition( index ) ); - - return 1; -} - -/* -> id = RL.GetTouchPointId( int index ) - -Get touch point identifier for given index - -- Success return int -*/ -int lcoreGetTouchPointId( lua_State *L ) { - int index = luaL_checkinteger( L, 1 ); - - lua_pushinteger( L, GetTouchPointId( index ) ); - - return 1; -} - -/* -> count = RL.GetTouchPointCount() - -Get touch point identifier for given index - -- Success return int -*/ -int lcoreGetTouchPointCount( lua_State *L ) { - lua_pushinteger( L, GetTouchPointCount() ); - - return 1; -} - -/* -## Core - Input-related Gestures -*/ - -/* -> RL.SetGesturesEnabled( unsigned int flags ) - -Enable a set of gestures using flags -*/ -int lcoreSetGesturesEnabled( lua_State *L ) { - unsigned int flags = (unsigned int)luaL_checkinteger( L, 1 ); - - SetGesturesEnabled( flags ); + SetConfigFlags( flag ); return 0; } /* -> detected = RL.IsGestureDetected( int gesture ) +> RL.TraceLog( int logLevel, string text ) -Check if a gesture have been detected +Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) +*/ +int lcoreTraceLog( lua_State *L ) { + int logLevel = luaL_checkinteger( L, 1 ); + + TraceLog( logLevel, "%s", luaL_checkstring( L, 2 ) ); + + return 0; +} + +/* +> RL.SetTraceLogLevel( int logLevel ) + +Set the current threshold (minimum) log level +*/ +int lcoreSetTraceLogLevel( lua_State *L ) { + int logLevel = luaL_checkinteger( L, 1 ); + + SetTraceLogLevel( logLevel ); + + return 0; +} + +/* +> RL.SetLogLevelInvalid( int logLevel ) + +Set the log level for bad function calls and invalid data formats. +*/ +int lcoreSetLogLevelInvalid( lua_State *L ) { + state->logLevelInvalid = luaL_checkinteger( L, 1 ); + + return 0; +} + +/* +> logLevel = RL.GetLogLevelInvalid() + +Get the log level for bad function calls and invalid data formats. + +- Success return int +*/ +int lcoreGetLogLevelInvalid( lua_State *L ) { + lua_pushinteger( L, state->logLevelInvalid ); + + return 1; +} + +/* +> RL.OpenURL( string url ) + +Open URL with default system browser (If available) +*/ +int lcoreOpenURL( lua_State *L ) { + OpenURL( luaL_checkstring( L, 1 ) ); + + return 0; +} + +/* +> enabled = RL.IsGCUnloadEnabled() + +Check if Lua garbage collection is set to unload object data - Success return bool */ -int lcoreIsGestureDetected( lua_State *L ) { - int gesture = luaL_checkinteger( L, 1 ); - - lua_pushboolean( L, IsGestureDetected( gesture ) ); +int lcoreIsGCUnloadEnabled( lua_State *L ) { + lua_pushboolean( L, state->gcUnload ); return 1; } /* -> gesture = RL.GetGestureDetected() - -Get latest detected gesture - -- Success return int -*/ -int lcoreGetGestureDetected( lua_State *L ) { - lua_pushinteger( L, GetGestureDetected() ); - - return 1; -} - -/* -> time = RL.GetGestureHoldDuration() - -Get gesture hold time in milliseconds - -- Success return float -*/ -int lcoreGetGestureHoldDuration( lua_State *L ) { - lua_pushnumber( L, GetGestureHoldDuration() ); - - return 1; -} - -/* -> vector = RL.GetGestureDragVector() - -Get gesture drag vector - -- Success return Vector2 -*/ -int lcoreGetGestureDragVector( lua_State *L ) { - uluaPushVector2( L, GetGestureDragVector() ); - - return 1; -} - -/* -> angle = RL.GetGestureDragAngle() - -Get gesture drag angle - -- Success return float -*/ -int lcoreGetGestureDragAngle( lua_State *L ) { - lua_pushnumber( L, GetGestureDragAngle() ); - - return 1; -} - -/* -> vector = RL.GetGesturePinchVector() - -Get gesture pinch delta - -- Success return Vector2 -*/ -int lcoreGetGesturePinchVector( lua_State *L ) { - uluaPushVector2( L, GetGesturePinchVector() ); - - return 1; -} - -/* -> angle = RL.GetGesturePinchAngle() - -Get gesture pinch angle - -- Success return float -*/ -int lcoreGetGesturePinchAngle( lua_State *L ) { - lua_pushnumber( L, GetGesturePinchAngle() ); - - return 1; -} - -/* -## Core - File +## Core - Files management functions */ /* @@ -2002,7 +1611,585 @@ int lcoreDecodeDataBase64( lua_State *L ) { } /* -## Core - Camera2D +## Core - Input-related functions: keyboard +*/ + +/* +> pressed = RL.IsKeyPressed( int key ) + +Detect if a key has been pressed once + +- Success return bool +*/ +int lcoreIsKeyPressed( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsKeyPressed( key ) ); + + return 1; +} + +/* +> pressed = RL.IsKeyDown( int key ) + +Detect if a key is being pressed + +- Success return bool +*/ +int lcoreIsKeyDown( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsKeyDown( key ) ); + + return 1; +} + +/* +> released = RL.IsKeyReleased( int key ) + +Detect if a key has been released once + +- Success return bool +*/ +int lcoreIsKeyReleased( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsKeyReleased( key ) ); + + return 1; +} + +/* +> released = RL.IsKeyUp( int key ) + +Check if a key is NOT being pressed + +- Success return bool +*/ +int lcoreIsKeyUp( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsKeyUp( key ) ); + + return 1; +} + +/* +> keycode = RL.GetKeyPressed() + +Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty + +- Success return int +*/ +int lcoreGetKeyPressed( lua_State *L ) { + lua_pushinteger( L, GetKeyPressed() ); + + return 1; +} + +/* +> unicode = RL.GetCharPressed() + +Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty + +- Success return int +*/ +int lcoreGetCharPressed( lua_State *L ) { + lua_pushinteger( L, GetCharPressed() ); + + return 1; +} + +/* +> RL.SetExitKey( int key ) + +Set a custom key to exit program (default is ESC) +*/ +int lcoreSetExitKey( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + SetExitKey( key ); + + return 0; +} + +/* +> keyName = RL.GetKeyName( int key, int scancode ) + +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. + +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 +*/ +int lcoreGetKeyName( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + int scancode = luaL_checkinteger( L, 2 ); + + const char *keyName = glfwGetKeyName( key, scancode ); + + if ( keyName != NULL ) { + lua_pushstring( L, keyName ); + } + else { + lua_pushnil( L ); + } + + return 1; +} + +/* +> scancode = RL.GetKeyScancode( int key ) + +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 +*/ +int lcoreGetKeyScancode( lua_State *L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushinteger( L, glfwGetKeyScancode( key ) ); + + return 1; +} + +/* +## Core - Input-related functions: gamepads +*/ + +/* +> available = RL.IsGamepadAvailable( int gamepad ) + +Detect if a gamepad is available + +- Success return bool +*/ +int lcoreIsGamepadAvailable( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsGamepadAvailable( gamepad ) ); + + return 1; +} + +/* +> pressed = RL.IsGamepadButtonPressed( int gamepad, int button ) + +Detect if a gamepad button has been pressed once + +- Success return bool +*/ +int lcoreIsGamepadButtonPressed( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + int button = luaL_checkinteger( L, 2 ); + + lua_pushboolean( L, IsGamepadButtonPressed( gamepad, button ) ); + + return 1; +} + +/* +> pressed = RL.IsGamepadButtonDown( int gamepad, int button ) + +Detect if a gamepad button is being pressed + +- Success return bool +*/ +int lcoreIsGamepadButtonDown( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + int button = luaL_checkinteger( L, 2 ); + + lua_pushboolean( L, IsGamepadButtonDown( gamepad, button ) ); + + return 1; +} + +/* +> released = RL.IsGamepadButtonReleased( int gamepad, int button ) + +Detect if a gamepad button has been released once + +- Success return bool +*/ +int lcoreIsGamepadButtonReleased( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + int button = luaL_checkinteger( L, 2 ); + + lua_pushboolean( L, IsGamepadButtonReleased( gamepad, button ) ); + + return 1; +} + +/* +> count = RL.GetGamepadAxisCount( int gamepad ) + +Return gamepad axis count for a gamepad + +- Success return int +*/ +int lcoreGetGamepadAxisCount( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + + lua_pushinteger( L, GetGamepadAxisCount( gamepad ) ); + + return 1; +} + +/* +> value = RL.GetGamepadAxisMovement( int gamepad, int axis ) + +Return axis movement value for a gamepad axis + +- Success return float +*/ +int lcoreGetGamepadAxisMovement( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + int axis = luaL_checkinteger( L, 2 ); + + lua_pushnumber( L, GetGamepadAxisMovement( gamepad, axis ) ); + + return 1; +} + +/* +> name = RL.GetGamepadName( int gamepad ) + +Return gamepad internal name id + +- Success return string +*/ +int lcoreGetGamepadName( lua_State *L ) { + int gamepad = luaL_checkinteger( L, 1 ); + + lua_pushstring( L, GetGamepadName( gamepad ) ); + + return 1; +} + +/* +## Core - Input-related functions: mouse +*/ + +/* +> pressed = RL.IsMouseButtonPressed( int button ) + +Detect if a mouse button has been pressed once + +- Success return bool +*/ +int lcoreIsMouseButtonPressed( lua_State *L ) { + int button = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsMouseButtonPressed( button ) ); + + return 1; +} + +/* +> pressed = RL.IsMouseButtonDown( int button ) + +Detect if a mouse button is being pressed + +- Success return bool +*/ +int lcoreIsMouseButtonDown( lua_State *L ) { + int button = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsMouseButtonDown( button ) ); + + return 1; +} + +/* +> released = RL.IsMouseButtonReleased( int button ) + +Detect if a mouse button has been released once + +- Success return bool +*/ +int lcoreIsMouseButtonReleased( lua_State *L ) { + int button = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsMouseButtonReleased( button ) ); + + return 1; +} + +/* +> released = RL.IsMouseButtonUp( int button ) + +Check if a mouse button is NOT being pressed + +- Success return bool +*/ +int lcoreIsMouseButtonUp( lua_State *L ) { + int button = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsMouseButtonUp( button ) ); + + return 1; +} + +/* +> position = RL.GetMousePosition() + +Returns mouse position + +- Success return Vector2 +*/ +int lcoreGetMousePosition( lua_State *L ) { + uluaPushVector2( L, GetMousePosition() ); + + return 1; +} + +/* +> position = RL.GetMouseDelta() + +Get mouse delta between frames + +- Success return Vector2 +*/ +int lcoreGetMouseDelta( lua_State *L ) { + uluaPushVector2( L, GetMouseDelta() ); + + return 1; +} + +/* +> RL.SetMousePosition( Vector2 position ) + +Set mouse position XY +*/ +int lcoreSetMousePosition( lua_State *L ) { + Vector2 pos = uluaGetVector2( L, 1 ); + + SetMousePosition( pos.x, pos.y ); + + return 0; +} + +/* +> RL.SetMouseOffset( Vector2 offset ) + +Set mouse offset +*/ +int lcoreSetMouseOffset( lua_State *L ) { + Vector2 offset = uluaGetVector2( L, 1 ); + + SetMouseOffset( offset.x, offset.y ); + + return 0; +} + +/* +> RL.SetMouseScale( Vector2 scale ) + +Set mouse scaling +*/ +int lcoreSetMouseScale( lua_State *L ) { + Vector2 scale = uluaGetVector2( L, 1 ); + + SetMouseScale( scale.x, scale.y ); + + return 0; +} + +/* +> movement = RL.GetMouseWheelMove() + +Returns mouse wheel movement Y + +- Success return float +*/ +int lcoreGetMouseWheelMove( lua_State *L ) { + lua_pushnumber( L, GetMouseWheelMove() ); + + return 1; +} + +/* +> RL.SetMouseCursor( int cursor ) + +Set mouse cursor +*/ +int lcoreSetMouseCursor( lua_State *L ) { + int cursor = luaL_checkinteger( L, 1 ); + + SetMouseCursor( cursor ); + + return 0; +} + +/* +## Core - Input-related functions: touch +*/ + +/* +> position = RL.GetTouchPosition( int index ) + +Get touch position XY for a touch point index (relative to screen size) + +- Success return Vector2 +*/ +int lcoreGetTouchPosition( lua_State *L ) { + int index = luaL_checkinteger( L, 1 ); + + uluaPushVector2( L, GetTouchPosition( index ) ); + + return 1; +} + +/* +> id = RL.GetTouchPointId( int index ) + +Get touch point identifier for given index + +- Success return int +*/ +int lcoreGetTouchPointId( lua_State *L ) { + int index = luaL_checkinteger( L, 1 ); + + lua_pushinteger( L, GetTouchPointId( index ) ); + + return 1; +} + +/* +> count = RL.GetTouchPointCount() + +Get touch point identifier for given index + +- Success return int +*/ +int lcoreGetTouchPointCount( lua_State *L ) { + lua_pushinteger( L, GetTouchPointCount() ); + + return 1; +} + +/* +## Core - Input-related functions: gestures +*/ + +/* +> RL.SetGesturesEnabled( unsigned int flags ) + +Enable a set of gestures using flags +*/ +int lcoreSetGesturesEnabled( lua_State *L ) { + unsigned int flags = (unsigned int)luaL_checkinteger( L, 1 ); + + SetGesturesEnabled( flags ); + + return 0; +} + +/* +> detected = RL.IsGestureDetected( int gesture ) + +Check if a gesture have been detected + +- Success return bool +*/ +int lcoreIsGestureDetected( lua_State *L ) { + int gesture = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsGestureDetected( gesture ) ); + + return 1; +} + +/* +> gesture = RL.GetGestureDetected() + +Get latest detected gesture + +- Success return int +*/ +int lcoreGetGestureDetected( lua_State *L ) { + lua_pushinteger( L, GetGestureDetected() ); + + return 1; +} + +/* +> time = RL.GetGestureHoldDuration() + +Get gesture hold time in milliseconds + +- Success return float +*/ +int lcoreGetGestureHoldDuration( lua_State *L ) { + lua_pushnumber( L, GetGestureHoldDuration() ); + + return 1; +} + +/* +> vector = RL.GetGestureDragVector() + +Get gesture drag vector + +- Success return Vector2 +*/ +int lcoreGetGestureDragVector( lua_State *L ) { + uluaPushVector2( L, GetGestureDragVector() ); + + return 1; +} + +/* +> angle = RL.GetGestureDragAngle() + +Get gesture drag angle + +- Success return float +*/ +int lcoreGetGestureDragAngle( lua_State *L ) { + lua_pushnumber( L, GetGestureDragAngle() ); + + return 1; +} + +/* +> vector = RL.GetGesturePinchVector() + +Get gesture pinch delta + +- Success return Vector2 +*/ +int lcoreGetGesturePinchVector( lua_State *L ) { + uluaPushVector2( L, GetGesturePinchVector() ); + + return 1; +} + +/* +> angle = RL.GetGesturePinchAngle() + +Get gesture pinch angle + +- Success return float +*/ +int lcoreGetGesturePinchAngle( lua_State *L ) { + lua_pushnumber( L, GetGesturePinchAngle() ); + + return 1; +} + +/* +## Core - Camera2D System functions */ /* @@ -2025,30 +2212,6 @@ int lcoreCreateCamera2D( lua_State *L ) { return 1; } -/* -> RL.BeginMode2D( camera2D camera ) - -Begin 2D mode with custom camera (2D) -*/ -int lcoreBeginMode2D( lua_State *L ) { - Camera2D *camera = uluaGetCamera2D( L, 1 ); - - BeginMode2D( *camera ); - - return 0; -} - -/* -> RL.EndMode2D() - -Ends 2D mode with custom camera -*/ -int lcoreEndMode2D( lua_State *L ) { - EndMode2D(); - - return 0; -} - /* > RL.SetCamera2DTarget( camera2D camera, Vector2 target ) @@ -2163,7 +2326,7 @@ int lcoreGetCamera2DZoom( lua_State *L ) { } /* -## Core - Camera3D +## Core - Camera3D System functions */ /* @@ -2187,30 +2350,6 @@ int lcoreCreateCamera3D( lua_State *L ) { return 1; } -/* -> RL.BeginMode3D( camera3D camera ) - -Begin 3D mode with custom camera (3D) -*/ -int lcoreBeginMode3D( lua_State *L ) { - Camera3D *camera = uluaGetCamera3D( L, 1 ); - - BeginMode3D( *camera ); - - return 0; -} - -/* -> RL.EndMode3D() - -Ends 3D mode and returns to default 2D orthographic mode -*/ -int lcoreEndMode3D( lua_State *L ) { - EndMode3D(); - - return 0; -} - /* > RL.SetCamera3DPosition( camera3D camera, Vector3 position ) @@ -2577,122 +2716,7 @@ int lcoreUpdateCamera3DPro( lua_State *L ) { } /* -## Core - Screen-space -*/ - -/* -> ray = RL.GetMouseRay( Vector2 mousePosition, Camera3D camera ) - -Get a ray trace from mouse position - -- Success return Ray -*/ -int lcoreGetMouseRay( lua_State *L ) { - Vector2 mousePosition = uluaGetVector2( L, 1 ); - Camera3D *camera = uluaGetCamera3D( L, 2 ); - - uluaPushRay( L, GetMouseRay( mousePosition, *camera ) ); - - return 1; -} - -/* -> matrix = RL.GetCameraMatrix( Camera3D camera ) - -Get camera transform matrix (view matrix) - -- Success return Matrix -*/ -int lcoreGetCameraMatrix( lua_State *L ) { - Camera3D *camera = uluaGetCamera3D( L, 1 ); - - uluaPushMatrix( L, GetCameraMatrix( *camera ) ); - - return 1; -} - -/* -> matrix = RL.GetCameraMatrix2D( Camera2D camera ) - -Get camera 2d transform matrix - -- Success return Matrix -*/ -int lcoreGetCameraMatrix2D( lua_State *L ) { - Camera2D *camera = uluaGetCamera2D( L, 1 ); - - uluaPushMatrix( L, GetCameraMatrix2D( *camera ) ); - - return 1; -} - -/* -> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera ) - -Get the screen space position for a 3d world space position - -- Success return Vector2 -*/ -int lcoreGetWorldToScreen( lua_State *L ) { - Vector3 position = uluaGetVector3( L, 1 ); - Camera3D *camera = uluaGetCamera3D( L, 2 ); - - uluaPushVector2( L, GetWorldToScreen( position, *camera ) ); - - return 1; -} - -/* -> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size ) - -Get size position for a 3d world space position - -- Success return Vector2 -*/ -int lcoreGetWorldToScreenEx( lua_State *L ) { - Vector3 position = uluaGetVector3( L, 1 ); - Camera3D *camera = uluaGetCamera3D( L, 2 ); - Vector2 size = uluaGetVector2( L, 3 ); - - uluaPushVector2( L, GetWorldToScreenEx( position, *camera, size.x, size.y ) ); - - return 1; -} - -/* -> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera ) - -Get the screen space position for a 2d camera world space position - -- Success return Vector2 -*/ -int lcoreGetWorldToScreen2D( lua_State *L ) { - Vector2 position = uluaGetVector2( L, 1 ); - Camera2D *camera = uluaGetCamera2D( L, 2 ); - - uluaPushVector2( L, GetWorldToScreen2D( position, *camera ) ); - - return 1; -} - -/* -> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera ) - -Get the world space position for a 2d camera screen space position - -- Success return Vector2 -*/ -int lcoreGetScreenToWorld2D( lua_State *L ) { - Vector2 position = uluaGetVector2( L, 1 ); - Camera2D *camera = uluaGetCamera2D( L, 2 ); - - uluaPushVector2( L, GetScreenToWorld2D( position, *camera ) ); - - return 1; -} - -/* -## Core - Buffer +## Core - Buffer management functions */ /* diff --git a/src/lua_core.c b/src/lua_core.c index 89ca581..b32fd57 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1500,7 +1500,7 @@ void luaRegister() { lua_getglobal( L, "RL" ); /* Core. */ - /* Window. */ + /* Window-related functions. */ assingGlobalFunction( "IsWindowReady", lcoreIsWindowReady ); assingGlobalFunction( "IsWindowFullscreen", lcoreIsWindowFullscreen ); assingGlobalFunction( "IsWindowHidden", lcoreIsWindowHidden ); @@ -1533,41 +1533,33 @@ void luaRegister() { assingGlobalFunction( "CloseWindow", lcoreCloseWindow ); assingGlobalFunction( "SetClipboardText", lcoreSetClipboardText ); assingGlobalFunction( "GetClipboardText", lcoreGetClipboardText ); - /* Timing. */ - assingGlobalFunction( "SetTargetFPS", lcoreSetTargetFPS ); - assingGlobalFunction( "GetFPS", lcoreGetFPS ); - assingGlobalFunction( "GetFrameTime", lcoreGetFrameTime ); - assingGlobalFunction( "GetTime", lcoreGetTime ); - /* Misc. */ - assingGlobalFunction( "TakeScreenshot", lcoreTakeScreenshot ); - assingGlobalFunction( "SetConfigFlags", lcoreSetConfigFlags ); - assingGlobalFunction( "TraceLog", lcoreTraceLog ); - assingGlobalFunction( "SetTraceLogLevel", lcoreSetTraceLogLevel ); - assingGlobalFunction( "SetLogLevelInvalid", lcoreSetLogLevelInvalid ); - assingGlobalFunction( "GetLogLevelInvalid", lcoreGetLogLevelInvalid ); - assingGlobalFunction( "OpenURL", lcoreOpenURL ); - assingGlobalFunction( "IsGCUnloadEnabled", lcoreIsGCUnloadEnabled ); - /* Cursor. */ + /* Cursor-related functions. */ assingGlobalFunction( "ShowCursor", lcoreShowCursor ); assingGlobalFunction( "HideCursor", lcoreHideCursor ); assingGlobalFunction( "IsCursorHidden", lcoreIsCursorHidden ); assingGlobalFunction( "EnableCursor", lcoreEnableCursor ); assingGlobalFunction( "DisableCursor", lcoreDisableCursor ); assingGlobalFunction( "IsCursorOnScreen", lcoreIsCursorOnScreen ); - /* Drawing. */ + /* Drawing-related functions. */ assingGlobalFunction( "ClearBackground", lcoreClearBackground ); assingGlobalFunction( "BeginDrawing", lcoreBeginDrawing ); assingGlobalFunction( "EndDrawing", lcoreEndDrawing ); + assingGlobalFunction( "BeginMode2D", lcoreBeginMode2D ); + assingGlobalFunction( "EndMode2D", lcoreEndMode2D ); + assingGlobalFunction( "BeginMode3D", lcoreBeginMode3D ); + assingGlobalFunction( "EndMode3D", lcoreEndMode3D ); + assingGlobalFunction( "BeginTextureMode", lcoreBeginTextureMode ); + assingGlobalFunction( "EndTextureMode", lcoreEndTextureMode ); + assingGlobalFunction( "BeginShaderMode", lcoreBeginShaderMode ); + assingGlobalFunction( "EndShaderMode", lcoreEndShaderMode ); assingGlobalFunction( "BeginBlendMode", lcoreBeginBlendMode ); assingGlobalFunction( "EndBlendMode", lcoreEndBlendMode ); assingGlobalFunction( "BeginScissorMode", lcoreBeginScissorMode ); assingGlobalFunction( "EndScissorMode", lcoreEndScissorMode ); - /* Shader. */ + /* Shader management functions. */ assingGlobalFunction( "LoadShader", lcoreLoadShader ); assingGlobalFunction( "LoadShaderFromMemory", lcoreLoadShaderFromMemory ); assingGlobalFunction( "IsShaderReady", lcoreIsShaderReady ); - assingGlobalFunction( "BeginShaderMode", lcoreBeginShaderMode ); - assingGlobalFunction( "EndShaderMode", lcoreEndShaderMode ); assingGlobalFunction( "GetShaderLocation", lcoreGetShaderLocation ); assingGlobalFunction( "GetShaderLocationAttrib", lcoreGetShaderLocationAttrib ); assingGlobalFunction( "SetShaderLocationIndex", lcoreSetShaderLocationIndex ); @@ -1577,7 +1569,29 @@ void luaRegister() { assingGlobalFunction( "SetShaderValue", lcoreSetShaderValue ); assingGlobalFunction( "SetShaderValueV", lcoreSetShaderValueV ); assingGlobalFunction( "UnloadShader", lcoreUnloadShader ); - /* File. */ + /* Screen-space-related functions. */ + assingGlobalFunction( "GetMouseRay", lcoreGetMouseRay ); + assingGlobalFunction( "GetCameraMatrix", lcoreGetCameraMatrix ); + assingGlobalFunction( "GetCameraMatrix2D", lcoreGetCameraMatrix2D ); + assingGlobalFunction( "GetWorldToScreen", lcoreGetWorldToScreen ); + assingGlobalFunction( "GetWorldToScreenEx", lcoreGetWorldToScreenEx ); + assingGlobalFunction( "GetWorldToScreen2D", lcoreGetWorldToScreen2D ); + assingGlobalFunction( "GetScreenToWorld2D", lcoreGetScreenToWorld2D ); + /* Timing-related functions. */ + assingGlobalFunction( "SetTargetFPS", lcoreSetTargetFPS ); + assingGlobalFunction( "GetFPS", lcoreGetFPS ); + assingGlobalFunction( "GetFrameTime", lcoreGetFrameTime ); + assingGlobalFunction( "GetTime", lcoreGetTime ); + /* Misc. functions. */ + assingGlobalFunction( "TakeScreenshot", lcoreTakeScreenshot ); + assingGlobalFunction( "SetConfigFlags", lcoreSetConfigFlags ); + assingGlobalFunction( "TraceLog", lcoreTraceLog ); + assingGlobalFunction( "SetTraceLogLevel", lcoreSetTraceLogLevel ); + assingGlobalFunction( "SetLogLevelInvalid", lcoreSetLogLevelInvalid ); + assingGlobalFunction( "GetLogLevelInvalid", lcoreGetLogLevelInvalid ); + assingGlobalFunction( "OpenURL", lcoreOpenURL ); + assingGlobalFunction( "IsGCUnloadEnabled", lcoreIsGCUnloadEnabled ); + /* Files management functions. */ assingGlobalFunction( "GetBasePath", lcoreGetBasePath ); assingGlobalFunction( "FileExists", lcoreFileExists ); assingGlobalFunction( "DirectoryExists", lcoreDirectoryExists ); @@ -1601,10 +1615,51 @@ void luaRegister() { assingGlobalFunction( "DecompressData", lcoreDecompressData ); assingGlobalFunction( "EncodeDataBase64", lcoreEncodeDataBase64 ); assingGlobalFunction( "DecodeDataBase64", lcoreDecodeDataBase64 ); - /* Camera2D. */ + /* Input-related functions: keyboard. */ + assingGlobalFunction( "IsKeyPressed", lcoreIsKeyPressed ); + assingGlobalFunction( "IsKeyDown", lcoreIsKeyDown ); + assingGlobalFunction( "IsKeyReleased", lcoreIsKeyReleased ); + assingGlobalFunction( "IsKeyUp", lcoreIsKeyUp ); + assingGlobalFunction( "GetKeyPressed", lcoreGetKeyPressed ); + assingGlobalFunction( "GetCharPressed", lcoreGetCharPressed ); + assingGlobalFunction( "SetExitKey", lcoreSetExitKey ); + assingGlobalFunction( "GetKeyName", lcoreGetKeyName ); + assingGlobalFunction( "GetKeyScancode", lcoreGetKeyScancode ); + /* Input-related functions: gamepads. */ + assingGlobalFunction( "IsGamepadAvailable", lcoreIsGamepadAvailable ); + assingGlobalFunction( "IsGamepadButtonPressed", lcoreIsGamepadButtonPressed ); + assingGlobalFunction( "IsGamepadButtonDown", lcoreIsGamepadButtonDown ); + assingGlobalFunction( "IsGamepadButtonReleased", lcoreIsGamepadButtonReleased ); + assingGlobalFunction( "GetGamepadAxisCount", lcoreGetGamepadAxisCount ); + assingGlobalFunction( "GetGamepadAxisMovement", lcoreGetGamepadAxisMovement ); + assingGlobalFunction( "GetGamepadName", lcoreGetGamepadName ); + /* Input-related functions: mouse. */ + assingGlobalFunction( "IsMouseButtonPressed", lcoreIsMouseButtonPressed ); + assingGlobalFunction( "IsMouseButtonDown", lcoreIsMouseButtonDown ); + assingGlobalFunction( "IsMouseButtonReleased", lcoreIsMouseButtonReleased ); + assingGlobalFunction( "IsMouseButtonUp", lcoreIsMouseButtonUp ); + assingGlobalFunction( "GetMousePosition", lcoreGetMousePosition ); + assingGlobalFunction( "GetMouseDelta", lcoreGetMouseDelta ); + assingGlobalFunction( "SetMousePosition", lcoreSetMousePosition ); + assingGlobalFunction( "SetMouseOffset", lcoreSetMouseOffset ); + assingGlobalFunction( "SetMouseScale", lcoreSetMouseScale ); + assingGlobalFunction( "GetMouseWheelMove", lcoreGetMouseWheelMove ); + assingGlobalFunction( "SetMouseCursor", lcoreSetMouseCursor ); + /* Input-related functions: touch */ + assingGlobalFunction( "GetTouchPosition", lcoreGetTouchPosition ); + assingGlobalFunction( "GetTouchPointId", lcoreGetTouchPointId ); + assingGlobalFunction( "GetTouchPointCount", lcoreGetTouchPointCount ); + /* Input-related functions: gestures. */ + assingGlobalFunction( "SetGesturesEnabled", lcoreSetGesturesEnabled ); + assingGlobalFunction( "IsGestureDetected", lcoreIsGestureDetected ); + assingGlobalFunction( "GetGestureDetected", lcoreGetGestureDetected ); + assingGlobalFunction( "GetGestureHoldDuration", lcoreGetGestureHoldDuration ); + assingGlobalFunction( "GetGestureDragVector", lcoreGetGestureDragVector ); + assingGlobalFunction( "GetGestureDragAngle", lcoreGetGestureDragAngle ); + assingGlobalFunction( "GetGesturePinchVector", lcoreGetGesturePinchVector ); + assingGlobalFunction( "GetGesturePinchAngle", lcoreGetGesturePinchAngle ); + /* Camera2D System functions. */ assingGlobalFunction( "CreateCamera2D", lcoreCreateCamera2D ); - assingGlobalFunction( "BeginMode2D", lcoreBeginMode2D ); - assingGlobalFunction( "EndMode2D", lcoreEndMode2D ); assingGlobalFunction( "SetCamera2DTarget", lcoreSetCamera2DTarget ); assingGlobalFunction( "SetCamera2DOffset", lcoreSetCamera2DOffset ); assingGlobalFunction( "SetCamera2DRotation", lcoreSetCamera2DRotation ); @@ -1613,10 +1668,8 @@ void luaRegister() { assingGlobalFunction( "GetCamera2DOffset", lcoreGetCamera2DOffset ); assingGlobalFunction( "GetCamera2DRotation", lcoreGetCamera2DRotation ); assingGlobalFunction( "GetCamera2DZoom", lcoreGetCamera2DZoom ); - /* Camera3D. */ + /* Camera3D System functions. */ assingGlobalFunction( "CreateCamera3D", lcoreCreateCamera3D ); - assingGlobalFunction( "BeginMode3D", lcoreBeginMode3D ); - assingGlobalFunction( "EndMode3D", lcoreEndMode3D ); assingGlobalFunction( "SetCamera3DPosition", lcoreSetCamera3DPosition ); assingGlobalFunction( "SetCamera3DTarget", lcoreSetCamera3DTarget ); assingGlobalFunction( "SetCamera3DUp", lcoreSetCamera3DUp ); @@ -1641,58 +1694,7 @@ void luaRegister() { assingGlobalFunction( "GetCamera3DProjectionMatrix", lcoreGetCamera3DProjectionMatrix ); assingGlobalFunction( "UpdateCamera3D", lcoreUpdateCamera3D ); assingGlobalFunction( "UpdateCamera3DPro", lcoreUpdateCamera3DPro ); - /* Input-related Keyboard. */ - assingGlobalFunction( "IsKeyPressed", lcoreIsKeyPressed ); - assingGlobalFunction( "IsKeyDown", lcoreIsKeyDown ); - assingGlobalFunction( "IsKeyReleased", lcoreIsKeyReleased ); - assingGlobalFunction( "IsKeyUp", lcoreIsKeyUp ); - assingGlobalFunction( "GetKeyPressed", lcoreGetKeyPressed ); - assingGlobalFunction( "GetCharPressed", lcoreGetCharPressed ); - assingGlobalFunction( "SetExitKey", lcoreSetExitKey ); - assingGlobalFunction( "GetKeyName", lcoreGetKeyName ); - assingGlobalFunction( "GetKeyScancode", lcoreGetKeyScancode ); - /* Input-related Gamepad. */ - assingGlobalFunction( "IsGamepadAvailable", lcoreIsGamepadAvailable ); - assingGlobalFunction( "IsGamepadButtonPressed", lcoreIsGamepadButtonPressed ); - assingGlobalFunction( "IsGamepadButtonDown", lcoreIsGamepadButtonDown ); - assingGlobalFunction( "IsGamepadButtonReleased", lcoreIsGamepadButtonReleased ); - assingGlobalFunction( "GetGamepadAxisCount", lcoreGetGamepadAxisCount ); - assingGlobalFunction( "GetGamepadAxisMovement", lcoreGetGamepadAxisMovement ); - assingGlobalFunction( "GetGamepadName", lcoreGetGamepadName ); - /* Input-related Mouse. */ - assingGlobalFunction( "IsMouseButtonPressed", lcoreIsMouseButtonPressed ); - assingGlobalFunction( "IsMouseButtonDown", lcoreIsMouseButtonDown ); - assingGlobalFunction( "IsMouseButtonReleased", lcoreIsMouseButtonReleased ); - assingGlobalFunction( "IsMouseButtonUp", lcoreIsMouseButtonUp ); - assingGlobalFunction( "GetMousePosition", lcoreGetMousePosition ); - assingGlobalFunction( "GetMouseDelta", lcoreGetMouseDelta ); - assingGlobalFunction( "SetMousePosition", lcoreSetMousePosition ); - assingGlobalFunction( "SetMouseOffset", lcoreSetMouseOffset ); - assingGlobalFunction( "SetMouseScale", lcoreSetMouseScale ); - assingGlobalFunction( "GetMouseWheelMove", lcoreGetMouseWheelMove ); - assingGlobalFunction( "SetMouseCursor", lcoreSetMouseCursor ); - /* Input-related Touch */ - assingGlobalFunction( "GetTouchPosition", lcoreGetTouchPosition ); - assingGlobalFunction( "GetTouchPointId", lcoreGetTouchPointId ); - assingGlobalFunction( "GetTouchPointCount", lcoreGetTouchPointCount ); - /* Input-related Gestures. */ - assingGlobalFunction( "SetGesturesEnabled", lcoreSetGesturesEnabled ); - assingGlobalFunction( "IsGestureDetected", lcoreIsGestureDetected ); - assingGlobalFunction( "GetGestureDetected", lcoreGetGestureDetected ); - assingGlobalFunction( "GetGestureHoldDuration", lcoreGetGestureHoldDuration ); - assingGlobalFunction( "GetGestureDragVector", lcoreGetGestureDragVector ); - assingGlobalFunction( "GetGestureDragAngle", lcoreGetGestureDragAngle ); - assingGlobalFunction( "GetGesturePinchVector", lcoreGetGesturePinchVector ); - assingGlobalFunction( "GetGesturePinchAngle", lcoreGetGesturePinchAngle ); - /* Screen-space. */ - assingGlobalFunction( "GetMouseRay", lcoreGetMouseRay ); - assingGlobalFunction( "GetCameraMatrix", lcoreGetCameraMatrix ); - assingGlobalFunction( "GetCameraMatrix2D", lcoreGetCameraMatrix2D ); - assingGlobalFunction( "GetWorldToScreen", lcoreGetWorldToScreen ); - assingGlobalFunction( "GetWorldToScreenEx", lcoreGetWorldToScreenEx ); - assingGlobalFunction( "GetWorldToScreen2D", lcoreGetWorldToScreen2D ); - assingGlobalFunction( "GetScreenToWorld2D", lcoreGetScreenToWorld2D ); - /* Buffer. */ + /* Buffer management functions. */ assingGlobalFunction( "LoadBuffer", lcoreLoadBuffer ); assingGlobalFunction( "UnloadBuffer", lcoreUnloadBuffer ); assingGlobalFunction( "GetBufferData", lcoreGetBufferData ); @@ -1829,8 +1831,6 @@ void luaRegister() { assingGlobalFunction( "DrawTextureRec", ltexturesDrawTextureRec ); assingGlobalFunction( "DrawTexturePro", ltexturesDrawTexturePro ); assingGlobalFunction( "DrawTextureNPatch", ltexturesDrawTextureNPatch ); - assingGlobalFunction( "BeginTextureMode", ltexturesBeginTextureMode ); - assingGlobalFunction( "EndTextureMode", ltexturesEndTextureMode ); /* Texture Configuration. */ assingGlobalFunction( "GenTextureMipmaps", ltexturesGenTextureMipmaps ); assingGlobalFunction( "SetTextureFilter", ltexturesSetTextureFilter ); diff --git a/src/textures.c b/src/textures.c index f31d4d8..2274aa9 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1258,30 +1258,6 @@ int ltexturesDrawTextureNPatch( lua_State *L ) { return 0; } -/* -> RL.BeginTextureMode( RenderTexture target ) - -Begin drawing to render texture -*/ -int ltexturesBeginTextureMode( lua_State *L ) { - RenderTexture *renderTexture = uluaGetRenderTexture( L, 1 ); - - BeginTextureMode( *renderTexture ); - - return 0; -} - -/* -> RL.EndTextureMode() - -Ends drawing to render texture -*/ -int ltexturesEndTextureMode( lua_State *L ) { - EndTextureMode(); - - return 0; -} - /* ## Textures - Texture Configuration */