[client] make FPS counter more accurate

This commit is contained in:
Geoffrey McRae committed 2017-12-12 03:59:56 +11:00
1 parent a7c4cdcea1
commit f2216168f4
1 file changed
+2 -3
+2 -3
View File
@@ -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;