22 void glCheckError(
const char* file,
unsigned int line,
const char* expression)
25 GLenum errorCode = glGetError();
27 if (errorCode != GL_NO_ERROR)
29 std::string fileString = file;
30 std::string error =
"Unknown error";
31 std::string description =
"No description";
38 error =
"GL_INVALID_ENUM";
39 description =
"An unacceptable value has been specified for an enumerated argument.";
43 case GL_INVALID_VALUE:
45 error =
"GL_INVALID_VALUE";
46 description =
"A numeric argument is out of range.";
50 case GL_INVALID_OPERATION:
52 error =
"GL_INVALID_OPERATION";
53 description =
"The specified operation is not allowed in the current state.";
57 case GL_STACK_OVERFLOW:
59 error =
"GL_STACK_OVERFLOW";
60 description =
"This command would cause a stack overflow.";
64 case GL_STACK_UNDERFLOW:
66 error =
"GL_STACK_UNDERFLOW";
67 description =
"This command would cause a stack underflow.";
71 case GL_OUT_OF_MEMORY:
73 error =
"GL_OUT_OF_MEMORY";
74 description =
"There is not enough memory left to execute the command.";
80 error =
"GK_UNKNOWN_ERROR";
81 description =
"Unknown error: " + std::to_string(errorCode);
94 std::cerr <<
"An internal OpenGL call failed in " 95 << fileString.substr(fileString.find_last_of(
"\\/") + 1) <<
"(" << line <<
")." 96 <<
"\nExpression:\n " << expression
97 <<
"\nError description:\n " << error <<
"\n " << description <<
"\n"
void glCheckError(const char *file, unsigned int line, const char *expression)