Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
biasgl.h
1 #ifndef _biasgl_h_
2 #define _biasgl_h_
3 
4 /**
5 \brief wrapper to include all gl, glut, glew headers that corresponds to current HAVE_.. configurations settings.
6 
7 Requires OpenGL (BIAS_HAVE_OPENGL).
8 Switches glew usage optionally based on B
9 \attention Does NOT include glu.h.
10 
11 - keep choice of using glew/gl/glut/... flexible in client apps
12  while asserting glew is included first!
13 - disable GL warnings in a central place.
14 - allows precompiled headers
15 - Please note that the app. has to call glewinit like this
16 iff glew is used:
17 \verbatim
18  if (!(GLEW_VERSION_1_1)) {
19  // init and try again:
20  GLenum result = glewInit();
21  if (result != GLEW_OK){
22  BIASERR("glewInit failed.");
23  };
24  }
25 \endverbatim
26 \author: Jan Woetzel, Bogumil Bartczak
27 */
28 
29 #include <bias_config.h>
30 #include <Base/Common/W32Compat.hh>
31 #ifndef BIAS_HAVE_OPENGL
32 # error Please recompile BIAS with USE_OPENGL to use OpenGL.
33 #endif // BIAS_HAVE_OPENGL
34 
35 
36 #ifdef WIN32
37 // NO lean and mean here because too many BIAS files
38 // rely on global windows.h instead of direct includes
39 // for the specialized headers like Winsock2.h JW
40 //# define WIN32_LEAN_AND_MEAN
41 # include <windows.h>
42 # ifdef BIAS_HAVE_WXWIDGETS
43 # include <wx/msw/winundef.h>
44 # endif
45 #endif
46 
47 
48 #if defined(BIAS_HAVE_GLEW) || defined(MIP_HAVE_GLEW)
49 
50 // USE glew:
51 // must define kind of lib/src for glew extension handler lib
52 // (linker errors otherwise) !
53 // decide weterh we want to link against static or dll glew
54 
55 // Win32 static build or Linux
56 
57 #ifdef BIAS_BUILD_SHARED_LIBS
58 /*
59  GLEW_STATIC needs to be set when using the static version.
60  GLEW_BUILD is set when building the DLL version.
61 
62  this is what happens in glew.h :
63 // #ifdef GLEW_STATIC
64 // # define GLEWAPI extern
65 // #else
66 // # ifdef GLEW_BUILD
67 // # define GLEWAPI extern __declspec(dllexport)
68 // # else
69 // # define GLEWAPI extern __declspec(dllimport)
70 // # endif
71 // #endif
72 
73 */
74  #ifdef WIN32
75  //adding the declspecs described above by defining glew_build
76  //creates linker errors when linking against the glew32.dll.
77  //if we link against the glew.lib statically while building shared bias.libs
78  //we create multiple instances of glew which is quite undesirable
79  //not defining glew_build seems to work.
80  // #define GLEW_BUILD
81  /* # ifdef GLEW_STATIC
82  # error GLEW_STATIC is defined but shouldnt be in DLL BUILD.
83  # endif*/
84  #else //win32
85  # ifndef GLEW_STATIC
86  # define GLEW_STATIC
87  # endif // GLEW_STATIC
88  #endif //win32
89 #else //MIP_BUILD_SHARED_LIBS
90  # ifndef GLEW_STATIC
91  # define GLEW_STATIC
92  # endif // GLEW_STATIC
93 #endif //MIP_BUILD_SHARED_LIBS
94 
95 //// checks, only one of both!
96 //# ifdef GLEW_BUILD
97 //# error GLEW_BUILD is defined but shouldnt be, GLEW_STATIC is too.
98 //# endif
99 
100 
101 //#endif // WIN32 _DLL
102 
103 
104 
105 # include <GL/glew.h> // includes gl.h and glu.h
106 # ifdef WIN32
107 # include <GL/wglew.h>
108 # else // WIN32
109 // workaround for glx
110 // do NOT use glxew for now because glxChooseFBConfig crashes, then.
111 //# include <GL/glxew.h>
112 
113 # endif //WIN32
114 
115 #else //BIAS_HAVE_GLEW or MIP_HAVE_GLEW
116 
117 # ifdef __APPLE__
118 # include <OpenGL/gl.h>
119 # else // __APPLE__
120 # include <GL/gl.h>
121 # endif // __APPLE__
122 
123 #endif // BIAS_HAVE_GLEW or MIP_HAVE_GLEW
124 
125 
126 
127 //
128 // Do not include wxglcanvas here
129 // because then we are bound to glew if compiling with wx
130 // because wx/glcanvas.h includes glx.h (JW)
131 // Thus, include glxew.h *before* the few
132 //
133 //#if defined(BIAS_HAVE_WXWIDGETS) || defined(MIP_HAVE_WXWIDGETS)
134 // order is mandatory: include glew first to avoid redefinitions !!! (JW)
135 // there *must not* be a gl.h inclusion before glew !
136 // wxglcanvas includes glx.h,
137 // thus we must include glxew first to avoid conflict in glew case
138 //# if defined(BIAS_HAVE_GLEW) || defined(MIP_HAVE_GLEW)
139 //# if !defined(WIN32)
140 //# include <GL/glxew.h>
141 //# endif // GLEW
142 //# endif // Linux
143 //# include <wx/glcanvas.h>
144 //#endif
145 
146 
147 #if defined (BIAS_HAVE_GLUT) || defined(MIP_HAVE_GLUT)
148 # ifdef WIN32
149 // avoid some entry calls /4505 warnings with this define on WIN32:
150 # define GLUT_BUILDING_LIB
151 # include <GL/glut.h>
152 # else // WIN32
153 # ifdef _APPLE__
154 # include <GLUT/glut.h>
155 # else // __APPLE__
156 # include <GL/glut.h>
157 # endif // __APPLE__
158 # endif // WIN32
159 #endif // BIAS_HAVE_GLUT
160 
161 
162 // macros, e.g. CHECK_GL_ERROR
163 #include <Gui/glcheck.h>
164 
165 
166 // --- define special token extension values for "hidden" features (jw) ---
167 //#ifndef GL_CRYCBY_422_NVX
168 //# define GL_CRYCBY_422_NVX 0x600A
169 //#endif
170 //#ifndef GL_YCRYCB_422_NVX
171 //# define GL_YCRYCB_422_NVX 0x600B
172 //#endif
173 
174 //#if defined WIN32 && !defined(EXT_timer_query)
175 // -- Nvidia OpenGL rendering timing
176 // -- without stalling the render pipeline (in contrast to glFinish)
177 //# ifndef GLint64EXT
178 // typedef __int64 GLint64EXT;
179 //# endif // GLint64EXT
180 //# ifndef GLuint64EXT
181 // typedef unsigned __int64 GLuint64EXT;
182 //# endif // GLuint64EXT
183 //# ifndef GL_TIME_ELAPSED_EXT
184 //# define GL_TIME_ELAPSED_EXT 0x88BF
185 //# endif // GL_TIME_ELAPSED_EXT
186 // void glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params);
187 // void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params);
188 //#endif // WIN32 & !EXT_timer_query
189 
190 
191 #endif // _biasgl_h_
192 // DO NOT ADD CODE AFTER THIS LINE
193