CGlobals.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.2.0 $Rev: 2159 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CGlobalsH
46 #define CGlobalsH
47 //------------------------------------------------------------------------------
48 
49 //==============================================================================
85 //==============================================================================
86 
87 //------------------------------------------------------------------------------
88 #ifndef DOXYGEN_SHOULD_SKIP_THIS
89 //------------------------------------------------------------------------------
90 
91 //==============================================================================
92 // GENERAL SETTINGS
93 //==============================================================================
94 
95 //------------------------------------------------------------------------------
96 // STANDARD LIBRARIES
97 //------------------------------------------------------------------------------
98 
99 #include <cstdlib>
100 #include <cstring>
101 #include <memory>
102 
103 
104 //------------------------------------------------------------------------------
105 // COMPILING OPTIONS
106 //------------------------------------------------------------------------------
107 
108 // OPENGL SUPPORT
109 // Enable or disable OpenGL and GLEW libraries.
110 #define C_USE_OPENGL
111 
112 // EIGEN SUPPORT
113 // Enable or disable external Eigen math library.
114 #define C_USE_EIGEN
115 
116 // 3DS FILE SUPPORT
117 // Enable or disable external support for 3DS files.
118 #define C_USE_FILE_3DS
119 
120 // GIF FILE SUPPORT
121 // Enable or disable external support for GIF files.
122 #define C_USE_FILE_GIF
123 
124 // JPG FILE SUPPORT
125 // Enable or disable external support for JPG files.
126 #define C_USE_FILE_JPG
127 
128 // PNG FILE SUPPORT
129 // Enable of disable external support for PNG files.
130 #define C_USE_FILE_PNG
131 
132 
133 //==============================================================================
134 // OPERATING SYSTEM SPECIFIC
135 //==============================================================================
136 
137 //------------------------------------------------------------------------------
138 // WIN32 / WIN64 OS
139 //------------------------------------------------------------------------------
140 #if defined(WIN32) | defined(WIN64)
141 
142  //--------------------------------------------------------------------
143  // GENERAL
144  //--------------------------------------------------------------------
145 
146  // OS specific
147  #if !defined(NOMINMAX)
148  #define NOMINMAX
149  #endif
150  #include <windows.h>
151 
152  // if building with .NET, we need to explicitly tell MSVC that we are using unmanaged code
153  // http://msdn.microsoft.com/en-us/library/4ex65770(v=vs.110).aspx
154  #if (_MANAGED == 1)
155  #define nullptr __nullptr
156  #endif
157 
158  // printf
159  #include <conio.h>
160  #define cPrint _cprintf
161 
162  // math
163  #if !defined(C_USE_EIGEN)
164  #define _USE_MATH_DEFINES
165  #include <cmath>
166  #endif
167 
168  // OpenGL GLEW library
169  #if defined(C_USE_OPENGL)
170  #ifndef GLEW_STATIC
171  #define GLEW_STATIC
172  #endif
173  #endif
174 
175  //--------------------------------------------------------------------
176  // HAPTIC DEVICES
177  //--------------------------------------------------------------------
178  #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
179  #define C_ENABLE_DELTA_DEVICE_SUPPORT
180  #define C_ENABLE_PHANTOM_DEVICE_SUPPORT
181  #define C_ENABLE_LEAP_DEVICE_SUPPORT
182  // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
183 
184  //--------------------------------------------------------------------
185  // SYSTEM LIBRARIES
186  //--------------------------------------------------------------------
187  #pragma comment (lib, "winmm.lib")
188 
189 #endif
190 
191 
192 //------------------------------------------------------------------------------
193 // LINUX OS
194 //------------------------------------------------------------------------------
195 #if defined(LINUX)
196 
197  //--------------------------------------------------------------------
198  // GENERAL
199  //--------------------------------------------------------------------
200 
201  // OS specific
202  #include <ctime>
203  #include <pthread.h>
204  #include <dlfcn.h>
205 
206  // printf
207  #define cPrint printf
208 
209  //--------------------------------------------------------------------
210  // HAPTIC DEVICES
211  //--------------------------------------------------------------------
212  #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
213  #define C_ENABLE_DELTA_DEVICE_SUPPORT
214  #define C_ENABLE_PHANTOM_DEVICE_SUPPORT
215  #define C_ENABLE_LEAP_DEVICE_SUPPORT
216  // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
217 
218 #endif
219 
220 
221 //------------------------------------------------------------------------------
222 // MAC OS
223 //------------------------------------------------------------------------------
224 #if defined(MACOSX)
225 
226  //--------------------------------------------------------------------
227  // GENERAL
228  //--------------------------------------------------------------------
229 
230  // OS specific
231  #include <mach/mach_time.h>
232  #include <pthread.h>
233  #include <dlfcn.h>
234 
235  // printf
236  #define cPrint printf
237 
238  //--------------------------------------------------------------------
239  // HAPTIC DEVICES
240  //--------------------------------------------------------------------
241  #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
242  #define C_ENABLE_DELTA_DEVICE_SUPPORT
243  #define C_ENABLE_LEAP_DEVICE_SUPPORT
244  // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
245 
246 #endif
247 
248 
249 //------------------------------------------------------------------------------
250 #endif // DOXYGEN_SHOULD_SKIP_THIS
251 //------------------------------------------------------------------------------
252 
253 
254 //==============================================================================
255 // GENERAL PURPOSE FUNCTIONS:
256 //==============================================================================
257 
258 //------------------------------------------------------------------------------
259 namespace chai3d {
260 //------------------------------------------------------------------------------
261 
263 void cSleepMs(const unsigned int a_interval);
264 
265 
266 //------------------------------------------------------------------------------
267 #ifndef DOXYGEN_SHOULD_SKIP_THIS
268 //------------------------------------------------------------------------------
269 
270 //==============================================================================
271 // CHAI3D - OPENGL:
272 //==============================================================================
273 
274 //------------------------------------------------------------------------------
275 // The following definitions allow CHAI3D to compile without the external OpenGL
276 // libraries. This mode of compilation is controlled by the flag C_USE_OPENGL.
277 // Compiling the framework without OpenGL can be very useful if you plan to
278 // use CHAI3D for haptic rendering purposes only, or on real-time operating
279 // systems such as QNX or VxWorks for instance where OpenGL is not supported.
280 //------------------------------------------------------------------------------
281 
282 #ifndef C_USE_OPENGL
283 
284 typedef unsigned int GLenum;
285 typedef unsigned int GLuint;
286 typedef int GLint;
287 typedef int GLsizei;
288 typedef unsigned char GLboolean;
289 typedef signed char GLbyte;
290 typedef short GLshort;
291 typedef unsigned char GLubyte;
292 typedef unsigned short GLushort;
293 typedef unsigned long GLulong;
294 typedef float GLfloat;
295 typedef float GLclampf;
296 typedef double GLdouble;
297 typedef double GLclampd;
298 
299 #define GL_FALSE 0
300 #define GL_TRUE 1
301 #define GL_EXP 0x0800
302 #define GL_EXP2 0x0801
303 #define GL_UNSIGNED_BYTE 0x1401
304 #define GL_LINE 0x1B01
305 #define GL_POINTS 0x0000
306 #define GL_BYTE 0x1400
307 #define GL_SHORT 0x1402
308 #define GL_UNSIGNED_SHORT 0x1403
309 #define GL_UNSIGNED_INT 0x1405
310 #define GL_DEPTH_COMPONENT 0x1902
311 #define GL_RGB 0x1907
312 #define GL_RGBA 0x1908
313 #define GL_LUMINANCE 0x1909
314 #define GL_LUMINANCE_ALPHA 0x190A
315 #define GL_TEXTURE0 0x84C0
316 #define GL_TEXTURE1 0x84C1
317 #define GL_TEXTURE2 0x84C2
318 #define GL_TEXTURE3 0x84C3
319 #define GL_TEXTURE4 0x84C4
320 #define GL_POINT 0x1B00
321 #define GL_LINE 0x1B01
322 #define GL_FILL 0x1B02
323 #define GL_MODULATE 0x2100
324 #define GL_DECAL 0x2101
325 #define GL_LINEAR 0x2601
326 #define GL_LINEAR_MIPMAP_LINEAR 0x2703
327 #define GL_CLAMP 0x2900
328 #define GL_REPEAT 0x2901
329 #define GL_LIGHT0 0x4000
330 #define GL_VERTEX_ARRAY 0x8074
331 #define GLUquadricObj void
332 
333 #define GL_CLAMP_TO_EDGE 0x812F
334 #define GL_NEAREST 0x2600
335 #define GL_NEAREST_MIPMAP_NEAREST 0x2700
336 
337 #endif // C_USE_OPENGL
338 
339 //------------------------------------------------------------------------------
340 #endif // DOXYGEN_SHOULD_SKIP_THIS
341 //------------------------------------------------------------------------------
342 } // namespace chai3d
343 //------------------------------------------------------------------------------
344 
345 //------------------------------------------------------------------------------
346 #endif
347 //------------------------------------------------------------------------------
Definition: CAudioBuffer.cpp:56
void cSleepMs(const unsigned int a_interval)
This function suspends the execution of the current thread for a specified interval.
Definition: CGlobals.cpp:60