From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/GfxDevice/opengl/GLAssert.cpp | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Runtime/GfxDevice/opengl/GLAssert.cpp (limited to 'Runtime/GfxDevice/opengl/GLAssert.cpp') 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 +#else +#include +#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(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(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; + } + } +} -- cgit v1.1-26-g67d0