From f0b536ac93b3a9a49dfff8a7637f09b153a3b955 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 22 Feb 2019 21:49:07 +0100 Subject: Improvise interactive wall drawing Internal wall cells need to be disabled to prevent delayed propagation of the reflected populations. This is just quickly thrown together - both the visual drawing and the backend's material handling remain to be improved. --- src/glfw/window.cc | 11 ++++++++--- src/glfw/window.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/glfw') diff --git a/src/glfw/window.cc b/src/glfw/window.cc index 98890b7..4f14501 100644 --- a/src/glfw/window.cc +++ b/src/glfw/window.cc @@ -37,14 +37,19 @@ int Window::getHeight() const { return _height; } -std::tuple Window::getMouse() const { - const bool clicked = glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; +std::tuple Window::getMouse() const { + int state = 0; + if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS ) { + state = 1; + } else if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) { + state = 2; + } double x, y; glfwGetCursorPos(_handle, &x, &y); return std::make_tuple( - clicked, + state, x - int(getWidth()/2), int(getHeight()/2 - y) ); diff --git a/src/glfw/window.h b/src/glfw/window.h index af7ba4d..143d457 100644 --- a/src/glfw/window.h +++ b/src/glfw/window.h @@ -27,7 +27,7 @@ public: int getWidth() const; int getHeight() const; - std::tuple getMouse() const; + std::tuple getMouse() const; KeyWatcher getKeyWatcher(int key) const; -- cgit v1.2.3