aboutsummaryrefslogtreecommitdiff
path: root/src/glx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glx.c')
-rw-r--r--src/glx.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/glx.c b/src/glx.c
index 4a5af9d..6712947 100644
--- a/src/glx.c
+++ b/src/glx.c
@@ -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;