In the snippet that introduces the variable time step:
double lastTime = getCurrentTime();
while (true)
{
double current = getCurrentTime();
double elapsed = current - lastTime;
processInput();
update(elapsed);
render();
lastTime = current;
}
the lastTime is computed at the wrong time: in that configuration, lastTime and current are computed directly after one another.
If I'm not mistaken, the correct snippet would be:
double lastTime = getCurrentTime();
while (true)
{
double current = getCurrentTime();
double elapsed = current - lastTime;
lastTime = current;
processInput();
update(elapsed);
render();
}
The next snippet after that gets it right.
In the snippet that introduces the variable time step:
the lastTime is computed at the wrong time: in that configuration,
lastTimeandcurrentare computed directly after one another.If I'm not mistaken, the correct snippet would be:
The next snippet after that gets it right.