float t = 0.0f;
float dt = 0.1f;
float currentTime = 0.0f;
float accumulator = 0.0f;
while (!quit)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const float newTime = time();
float deltaTime = newTime - currentTime;
currentTime = newTime;
if (deltaTime>0.25f)
deltaTime = 0.25f;
accumulator += deltaTime;
while (accumulator>=dt)
{
accumulator -= dt;
previous = current;
integrate(current, t, dt);
t += dt;
}
State state = interpolate(previous, current, accumulator/dt);
glBegin(GL_POINTS);
glColor3f(1,1,1);
glVertex3f(state.x, 0, 0);
glEnd();
updateDisplay();
}