X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glwrap.h;fp=glwrap.h;h=2dc18383c0c864e40e5b033ce67f2f209fe895dd;hb=4ef9d74d4ff12afcc7e31bf13fe2a4993f06b987;hp=81e1e34c9f0ccc11980de3e70caf42366dd501c2;hpb=385fae6dca60b9b41e91c9b8bfe1a05a4eb18240;p=fips diff --git a/glwrap.h b/glwrap.h index 81e1e34..2dc1838 100644 --- a/glwrap.h +++ b/glwrap.h @@ -22,6 +22,21 @@ #ifndef GLWRAP_H #define GLWRAP_H +/* Lookup a function named 'name' in the underlying, real, libGL.so */ +void * +glwrap_lookup (char *name); + +/* Defer to the real 'function' (from libGL.so) to do the real work. + * The symbol is looked up once and cached in a static variable for + * future uses. + */ +#define GLWRAP_DEFER(function,...) do { \ + static typeof(&function) real_ ## function; \ + if (! real_ ## function) \ + real_ ## function = glwrap_lookup (#function); \ + real_ ## function(__VA_ARGS__); \ +} while (0); + /* Should be called at the end of ever function wrapper for an OpenGL * function that ends a frame, (glXSwapBuffers and similar). */