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?
There are two glut functions that will get mouse location. glutMouseFunc(int button, int state, int x,int y); // gives which mouse button was clicked, button up/down, pos, when inside the glut window. Note only is called when the mouse button is pushed or released.
Press the Windows key on your keyboard. In the box that appears, type Ease of Access mouse settings and press Enter . In the Mouse Keys section, toggle the switch under Use numeric pad to move mouse around the screen to On. Press Alt + F4 to exit this menu.
The cursor position is represented by the line number and the character number and signifies where the next character will be displayed. For example, cursor position 1,1 always indicates the upper-leftmost corner position on the terminal. Cursor position 10,30 indicates the 30th character position on the 10th line.
Initially this cursor is positioned before first row (default position). You can move the cursor of the ResultSet object to the next row from the current position, using the next() method of the ResultSet interface. This method returns a boolean value specifying whether the ResultSet object contains more rows.
Use glutWarpPointer(x, y)
, where x
and y
(both int
s) are in pixels (relative to the window's origin). For example:
glutWarpPointer(windowWidth / 2, windowHeight / 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With