Demos (master): egl/openvg: Print FPS for lion.
Chia-I Wu
olv at kemper.freedesktop.org
Fri Dec 3 06:26:18 UTC 2010
Module: Demos
Branch: master
Commit: b9a2844609a700b61f22c1c17a908237acf6c5a5
URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=b9a2844609a700b61f22c1c17a908237acf6c5a5
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Fri Dec 3 13:03:57 2010 +0800
egl/openvg: Print FPS for lion.
---
src/egl/openvg/lion.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/egl/openvg/lion.c b/src/egl/openvg/lion.c
index c5dba4f..bb80ce7 100644
--- a/src/egl/openvg/lion.c
+++ b/src/egl/openvg/lion.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <VG/openvg.h>
#include <EGL/egl.h>
@@ -11,6 +12,10 @@ VGfloat angle = 0;
static void
draw(void)
{
+ static double t0 = -1.0;
+ static int num_frames;
+ double now;
+
vgClear(0, 0, width, height);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
@@ -20,6 +25,23 @@ draw(void)
vgTranslate(-width/2, -height/2);
lion_render(lion);
+ vgFlush();
+ num_frames++;
+
+ if (t0 < 0.0) {
+ t0 = eglutGet(EGLUT_ELAPSED_TIME) / 1000.0;
+ num_frames = 0;
+ }
+
+ now = eglutGet(EGLUT_ELAPSED_TIME) / 1000.0;
+ if (now - t0 > 5.0) {
+ /* just a rough estimate */
+ printf("%d frames in %3.1f seconds = %6.3f FPS\n",
+ num_frames, now - t0, num_frames / (now - t0));
+
+ t0 = now;
+ num_frames = 0;
+ }
++angle;
eglutPostRedisplay();
More information about the mesa-commit
mailing list