Graphics: Attempt to provide more consistent frame timings
We now actively track how far behind / in front of an ideal timestep we are during each frame, and try to catch up / delay approximate this timing. Therefore we use more precise timers and sleep functions (nanosleep if available). We also delay **before** the final buffer swap so the frame displays at more consistent points in time. Not only should this provide a somewhat more consistent looking map scrolling at lower frame rates, it also guarantees that we don't fall out of sync eg. with the Audio during longer cutscenes. 'Graphics.frameReset()' now finally has a function, in that it resets the ideal timestep approximation, which I beliefe was also its job in the original RMXP engine. I'm not sure how well this will work when the frame rate is set to the monitor refresh rate and vsync is turned on. Very likely unnecessary frame skips will occur here and there due to imprecise timers. In the future we should probably check if the frame rate is equal to or higher than the monitor rate, and disable frame skip accordingly. These changes currently break the F2 FPS display (it shows a value that's slightly too high).
This commit is contained in:
parent
906f9fae17
commit
58bd60a70f
3 changed files with 101 additions and 16 deletions
|
@ -394,7 +394,7 @@ void EventThread::notifyFrame()
|
|||
|
||||
static uint64_t freq = SDL_GetPerformanceFrequency();
|
||||
|
||||
int32_t currFPS = freq / diff;
|
||||
double currFPS = (double) freq / diff;
|
||||
fps.acc += currFPS;
|
||||
++fps.accDiv;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue