Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
glcheck.h
1 #ifndef _glcheck_h_
2 #define _glcheck_h_
3 
4 /** macros to check gl status.
5 
6 To be used like this:
7 \verbatim
8  CHECK_GL:ERROR
9 \endverbatim
10 author: Jan Woetzel
11 */
12 
13 #include <bias_config.h>
14 
15 #ifndef BIAS_HAVE_OPENGL
16 # error Please recompile BIAS with USE_OPENGL to use OpenGL.
17 #endif // BIAS_HAVE_OPENGL
18 
19 #include <Gui/biasgl.h>
20 #ifdef __APPLE__
21 # include <OpenGL/glu.h>
22 #else // __APPLE__
23 # include <GL/glu.h> // for gluErrorString
24 #endif // __APPLE__
25 
26 
27 // BIAS ERR stream:
28 #include <Base/Debug/Error.hh>
29 
30 // STD for output of macros:
31 #include <string>
32 #include <sstream>
33 #include <iostream>
34 
35 
36 // ---------------------------------------------------
37 ///use this macro in your code to check for OpenGL errors with "click+jump"
38 ///@author Jan Woetzel
39 #if defined(BIAS_DEBUG) && defined(WIN32)
40 
41 #define CHECK_GL_ERROR \
42 {\
43  GLenum lastErr = glGetError(); \
44  if (lastErr!=GL_NO_ERROR) { \
45  std::stringstream ss; \
46  ss<<std::endl<<__FILE__<<"("<<__LINE__<<") : "<<FUNCNAME<<std::endl \
47  <<"\tOpenGL Error: "<<(char *)gluErrorString(lastErr)<<std::endl; \
48  ERROR_STREAM<<ss.str(); \
49  OutputDebugStringA(ss.str().c_str()); \
50  } \
51 }
52 
53 #elif defined(BIAS_DEBUG)
54 
55 #define CHECK_GL_ERROR \
56 {\
57  GLenum lastErr = glGetError(); \
58  if (lastErr!=GL_NO_ERROR) { \
59  std::stringstream ss; \
60  ss<<std::endl<<__FILE__<<":"<<__LINE__<<" : "<<FUNCNAME<<std::endl \
61  <<"\tOpenGL Error: "<<(char *)gluErrorString(lastErr)<<std::endl; \
62  ERROR_STREAM<<ss.str(); \
63  } \
64 }
65 #else
66 // release: no output
67 # define CHECK_GL_ERROR
68 #endif
69 
70 
71 
72 #endif // _glcheck_h_
73 // DO NOT ADD CODE AFTER THIS LINE
74