OPENGL: Ensure that glGetError() is cleared before calling a checked function

This commit is contained in:
Cameron Cawley 2022-06-29 21:40:01 +01:00
parent 863988fee4
commit c13961362f
2 changed files with 9 additions and 1 deletions

View File

@ -55,6 +55,13 @@ Common::String getGLErrStr(GLenum error) {
}
} // End of anonymous namespace
void clearGLError() {
GLenum error;
while ((error = glGetError()) != GL_NO_ERROR)
;
}
void checkGLError(const char *expr, const char *file, int line) {
GLenum error;

View File

@ -29,10 +29,11 @@
#ifdef OPENGL_DEBUG
namespace OpenGL {
void clearGLError();
void checkGLError(const char *expr, const char *file, int line);
} // End of namespace OpenGL
#define GL_WRAP_DEBUG(call, name) do { (call); OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
#define GL_WRAP_DEBUG(call, name) do { OpenGL::clearGLError(); (call); OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
#else
#define GL_WRAP_DEBUG(call, name) do { (call); } while (false)
#endif