diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-27 18:39:56 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-27 19:21:17 +0100 |
commit | 126c248cf55d10c1584f9bb340144b42ae57e847 (patch) | |
tree | 3144da146b96ef6c59526f65dcd9b6559ce880f8 | |
parent | 604ae85b6e76befe96036d16c4e3096b966a03e0 (diff) | |
download | faqe-126c248cf55d10c1584f9bb340144b42ae57e847.tar.gz faqe-126c248cf55d10c1584f9bb340144b42ae57e847.tar.xz faqe-126c248cf55d10c1584f9bb340144b42ae57e847.zip |
Add gl_strerror implementation
gl_strerror takes an OpenGL error enum and acts like strerror.
-rw-r--r-- | gldefs.h | 9 | ||||
-rw-r--r-- | loadgl.c.in | 16 | ||||
-rw-r--r-- | loadgl.h.in | 1 | ||||
-rw-r--r-- | loadgl.m4 | 1 |
4 files changed, 27 insertions, 0 deletions
@@ -32,10 +32,19 @@ typedef double GLdouble; typedef double GLclampd; enum { + GL_NO_ERROR = 0, GL_FALSE = 0, GL_TRUE = 1, GL_TRIANGLES = 0x0004, GL_FRONT_AND_BACK = 0x0408, + GL_INVALID_ENUM = 0x0500, + GL_INVALID_VALUE = 0x0501, + GL_INVALID_OPERATION = 0x0502, + GL_STACK_OVERFLOW = 0x0503, + GL_STACK_UNDERFLOW = 0x0504, + GL_OUT_OF_MEMORY = 0x0505, + GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506, + GL_CONTEXT_LOST = 0x0507, GL_UNSIGNED_INT = 0x1405, GL_FLOAT = 0x1406, GL_LINE = 0x1B01, diff --git a/loadgl.c.in b/loadgl.c.in index a76eebc..1959b64 100644 --- a/loadgl.c.in +++ b/loadgl.c.in @@ -46,3 +46,19 @@ const char *lgl_strerror(enum lgl_status status) } return "Unknown"; } + +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"; +} diff --git a/loadgl.h.in b/loadgl.h.in index e7381cd..e741d5e 100644 --- a/loadgl.h.in +++ b/loadgl.h.in @@ -16,6 +16,7 @@ enum lgl_status { enum lgl_status lgl_load(lgl_loadfunc *load); const char *lgl_strerror(enum lgl_status status); +const char *gl_strerror(GLenum error); #define _LGL_INTERFACE(rett, name, func, ...) \ typedef rett func(__VA_ARGS__); \ @@ -21,6 +21,7 @@ define(`LOADS', `undivert(3)') # Functions +LOAD(glGetError, GLenum, gl_error, void) LOAD(glViewport, void, gl_viewport, GLint x, GLint y, GLsizei width, GLsizei height) LOAD(glClearColor, void, gl_clearcolor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) LOAD(glClear, void, gl_clear, GLbitfield mask) |