diff options
| author | Ray <[email protected]> | 2023-02-14 20:00:51 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-02-14 20:00:51 +0100 |
| commit | ea590c44a967075b3f6b420fa76e6387075ecf1d (patch) | |
| tree | b456de45fef83507415dcc309c05e64cb9232946 /src/rcore.c | |
| parent | 73989a49817225f11f547d270598e93745bf7df0 (diff) | |
| download | raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.tar.gz raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.zip | |
REVIEWED: Camera redesign PR
Diffstat (limited to 'src/rcore.c')
| -rw-r--r-- | src/rcore.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rcore.c b/src/rcore.c index 83a70632..f81d2318 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -925,6 +925,8 @@ void InitWindow(int width, int height, const char *title) CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f; CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f; + + SetMousePosition((int)CORE.Input.Mouse.currentPosition.x, (int)CORE.Input.Mouse.currentPosition.x); #if defined(SUPPORT_EVENTS_AUTOMATION) events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent)); @@ -2024,6 +2026,13 @@ void DisableCursor(void) { #if defined(PLATFORM_DESKTOP) glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED); + + // Set cursor position in the middle of screen and update delta accordingly + SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); + CORE.Input.Mouse.currentPosition.x = CORE.Window.screen.width/2; + CORE.Input.Mouse.currentPosition.y = CORE.Window.screen.width/2; + CORE.Input.Mouse.previousPosition.x = CORE.Input.Mouse.currentPosition.x; + CORE.Input.Mouse.previousPosition.y = CORE.Input.Mouse.currentPosition.y; #endif #if defined(PLATFORM_WEB) emscripten_request_pointerlock("#canvas", 1); @@ -2189,7 +2198,7 @@ void EndMode2D(void) } // Initializes 3D mode with custom camera (3D) -void BeginMode3D(Camera3D camera) +void BeginMode3D(Camera camera) { rlDrawRenderBatchActive(); // Update and draw internal render batch @@ -3788,7 +3797,7 @@ Vector2 GetMousePosition(void) // Get mouse delta between frames Vector2 GetMouseDelta(void) { - Vector2 delta = {0}; + Vector2 delta = { 0 }; delta.x = CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x; delta.y = CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y; |
