17static inline const char *GetGLErrorString(GLenum error)
24 return "GL_INVALID_ENUM";
25 case GL_INVALID_VALUE:
26 return "GL_INVALID_VALUE";
27 case GL_INVALID_OPERATION:
28 return "GL_INVALID_OPERATION";
29 case GL_INVALID_FRAMEBUFFER_OPERATION:
30 return "GL_INVALID_FRAMEBUFFER_OPERATION";
31 case GL_OUT_OF_MEMORY:
32 return "GL_OUT_OF_MEMORY";
33 case GL_STACK_UNDERFLOW:
34 return "GL_STACK_UNDERFLOW";
35 case GL_STACK_OVERFLOW:
36 return "GL_STACK_OVERFLOW";
38 return "Unknown GL error";
42static inline void CheckAndThrowGLErrors()
44 GLenum err = glGetError();
45 bool hasError = (err != GL_NO_ERROR);
47 while (err != GL_NO_ERROR)
49 std::cerr <<
"GLError " << GetGLErrorString(err)
50 <<
" set in File: " << __FILE__
51 <<
" Line: " << __LINE__ << std::endl;
57 throw std::runtime_error(
"GL error(s) caught");
61static inline void FlushGLErrors()
64 while ((err = glGetError()) != GL_NO_ERROR)