15 #ifndef __vtkOpenGLError_h
16 #define __vtkOpenGLError_h
19 #include "vtkSetGet.h"
21 #define VTK_REPORT_OPENGL_ERRORS
61 switch(static_cast<GLenum>(code))
67 return "Invalid enum";
69 case GL_INVALID_VALUE:
70 return "Invalid value";
72 case GL_INVALID_OPERATION:
73 return "Invalid operation";
75 case GL_STACK_OVERFLOW:
76 return "Stack overflow";
78 case GL_STACK_UNDERFLOW:
79 return "Stack underflow";
81 case GL_OUT_OF_MEMORY:
82 return "Out of memory";
85 return "Table too large";
88 return "Invalid framebuffer operation";
91 return "Texture too large";
94 return "Unknown error";
104 #if defined(VTK_REPORT_OPENGL_ERRORS)
108 unsigned int *errCode,
109 const char **errDesc)
112 GLenum code = glGetError();
115 errCode[i] =
static_cast<unsigned int>(code);
118 while (code!=GL_NO_ERROR)
124 errCode[i] =
static_cast<unsigned int>(code);
134 unsigned int *errCode,
135 const char **errDesc)
149 #if defined(VTK_REPORT_OPENGL_ERRORS)
155 unsigned int *errCode,
156 const char **errDesc)
158 os << numErrors <<
" OpenGL errors detected" << endl;
159 for (
int i=0; (i<numErrors)&&(i<maxErrors); ++i)
161 os <<
" " << i <<
" : (" << errCode[i] <<
") " << errDesc[i] << endl;
163 if (numErrors>maxErrors)
166 <<
"More than " << maxErrors
167 <<
" detected! The remainder are not reported"
177 unsigned int *errCode,
178 const char **errDesc)
190 #if defined(VTK_REPORT_OPENGL_ERRORS)
194 while (glGetError()!=GL_NO_ERROR){;}
201 #if !defined(VTK_REPORT_OPENGL_ERRORS)
202 # define vtkOpenGLClearErrorMacro()
203 # define vtkOpenGLCheckErrorMacro(message)
204 # define vtkOpenGLStaticCheckErrorMacro(message)
206 # define vtkOpenGLClearErrorMacro() vtkClearOpenGLErrors();
208 # define vtkOpenGLCheckErrorMacroImpl(ostr, message) \
210 const int maxErrors = 16; \
211 unsigned int errCode[maxErrors] = {0}; \
212 const char *errDesc[maxErrors] = {NULL}; \
215 = vtkGetOpenGLErrors( \
222 std::ostringstream oss; \
223 vtkPrintOpenGLErrors( \
230 ostr(<< message << " " << oss.str().c_str()); \
233 # define vtkOpenGLCheckErrorMacro(message) \
234 vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message)
235 # define vtkOpenGLStaticCheckErrorMacro(message) \
236 vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message)
242 # define vtkOpenGLDebugClearErrorMacro()
243 # define vtkOpenGLDebugCheckErrorMacro(message)
245 # define vtkOpenGLDebugClearErrorMacro() \
246 vtkOpenGLClearErrorMacro()
247 # define vtkOpenGLDebugCheckErrorMacro(message) \
248 vtkOpenGLStaticCheckErrorMacro(message)
const GLenum TABLE_TOO_LARGE
const GLenum INVALID_FRAMEBUFFER_OPERATION_EXT
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
int vtkGetOpenGLErrors(int maxNum, unsigned int *errCode, const char **errDesc)
typedef GLenum(APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target)
const char * vtkOpenGLStrError(unsigned int code)
void vtkPrintOpenGLErrors(ostream &os, int maxErrors, int numErrors, unsigned int *errCode, const char **errDesc)
void vtkClearOpenGLErrors()
const GLenum TEXTURE_TOO_LARGE_EXT