Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ut

OpenGL positioning the mouse cursor in OpenGl?

This topic is 6941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Trying to code up a little demo in OpenGL using Linux and Mesa( so I guess it''s really Mesa). Does anyone know how to set the mouse position? Our problem is that when we exit the boundaries of the window, we stop moving, since we''re using glutPassiveMotionFunc. What we want is to not be able to leave the window until the program is exited. This way we can continue to rotate and view the screen like you would in any FPS game. Any help,tips, tricks would be appreciated. Ut

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hi Ut,

I too was wondering how to make a good mouse look function for my game. Awhile back I remember Quake2 junking out on my and I got to see how the master (carmack) did it.

Everytime you call the function to check the keys put this in there :

POINT p; // Point in the window
GetCursorPos(&p); // Get current mouse position
SetCursorPos(320, 240); // set the cursor in the center of
// the window
yrot -= (float)(320 - p.x)/100 * 12;
xrot -= (float)(240 - p.y)/100 * 12; // change -= to += for
// inverted
And voila! You got a mouse look simular or exactly like quake. To change the mouse speed, change the value 12.

I hope this helps!

Justin Eslinger
My game : Quell - to kill, to torment, to reduce to submission

Homepage : http://members.xoom.com/Blackscar/

Share this post


Link to post
Share on other sites
Do you have to include a specific header to get this working? And was this for a windows or linux implementation? I couldn''t find a glut call that would do it, and I have a suspicion that SetCursorPos is a Microsoft call. Let me know if it can be done in linux though and if so what header needs to be included. Thanks for your help!

Ut

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!