diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-10 12:56:55 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-10 13:18:12 +0200 |
commit | 3b2fceed064c06d55e1cd33d51e855e909c81f75 (patch) | |
tree | 962611955ddac906d906af1b44076d7cfae2bb64 /src/glx.c | |
parent | e57daa001cc74682cdb905d8e0c6c8c3a2c29372 (diff) |
add event and test graphics
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; |