diff options
Diffstat (limited to 'src/glx.c')
-rw-r--r-- | src/glx.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -1,7 +1,12 @@ #include "../include/mgl/glx.h" #include <dlfcn.h> +/*#include <GL/glx.h>*/ #include <stdio.h> -#include <GL/glx.h> + +typedef struct { + void **func; + const char *name; +} dlsym_assign; static void* dlsym_print_fail(void *handle, const char *name) { dlerror(); @@ -22,10 +27,21 @@ int mgl_glx_load(mgl_glx *self) { return -1; } - self->glXGetFBConfigs = (GLXFBConfig* (*)(Display*, int, int*))dlsym_print_fail(self->handle, "glXGetFBConfigs"); - if(!self->glXGetFBConfigs) { - mgl_glx_unload(self); - return -1; + const dlsym_assign assign[] = { + { &self->glXChooseVisual, "glXChooseVisual" }, + { &self->glXCreateContext, "glXCreateContext" }, + { &self->glXDestroyContext, "glXDestroyContext" }, + { &self->glXMakeCurrent, "glXMakeCurrent" }, + { &self->glXSwapBuffers, "glXSwapBuffers" }, + { NULL, NULL } + }; + + for(int i = 0; assign[i].func; ++i) { + *assign[i].func = dlsym_print_fail(self->handle, assign[i].name); + if(!assign[i].func) { + mgl_glx_unload(self); + return -1; + } } return 0; |