Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs in loading OpenGL/GLX/EGL libraries #229

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions src/dispatch_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
#define GLES2_LIB "libGLESv2.dll"
#define OPENGL_LIB "OPENGL32"
#else
#define GLVND_GLX_LIB "libGLX.so.1"
#define GLVND_GLX_LIB "libGLX.so.0"
#define GLX_LIB "libGL.so.1"
#define EGL_LIB "libEGL.so.1"
#define GLES1_LIB "libGLESv1_CM.so.1"
Expand Down Expand Up @@ -580,21 +580,28 @@ epoxy_current_context_is_glx(void)
#else
void *sym;

sym = epoxy_conservative_glx_dlsym("glXGetCurrentContext", false);
if (sym) {
if (glXGetCurrentContext())
return true;
} else {
(void)dlerror();
// There is no point of getting symbols from library, which is not loaded,
// as handle will always be NULL, when exit_on_fail is false
if (api.glx_handle) {
sym = epoxy_conservative_glx_dlsym("glXGetCurrentContext", false);
if (sym) {
if (glXGetCurrentContext())
return true;
} else {
(void)dlerror();
}
}

#if PLATFORM_HAS_EGL
sym = epoxy_conservative_egl_dlsym("eglGetCurrentContext", false);
if (sym) {
if (epoxy_egl_get_current_gl_context_api() != EGL_NONE)
return false;
} else {
(void)dlerror();
// Same as for GLX
if (api.egl_handle) {
sym = epoxy_conservative_egl_dlsym("eglGetCurrentContext", false);
if (sym) {
if (epoxy_egl_get_current_gl_context_api() != EGL_NONE)
return false;
} else {
(void)dlerror();
}
}
#endif /* PLATFORM_HAS_EGL */

Expand Down Expand Up @@ -674,9 +681,13 @@ epoxy_load_gl(void)
if (!api.gl_handle)
get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true);
#endif

get_dlopen_handle(&api.glx_handle, GLX_LIB, true, true);
api.gl_handle = api.glx_handle;
if (!api.gl_handle) {
get_dlopen_handle(&api.gl_handle, GLX_LIB, true, true);
#if PLATFORM_HAS_GLX
if (!api.glx_handle)
api.glx_handle = api.gl_handle;
#endif
}
#endif
}

Expand Down