View Full Version : mouse speed between sampled mouse input points

02-02-2005, 04:27 PM
Hi everyone!

I have used the glutMouseFunc() and glutMotionFunc() to track what the user has drawn with the mouse. However, for every consecutive mouse input points these functions give me (e.g x, y), i need to find the speed in between the consecutive points.

That is to say, i need to find the distance and the time between consecutive mouse input points.

Is there a way to do that?

I have heard about using performance counter and frequency and also the multimedia timer to get the time..however, i do not know how to go about doing any of these windows functions in openGL.

Thank you to anyone replying this post!

02-03-2005, 12:33 AM
Just measure the time between the mouse clicks.

02-03-2005, 10:11 PM
..and use a couple of

int iOldX;
int iOldY;to store the old mouse coordinates (from the previous frame). This way you know that the mouse has moved iNewX = x - iOldX units etc between each frame.

02-04-2005, 07:02 AM
Just measure the time between the mouse clicks?

Sorry but I am a novice.. how do i measure the time between the mouse clicks? Any function for me to invoke?

Thanks again!

02-06-2005, 08:43 AM
if you're in linux, you can use gettimeofday(...)

in windows the function is GetTickCount(), i think.