diff options
author | Joursoir <chat@joursoir.net> | 2021-04-04 14:04:23 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-04-04 14:04:23 +0000 |
commit | 685ff91f73d4aa437d801e0c93dee2b904eb8880 (patch) | |
tree | 122b01080ea2958e6e1a7a68fa93bf0bc439f707 /src/window/Window.cpp | |
parent | 60271422194afae4a9c89dceaed5c2d53c51ff00 (diff) | |
download | space-simulator-685ff91f73d4aa437d801e0c93dee2b904eb8880.tar.gz space-simulator-685ff91f73d4aa437d801e0c93dee2b904eb8880.tar.bz2 space-simulator-685ff91f73d4aa437d801e0c93dee2b904eb8880.zip |
Window & Events: cursor mode improve
Diffstat (limited to 'src/window/Window.cpp')
-rw-r--r-- | src/window/Window.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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); } |