I am making an OpenGL application, using GLUT as my base. I am just started to implement non-console interactions, and the mouse was easy enough to implement. Then, when I went to implement mouse scrolling, I found that no events are passed to glutMouseFunc
when the mouse is scrolled. I saw on other forums that it should call it's callback with 3
and 4
into int button
for scroll up and down, respectively.
I am trying to avoid glutMouseWheelFunc(...)
as much as possible, due to it not being platform-independent.
So, how can I implement scrolling in a working, platform-independent way?
Thanks!
Here is a short code segment showing the issue -
#pragma once
#include <iostream>
#include <GL/glut.h>
#include <GL/glext.h>
void onMouse(int button, int state, int x, int y);
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(256,256);
glutCreateWindow("Mousewheel Test");
glutMouseFunc(onMouse);
glutMainLoop();
}
void onMouse(int button, int state, int x, int y){
//Here, an event is generated for left, right, and middle clicks (though middle is the same as right...),
//but not scrolling!
std::cout << "Mouse event. Button: " << button << " state: " << state << '\n';
}