From 1de5e22423bee66769966f21a4c256a0011aba81 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 10 Aug 2024 07:07:31 +0200 Subject: Make libglx optional (alpine doesn't have it) --- README.md | 2 +- src/gl.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d952ba8..91e07c9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Right now mgl only supports x11. Mgl allows you to choose glx or egl at runtime. ## Build `x11, libxrender, libxrandr` ## Runtime -`libglvnd (libGL.so, libGLX.so, libEGL.so)` +`libglvnd (libGL.so, libEGL.so)` # Notes Every window _get_ function is cached from the last event poll, no calls to x11 is made.\ Only one window can be created and used at once.\ diff --git a/src/gl.c b/src/gl.c index d905eb0..7c9a6bc 100644 --- a/src/gl.c +++ b/src/gl.c @@ -116,8 +116,11 @@ static int mgl_gl_load_glx(mgl_gl *self) { { NULL, NULL } }; + /* In some distros (alpine for example libGLX doesn't exist, but libGL can be used instead) */ + void *library = self->glx_library ? self->glx_library : self->gl_library; + for(int i = 0; required_dlsym[i].func; ++i) { - *required_dlsym[i].func = dlsym_print_fail(self->glx_library, required_dlsym[i].name, 1); + *required_dlsym[i].func = dlsym_print_fail(library, required_dlsym[i].name, 1); if(!*required_dlsym[i].func) return -1; } @@ -169,11 +172,6 @@ int mgl_gl_load(mgl_gl *self) { } self->glx_library = dlopen("libGLX.so.0", RTLD_LAZY); - if(!self->glx_library) { - fprintf(stderr, "mgl error:dlopen(\"%s\", RTLD_LAZY) failed\n", "libGLX.so.0"); - mgl_gl_unload(self); - return -1; - } self->egl_library = dlopen("libEGL.so.1", RTLD_LAZY); if(!self->egl_library) { -- cgit v1.2.3