3 #ifndef vtkOpenGLError_h 4 #define vtkOpenGLError_h 12 #define VTK_REPORT_OPENGL_ERRORS 16 #if defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS) 17 #define VTK_REPORT_OPENGL_ERRORS 18 #endif // defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS) 60 switch(static_cast<GLenum>(code))
65 return "Invalid enum";
66 case GL_INVALID_VALUE:
67 return "Invalid value";
68 case GL_INVALID_OPERATION:
69 return "Invalid operation";
70 case GL_OUT_OF_MEMORY:
71 return "Out of memory";
72 #ifndef GL_ES_VERSION_3_0 73 case GL_STACK_OVERFLOW:
74 return "Stack overflow";
75 case GL_STACK_UNDERFLOW:
76 return "Stack underflow";
77 case GL_TABLE_TOO_LARGE:
78 return "Table too large";
79 case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
80 return "Invalid framebuffer operation";
83 return "Unknown error";
94 #if defined(VTK_REPORT_OPENGL_ERRORS) 98 unsigned int *errCode,
102 GLenum code = glGetError();
105 errCode[i] =
static_cast<unsigned int>(code);
108 while (code != GL_NO_ERROR && i < maxNum)
114 errCode[i] =
static_cast<unsigned int>(code);
124 unsigned int *errCode,
125 const char **errDesc)
140 #if defined(VTK_REPORT_OPENGL_ERRORS) 146 unsigned int *errCode,
147 const char **errDesc)
149 os << numErrors <<
" OpenGL errors detected" << std::endl;
150 for (
int i=0; (i<numErrors)&&(i<maxErrors); ++i)
152 os <<
" " << i <<
" : (" << errCode[i] <<
") " << errDesc[i] << std::endl;
154 if (numErrors>maxErrors)
157 <<
"More than " << maxErrors
158 <<
" detected! The remainder are not reported" 168 unsigned int *errCode,
169 const char **errDesc)
184 #if defined(VTK_REPORT_OPENGL_ERRORS) 188 const int maxNumErrors = 16;
189 unsigned int errCode[maxNumErrors] = {0};
190 const char* errDesc[maxNumErrors] = {
nullptr};
194 std::ostringstream oss;
196 vtkGenericWarningMacro(<< headerMessage << oss.str());
213 #if defined(VTK_REPORT_OPENGL_ERRORS) 221 glError = glGetError();
224 while(i < maxErrors && glError != GL_NO_ERROR);
234 #if !defined(VTK_REPORT_OPENGL_ERRORS) 235 # define vtkOpenGLClearErrorMacro() 236 # define vtkOpenGLCheckErrorMacro(message) 237 # define vtkOpenGLStaticCheckErrorMacro(message) 239 # define vtkOpenGLClearErrorMacro() vtkClearOpenGLErrors(16); 241 # define vtkOpenGLCheckErrorMacroImpl(ostr, message) \ 244 const int maxErrors = 16; \ 245 unsigned int errCode[maxErrors] = {0}; \ 246 const char *errDesc[maxErrors] = {nullptr}; \ 249 = vtkGetOpenGLErrors( \ 256 std::ostringstream oss; \ 257 vtkPrintOpenGLErrors( \ 264 ostr(<< message << " " << oss.str()); \ 267 # define vtkOpenGLCheckErrorMacro(message) \ 268 vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message) 269 # define vtkOpenGLStaticCheckErrorMacro(message) \ 270 vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message) 276 # define vtkOpenGLDebugClearErrorMacro() 277 # define vtkOpenGLDebugCheckErrorMacro(message) 279 # define vtkOpenGLDebugClearErrorMacro() \ 280 vtkOpenGLClearErrorMacro() 281 # define vtkOpenGLDebugCheckErrorMacro(message) \ 282 vtkOpenGLStaticCheckErrorMacro(message) void vtkClearOpenGLErrors(const unsigned int maxErrors=16)
Clear OpenGL's error flags.
VTK_ABI_NAMESPACE_BEGIN const char * vtkOpenGLStrError(unsigned int code)
The following functions can be used to detect and report, and/or silently clear OpenGL error flags...
#define VTK_ABI_NAMESPACE_END
bool vtkOpenGLCheckErrors(const char *headerMessage="")
Errors are queried and reported via vtkGenericWarningMacro.
#define VTK_ABI_NAMESPACE_BEGIN
int vtkGetOpenGLErrors(int maxNum, unsigned int *errCode, const char **errDesc)
Check for OpenGL errors.
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.