#include <dlfcn.h>
#include <stdio.h>
+#include <stdlib.h>
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <sys/time.h>
#include <string.h>
+#include <glaze.h>
+
/* How many frames between reports. */
#define REPORT_FREQ 60
void
glXSwapBuffers (Display *dpy, GLXDrawable drawable)
{
- static typeof(&glXSwapBuffers) real_glXSwapBuffers = NULL;
-
- if (real_glXSwapBuffers == NULL)
- real_glXSwapBuffers = dlsym (RTLD_NEXT, "glXSwapBuffers");
-
on_each_frame ();
- real_glXSwapBuffers (dpy, drawable);
-}
-
-void
-(*glXGetProcAddressARB (const GLubyte *func))(void)
-{
- static typeof(&glXGetProcAddressARB) real_glXGetProcAddressARB = NULL;
-
- if (strcmp((char *) func, "glXSwapBuffers") == 0)
- return (void*) glXSwapBuffers;
-
- if (real_glXGetProcAddressARB == NULL)
- real_glXGetProcAddressARB = dlsym (RTLD_NEXT, "glXGetProcAddressARB");
-
- return real_glXGetProcAddressARB (func);
+ GLAZE_DEFER (glXSwapBuffers, dpy, drawable);
}