diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 7b7ff6396..18a2eae27 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -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 diff --git a/src/graphics/glwrap.hpp b/src/graphics/glwrap.hpp index e150bb06f..a9e42b9e5 100644 --- a/src/graphics/glwrap.hpp +++ b/src/graphics/glwrap.hpp @@ -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