aboutsummaryrefslogtreecommitdiffstats
path: root/gl.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-03-30 15:35:05 +0100
committerTomasz Kramkowski <tk@the-tk.com>2018-03-30 15:35:05 +0100
commit83b3fe86b1c13f40a6be4580b4079980030a54a7 (patch)
treed3ea228b9ac42d7ed34ba8699167bf8ff29931e1 /gl.c
parent93c76bf190d843ef77c71682570f28e9fb871a08 (diff)
downloadfaqe-83b3fe86b1c13f40a6be4580b4079980030a54a7.tar.gz
faqe-83b3fe86b1c13f40a6be4580b4079980030a54a7.tar.xz
faqe-83b3fe86b1c13f40a6be4580b4079980030a54a7.zip
Simplify gl loading by removing m4 and merging gldefs.h
m4 has been removed, loadgl.c.in is now gl.c, gldefs.h and loadgl.h.in have now been merged into gl.h. loadgl.m4 has been transformed into glfunc.h which is being used in the way of a bie index file to generate information at 3 places. lgl_load is now gl_load and doesn't return anything, the jongjmp.h method of error handling was pre-emptive and for now this much simpler system will suffice. This means that lgl_strerror is no longer neede.
Diffstat (limited to 'gl.c')
-rw-r--r--gl.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/gl.c b/gl.c
new file mode 100644
index 0000000..8e84e16
--- /dev/null
+++ b/gl.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Tomasz Kramkowski <tk@the-tk.com>
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "eprintf.h"
+#include "gl.h"
+
+#define GL_FUNC(glname, rtype, name, ...) name##_func *name;
+#include "glfunc.h"
+#undef GL_FUNC
+
+static void *load_func(const char *name, gl_loadfunc *load)
+{
+ void *ret;
+
+ ret = load(name);
+ if (ret == NULL)
+ eprintf("Could not load OpenGL function: %s\n", name);
+
+ return ret;
+}
+
+void gl_load(gl_loadfunc *load)
+{
+#define GL_FUNC(glname, rtype, name, ...) \
+ name = (name##_func *)load_func(#glname, load);
+#include "glfunc.h"
+#undef GL_FUNC
+}
+
+const char *gl_strerror(GLenum error)
+{
+ switch (error) {
+ case GL_NO_ERROR: return "No error";
+ case GL_INVALID_ENUM: return "Invalid enumeration";
+ case GL_INVALID_VALUE: return "Invalid value";
+ case GL_INVALID_OPERATION: return "Invalid operation";
+ case GL_STACK_OVERFLOW: return "Stack overflow";
+ case GL_STACK_UNDERFLOW: return "Stack underflow";
+ case GL_OUT_OF_MEMORY: return "Out of memory";
+ case GL_INVALID_FRAMEBUFFER_OPERATION: return "Invalid framebuffer operation";
+ case GL_CONTEXT_LOST: return "Context lost";
+ }
+ return "Unknown";
+}