X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glxwrap.c;h=80ccf1afdb6ed7148b81f1a04a30cd628b58b4da;hb=8468b2b9d524832211f8e20791a1459003a563ff;hp=51b5faf58f83f8017c822d7d287f7eb72dbb12d0;hpb=1f4014b53a4dc77768f3998a6fd3b67024431fa3;p=fips diff --git a/glxwrap.c b/glxwrap.c index 51b5faf..80ccf1a 100644 --- a/glxwrap.c +++ b/glxwrap.c @@ -19,18 +19,16 @@ * THE SOFTWARE. */ -#include -#include - -#include +#include "fips.h" #include #include #include -#include #include +#include "dlwrap.h" + typedef void (* fips_glXSwapBuffers_t)(Display *dpy, GLXDrawable drawable); static void * @@ -40,7 +38,7 @@ lookup (const char *name) static void *libgl_handle = NULL; if (! libgl_handle) { - libgl_handle = dlopen (libgl_filename, RTLD_NOW); + libgl_handle = dlwrap_real_dlopen (libgl_filename, RTLD_NOW | RTLD_DEEPBIND); if (! libgl_handle) { fprintf (stderr, "Error: Failed to dlopen %s\n", libgl_filename); @@ -48,7 +46,7 @@ lookup (const char *name) } } - return dlsym (libgl_handle, name); + return dlwrap_real_dlsym (libgl_handle, name); } static void @@ -94,3 +92,26 @@ glXSwapBuffers (Display *dpy, GLXDrawable drawable) printf("FPS: %.3f\n", fps); } } + + +typedef __GLXextFuncPtr (* fips_glXGetProcAddressARB_t)(const GLubyte *func); +__GLXextFuncPtr +glXGetProcAddressARB (const GLubyte *func) +{ + static fips_glXGetProcAddressARB_t real_glXGetProcAddressARB = NULL; + const char *name = "glXGetProcAddressARB"; + + if (! real_glXGetProcAddressARB) { + real_glXGetProcAddressARB = (fips_glXGetProcAddressARB_t) lookup (name); + if (! real_glXGetProcAddressARB) { + fprintf (stderr, "Error: Failed to find function %s.\n", + name); + return NULL; + } + } + + if (strcmp ((const char *)func, "glXSwapBuffers") == 0) + return (__GLXextFuncPtr) glXSwapBuffers; + else + return real_glXGetProcAddressARB (func); +}