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/opengles20/AssertGLES20.cpp | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Runtime/GfxDevice/opengles20/AssertGLES20.cpp (limited to 'Runtime/GfxDevice/opengles20/AssertGLES20.cpp') diff --git a/Runtime/GfxDevice/opengles20/AssertGLES20.cpp b/Runtime/GfxDevice/opengles20/AssertGLES20.cpp new file mode 100644 index 0000000..1b77623 --- /dev/null +++ b/Runtime/GfxDevice/opengles20/AssertGLES20.cpp @@ -0,0 +1,58 @@ +#include "UnityPrefix.h" +#include "AssertGLES20.h" +#include "IncludesGLES20.h" + +#if GFX_SUPPORTS_OPENGLES20 + +using namespace std; + +static const char* GetErrorString(GLenum glerr) +{ + // Error descriptions taken from OpenGLES 1.1 specification (page 13) + switch(glerr) + { + case GL_NO_ERROR: + return "GL_NO_ERROR: No error occured"; + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM: enum argument out of range"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE: Numeric argument out of range"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION: Operation illegal in current state"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY: Not enough memory left to execute command"; + case 0x0506: // INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 + return "GL_INVALID_FRAMEBUFFER_OPERATION_EXT"; + default: +#if UNITY_WEBGL + printf_console("AssertGles20::GetErrorString invoked for unknown error %d",glerr); +#endif + return "Unknown error"; + } +} + +void CheckOpenGLES2Error (const char *prefix, const char* file, long line) +{ + const int kMaxErrors = 10; + int counter = 0; + + GLenum glerr; + while( (glerr = glGetError ()) != GL_NO_ERROR ) + { + string errorString(GetErrorString(glerr)); + + if (prefix) + errorString = string(prefix) + ": " + errorString; + + DebugStringToFile (errorString.c_str(), 0, file, line, kAssert); + + ++counter; + if( counter > kMaxErrors ) + { + printf_console( "GLES: error count exceeds %i, stop reporting errors\n", kMaxErrors ); + return; + } + } +} + +#endif // GFX_SUPPORTS_OPENGLES20 -- cgit v1.1-26-g67d0