aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/demo_utils.h9
-rw-r--r--examples/pugl_shader_demo.c4
2 files changed, 7 insertions, 6 deletions
diff --git a/examples/demo_utils.h b/examples/demo_utils.h
index b43cc2b..da3b2cd 100644
--- a/examples/demo_utils.h
+++ b/examples/demo_utils.h
@@ -95,13 +95,14 @@ puglPrintFps(const PuglWorld* world,
unsigned* const framesDrawn)
{
const double thisTime = puglGetTime(world);
- if (thisTime > printer->lastReportTime + 5) {
- const double fps = *framesDrawn / (thisTime - printer->lastReportTime);
+ if (thisTime > printer->lastReportTime + 5.0) {
+ const double elapsed = (thisTime - printer->lastReportTime);
+ const double fps = *framesDrawn / elapsed;
fprintf(stderr,
- "FPS: %.2f (%u frames in %.0f seconds)\n",
+ "FPS: %.2f (%u frames / %.2f seconds)\n",
fps,
*framesDrawn,
- thisTime - printer->lastReportTime);
+ elapsed);
printer->lastReportTime = thisTime;
*framesDrawn = 0;
diff --git a/examples/pugl_shader_demo.c b/examples/pugl_shader_demo.c
index 9ba3da0..2cdcb6e 100644
--- a/examples/pugl_shader_demo.c
+++ b/examples/pugl_shader_demo.c
@@ -470,7 +470,7 @@ updateTimeout(const PuglTestApp* const app)
const double nextExposeTime = nextFrameEndTime - neededTime;
const double timeUntilNext = nextExposeTime - now;
- return timeUntilNext;
+ return fmax(0.0, (timeUntilNext * 0.9) - 0.001);
}
int
@@ -505,7 +505,7 @@ main(int argc, char** argv)
const double startTime = puglGetTime(app.world);
PuglFpsPrinter fpsPrinter = {startTime};
while (!app.quit) {
- puglUpdate(app.world, fmax(0.0, updateTimeout(&app)));
+ puglUpdate(app.world, updateTimeout(&app));
puglPrintFps(app.world, &fpsPrinter, &app.framesDrawn);
}