Added a helper function that prints opengl errors

This commit is contained in:
Deve 2017-01-09 23:21:40 +01:00
parent be2e86166f
commit ecd5445eed
2 changed files with 45 additions and 0 deletions

View File

@ -765,5 +765,49 @@ else \
#endif // ifdef XX
} // getGLLimits
// ----------------------------------------------------------------------------
/** Executes glGetError and prints error to the console
* \return True if error ocurred
*/
bool checkGLError()
{
GLenum err = glGetError();
switch (err)
{
case GL_NO_ERROR:
break;
case GL_INVALID_ENUM:
Log::warn("GLWrap", "glGetError: GL_INVALID_ENUM");
break;
case GL_INVALID_VALUE:
Log::warn("GLWrap", "glGetError: GL_INVALID_VALUE");
break;
case GL_INVALID_OPERATION:
Log::warn("GLWrap", "glGetError: GL_INVALID_OPERATION");
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
Log::warn("GLWrap", "glGetError: GL_INVALID_FRAMEBUFFER_OPERATION");
break;
case GL_OUT_OF_MEMORY:
Log::warn("GLWrap", "glGetError: GL_OUT_OF_MEMORY");
break;
#if !defined(USE_GLES2)
case GL_STACK_UNDERFLOW:
Log::warn("GLWrap", "glGetError: GL_STACK_UNDERFLOW");
break;
case GL_STACK_OVERFLOW:
Log::warn("GLWrap", "glGetError: GL_STACK_OVERFLOW");
break;
#endif
default:
Log::warn("GLWrap", "glGetError: %i", (int)err);
break;
}
return err != GL_NO_ERROR;
}
#endif // !SERVER_ONLY

View File

@ -168,6 +168,7 @@ void draw3DLine(const core::vector3df& start,
bool hasGLExtension(const char* extension);
const std::string getGLExtensions();
void getGLLimits(HardwareStats::Json *json);
bool checkGLError();
#endif