From 9779fd7484f7af6d10ae28ca3763c6d938c341e3 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 22 Feb 2019 22:24:30 +0100 Subject: Tidy up wall drawing and geometry initialization --- src/glfw/window.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/glfw') diff --git a/src/glfw/window.cc b/src/glfw/window.cc index 4f14501..c0074ad 100644 --- a/src/glfw/window.cc +++ b/src/glfw/window.cc @@ -38,21 +38,20 @@ int Window::getHeight() const { } std::tuple Window::getMouse() const { - int state = 0; + double x, y; + glfwGetCursorPos(_handle, &x, &y); + x = int(x - getWidth()/2); + y = int(getHeight()/2 - y); + if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS ) { - state = 1; - } else if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) { - state = 2; + return std::make_tuple(1, x, y); } - double x, y; - glfwGetCursorPos(_handle, &x, &y); + if ( glfwGetMouseButton(_handle, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) { + return std::make_tuple(2, x, y); + } - return std::make_tuple( - state, - x - int(getWidth()/2), - int(getHeight()/2 - y) - ); + return std::make_tuple(0, x, y); } KeyWatcher Window::getKeyWatcher(int key) const { -- cgit v1.2.3