From 83b3fe86b1c13f40a6be4580b4079980030a54a7 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 30 Mar 2018 15:35:05 +0100 Subject: 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. --- gl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 gl.c (limited to 'gl.c') 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 + * 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"; +} -- cgit v1.2.3-54-g00ecf