From 3b2fceed064c06d55e1cd33d51e855e909c81f75 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 10 Oct 2021 12:56:55 +0200 Subject: add event and test graphics --- src/glx.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/glx.c') 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 +/*#include */ #include -#include + +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; -- cgit v1.2.3