A few years ago i decided to make a small game engine. It works well enough but as with any project there is always more to do.
One day i decided to make a media player based off the engine. Put a few squares on the screen, some artwork and fmod, then BAM, a fully working media player.(please excuse the excessive comma usage)
If you interested I will post a link later. Anyway If your familiar with OpenGl then you know that a lot of things are not naively available. So using additional libraries is essential to making things go quickly. One of those libraries is GLUT. Glut takes care of a lot of the window management and interaction with the os(keyboard, mouse, ect).
When i first built the player it was all clickable. Which is fine for a v1 (or v4 is what the version before the change was on) but there comes a time in a mans life when he has to make a change. That change came into the form of using the scroll wheel. The scroll wheel has be come an integral part of everyday life and it kills me that i couldn’t use it to traverse the albums in my media player sooooooo, i added it.
The library mentioned above GLUT, does not handle the scroll wheel with the original version( made sometime in the 90’s), but the great people on the FREEGLUT team have been updating a version consistently over the years. Using the freeglut lib instead of the original glut lib allows you to take advantage of the scroll wheel. Its very easy to do.
1) Download the freegult binaries and add the reference to your project:
#include <GL\freeglut.h>
2) add the callback to your code with the handling function:
glutMouseWheelFunc(mouse_wheel);
3) Write your handling function:
void mouse_wheel(int wheel, int direction, int x, int y) {
if (wheel == 0) { //1st (usually only) mouse wheel
if (direction < 0) { //Down
} else {//UP
}
}
}
And that’s it. I had scroll wheel functionality. I replaced my regular glut.h with freeglut.h and didn’t need to do anything except add my mouse wheel callback.