Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the position of the mouse cursor in OpenGL/Glut?

Tags:

opengl

mouse

glut

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?

like image 583
KingNestor Avatar asked Apr 24 '09 02:04

KingNestor


People also ask

How do you get the mouse position in glut?

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.

How can you change the position of the cursor on the screen?

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.

What is the position of cursor?

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.

Which method moves cursor position to next row?

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.


1 Answers

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);
like image 93
hbw Avatar answered Oct 13 '22 01:10

hbw