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_INVALID_FRAMEBUFFER_OPERATION:
78 return "Invalid framebuffer operation";
81 return "Unknown error";
92 #if defined(VTK_REPORT_OPENGL_ERRORS) 96 unsigned int *errCode,
100 GLenum code = glGetError();
103 errCode[i] =
static_cast<unsigned int>(code);
106 while (code != GL_NO_ERROR && i < maxNum)
112 errCode[i] =
static_cast<unsigned int>(code);
122 unsigned int *errCode,
123 const char **errDesc)
138 #if defined(VTK_REPORT_OPENGL_ERRORS) 144 unsigned int *errCode,
145 const char **errDesc)
147 os << numErrors <<
" OpenGL errors detected" << std::endl;
148 for (
int i=0; (i<numErrors)&&(i<maxErrors); ++i)
150 os <<
" " << i <<
" : (" << errCode[i] <<
") " << errDesc[i] << std::endl;
152 if (numErrors>maxErrors)
155 <<
"More than " << maxErrors
156 <<
" detected! The remainder are not reported" 166 unsigned int *errCode,
167 const char **errDesc)
182 #if defined(VTK_REPORT_OPENGL_ERRORS) 186 const int maxNumErrors = 16;
187 unsigned int errCode[maxNumErrors] = {0};
188 const char* errDesc[maxNumErrors] = {
nullptr};
192 std::ostringstream oss;
194 vtkGenericWarningMacro(<< headerMessage << oss.str());
211 #if defined(VTK_REPORT_OPENGL_ERRORS) 219 glError = glGetError();
222 while(i < maxErrors && glError != GL_NO_ERROR);
232 #if !defined(VTK_REPORT_OPENGL_ERRORS) 233 # define vtkOpenGLClearErrorMacro() do {} while (false) 234 # define vtkOpenGLCheckErrorMacro(message) 235 # define vtkOpenGLStaticCheckErrorMacro(message) 237 #define vtkOpenGLClearErrorMacro() \ 240 vtkClearOpenGLErrors(16); \ 244 # define vtkOpenGLCheckErrorMacroImpl(ostr, message) \ 247 const int maxErrors = 16; \ 248 unsigned int errCode[maxErrors] = {0}; \ 249 const char *errDesc[maxErrors] = {nullptr}; \ 252 = vtkGetOpenGLErrors( \ 259 std::ostringstream oss; \ 260 vtkPrintOpenGLErrors( \ 267 ostr(<< message << " " << oss.str()); \ 270 # define vtkOpenGLCheckErrorMacro(message) \ 271 vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message) 272 # define vtkOpenGLStaticCheckErrorMacro(message) \ 273 vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message) 279 # define vtkOpenGLDebugClearErrorMacro() 280 # define vtkOpenGLDebugCheckErrorMacro(message) 282 # define vtkOpenGLDebugClearErrorMacro() \ 283 vtkOpenGLClearErrorMacro() 284 # define vtkOpenGLDebugCheckErrorMacro(message) \ 285 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.