Macros | Functions
vtkOpenGLError.h File Reference
#include "vtkSetGet.h"
#include "vtk_glew.h"
#include <sstream>
Include dependency graph for vtkOpenGLError.h:

Go to the source code of this file.

Macros

#define VTK_REPORT_OPENGL_ERRORS
 
#define vtkOpenGLClearErrorMacro()   vtkClearOpenGLErrors(16);
 
#define vtkOpenGLCheckErrorMacroImpl(ostr, message)
 
#define vtkOpenGLCheckErrorMacro(message)   vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message)
 
#define vtkOpenGLStaticCheckErrorMacro(message)   vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message)
 
#define vtkOpenGLDebugClearErrorMacro()   vtkOpenGLClearErrorMacro()
 
#define vtkOpenGLDebugCheckErrorMacro(message)   vtkOpenGLStaticCheckErrorMacro(message)
 

Functions

const char * vtkOpenGLStrError (unsigned int code)
 The following functions can be used to detect and report, and/or silently clear OpenGL error flags. More...
 
int vtkGetOpenGLErrors (int maxNum, unsigned int *errCode, const char **errDesc)
 Check for OpenGL errors. More...
 
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. More...
 
bool vtkOpenGLCheckErrors (const char *headerMessage="")
 Errors are queried and reported via vtkGenericWarningMacro. More...
 
void vtkClearOpenGLErrors (const unsigned int maxErrors=16)
 Clear OpenGL's error flags. More...
 

Macro Definition Documentation

◆ VTK_REPORT_OPENGL_ERRORS

#define VTK_REPORT_OPENGL_ERRORS

Definition at line 24 of file vtkOpenGLError.h.

◆ vtkOpenGLClearErrorMacro

#define vtkOpenGLClearErrorMacro ( )    vtkClearOpenGLErrors(16);

Definition at line 250 of file vtkOpenGLError.h.

◆ vtkOpenGLCheckErrorMacroImpl

#define vtkOpenGLCheckErrorMacroImpl (   ostr,
  message 
)
Value:
{ \
const int maxErrors = 16; \
unsigned int errCode[maxErrors] = {0}; \
const char *errDesc[maxErrors] = {NULL}; \
\
int numErrors \
maxErrors, \
errCode, \
errDesc); \
\
if (numErrors) \
{ \
std::ostringstream oss; \
vtkPrintOpenGLErrors( \
oss, \
maxErrors, \
numErrors, \
errCode, \
errDesc); \
\
ostr(<< message << " " << oss.str().c_str()); \
} \
}
int vtkGetOpenGLErrors(int maxNum, unsigned int *errCode, const char **errDesc)
Check for OpenGL errors.

Definition at line 252 of file vtkOpenGLError.h.

◆ vtkOpenGLCheckErrorMacro

#define vtkOpenGLCheckErrorMacro (   message)    vtkOpenGLCheckErrorMacroImpl(vtkErrorMacro, message)

Definition at line 277 of file vtkOpenGLError.h.

◆ vtkOpenGLStaticCheckErrorMacro

#define vtkOpenGLStaticCheckErrorMacro (   message)    vtkOpenGLCheckErrorMacroImpl(vtkGenericWarningMacro, message)

Definition at line 279 of file vtkOpenGLError.h.

◆ vtkOpenGLDebugClearErrorMacro

#define vtkOpenGLDebugClearErrorMacro ( )    vtkOpenGLClearErrorMacro()

Definition at line 289 of file vtkOpenGLError.h.

◆ vtkOpenGLDebugCheckErrorMacro

#define vtkOpenGLDebugCheckErrorMacro (   message)    vtkOpenGLStaticCheckErrorMacro(message)

Definition at line 291 of file vtkOpenGLError.h.

Function Documentation

◆ vtkOpenGLStrError()

const char* vtkOpenGLStrError ( unsigned int  code)
inline

The following functions can be used to detect and report, and/or silently clear OpenGL error flags.

These are not intended to be used directly, instead use the following macros.

vtkOpenGLClearErrorMacro() – Silently clear OpenGL error flags.

vtkOpenGLCheckErrorMacro(message) – Check and clear OpenGL's error flags. Report errors detected via vtkErrorMacro.

vtkOpenGLStaticCheckErrorMacro(message) – Check and clear OpenGL's error flags. Report errors detected via vtkGenericWarningMacro. This may be used in static methods and outside of vtkObjects.

The intended usage pattern is to 1) call vtkOpenGLClearErrorMacro at the top of, and 2) vtkOpenGLCheckErrorMacro at the bottom of methods that make OpenGL calls.

By calling vtkOpenGLClearErrorMacro at the top of a method that makes OpenGL calls, you isolate the code and prevent it from detecting any preceding errors. By calling vtkOpenGLCheckErrorMacro at the bottom of the method you clear the error flags and report any errors that have occurred in the method where they occurred.

The macros maybe completely disabled via the CMakeLists variable VTK_REPORT_OPENGL_ERRORS. Note that in that case error flags are never cleared so that if an error occurs the flags will remain dirty making it impossible for anyone else to use them reliably. Please don't disable them with out a good reason. Convert an OpenGL error code into a descriptive string.

Definition at line 69 of file vtkOpenGLError.h.

◆ vtkGetOpenGLErrors()

int vtkGetOpenGLErrors ( int  maxNum,
unsigned int errCode,
const char **  errDesc 
)
inline

Check for OpenGL errors.

Error status is querried until OpenGL reports no errors. The list of errors and their descriptions are returned in the user supplied arrays. User passes the size of the arrays as the first argument. Error flags will still be cleared if the user arrays are less than the number of errors.

Definition at line 107 of file vtkOpenGLError.h.

◆ vtkPrintOpenGLErrors()

void vtkPrintOpenGLErrors ( ostream &  os,
int  maxErrors,
int  numErrors,
unsigned int errCode,
const char **  errDesc 
)
inline

Send a set of errors collected by GetOpenGLErrors to the give stream.

The number of errors is obtained in the return value of GetOpenGLErrors, while the max errors gives the size of the error arrays.

Definition at line 153 of file vtkOpenGLError.h.

◆ vtkOpenGLCheckErrors()

bool vtkOpenGLCheckErrors ( const char *  headerMessage = "")
inline

Errors are queried and reported via vtkGenericWarningMacro.

An optional header message can be appended to the stream. Returns true if no errors were reported.

Definition at line 197 of file vtkOpenGLError.h.

◆ vtkClearOpenGLErrors()

void vtkClearOpenGLErrors ( const unsigned int  maxErrors = 16)
inline

Clear OpenGL's error flags.

Definition at line 226 of file vtkOpenGLError.h.