X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glxwrap.c;h=d7d4191ce528ae5b59c5f8a9317b8e99a179d679;hb=d6ac766abe401b681282cdcf273e7fb67fff99bd;hp=885f679c860bed17b0004c89e27986bb21515742;hpb=4ef9d74d4ff12afcc7e31bf13fe2a4993f06b987;p=fips diff --git a/glxwrap.c b/glxwrap.c index 885f679..d7d4191 100644 --- a/glxwrap.c +++ b/glxwrap.c @@ -21,45 +21,64 @@ #include "fips.h" +#include "fips-dispatch.h" + #include #include #include #include "dlwrap.h" - #include "glwrap.h" +#include "metrics.h" void glXSwapBuffers (Display *dpy, GLXDrawable drawable) { GLWRAP_DEFER (glXSwapBuffers, dpy, drawable); - glwrap_end_frame (); + metrics_end_frame (); } - -typedef __GLXextFuncPtr (* fips_glXGetProcAddressARB_t)(const GLubyte *func); -__GLXextFuncPtr -glXGetProcAddressARB (const GLubyte *func) +/* glXGetProcAddressARB is a function which accepts a string and + * returns a generic function pointer (which nominally accepts void and + * has void return type). Of course, the user is expected to cast the + * returned function pointer to a function pointer of the expected + * type. + */ +void (*glXGetProcAddressARB (const GLubyte *func))(void) { - __GLXextFuncPtr ptr; - static fips_glXGetProcAddressARB_t real_glXGetProcAddressARB = NULL; - char *name = "glXGetProcAddressARB"; - - if (! real_glXGetProcAddressARB) { - real_glXGetProcAddressARB = glwrap_lookup (name); - if (! real_glXGetProcAddressARB) { - fprintf (stderr, "Error: Failed to find function %s.\n", - name); - return NULL; - } - } + void *ret; /* If our library has this symbol, that's what we want to give. */ - ptr = dlwrap_real_dlsym (NULL, (const char *) func); - if (ptr) - return ptr; + ret = dlwrap_real_dlsym (NULL, (const char *) func); + if (ret) + return ret; /* Otherwise, just defer to the real glXGetProcAddressARB. */ - return real_glXGetProcAddressARB (func); + GLWRAP_DEFER_WITH_RETURN (ret, glXGetProcAddressARB, func); + + return ret; +} + +void (*glXGetProcAddress (const GLubyte *func))(void) +{ + /* This comment must not be removed. It ensures that the + * glXGetProcAddress function ends up in our exported symbol + * list even though there's not otherwise any code saying: + * + * GLWRAP_DEFER_WITH_RETURN (ret, glXGetProcAddress, func); + */ + return glXGetProcAddressARB(func); +} + +Bool +glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx) +{ + Bool ret; + + fips_dispatch_init (FIPS_API_GLX); + + GLWRAP_DEFER_WITH_RETURN (ret, glXMakeCurrent, dpy, drawable, ctx); + + return ret; }