aboutsummaryrefslogtreecommitdiff
path: root/src/gl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gl.c')
-rw-r--r--src/gl.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/gl.c b/src/gl.c
index c83ab49..023ffbb 100644
--- a/src/gl.c
+++ b/src/gl.c
@@ -1,6 +1,6 @@
#include "../include/mgl/gl.h"
#include <dlfcn.h>
-/*#include <GL/gl.h>*/
+/*#include <GL/glx.h>*/
#include <stdio.h>
typedef struct {
@@ -20,28 +20,46 @@ static void* dlsym_print_fail(void *handle, const char *name) {
}
int mgl_gl_load(mgl_gl *self) {
- const char *gl_path = "/usr/lib/libOpenGL.so.0";
- self->handle = dlopen(gl_path, RTLD_LAZY);
+ const char *glx_path = "/usr/lib/libGL.so.1";
+ self->handle = dlopen(glx_path, RTLD_LAZY);
if(!self->handle) {
- fprintf(stderr, "dlopen(\"%s\", RTLD_LAZY) failed\n", gl_path);
+ fprintf(stderr, "dlopen(\"%s\", RTLD_LAZY) failed\n", glx_path);
return -1;
}
- const dlsym_assign assign[] = {
+ const dlsym_assign required_dlsym[] = {
+ { &self->glXChooseVisual, "glXChooseVisual" },
+ { &self->glXCreateContext, "glXCreateContext" },
+ { &self->glXDestroyContext, "glXDestroyContext" },
+ { &self->glXMakeCurrent, "glXMakeCurrent" },
+ { &self->glXSwapBuffers, "glXSwapBuffers" },
+
{ &self->glViewport, "glViewport" },
{ &self->glClearColor, "glClearColor" },
{ &self->glClear, "glClear" },
+
{ 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) {
+ for(int i = 0; required_dlsym[i].func; ++i) {
+ *required_dlsym[i].func = dlsym_print_fail(self->handle, required_dlsym[i].name);
+ if(!required_dlsym[i].func) {
mgl_gl_unload(self);
return -1;
}
}
+ const dlsym_assign optional_dlsym[] = {
+ { &self->glXSwapIntervalEXT, "glXSwapIntervalEXT" },
+ { &self->glXSwapIntervalMESA, "glXGetSwapIntervalMESA" },
+ { &self->glXSwapIntervalSGI, "glXSwapIntervalSGI" },
+ { NULL, NULL }
+ };
+
+ for(int i = 0; optional_dlsym[i].func; ++i) {
+ *optional_dlsym[i].func = dlsym_print_fail(self->handle, optional_dlsym[i].name);
+ }
+
return 0;
}