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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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!