diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-10 07:07:31 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-10 07:07:31 +0200 |
commit | 1de5e22423bee66769966f21a4c256a0011aba81 (patch) | |
tree | 0dbfff86ecf412d8e161806b20569538367390a5 | |
parent | ee6052d4e727e5197fd6cf5fb55b0fa5102145af (diff) |
Make libglx optional (alpine doesn't have it)
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/gl.c | 10 |
2 files changed, 5 insertions, 7 deletions
@@ -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.\ @@ -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) { |