1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

add isGLError() function.

This commit is contained in:
Sergey Lipskiy 2014-09-13 18:09:54 +07:00
parent 4f900df0ba
commit 245cd1b8b5
2 changed files with 48 additions and 0 deletions

View File

@ -823,3 +823,49 @@ bool checkFBO() {
}
return e == GL_FRAMEBUFFER_COMPLETE;
}
const char* GLErrorString(GLenum errorCode)
{
static const struct {
GLenum code;
const char *string;
} errors[]=
{
/* GL */
{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"},
{0, NULL }
};
int i;
for (i=0; errors[i].string; i++)
{
if (errors[i].code == errorCode)
{
return errors[i].string;
}
}
return NULL;
}
bool isGLError()
{
GLenum errCode;
const char* errString;
if ((errCode = glGetError()) != GL_NO_ERROR) {
errString = GLErrorString(errCode);
if (errString != NULL)
fprintf (stderr, "OpenGL Error: %s\n", errString);
return true;
}
return false;
}

View File

@ -111,4 +111,6 @@ void OGL_ReadScreen( void **dest, long *width, long *height );
bool checkFBO();
bool isGLError();
#endif