]> git.cworth.org Git - fips/blobdiff - glxwrap.c
Wrap all OpenGL drawing calls, measure GPU time of each, and account to shader.
[fips] / glxwrap.c
index 4d16e4d6a1b86c093bbad6f4d8b1f35ff337e0f8..78627d42005a223eca6128dd12177d06e8278257 100644 (file)
--- a/glxwrap.c
+++ b/glxwrap.c
 #include <GL/gl.h>
 #include <GL/glx.h>
 
-#include <sys/time.h>
-
 #include "dlwrap.h"
 
+#include "glwrap.h"
+
 typedef void (* fips_glXSwapBuffers_t)(Display *dpy, GLXDrawable drawable);
 
 static void *
@@ -69,28 +69,9 @@ call_glXSwapBuffers (Display *dpy, GLXDrawable drawable)
 void
 glXSwapBuffers (Display *dpy, GLXDrawable drawable)
 {
-       static int initialized = 0;
-       static int frames;
-       static struct timeval tv_start, tv_now;
-
-       if (! initialized) {
-               frames = 0;
-               gettimeofday (&tv_start, NULL);
-               initialized = 1;
-       }
-
        call_glXSwapBuffers (dpy, drawable);
 
-       frames++;
-       if (frames % 60 == 0) {
-               double fps;
-               gettimeofday (&tv_now, NULL);
-
-               fps = (double) frames / (tv_now.tv_sec - tv_start.tv_sec +
-                                        (tv_now.tv_usec - tv_start.tv_usec) / 1.0e6);
-
-               printf("FPS: %.3f\n", fps);
-       }
+       glwrap_end_frame ();
 }