Mouse Speed in GLUT and OpenGL?
Posted
by
CroCo
on Game Development
See other posts from Game Development
or by CroCo
Published on 2014-02-19T22:29:51Z
Indexed on
2014/08/19
16:32 UTC
Read the original article
Hit count: 222
I would like to simulate a point that moves in 2D. The input should be the speed of the mouse, so the new position will be computed as following
new_position = old_position + delta_time*mouse_velocity
As far as I know in GLUT there is no function to acquire the current speed of the mouse between each frame. What I've done so far to compute the delta_time as following
void Display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
static int delta_t, current_t, previous_t;
current_t = glutGet(GLUT_ELAPSED_TIME);
delta_t = current_t - previous_t;
std::cout << delta_t << std::endl;
previous_t = current_t;
glutSwapBuffers();
}
Where should I start from here? (Note: I have to get the speed of the mouse because I'm modeling a system)
Edit:
Based on the above code, delta_time
fluctuates so much
34
19
2
20
1
20
0
16
1
1
10
21
0
13
1
19
34
0
13
0
6
1
14
Why does this happen?
© Game Development or respective owner