Merge pull request #650 from KentuckyCompass/fps_counter

Fps counter
This commit is contained in:
Henrik Rydgård 2013-02-10 23:04:22 -08:00
commit c07370ac3c

View File

@ -214,6 +214,41 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
// Draw screen overlays before blitting. Saves and restores the Ge context.
gpuStats.numFrames++;
if (g_Config.bShowFPSCounter)
{
static double highestFps = 0.0;
static int lastFpsFrame = 0;
static double lastFpsTime = 0.0;
static double fps = 0.0;
{
time_update();
double now = time_now_d();
if (now >= lastFpsTime + 1.0)
{
fps = (gpuStats.numFrames - lastFpsFrame) / (now - lastFpsTime);
if (fps > highestFps)
highestFps = fps;
lastFpsFrame = gpuStats.numFrames;
lastFpsTime = now;
}
char stats[2048];
sprintf(stats, "FPS: %f\nRecord high FPS: %f", fps, highestFps);
float zoom = 0.3f; /// g_Config.iWindowZoom;
float soff = 0.3f;
PPGeBegin();
PPGeDrawText(stats, soff, soff, 0, zoom, 0xCC000000);
PPGeDrawText(stats, -soff, -soff, 0, zoom, 0xCC000000);
PPGeDrawText(stats, 0, 0, 0, zoom, 0xFFFFFFFF);
PPGeEnd();
}
}
// Now we can subvert the Ge engine in order to draw custom overlays like stat counters etc.
if (g_Config.bShowDebugStats && gpuStats.numDrawCalls) {
gpu->UpdateStats();