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:
parent
4f900df0ba
commit
245cd1b8b5
46
OpenGL.cpp
46
OpenGL.cpp
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user