From 0dda919bd9e96e9684ca35b9770f129afbf84af5 Mon Sep 17 00:00:00 2001 From: avolkov Date: Fri, 7 Feb 2003 22:59:45 +0000 Subject: [PATCH] Added 'effective' fps git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@715 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/sdl_common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 2446836d0..808e56fbb 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -42,6 +42,9 @@ int GfxFlags = 0; static TFB_Palette palette[256]; +#define FPS_PERIOD 1000 +int RenderedFrames = 0; + int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp) { @@ -426,10 +429,14 @@ TFB_ComputeFPS () last_time = current_time; fps_counter += delta_time; - if (fps_counter > 1000) + if (fps_counter > FPS_PERIOD) { + fprintf (stderr, "fps %.2f, effective %.2f\n", + (float)FPS_PERIOD / delta_time, + 1000.0 * RenderedFrames / fps_counter); + fps_counter = 0; - fprintf (stderr, "fps %.2f\n",1.0 / (delta_time / 1000.0)); + RenderedFrames = 0; } } @@ -658,7 +665,8 @@ TFB_FlushGraphics () // Only call from main thread!! } TFB_SwapBuffers (); - BroadcastCondVar (RenderingCond); + RenderedFrames++; + BroadcastCondVar (RenderingCond); } #endif