15 #ifndef vtkOpenGLError_h 16 #define vtkOpenGLError_h 18 #include "vtkSetGet.h" 24 #define VTK_REPORT_OPENGL_ERRORS 28 #if defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS) 29 #define VTK_REPORT_OPENGL_ERRORS 30 #endif // defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS) 71 switch(static_cast<GLenum>(code))
76 return "Invalid enum";
77 case GL_INVALID_VALUE:
78 return "Invalid value";
79 case GL_INVALID_OPERATION:
80 return "Invalid operation";
81 case GL_OUT_OF_MEMORY:
82 return "Out of memory";
83 #ifndef GL_ES_VERSION_3_0 84 case GL_STACK_OVERFLOW:
85 return "Stack overflow";
86 case GL_STACK_UNDERFLOW:
87 return "Stack underflow";
88 case GL_TABLE_TOO_LARGE:
89 return "Table too large";
90 case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
91 return "Invalid framebuffer operation";
94 return "Unknown error";
105 #if defined(VTK_REPORT_OPENGL_ERRORS) 109 unsigned int *errCode,
110 const char **errDesc)
113 GLenum code = glGetError();
116 errCode[i] =
static_cast<unsigned int>(code);
119 while (code != GL_NO_ERROR && i < maxNum)
125 errCode[i] =
static_cast<unsigned int>(code);
135 unsigned int *errCode,
136 const char **errDesc)
151 #if defined(VTK_REPORT_OPENGL_ERRORS) 157 unsigned int *errCode,
158 const char **errDesc)
160 os << numErrors <<
" OpenGL errors detected" << std::endl;
161 for (
int i=0; (i<numErrors)&&(i<maxErrors); ++i)
163 os <<
" " << i <<
" : (" << errCode[i] <<
") " << errDesc[i] << std::endl;
165 if (numErrors>maxErrors)
168 <<
"More than " << maxErrors
169 <<
" detected! The remainder are not reported" 179 unsigned int *errCode,
180 const char **errDesc)
195 #if defined(VTK_REPORT_OPENGL_ERRORS) 199 const int maxNumErrors = 16;
200 unsigned int errCode[maxNumErrors] = {0};
201 const char* errDesc[maxNumErrors] = {NULL};
205 std::ostringstream oss;
207 vtkGenericWarningMacro(<< headerMessage << oss.str().c_str());
224 #if defined(VTK_REPORT_OPENGL_ERRORS) 232 glError = glGetError();
235 while(i < maxErrors && glError != GL_NO_ERROR);
245 #if !defined(VTK_REPORT_OPENGL_ERRORS) 246 # define vtkOpenGLClearErrorMacro() 247 # define vtkOpenGLCheckErrorMacro(message) 248 # define vtkOpenGLStaticCheckErrorMacro(message) 250 # define vtkOpenGLClearErrorMacro() vtkClearOpenGLErrors(16); 252 # define vtkOpenGLCheckErrorMacroImpl(ostr, message) \ 254 const int maxErrors = 16; \ 255 unsigned int errCode[maxErrors] = {0}; \ 256 const char *errDesc[maxErrors] = {NULL}; \ 259 = vtkGetOpenGLErrors( \ 266 std::ostringstream oss; \ 267 vtkPrintOpenGLErrors( \ 274 ostr(<< message << " " << oss.str().c_str()); \ 277 # define vtkOpenGLCheckErrorMacro(message) \ 278 vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message) 279 # define vtkOpenGLStaticCheckErrorMacro(message) \ 280 vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message) 286 # define vtkOpenGLDebugClearErrorMacro() 287 # define vtkOpenGLDebugCheckErrorMacro(message) 289 # define vtkOpenGLDebugClearErrorMacro() \ 290 vtkOpenGLClearErrorMacro() 291 # define vtkOpenGLDebugCheckErrorMacro(message) \ 292 vtkOpenGLStaticCheckErrorMacro(message) void vtkClearOpenGLErrors(const unsigned int maxErrors=16)
Clear OpenGL's error flags.
bool vtkOpenGLCheckErrors(const char *headerMessage="")
Errors are queried and reported via vtkGenericWarningMacro.
int vtkGetOpenGLErrors(int maxNum, unsigned int *errCode, const char **errDesc)
Check for OpenGL errors.
const char * vtkOpenGLStrError(unsigned int code)
The following functions can be used to detect and report, and/or silently clear OpenGL error flags...
void vtkPrintOpenGLErrors(ostream &os, int maxErrors, int numErrors, unsigned int *errCode, const char **errDesc)
Send a set of errors collected by GetOpenGLErrors to the give stream.