OpenGL glutMotionFunc

Started by
1 comment, last by marti901 12 years, 4 months ago
I'm trying to make camera control in OpenGL/glut.

I works fine with the arrow keys.

But i won't work with the mouse because in only updates when in press a moue button.

Now i my question.
Is there a way to get the mouse x, y each time the mouse moves instead of each time there is a button pressed or released?

I use now: glutMotionFunc(MouseMove);

code of MouseMove


void MouseMove(int x, int y){
printf("MouseX = %d\n", x);
Player.HandleMouseMove(x);

glutWarpPointer(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);

}
Advertisement
glutMotionFunc indeed only triggers when you move the mouse with a button pressed. You want glutPassiveMotionFunc instead, which triggers at any time you move the mouse as long as the window is in focus. I am not sure if it triggers only when no buttons are pressed, or always triggering on movement, so you may have to use both.

glutMotionFunc indeed only triggers when you move the mouse with a button pressed. You want glutPassiveMotionFunc instead, which triggers at any time you move the mouse as long as the window is in focus. I am not sure if it triggers only when no buttons are pressed, or always triggering on movement, so you may have to use both.


That was the problem thxcool.gif

This topic is closed to new replies.

Advertisement