From 8cf444ef318ef98e5934017b764a537cdf4957da Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 21 Jul 2021 16:56:49 +1000 Subject: [PATCH] [client] main: sync to the ups if the ups exceeds minFrameTime --- client/src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 2d3f81f1..1a19d215 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -147,7 +147,7 @@ static int renderThread(void * unused) /* start up the fps timer */ LGTimer * fpsTimer; - if (!lgCreateTimer(1000, fpsTimerFn, NULL, &fpsTimer)) + if (!lgCreateTimer(500, fpsTimerFn, NULL, &fpsTimer)) { DEBUG_ERROR("Failed to create the fps timer"); return 1; @@ -165,7 +165,9 @@ static int renderThread(void * unused) { if (g_params.fpsMin != 0) { - if (!lgWaitEventAbs(e_frame, &time)) + float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed); + + if (!lgWaitEventAbs(e_frame, &time) || ups > g_params.fpsMin) { /* only update the time if we woke up early */ clock_gettime(CLOCK_MONOTONIC, &time);