diff options
Diffstat (limited to 'src/window')
-rw-r--r-- | src/window/Events.cpp | 3 | ||||
-rw-r--r-- | src/window/Window.cpp | 10 | ||||
-rw-r--r-- | src/window/Window.hpp | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/window/Events.cpp b/src/window/Events.cpp index 8799853..f6ffe61 100644 --- a/src/window/Events.cpp +++ b/src/window/Events.cpp @@ -78,6 +78,9 @@ void Events::KeyHandle(int key, int scancode, int action, int mode) void Events::CursorPosHandle(double xpos, double ypos) { + if(master->GetCursorMode() == GLFW_CURSOR_NORMAL) + return; + delta_x = xpos - x; delta_y = ypos - y; diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 7aef326..bedeaf9 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -32,6 +32,7 @@ Window *Window::Initialize(int width, int height, const char *title) Window *w = new Window(win, width, height); w->MakeContextCurrent(); + w->ToggleCursorMode(); return w; } @@ -49,8 +50,15 @@ void Window::MakeContextCurrent() glViewport(0, 0, width, height); } -void Window::SetCursorMode(int mode) +int Window::GetCursorMode() { + return glfwGetInputMode(win, GLFW_CURSOR); +} + +void Window::ToggleCursorMode() +{ + int mode = GetCursorMode() == GLFW_CURSOR_NORMAL ? + GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL; glfwSetInputMode(win, GLFW_CURSOR, mode); } diff --git a/src/window/Window.hpp b/src/window/Window.hpp index fe3b054..4457898 100644 --- a/src/window/Window.hpp +++ b/src/window/Window.hpp @@ -17,7 +17,8 @@ public: void Resize(int w, int h); void MakeContextCurrent(); - void SetCursorMode(int mode); + int GetCursorMode(); + void ToggleCursorMode(); bool IsShouldClose(); void SetShouldClose(int flag); void SwapBuffers(); |