I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom in and out of a scene? How do I do that?
相关问题
- Is GLFW designed to use without LWJGL (in java)?
- glDrawElements only draws half a quad
- Scaling png font down
- OpenGL buffer update [duplicate]
- How does gl_ClipVertex work relative to gl_ClipDis
相关文章
- Converting glm::lookat matrix to quaternion and ba
- Behavior of uniforms after glUseProgram() and spee
- Keep constant number of visible circles in 3D anim
- GLEW and Qt5 redefinition of headers
- How do I remove axis from a rotation matrix?
- how to calculate field of view of the camera from
- Assimp model loading library install/linking troub
- anyone can explain the “field of view”
Freeglut's glutMouseWheelFunc callback is version dependant and not reliable in X. Use standard mouse function and test for buttons 3 and 4.
The OpenGlut notes on glutMouseWheelFunc state:
Using standard GLUT mouse reporting:
As the OP stated, it is "dead simple". He was just wrong.
Note that venerable Nate Robin's GLUT library doesn't support the scrollwheel. But, later implementations of GLUT like FreeGLUT do.
Using the scroll wheel in FreeGLUT is dead simple. Here is how:
Declare a callback function that shall be called whenever the scroll wheel is scrolled. This is the prototype:
Register the callback with the (Free)GLUT function glutMouseWheelFunc().
Define the callback function. The second parameter gives the direction of the scroll. Values of +1 is forward, -1 is backward.
That's it!
observe case 3 and 4 in the switch statement below in the mouseClick callback
...