1
1
forked from 0ad/0ad

Improve ogl_WarnIfError() to report the file/line where the error was detected

This was SVN commit r16164.
This commit is contained in:
Ykkrosh 2015-01-19 20:06:16 +00:00
parent b74e853144
commit e1e163b3f7
2 changed files with 5 additions and 6 deletions

View File

@ -393,9 +393,7 @@ static void dump_gl_error(GLenum err)
#undef E
}
#ifndef ogl_WarnIfError
// don't include this function if it has been defined (in ogl.h) as a no-op
void ogl_WarnIfError()
void ogl_WarnIfErrorLoc(const char *file, int line)
{
// glGetError may return multiple errors, so we poll it in a loop.
// the debug_printf should only happen once (if this is set), though.
@ -416,9 +414,8 @@ void ogl_WarnIfError()
}
if(error_enountered)
debug_printf(L"OpenGL error(s) occurred: %04x\n", (unsigned int)first_error);
debug_printf(L"%hs:%d: OpenGL error(s) occurred: %04x\n", file, line, (unsigned int)first_error);
}
#endif
// ignore and reset the specified error (as returned by glGetError).

View File

@ -152,9 +152,11 @@ extern const char* ogl_ExtensionString();
*
* disabled in release mode for efficiency and to avoid annoying errors.
**/
extern void ogl_WarnIfError();
extern void ogl_WarnIfErrorLoc(const char *file, int line);
#ifdef NDEBUG
# define ogl_WarnIfError()
#else
# define ogl_WarnIfError() ogl_WarnIfErrorLoc(__FILE__, __LINE__)
#endif
/**