Added scroll navigation.

This commit is contained in:
Camilla Berglund 2010-11-17 23:33:46 +01:00
parent 3350cc73aa
commit 065c77190d

View File

@ -285,11 +285,12 @@ void key_callback(GLFWwindow window, int key, int action)
beta += 5; beta += 5;
break; break;
case GLFW_KEY_PAGEUP: case GLFW_KEY_PAGEUP:
if (zoom > 1) zoom -= 0.25f;
zoom -= 1; if (zoom < 0.f)
zoom = 0.f;
break; break;
case GLFW_KEY_PAGEDOWN: case GLFW_KEY_PAGEDOWN:
zoom += 1; zoom += 0.25f;
break; break;
default: default:
break; break;
@ -336,6 +337,18 @@ void mouse_position_callback(GLFWwindow window, int x, int y)
} }
//========================================================================
// Callback function for scroll events
//========================================================================
void scroll_callback(GLFWwindow window, int x, int y)
{
zoom += y / 4.f;
if (zoom < 0)
zoom = 0;
}
//======================================================================== //========================================================================
// Callback function for window resize events // Callback function for window resize events
//======================================================================== //========================================================================
@ -389,6 +402,7 @@ int main(int argc, char* argv[])
glfwSetWindowSizeCallback(window_resize_callback); glfwSetWindowSizeCallback(window_resize_callback);
glfwSetMouseButtonCallback(mouse_button_callback); glfwSetMouseButtonCallback(mouse_button_callback);
glfwSetMousePosCallback(mouse_position_callback); glfwSetMousePosCallback(mouse_position_callback);
glfwSetScrollCallback(scroll_callback);
// Initialize OpenGL // Initialize OpenGL
init_opengl(); init_opengl();