From b628c72193e068277ab4fbf0e6db9a572c43be46 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 2 Aug 2019 21:39:15 +0200 Subject: Test: Factor out FPS printer --- test/pugl_test.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'test/pugl_test.c') diff --git a/test/pugl_test.c b/test/pugl_test.c index f276d8a..12ce529 100644 --- a/test/pugl_test.c +++ b/test/pugl_test.c @@ -196,8 +196,8 @@ main(int argc, char** argv) puglShowWindow(view); - float lastReportTime = (float)puglGetTime(view); - bool requestedAttention = false; + PuglFpsPrinter fpsPrinter = { puglGetTime(view) }; + bool requestedAttention = false; while (!quit) { const float thisTime = (float)puglGetTime(view); @@ -214,14 +214,8 @@ main(int argc, char** argv) requestedAttention = true; } - if (continuous && thisTime > lastReportTime + 5) { - const double fps = framesDrawn / (thisTime - lastReportTime); - fprintf(stderr, - "%u frames in %.0f seconds = %.3f FPS\n", - framesDrawn, thisTime - lastReportTime, fps); - - lastReportTime = thisTime; - framesDrawn = 0; + if (continuous) { + puglPrintFps(view, &fpsPrinter, &framesDrawn); } } -- cgit v1.2.1