PDA

View Full Version : glut: recieving mouse coords even when idle?



Kiamo
09-04-2001, 07:10 PM
It seems the mouse function in my glut program wont get the mouse coords unless the mouse is moving around so the program isn't idle. Is there a way to get it to always do it? The reason I want to do this is so if you hold mouse 2 down, the camera rotates at a speed depending on where the pointer is in relation to the middle of the screen. But it doesn't seem to work right unless the mouse never stops moving so the program never goes idle...

So my question is: Can I have it keeping track of the mouse all the time, even when idle? glutIdleFunc() doesn't work with the Mouse func, incase you didn't know...

mikael_aronsson
09-04-2001, 09:27 PM
Hi !

Mouse events are sent when you click buttons and move the mouse, and that's the way it should be.

To do the rotation you would start a timer when the mouse button is clicked, the timer takes care of rotating to object, and when the mouse button is released you kill the timer.

Mikael

09-20-2001, 02:59 AM
Hi,

It IS possible to do that using the idle func, I use it this way (it only works on Win):

void IdleFunc()
{
POINT p;
GetCursorPos(&p); // Get the cursor position on the desktop
ScreenToClient(WindowFromPoint(p), &p); // Translate it to window coordinates
...
}

And initialize the idle function:
glutIdleFunc(IdleFunc);

Bye
Valoche

Keermalec
09-20-2001, 04:48 AM
Try using "glutPassiveMotionFunc(motionfunc)" in your initialisation function, where "motionfunc" is your mouse motion function.