tags:

views:

1072

answers:

1

I'm writing a simple game and I'm going to have the mouse control the camera (using GlutPassiveMotionFunc).

I'm going to pitch and yaw based off the mouse difference between callbacks, however I think it would be a good idea to "force" the mouse back to the center of the screen every time they tried to move it. This way their cursor won't be at the edge of the screen and they can't move any further in that direction.

What Glut / OpenGL command can I use to force the position of the mouse to change?

+3  A: 

Use glutWarpPointer(x, y), where x and y (both ints) are in pixels (relative to the window's origin). For example:

glutWarpPointer(windowWidth / 2, windowHeight / 2);
htw

related questions