rotation of the scene with the mouse ??

Hi there

I’am trying to fix my camera to the mouse so that when I move the mouse left, the view is rotated to the left and vice-versa (as in any 1st person shooter).

I am using GLUT glutPassiveMotionFunc() to achieve that. I look at dx and dy (x - oldx and y - oldy) and perform a rotation on my camera based on that. The problem is that when the mouse exits the window, the glutPassiveMotionFunc() don’t seems to be called and with no dx and dy, I can’t continue my camera rotation as well as I can’t rotate 360 degrees on myself.

Can anyone gives me some hint on a possible Glut implementation or on an other possible approach ??


this is normal, you can’t have mouse events when the mouse is not in your window!
actually, you can do it if you use DirectInput on Windows. but that is not the problem, you cannot turn 360° with one mouse movement (look at all the FPS games).

If you’re using Windows, you can do SetCapture() on mouse-down and ReleaseCapture() on mouse-up. Then you’ll still get mouse messages even when the cursor is outside your window.

HUmmm I just found an answer to my question. I just call glutWarpPointer() to bring my cursor back to the center when it gets too close to an window’s edge.

Thanks anyway for your help guys

Mike !!