mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 13:22:15 +00:00
[cogl] Rework the GL-error-to-string conversion
The code for the conversion of the GL error enumeration code into a string is not following the code style and conventions we follow in Clutter and COGL. The GE() macro is also using fprintf(stderr) directly instead of using g_warning() -- which is redirectable to an alternative logging system using the g_log* API.
This commit is contained in:
parent
642f551321
commit
64b727d329
@ -55,17 +55,17 @@ typedef struct _CoglBoxedValue
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const char *_cogl_error_string(GLenum errorCode);
|
||||
const gchar *cogl_gl_error_to_string (GLenum error_code);
|
||||
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum err; \
|
||||
(x); \
|
||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||
(char *)_cogl_error_string(err), \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum __err; \
|
||||
(x); \
|
||||
while ((err = glGetError ()) != GL_NO_ERROR) \
|
||||
{ \
|
||||
g_warning ("%s: GL error (%d): %s\n", \
|
||||
G_STRLOC, \
|
||||
cogl_gl_error_to_string (err));\
|
||||
} } G_STMT_END
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
|
||||
|
@ -46,39 +46,41 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||
#include "cogl-gles2-wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef COGL_DEBUG
|
||||
/* GL error to string conversion */
|
||||
#if COGL_DEBUG
|
||||
struct token_string
|
||||
{
|
||||
GLuint Token;
|
||||
const char *String;
|
||||
};
|
||||
static const struct {
|
||||
GLuint error_code;
|
||||
const gchar *error_string;
|
||||
} gl_errors[] = {
|
||||
{ GL_NO_ERROR, "No error" },
|
||||
{ GL_INVALID_ENUM, "Invalid enumeration value" },
|
||||
{ GL_INVALID_VALUE, "Invalid value" },
|
||||
{ GL_INVALID_OPERATION, "Invalid operation" },
|
||||
{ GL_STACK_OVERFLOW, "Stack overflow" },
|
||||
{ GL_STACK_UNDERFLOW, "Stack underflow" },
|
||||
{ GL_OUT_OF_MEMORY, "Out of memory" },
|
||||
|
||||
static const struct token_string Errors[] = {
|
||||
{ GL_NO_ERROR, "no error" },
|
||||
{ GL_INVALID_ENUM, "invalid enumerant" },
|
||||
{ GL_INVALID_VALUE, "invalid value" },
|
||||
{ GL_INVALID_OPERATION, "invalid operation" },
|
||||
{ GL_STACK_OVERFLOW, "stack overflow" },
|
||||
{ GL_STACK_UNDERFLOW, "stack underflow" },
|
||||
{ GL_OUT_OF_MEMORY, "out of memory" },
|
||||
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
|
||||
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "Invalid framebuffer operation" }
|
||||
#endif
|
||||
{ ~0, NULL }
|
||||
};
|
||||
|
||||
const char*
|
||||
_cogl_error_string(GLenum errorCode)
|
||||
static const guint n_gl_errors = G_N_ELEMENTS (gl_errors);
|
||||
|
||||
const gchar *
|
||||
cogl_gl_error_to_string (GLenum error_code)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; Errors[i].String; i++) {
|
||||
if (Errors[i].Token == errorCode)
|
||||
return Errors[i].String;
|
||||
}
|
||||
return "unknown";
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_gl_errors; i++)
|
||||
{
|
||||
if (gl_errors[i].error_code == error_code)
|
||||
return gl_errors[i].error_string;
|
||||
}
|
||||
|
||||
return "Unknown error";
|
||||
}
|
||||
#endif
|
||||
#endif /* COGL_DEBUG */
|
||||
|
||||
void
|
||||
cogl_clear (const CoglColor *color, gulong buffers)
|
||||
|
Loading…
Reference in New Issue
Block a user