From 486354d63f35014aa6cd46b77d68c3127b5bcded Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 17 Nov 2015 23:29:08 +0100 Subject: [PATCH] Fix libGL not being found on NetBSD Fixes #646. --- README.md | 1 + src/glx_context.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8480b67e..e78bb897 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ used by the tests and examples and are not required to build the library. - [WGL] Removed dependency on external WGL headers - [GLX] Replaced legacy renderable with `GLXWindow` - [GLX] Removed dependency on external GLX headers + - [GLX] Bugfix: NetBSD does not provide `libGL.so.1` - [EGL] Removed dependency on external EGL headers diff --git a/src/glx_context.c b/src/glx_context.c index 1539fbb5..426249d4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -152,19 +152,32 @@ static GLXContext createLegacyContext(_GLFWwindow* window, // int _glfwInitContextAPI(void) { + int i; + const char* sonames[] = + { #if defined(__CYGWIN__) - const char* soname = "libGL-1.so"; + "libGL-1.so", #else - const char* soname = "libGL.so.1"; + "libGL.so.1", + "libGL.so", #endif + NULL + }; + if (!_glfwCreateContextTLS()) return GLFW_FALSE; - _glfw.glx.handle = dlopen(soname, RTLD_LAZY | RTLD_GLOBAL); + for (i = 0; sonames[i]; i++) + { + _glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL); + if (_glfw.glx.handle) + break; + } + if (!_glfw.glx.handle) { - _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: %s", dlerror()); + _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX"); return GLFW_FALSE; }