improve frame limiter accuracy
This commit is contained in:
parent
03893907a1
commit
8add469c20
1 changed files with 2 additions and 2 deletions
|
@ -279,9 +279,9 @@ void limit_frame_rate(uint64_t *lasttime) {
|
|||
|
||||
double passed = (double)(SDL_GetPerformanceCounter() - *lasttime) / SDL_GetPerformanceFrequency();
|
||||
double delay = max(0, 1.0 / FPS - passed);
|
||||
uint32_t delay_ms = (uint32_t)(delay * 1000.0);
|
||||
int32_t delay_ms = (int32_t)rint(delay * 1000.0);
|
||||
|
||||
if(delay > 0 && delay_ms > 0) {
|
||||
if(delay_ms > 0) {
|
||||
SDL_Delay(delay_ms);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue