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) --- src/gl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') 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