X-Git-Url: http://git.tdb.fi/?p=gldbg.git;a=blobdiff_plain;f=source%2Fglwrap.c;h=bf05214b8a09d7ee844d5567626b395b2066f1db;hp=d51eb3192106b9ce94fa77b200a2c6797565f0de;hb=ca49785159e6a7cfd2d999a99041fa1567575a24;hpb=2f49929fc383eab718b5fb64d966535b753e7024 diff --git a/source/glwrap.c b/source/glwrap.c index d51eb31..bf05214 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -21,10 +21,13 @@ static inline void *glsym(const char *sym) static void *libgl = NULL; if(!libgl) { - libgl = dlopen("libGL.so", RTLD_NOW); + const char *libgl_name = getenv("GLWRAP_LIBGL"); + if(!libgl_name) + libgl_name = "libGL.so"; + libgl = dlopen(libgl_name, RTLD_NOW); if(!libgl) { - fprintf(stderr, "Could not open libGL: %s\n", dlerror()); + fprintf(stderr, "Could not open %s: %s\n", libgl_name, dlerror()); abort(); } } @@ -188,12 +191,20 @@ GLenum APIENTRY glGetError() void (*glXGetProcAddress(const GLubyte *procname))(void) { - void *handle = dlopen(NULL, RTLD_LAZY); - void (*ret)() = dlsym(handle, (const char *)procname); + void *handle = 0; + void (*ret)() = 0; + + if(glsym((const char *)procname)) + { + handle = dlopen(NULL, RTLD_LAZY); + ret = dlsym(handle, (const char *)procname); + } + begin_packet(FUNC_GLXGETPROCADDRESS); write_pointer(ret); - write_string(procname); + write_string((const char *)procname); send_packet(); + return ret; }