+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
#define _GNU_SOURCE /* For RTLD_NEXT */
#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);
-}
-
-void
-(*glXGetProcAddress (const GLubyte *func))(void)
-{
- static typeof(&glXGetProcAddress) real_glXGetProcAddress = NULL;
-
- if (strcmp((char *) func, "glXSwapBuffers") == 0)
- return (void*) glXSwapBuffers;
-
- if (real_glXGetProcAddress == NULL)
- real_glXGetProcAddress = dlsym (RTLD_NEXT, "glXGetProcAddress");
-
- return real_glXGetProcAddress (func);
+ GLAZE_DEFER (glXSwapBuffers, dpy, drawable);
}