My Project
Loading...
Searching...
No Matches
CGlobals.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
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 <string>
102#include <memory>
103
104
105//------------------------------------------------------------------------------
106// COMPILING OPTIONS
107//------------------------------------------------------------------------------
108
109// OPENAL SUPPORT
110// Enable or disable OpenAL.
111#define C_USE_OPENAL
112
113// OPENGL SUPPORT
114// Enable or disable OpenGL and GLEW libraries.
115#define C_USE_OPENGL
116
117// OPENGL SUPPORT DOUBLES
118// Enable or disable support doubles in OpenGL.
119#define C_USE_OPENGL_DOUBLES
120
121// EIGEN SUPPORT
122// Enable or disable external Eigen math library.
123#define C_USE_EIGEN
124
125// 3DS FILE SUPPORT
126// Enable or disable external support for 3DS files.
127#define C_USE_FILE_3DS
128
129// GIF FILE SUPPORT
130// Enable or disable external support for GIF files.
131#define C_USE_FILE_GIF
132
133// JPG FILE SUPPORT
134// Enable or disable external support for JPG files.
135#define C_USE_FILE_JPG
136
137// PNG FILE SUPPORT
138// Enable of disable external support for PNG files.
139#define C_USE_FILE_PNG
140
141
142//==============================================================================
143// OPERATING SYSTEM SPECIFIC
144//==============================================================================
145
146//------------------------------------------------------------------------------
147// WIN32 / WIN64 OS
148//------------------------------------------------------------------------------
149#if defined(WIN32) | defined(WIN64)
150
151 //--------------------------------------------------------------------
152 // GENERAL
153 //--------------------------------------------------------------------
154
155 // OS specific
156 #if !defined(NOMINMAX)
157 #define NOMINMAX
158 #endif
159 #include <windows.h>
160
161 // if building with .NET, we need to explicitly tell MSVC that we are using unmanaged code
162 // http://msdn.microsoft.com/en-us/library/4ex65770(v=vs.110).aspx
163 #if (_MANAGED == 1)
164 #define nullptr __nullptr
165 #endif
166
167 // printf
168 #include <conio.h>
169 #define cPrint _cprintf
170
171 // math
172 #if !defined(C_USE_EIGEN)
173 #define _USE_MATH_DEFINES
174 #include <cmath>
175 #endif
176
177 // OpenGL GLEW library
178 #if defined(C_USE_OPENGL)
179 #ifndef GLEW_STATIC
180 #define GLEW_STATIC
181 #endif
182 #endif
183
184 //--------------------------------------------------------------------
185 // HAPTIC DEVICES
186 //--------------------------------------------------------------------
187 #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
188 #define C_ENABLE_DELTA_DEVICE_SUPPORT
189 #define C_ENABLE_PHANTOM_DEVICE_SUPPORT
190 #define C_ENABLE_LEAP_DEVICE_SUPPORT
191 // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
192
193 //--------------------------------------------------------------------
194 // SYSTEM LIBRARIES
195 //--------------------------------------------------------------------
196 #pragma comment (lib, "winmm.lib")
197
198#endif
199
200
201//------------------------------------------------------------------------------
202// LINUX OS
203//------------------------------------------------------------------------------
204#if defined(LINUX)
205
206 //--------------------------------------------------------------------
207 // GENERAL
208 //--------------------------------------------------------------------
209
210 // OS specific
211 #include <ctime>
212 #include <pthread.h>
213 #include <dlfcn.h>
214 #include <limits.h>
215 #include <unistd.h>
216
217 // printf
218 #define cPrint printf
219
220 //--------------------------------------------------------------------
221 // HAPTIC DEVICES
222 //--------------------------------------------------------------------
223 #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
224 #define C_ENABLE_DELTA_DEVICE_SUPPORT
225 #define C_ENABLE_PHANTOM_DEVICE_SUPPORT
226 #define C_ENABLE_LEAP_DEVICE_SUPPORT
227 // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
228
229#endif
230
231
232//------------------------------------------------------------------------------
233// MAC OS
234//------------------------------------------------------------------------------
235#if defined(MACOSX)
236
237 //--------------------------------------------------------------------
238 // GENERAL
239 //--------------------------------------------------------------------
240
241 // OS specific
242 #include <CoreFoundation/CoreFoundation.h>
243 #include <mach/mach_time.h>
244 #include <pthread.h>
245 #include <dlfcn.h>
246 #include <limits.h>
247
248 // printf
249 #define cPrint printf
250
251 //--------------------------------------------------------------------
252 // HAPTIC DEVICES
253 //--------------------------------------------------------------------
254 #define C_ENABLE_CUSTOM_DEVICE_SUPPORT
255 #define C_ENABLE_DELTA_DEVICE_SUPPORT
256 #define C_ENABLE_LEAP_DEVICE_SUPPORT
257 // #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
258
259#endif
260
261
262//------------------------------------------------------------------------------
263// QNX
264//------------------------------------------------------------------------------
265#if defined(QNX)
266#undef C_USE_OPENGL
267#endif
268
269
270//------------------------------------------------------------------------------
271#endif // DOXYGEN_SHOULD_SKIP_THIS
272//------------------------------------------------------------------------------
273
274
275//==============================================================================
276// GENERAL PURPOSE FUNCTIONS:
277//==============================================================================
278
279//------------------------------------------------------------------------------
280namespace chai3d {
281//------------------------------------------------------------------------------
282
284void cSleepMs(const unsigned int a_interval);
285
287std::string cGetCurrentPath();
288
290const std::string cGetVersion();
291
293void cGetVersion(int& a_major, int& a_minor, int& a_patch);
294
295
296//------------------------------------------------------------------------------
297#ifndef DOXYGEN_SHOULD_SKIP_THIS
298//------------------------------------------------------------------------------
299
300//==============================================================================
301// CHAI3D - OPENGL:
302//==============================================================================
303
304//------------------------------------------------------------------------------
305// The following definitions allow CHAI3D to compile without the external OpenGL
306// libraries. This mode of compilation is controlled by the flag C_USE_OPENGL.
307// Compiling the framework without OpenGL can be very useful if you plan to
308// use CHAI3D for haptic rendering purposes only, or on real-time operating
309// systems such as QNX or VxWorks for instance where OpenGL is not supported.
310//------------------------------------------------------------------------------
311
312#ifndef C_USE_OPENGL
313
314typedef unsigned int GLenum;
315typedef unsigned int GLuint;
316typedef int GLint;
317typedef int GLsizei;
318typedef unsigned char GLboolean;
319typedef signed char GLbyte;
320typedef short GLshort;
321typedef unsigned char GLubyte;
322typedef unsigned short GLushort;
323typedef unsigned long GLulong;
324typedef float GLfloat;
325typedef float GLclampf;
326typedef double GLdouble;
327typedef double GLclampd;
328
329#define GL_FALSE 0
330#define GL_TRUE 1
331#define GL_EXP 0x0800
332#define GL_EXP2 0x0801
333#define GL_UNSIGNED_BYTE 0x1401
334#define GL_LINE 0x1B01
335#define GL_POINTS 0x0000
336#define GL_BYTE 0x1400
337#define GL_SHORT 0x1402
338#define GL_UNSIGNED_SHORT 0x1403
339#define GL_UNSIGNED_INT 0x1405
340#define GL_DEPTH_COMPONENT 0x1902
341#define GL_RGB 0x1907
342#define GL_RGBA 0x1908
343#define GL_LUMINANCE 0x1909
344#define GL_LUMINANCE_ALPHA 0x190A
345#define GL_TEXTURE0 0x84C0
346#define GL_TEXTURE1 0x84C1
347#define GL_TEXTURE2 0x84C2
348#define GL_TEXTURE3 0x84C3
349#define GL_TEXTURE4 0x84C4
350#define GL_POINT 0x1B00
351#define GL_POINTS 0x0000
352#define GL_LINES 0x0001
353#define GL_LINE_LOOP 0x0002
354#define GL_LINE_STRIP 0x0003
355#define GL_TRIANGLES 0x0004
356#define GL_TRIANGLE_STRIP 0x0005
357#define GL_TRIANGLE_FAN 0x0006
358#define GL_FILL 0x1B02
359
360#define GL_MODULATE 0x2100
361#define GL_DECAL 0x2101
362#define GL_LINEAR 0x2601
363#define GL_LINEAR_MIPMAP_LINEAR 0x2703
364#define GL_CLAMP 0x2900
365#define GL_REPEAT 0x2901
366#define GL_LIGHT0 0x4000
367#define GL_VERTEX_ARRAY 0x8074
368#define GLUquadricObj void
369
370#define GL_CLAMP_TO_EDGE 0x812F
371#define GL_NEAREST 0x2600
372#define GL_NEAREST_MIPMAP_NEAREST 0x2700
373
374#endif // C_USE_OPENGL
375
376//------------------------------------------------------------------------------
377#endif // DOXYGEN_SHOULD_SKIP_THIS
378//------------------------------------------------------------------------------
379} // namespace chai3d
380//------------------------------------------------------------------------------
381
382//------------------------------------------------------------------------------
383#endif
384//------------------------------------------------------------------------------
Definition CAudioBuffer.cpp:57
const std::string cGetVersion()
This function returns a string containing the CHAI3D library version.
Definition CGlobals.cpp:125
void cSleepMs(const unsigned int a_interval)
This function suspends the execution of the current thread for a specified interval.
Definition CGlobals.cpp:64
std::string cGetCurrentPath()
This function retrieves the absolute path of the current executable.
Definition CGlobals.cpp:87