diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 6e8589f..2bb7799 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -499,13 +499,7 @@ epoxy_get_proc_address(const char *name) #elif defined(__APPLE__) return epoxy_gl_dlsym(name); #else - if (api.egl_handle) { -#if PLATFORM_HAS_EGL - return eglGetProcAddress(name); -#else - return NULL; -#endif - } else if (api.glx_handle) { + if (api.glx_handle && glXGetCurrentContext()) { return glXGetProcAddressARB((const GLubyte *)name); } else { /* If the application hasn't explicitly called some of our GLX @@ -516,34 +510,36 @@ epoxy_get_proc_address(const char *name) * application's namespace, then use that. */ PFNGLXGETPROCADDRESSARBPROC glx_gpa; - #if PLATFORM_HAS_EGL PFNEGLGETPROCADDRESSPROC egl_gpa; - egl_gpa = dlsym(NULL, "eglGetProcAddress"); - if (egl_gpa) - return egl_gpa(name); #endif glx_gpa = dlsym(NULL, "glXGetProcAddressARB"); - if (glx_gpa) + if (glx_gpa && glXGetCurrentContext()) return glx_gpa((const GLubyte *)name); #if PLATFORM_HAS_EGL + egl_gpa = dlsym(NULL, "eglGetProcAddress"); + if (egl_gpa) + return egl_gpa(name); +#endif /* PLATFORM_HAS_EGL */ + /* OK, couldn't find anything in the app's address space. * Presumably they dlopened with RTLD_LOCAL, which hides it * from us. Just go dlopen()ing likely libraries and try them. */ + glx_gpa = do_dlsym(&api.glx_handle, GLX_LIB, "glXGetProcAddressARB", + false); + if (glx_gpa && glXGetCurrentContext()) + return glx_gpa((const GLubyte *)name); + +#if PLATFORM_HAS_EGL egl_gpa = do_dlsym(&api.egl_handle, "libEGL.so.1", "eglGetProcAddress", false); if (egl_gpa) return egl_gpa(name); #endif /* PLATFORM_HAS_EGL */ - return do_dlsym(&api.glx_handle, GLX_LIB, "glXGetProcAddressARB", - false); - if (glx_gpa) - return glx_gpa((const GLubyte *)name); - errx(1, "Couldn't find GLX or EGL libraries.\n"); } #endif diff --git a/test/Makefile.am b/test/Makefile.am index 40a63af..972a5db 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -64,7 +64,6 @@ check_BINARIES = $(EGL_AND_GLX_BIN) XFAIL_TESTS = \ egl_and_glx_different_pointers_egl_glx \ - egl_and_glx_different_pointers_glx \ $() check_PROGRAMS = $(TESTS)