PDA

View Full Version : how to pin mouse in center of screen?



D3GAN
02-12-2011, 09:46 AM
Hi everyone...
I want to pin my mouse in middle of screen I mean when user move mouse the only thing that he see is rotation in enviroment also mouse curser never reach window border ...

I want to handle my camera with mouse but when mouse reach window border or in full screen mode screen border the mouse position dont change but camera should still rotate slow or speedy depend on speed of mouse movement...

how should i solve this problem?

thank you

_arts_
02-12-2011, 11:03 AM
what OpenGL underlying library are you using ? For glut I'm not sure if it's possible, but try to see at freeglut website. For windows, X11, try to google "warp pointer".

ZbuffeR
02-12-2011, 11:29 AM
GLFW allow to do this.

D3GAN
02-12-2011, 12:47 PM
I try GLUT ... so I should use GLFW?

Stuart McDonald
02-14-2011, 09:27 AM
I used to use GLUT and switched to GLFW since I find it to be a nice interface, but you can do what you want in either. I solved a similar problem. I wanted the cursor to be clamped within a circle in the center of screen. Depending on where the cursor was it would change the view accordingly. I disabled the cursor and instead showed a line drawn from the center to the clamped position (I also slowy re-centered the cursor if it was close to the middle so the user could get back to flying straight).

To hide the cursor
glutSetCursor(GLUT_CURSOR_NONE);
glfwDisable(GLFW_MOUSE_CURSOR);

To warp the cursor to a screen position
glutWarpPointer(x,y);
glfwSetMousePos(x,y);

D3GAN
02-15-2011, 10:01 AM
Thanks...