From 450fb12e1d854618e1b8ba9ea6698aa5e4cc39fe Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sat, 15 Nov 2014 14:57:01 +0100 Subject: [PATCH] Mapping scroll wheel to camera distance. --- main.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.cc b/main.cc index 5991a78..282cffe 100644 --- a/main.cc +++ b/main.cc @@ -16,6 +16,8 @@ #include #include +Application app; + Application::Application() { graphics = Graphics(glm::uvec2(1024, 786), 0.1f, 100.0f); } @@ -67,10 +69,14 @@ static void keyCallback(GLFWwindow* _window, int _key, int, int _action, int) } } +static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) { + app.getLevel()->getCamera()->updateDistance(-(float)yoffset); +} + int main( int argc, char *argv[] ) { - Application app = Application(); + //Application app = Application(); ///////////////////////////////////////////////////////////////////////////////////// // Create OpenGL capable window: @@ -91,6 +97,7 @@ int main( int argc, char *argv[] ) glfwSetInputMode(app.getGraphics()->getWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); //glfwSetWindowSizeCallback(app.getGraphics(), resizeCallback); glfwSetKeyCallback(app.getGraphics()->getWindow(), keyCallback ); + glfwSetScrollCallback(app.getGraphics()->getWindow(), scrollCallback ); // Enable vertical sync (on cards that support it) with parameter 1 - 0 means off glfwSwapInterval( 0 );