Print the name of OpenGL errors when they occur.
Patch by vladislavbelov Differential Revision: https://code.wildfiregames.com/D313 This was SVN commit r19496.
This commit is contained in:
parent
ba5ab40c66
commit
6ee830068a
@ -373,10 +373,9 @@ static void importExtensionFunctions()
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
static void dump_gl_error(GLenum err)
|
||||
const char* ogl_GetErrorName(GLenum err)
|
||||
{
|
||||
debug_printf("OGL| ");
|
||||
#define E(e) case e: debug_printf("%s\n", #e); break;
|
||||
#define E(e) case e: return #e;
|
||||
switch (err)
|
||||
{
|
||||
E(GL_INVALID_ENUM)
|
||||
@ -388,11 +387,16 @@ static void dump_gl_error(GLenum err)
|
||||
#endif
|
||||
E(GL_OUT_OF_MEMORY)
|
||||
E(GL_INVALID_FRAMEBUFFER_OPERATION)
|
||||
default: debug_printf("Unknown GL error: %04x\n", err); break;
|
||||
default: return "Unknown GL error";
|
||||
}
|
||||
#undef E
|
||||
}
|
||||
|
||||
static void dump_gl_error(GLenum err)
|
||||
{
|
||||
debug_printf("OGL| %s (%04x)\n", ogl_GetErrorName(err), err);
|
||||
}
|
||||
|
||||
void ogl_WarnIfErrorLoc(const char *file, int line)
|
||||
{
|
||||
// glGetError may return multiple errors, so we poll it in a loop.
|
||||
@ -414,7 +418,7 @@ void ogl_WarnIfErrorLoc(const char *file, int line)
|
||||
}
|
||||
|
||||
if(error_enountered)
|
||||
debug_printf("%s:%d: OpenGL error(s) occurred: %04x\n", file, line, (unsigned int)first_error);
|
||||
debug_printf("%s:%d: OpenGL error(s) occurred: %s (%04x)\n", file, line, ogl_GetErrorName(first_error), (unsigned int)first_error);
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,6 +159,16 @@ extern void ogl_WarnIfErrorLoc(const char *file, int line);
|
||||
# define ogl_WarnIfError() ogl_WarnIfErrorLoc(__FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* get a name of the error.
|
||||
*
|
||||
* useful for debug.
|
||||
*
|
||||
* @return read-only C string of unspecified length containing
|
||||
* the error's name.
|
||||
**/
|
||||
extern const char* ogl_GetErrorName(GLenum err);
|
||||
|
||||
/**
|
||||
* ignore and reset the specified OpenGL error.
|
||||
*
|
||||
|
@ -1628,7 +1628,7 @@ void CRenderer::EndFrame()
|
||||
int err = glGetError();
|
||||
if (err)
|
||||
{
|
||||
ONCE(LOGERROR("CRenderer::EndFrame: GL errors %i occurred", err));
|
||||
ONCE(LOGERROR("CRenderer::EndFrame: GL errors %s (%04x) occurred", ogl_GetErrorName(err), err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user