PDA

View Full Version : Can't get gluProject and SetCursorPos to work together.



04-10-2002, 12:39 PM
Ok so I got a 3d coordinate and i want the 2d coordinates so I can move my mouse cursor there but I'm having some troubles. First I do gluProject and looking at the logs I get accurate x,y values but when I use SetCursorPos to move the mouse there it will kinda overshoot and move it too far. For example if my mouse is currently below the 3d object and I try to move the mouse to the 2d x,y the mouse will be moved above the 3d object. The same with when the mouse is to the right, it will be moved too far to the left. Neither function reutrned errors so I have no clue why it's doing this. It seems the poblem is in SetCursorPos but I'm not sure. I'm doing this in C++. Any help is GREATLY appreciated, it's been bugging me for months. Thx.

Rob The Bloke
04-10-2002, 12:48 PM
Usually mouse position is given by

(x, height - y)

You may also be trying to set the mouse cursor in relationship to the desktop rather than the client area of the screen....

04-10-2002, 01:09 PM
Yes I was using height-y because the opengl coordinate system is different than the coordinate system for the mouse. The problem still presists.

Obliviator
04-11-2002, 12:55 AM
Originally posted by toon:
Ok so I got a 3d coordinate and i want the 2d coordinates so I can move my mouse cursor there but I'm having some troubles. First I do gluProject and looking at the logs I get accurate x,y values but when I use SetCursorPos to move the mouse there it will kinda overshoot and move it too far. For example if my mouse is currently below the 3d object and I try to move the mouse to the 2d x,y the mouse will be moved above the 3d object. The same with when the mouse is to the right, it will be moved too far to the left. Neither function reutrned errors so I have no clue why it's doing this. It seems the poblem is in SetCursorPos but I'm not sure. I'm doing this in C++. Any help is GREATLY appreciated, it's been bugging me for months. Thx.


are you using glut?
if not, and you are using windows, you should think of coordinate transformation a la ClientToScreen/ScreenToClient to move your coordinates into the correct window offset

hope this helps...