diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am index af5efce4d..43fd46ca6 100644 --- a/tests/tools/Makefile.am +++ b/tests/tools/Makefile.am @@ -10,6 +10,12 @@ libdisable_npots_la_SOURCES = disable-npots.c libdisable_npots_la_LIBADD = -ldl +INCLUDES = \ + -I$(top_srcdir)/clutter \ + -I$(top_builddir)/clutter \ + $(CLUTTER_CFLAGS) \ + -D_GNU_SOURCE + all-local : disable-npots.sh clean-local : diff --git a/tests/tools/disable-npots.c b/tests/tools/disable-npots.c index baa1f5778..2a942d2af 100644 --- a/tests/tools/disable-npots.c +++ b/tests/tools/disable-npots.c @@ -4,13 +4,22 @@ * overrides glGetString and removes the extension strings. */ -#include +/* This is just included to get the right GL header */ +#include + #include #include #include #include #include +/* If RTLD_NEXT isn't available then try just using NULL */ +#ifdef RTLD_NEXT +#define LIB_HANDLE RTLD_NEXT +#else +#define LIB_HANDLE NULL +#endif + typedef const GLubyte * (* GetStringFunc) (GLenum name); static const char * const bad_strings[] @@ -23,16 +32,14 @@ const GLubyte * glGetString (GLenum name) { const GLubyte *ret = NULL; - static void *gl_lib = NULL; static GetStringFunc func = NULL; static GLubyte *extensions = NULL; - if (gl_lib == NULL - && (gl_lib = dlopen ("libGL.so", RTLD_LAZY)) == NULL) - fprintf (stderr, "dlopen: %s\n", dlerror ()); - else if (func == NULL - && (func = (GetStringFunc) dlsym (gl_lib, "glGetString")) == NULL) + if (func == NULL + && (func = (GetStringFunc) dlsym (LIB_HANDLE, "glGetString")) == NULL) fprintf (stderr, "dlsym: %s\n", dlerror ()); + else if (func == glGetString) + fprintf (stderr, "dlsym returned the wrapper of glGetString\n"); else { ret = (* func) (name);