PDA

View Full Version : glutWarpPointer issues


Bossa Nova
2003.04.26, 09:21 PM
I'm currently implementing mouselook in a project but am having some serious difficulties.

When the player moves the mouse the view changes - this works just fine. However, when the player moves the mosue outside the window, the mouse no longer updates (with glutPassiveMotionFunc()).

To rectify this, I try to set the mouse position to the center of the windo with glutWarpPointer. However, this functions seems to have a problem. Most notibly, all other glut function calls stop right after having called glutWarpPointer. In other words, the system doesn't report another mouse move for a second or two after glutWarpPointer is called. (same with keyboard, and keyboardUp funcs).

I'm trying to find a good way around this. Keep in mind I'm trying to keep things as cross platform as possible. However -if it were a simple fix to call an OS X function I could use this. Windows has a setCursorPosition function that seems to be what I want. However, I'm not sure of a MacOS equivalent.

Anyway, if anybody has a thought on what I should do let me know. Thanks,

OneSadCookie
2003.04.27, 03:24 AM
Seems like a bug in GLUT. You could try filing a bug with Apple and see what happens...

CGDisplayMoveCursorToPoint is the only Mac OS X function I know of that can move the mouse pointer, so this is probably what GLUT's using internally.

One possibility is that you call CGGetLastMouseDelta from your idle function to get unbounded mouse deltas, and keep the glutWarpPointer path for OS 9, Linux, Windows, &c.

Anther possibility is that you investigate using CGSetLocalEventsSuppressionInterval to set the suppression interval to 0 seconds. I seem to recall people had some success with that. If you get the GLUT source, you could probably put a call to this in glutInit, and keep your source cross-platform.

Hog
2003.04.27, 02:11 PM
Originally posted by OneSadCookie

CGDisplayMoveCursorToPoint is the only Mac OS X function I know of that can move the mouse pointer, so this is probably what GLUT's using internally.


doesn't it use CGWarpMouseCursorPosition()?

OneSadCookie
2003.04.27, 05:38 PM
Hmm, possibly, I'm not familiar with that function.

Guess you'll only know by getting the source :)

What's the difference between that and CGDisplayMoveCursorToPoint?

Bossa Nova
2003.04.27, 07:43 PM
Thanks for the replies.

Tried a couple of different solutions. CGWarpMouseCursorPosition worked quite well except that after warping the cursor mouse movement is frozen for a second or two. This is documented for both WarpMouseCursorPosition and (I believe) DisplayMoveCursorToPoint. However, I haven't actually looked at the latter.

Anyway, I decided to use CGGetMouseLastDelta inside in #ifdef to keep things portable. This works great! Thanks for the help.

I tried to do mouselook in my udg2002 entry and had the same problem. Its kinda been looming over my head while I do other work on my new project. Its nice to have it figured out.

inio
2003.04.27, 10:55 PM
CGPoint pos; pos.x = x; pos.y = y;
CGSetLocalEventsSuppressionInterval(0);
CGWarpMouseCursorPosition(pos);
From this code I wrote a while back (http://www.inio.org/~inio/glutWarpCursor.sit).

mehmet
2007.01.30, 12:53 PM
How can I use this code in my OpenGL code which is right now using glut library. Can I link them together and use together? I am using a Unix machine.

Thanks