diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/GfxDevice/opengl/GLAssert.cpp |
Diffstat (limited to 'Runtime/GfxDevice/opengl/GLAssert.cpp')
-rw-r--r-- | Runtime/GfxDevice/opengl/GLAssert.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Runtime/GfxDevice/opengl/GLAssert.cpp b/Runtime/GfxDevice/opengl/GLAssert.cpp new file mode 100644 index 0000000..4f3501d --- /dev/null +++ b/Runtime/GfxDevice/opengl/GLAssert.cpp @@ -0,0 +1,42 @@ +#include "UnityPrefix.h" +#include "GLAssert.h" +#include "UnityGL.h" + +#if UNITY_WIN || UNITY_LINUX +#include <GL/glu.h> +#else +#include <OpenGL/glu.h> +#endif + +using namespace std; + +void CheckOpenGLError (const char *prefix, const char* file, long line) +{ + const int kMaxErrors = 10; + int counter = 0; + + GLenum glerr; + while( (glerr = glGetError ()) != GL_NO_ERROR ) + { + if (prefix) + { + string errorString = prefix; + errorString += ": "; + const char* gluMsg = reinterpret_cast<const char*>(gluErrorString (glerr)); + errorString += gluMsg ? gluMsg : Format("unknown error 0x%x", glerr); + DebugStringToFile (errorString.c_str(), 0, file, line, kAssert); + } + else + { + const char* gluMsg = reinterpret_cast<const char*>(gluErrorString (glerr)); + string errorString = gluMsg ? gluMsg : Format("unknown error 0x%x", glerr); + DebugStringToFile (errorString.c_str(), 0, file, line, kAssert); + } + ++counter; + if( counter > kMaxErrors ) + { + printf_console( "GL: error count exceeds %i, stop reporting errors\n", kMaxErrors ); + return; + } + } +} |