mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04: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;
|
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();
|
||||||
|
Loading…
Reference in New Issue
Block a user