mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Added scroll navigation.
This commit is contained in:
parent
3350cc73aa
commit
065c77190d
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user