1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 12:18:51 -05:00

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;
break;
case GLFW_KEY_PAGEUP:
if (zoom > 1)
zoom -= 1;
zoom -= 0.25f;
if (zoom < 0.f)
zoom = 0.f;
break;
case GLFW_KEY_PAGEDOWN:
zoom += 1;
zoom += 0.25f;
break;
default:
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
//========================================================================
@ -389,6 +402,7 @@ int main(int argc, char* argv[])
glfwSetWindowSizeCallback(window_resize_callback);
glfwSetMouseButtonCallback(mouse_button_callback);
glfwSetMousePosCallback(mouse_position_callback);
glfwSetScrollCallback(scroll_callback);
// Initialize OpenGL
init_opengl();