Simulating gravity with falling object

I’m currently taking a Calculus course and a Physics course. I wanted to play around with OpenGL and to simulate and ball being dropped with an acceleration of -9.8m/s^2. I’m guessing I need to use the glutTimerFunc function, but it looks like I’m not doing something right because my ball drops at a snail’s pace. Here’s my code:


const GLfloat gravity = -9.8;

void timer(GLint t=1)
{
    ball.setVelocity(t);
    ball.setPos(t);
    display();
    
    glutTimerFunc(1, timer, 1);
}
void Object::setVelocity(GLint t)
{
    velocity += gravity * t/1000;
}


void Object::setPos(GLint t)
{
    position += velocity * t/1000;
}


I’m guessing my glutTimerFunc is being called once every 1 millisecond right? And the third argument I’m not sure about, but I’m guessing it’s the time interval that elapsed between calls to glutTimerFunc?

So since t=1 and it’s in milliseconds I divide t by 1000. But this makes the ball move so slow, I don’t know why.

mike

I think I figured it out. when I set position it should be position += velocity