Advertisement
Sk8erPeter

glGetError() error information output (OpenGL debugging)

Dec 8th, 2013
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.00 KB | None | 0 0
  1. /**
  2.  * Return error information using glGetError
  3.  *
  4.  * @see http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml
  5.  * @see http://www.opengl.org/wiki/OpenGL_Error
  6.  */
  7. inline void GetOpenGLError(std::string debugMessage = "", bool longMessage = false) {
  8.  
  9.   GLenum error = glGetError();
  10.   if (debugMessage != "") {
  11.     std::cout << "glGetError(): \"" << debugMessage << "\" - ";
  12.   }
  13.  
  14.   if (error != GL_NO_ERROR) {
  15.     switch (error) {
  16.       case GL_INVALID_ENUM:
  17.         std::cout << "GL_INVALID_ENUM" << (longMessage ? " (0x0500 - Given when an enumeration parameter is not a legal enumeration for that function. This is given only for local problems; if the spec allows the enumeration in certain circumstances, where other parameters or state dictate those circumstances, then GL_INVALID_OPERATION​ is the result instead.)" : "") << std::endl;
  18.         break;
  19.       case GL_INVALID_VALUE:
  20.         std::cout << "GL_INVALID_VALUE" << (longMessage ? " (0x0501 - Given when a value parameter is not a legal value for that function. This is only given for local problems; if the spec allows the value in certain circumstances, where other parameters or state dictate those circumstances, then GL_INVALID_OPERATION is the result instead.)" : "") << std::endl;
  21.         break;
  22.       case GL_INVALID_OPERATION:
  23.         std::cout << "GL_INVALID_OPERATION" << (longMessage ? " (0x0502 - Given when the set of state for a command is not legal for the parameters given to that command. It is also given for commands where combinations of parameters define what the legal parameters are.)" : "") << std::endl;
  24.         break;
  25.       case GL_STACK_OVERFLOW:
  26.         std::cout << "GL_STACK_OVERFLOW" << (longMessage ? " (0x0503 - Given when a stack pushing operation cannot be done because it would overflow the limit of that stack's size.)" : "") << std::endl;
  27.         break;
  28.       case GL_STACK_UNDERFLOW:
  29.         std::cout << "GL_STACK_UNDERFLOW" << (longMessage ? " (0x0504 - Given when a stack popping operation cannot be done because the stack is already at its lowest point.)" : "") << std::endl;
  30.         break;
  31.       case GL_OUT_OF_MEMORY:
  32.         std::cout << "GL_OUT_OF_MEMORY" << (longMessage ? " (0x0505 - Given when performing an operation that can allocate memory, and the memory cannot be allocated. The results of OpenGL functions that return this error are undefined; it is allowable for partial operations to happen.)" : "") << std::endl;
  33.         break;
  34. //      case GL_INVALID_FRAMEBUFFER_OPERATION:
  35. //        std::cout << "GL_INVALID_FRAMEBUFFER_OPERATION" << (longMessage ? " (0x0506 - Given when doing anything that would attempt to read from or write/render to a framebuffer that is not complete.)" : "") << std::endl;
  36. //        break;
  37. //      case GL_TABLE_TOO_LARGE​1:
  38. //        std::cout << "GL_TABLE_TOO_LARGE​1" << (longMessage ? " (0x8031 - Part of the ARB_imaging extension.)" : "") << std::endl;
  39. //        break;
  40.     };
  41.   } else if (debugMessage != "") {
  42.     std::cout << "No error." << std::endl;
  43.   }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement