utils: pretty-print output of gl_get_error_string().

This commit is contained in:
Gwenole Beauchesne 2012-01-13 14:13:55 +01:00
parent a3c9365f15
commit 30ef6802d6

View file

@ -62,30 +62,24 @@ find_string(const char *name, const char *ext, const char *sep)
const char * const char *
gl_get_error_string(GLenum error) gl_get_error_string(GLenum error)
{ {
static const struct { switch (error) {
GLenum val; #define MAP(id, str) \
const char *str; case id: return str " (" #id ")"
} MAP(GL_NO_ERROR, "no error");
gl_errors[] = { MAP(GL_INVALID_ENUM, "invalid enumerant");
{ GL_NO_ERROR, "no error" }, MAP(GL_INVALID_VALUE, "invalid value");
{ GL_INVALID_ENUM, "invalid enumerant" }, MAP(GL_INVALID_OPERATION, "invalid operation");
{ GL_INVALID_VALUE, "invalid value" }, MAP(GL_STACK_OVERFLOW, "stack overflow");
{ GL_INVALID_OPERATION, "invalid operation" }, MAP(GL_STACK_UNDERFLOW, "stack underflow");
{ GL_STACK_OVERFLOW, "stack overflow" }, MAP(GL_OUT_OF_MEMORY, "out of memory");
{ GL_STACK_UNDERFLOW, "stack underflow" },
{ GL_OUT_OF_MEMORY, "out of memory" },
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT #ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, MAP(GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
"invalid framebuffer operation");
#endif #endif
{ ~0, NULL } #undef MAP
default: break;
}; };
return "<unknown>";
guint i;
for (i = 0; gl_errors[i].str; i++) {
if (gl_errors[i].val == error)
return gl_errors[i].str;
}
return "unknown";
} }
/** /**