From f2216168f4e0d9f8a68df57d412dd7060aa9c00e Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 2 Dec 2017 16:53:28 +1100 Subject: [PATCH] [client] make FPS counter more accurate --- client/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/main.c b/client/main.c index 12bc8988..6c40284d 100644 --- a/client/main.c +++ b/client/main.c @@ -407,7 +407,7 @@ int renderThread(void * unused) if (params.showFPS) { - if (frameCount == 10) + if (++frameCount == 10) { SDL_Surface *textSurface = NULL; if (textTexture) @@ -416,7 +416,7 @@ int renderThread(void * unused) textTexture = NULL; } const unsigned int time = SDL_GetTicks(); - const float avgFPS = frameCount / ((time - ticks) / 1000.0f); + const float avgFPS = (float)frameCount / ((time - ticks) / 1000.0f); char strFPS[12]; snprintf(strFPS, sizeof(strFPS), "FPS: %6.2f", avgFPS); SDL_Color color = {0xff, 0xff, 0xff}; @@ -468,7 +468,6 @@ int renderThread(void * unused) } SDL_RenderPresent(state.renderer); - ++frameCount; state.started = true; bool ready = false;