[client] prevent usleep underflow in FPS limiter

This commit is contained in:
Geoffrey McRae 2018-05-24 18:10:23 +10:00
parent 3adcbfaa7d
commit 5de9a8dce6

View File

@ -189,14 +189,15 @@ int renderThread(void * unused)
{
if (state.started)
{
uint64_t start = microtime();
const uint64_t start = microtime();
if (!state.lgr->render(state.lgrData, state.window))
break;
if (microtime() - start < state.fpsSleep)
const uint64_t total = microtime() - start;
if (total < state.fpsSleep)
{
usleep(state.fpsSleep - (microtime() - start));
usleep(state.fpsSleep - total);
int64_t delta = (1000000 / params.fpsLimit) - (microtime() - start);
state.fpsSleep += delta;
}