I've implemented Glenn Fiedler's Fix Your Timestep! quite a few times in single-threaded games.
This leaves me with two independent fake threads: simulation and rendering. Timing in these threads is independent too:
dt for simulation and render is not the same.
If I'm not mistaken, simulation should be up to Fiedler's while loop end. After the while loop,
accumulator < dt so I'm left with some unspent time (
accumulator) in the simulation thread.
The problem comes in the draw/interpolation phase:
const double alpha = accumulator / dt; State state = currentState*alpha + previousState * ( 1.0 - alpha ); render( state );
In my render callback, I have the current timestamp to which I can subtract the last-simulated-in-physics-timestamp to have a
dt for the current frame.
Should I just forget about this
dt and draw using the physics thread's
accumulator? It seems weird, since, well, I want to interpolate for the unspent time between simulation and render too, right?
Of course, I want simulation and rendering to be completely independent, but I can't get around the fact that in Glenn's implementation the renderer produces time and the simulation consumes it in discrete dt sized chunks.