From f302f00e0dfd96c5b2c414fbd1c106c7531fea22 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 25 Mar 2009 04:51:07 +0000 Subject: [PATCH] win32: add a 3d fps counter so you can see how fast the game logic is running. this isnt as good as a proper lag counter --- desmume/src/gfx3d.cpp | 2 ++ desmume/src/gfx3d.h | 7 +++++++ desmume/src/windows/main.cpp | 13 +++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 56adf718a..fb2383103 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -1323,6 +1323,8 @@ static void gfx3d_FlushFIFO() void gfx3d_glFlush(u32 v) { + gfx3d.frameCtr++; + gfx3d_FlushFIFO(); //assert(!flushPending); diff --git a/desmume/src/gfx3d.h b/desmume/src/gfx3d.h index 93f8355f2..859227ba1 100644 --- a/desmume/src/gfx3d.h +++ b/desmume/src/gfx3d.h @@ -133,6 +133,8 @@ struct GFX3D , alphaTestRef(0) , clearDepth(1) , clearColor(0) + , frameCtr(0) + , frameCtrRaw(0) { fogColor[0] = fogColor[1] = fogColor[2] = fogColor[3] = 0; fogOffset = 0; @@ -163,6 +165,11 @@ struct GFX3D float fogColor[4]; float fogOffset; + //ticks every time flush() is called + int frameCtr; + + //you can use this to track how many real frames passed, for comparing to frameCtr; + int frameCtrRaw; u32 rgbToonTable[32]; }; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index ca8f427a2..5c68f5237 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -889,13 +889,22 @@ DWORD WINAPI run() // if (!skipnextframe) // { - - if (FpsDisplay) osd->addFixed(0, 5, "%02d Fps", fps); + static int fps3d = 0; + + if (FpsDisplay) osd->addFixed(0, 5, "%02d Fps / %02d 3d", fps, fps3d); osd->update(); Display(); osd->clear(); + gfx3d.frameCtrRaw++; + if(gfx3d.frameCtrRaw == 60) { + fps3d = gfx3d.frameCtr; + gfx3d.frameCtrRaw = 0; + gfx3d.frameCtr = 0; + } + + fpsframecount++; QueryPerformanceCounter((LARGE_INTEGER *)&curticks);