Main Page
Overview
Documentation
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.1.1 $Rev: 1940 $
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
// OPTIONS
135
//------------------------------------------------------------------------------
136
137
// Maximum supported display contexts.
138
const
int
C_MAX_DISPLAY_CONTEXTS = 4;
139
140
141
//==============================================================================
142
// OPERATING SYSTEM SPECIFIC
143
//==============================================================================
144
145
//------------------------------------------------------------------------------
146
// WIN32 / WIN64 OS
147
//------------------------------------------------------------------------------
148
#if defined(WIN32) | defined(WIN64)
149
150
//--------------------------------------------------------------------
151
// GENERAL
152
//--------------------------------------------------------------------
153
154
// OS specific
155
#if !defined(NOMINMAX)
156
#define NOMINMAX
157
#endif
158
#include <windows.h>
159
160
// if building with .NET, we need to explicitly tell MSVC that we are using unmanaged code
161
// http://msdn.microsoft.com/en-us/library/4ex65770(v=vs.110).aspx
162
#if (_MANAGED == 1)
163
#define nullptr __nullptr
164
#endif
165
166
// printf
167
#include <conio.h>
168
#define cPrint _cprintf
169
170
// math
171
#if !defined(C_USE_EIGEN)
172
#define _USE_MATH_DEFINES
173
#include <cmath>
174
#endif
175
176
// OpenGL GLEW library
177
#if defined(C_USE_OPENGL)
178
#ifndef GLEW_STATIC
179
#define GLEW_STATIC
180
#endif
181
#endif
182
183
//--------------------------------------------------------------------
184
// HAPTIC DEVICES
185
//--------------------------------------------------------------------
186
#define C_ENABLE_CUSTOM_DEVICE_SUPPORT
187
#define C_ENABLE_DELTA_DEVICE_SUPPORT
188
#define C_ENABLE_PHANTOM_DEVICE_SUPPORT
189
#define C_ENABLE_LEAP_DEVICE_SUPPORT
190
// #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
191
192
//--------------------------------------------------------------------
193
// SYSTEM LIBRARIES
194
//--------------------------------------------------------------------
195
#pragma comment (lib, "winmm.lib")
196
197
#endif
198
199
200
//------------------------------------------------------------------------------
201
// LINUX OS
202
//------------------------------------------------------------------------------
203
#if defined(LINUX)
204
205
//--------------------------------------------------------------------
206
// GENERAL
207
//--------------------------------------------------------------------
208
209
// OS specific
210
#include <ctime>
211
#include <pthread.h>
212
#include <dlfcn.h>
213
214
// printf
215
#define cPrint printf
216
217
//--------------------------------------------------------------------
218
// HAPTIC DEVICES
219
//--------------------------------------------------------------------
220
#define C_ENABLE_CUSTOM_DEVICE_SUPPORT
221
#define C_ENABLE_DELTA_DEVICE_SUPPORT
222
#define C_ENABLE_PHANTOM_DEVICE_SUPPORT
223
#define C_ENABLE_LEAP_DEVICE_SUPPORT
224
// #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
225
226
#endif
227
228
229
//------------------------------------------------------------------------------
230
// MAC OS
231
//------------------------------------------------------------------------------
232
#if defined(MACOSX)
233
234
//--------------------------------------------------------------------
235
// GENERAL
236
//--------------------------------------------------------------------
237
238
// OS specific
239
#include <mach/mach_time.h>
240
#include <pthread.h>
241
#include <dlfcn.h>
242
243
// printf
244
#define cPrint printf
245
246
//--------------------------------------------------------------------
247
// HAPTIC DEVICES
248
//--------------------------------------------------------------------
249
#define C_ENABLE_CUSTOM_DEVICE_SUPPORT
250
#define C_ENABLE_DELTA_DEVICE_SUPPORT
251
#define C_ENABLE_LEAP_DEVICE_SUPPORT
252
// #define C_ENABLE_SIXENSE_DEVICE_SUPPORT
253
254
#endif
255
256
257
//------------------------------------------------------------------------------
258
#endif // DOXYGEN_SHOULD_SKIP_THIS
259
//------------------------------------------------------------------------------
260
261
262
//==============================================================================
263
// GENERAL PURPOSE FUNCTIONS:
264
//==============================================================================
265
266
//------------------------------------------------------------------------------
267
namespace
chai3d
{
268
//------------------------------------------------------------------------------
269
271
void
cSleepMs
(
const
unsigned
int
a_interval);
272
273
274
//------------------------------------------------------------------------------
275
#ifndef DOXYGEN_SHOULD_SKIP_THIS
276
//------------------------------------------------------------------------------
277
278
//==============================================================================
279
// CHAI3D - OPENGL:
280
//==============================================================================
281
282
//------------------------------------------------------------------------------
283
// The following definitions allow CHAI3D to compile without the external OpenGL
284
// libraries. This mode of compilation is controlled by the flag C_USE_OPENGL.
285
// Compiling the framework without OpenGL can be very useful if you plan to
286
// use CHAI3D for haptic rendering purposes only, or on real-time operating
287
// systems such as QNX or VxWorks for instance where OpenGL is not supported.
288
//------------------------------------------------------------------------------
289
290
#ifndef C_USE_OPENGL
291
292
typedef
unsigned
int
GLenum;
293
typedef
unsigned
int
GLuint;
294
typedef
int
GLint;
295
typedef
int
GLsizei;
296
typedef
unsigned
char
GLboolean;
297
typedef
signed
char
GLbyte;
298
typedef
short
GLshort;
299
typedef
unsigned
char
GLubyte;
300
typedef
unsigned
short
GLushort;
301
typedef
unsigned
long
GLulong;
302
typedef
float
GLfloat;
303
typedef
float
GLclampf;
304
typedef
double
GLdouble;
305
typedef
double
GLclampd;
306
307
#define GL_FALSE 0
308
#define GL_TRUE 1
309
#define GL_EXP 0x0800
310
#define GL_EXP2 0x0801
311
#define GL_UNSIGNED_BYTE 0x1401
312
#define GL_LINE 0x1B01
313
#define GL_POINTS 0x0000
314
#define GL_BYTE 0x1400
315
#define GL_SHORT 0x1402
316
#define GL_UNSIGNED_SHORT 0x1403
317
#define GL_UNSIGNED_INT 0x1405
318
#define GL_DEPTH_COMPONENT 0x1902
319
#define GL_RGB 0x1907
320
#define GL_RGBA 0x1908
321
#define GL_LUMINANCE 0x1909
322
#define GL_LUMINANCE_ALPHA 0x190A
323
#define GL_TEXTURE0 0x84C0
324
#define GL_TEXTURE1 0x84C1
325
#define GL_TEXTURE2 0x84C2
326
#define GL_TEXTURE3 0x84C3
327
#define GL_TEXTURE4 0x84C4
328
#define GL_POINT 0x1B00
329
#define GL_LINE 0x1B01
330
#define GL_FILL 0x1B02
331
#define GL_MODULATE 0x2100
332
#define GL_DECAL 0x2101
333
#define GL_LINEAR 0x2601
334
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
335
#define GL_CLAMP 0x2900
336
#define GL_REPEAT 0x2901
337
#define GL_LIGHT0 0x4000
338
#define GL_VERTEX_ARRAY 0x8074
339
#define GLUquadricObj void
340
341
#define GL_CLAMP_TO_EDGE 0x812F
342
#define GL_NEAREST 0x2600
343
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
344
345
#endif // C_USE_OPENGL
346
347
//------------------------------------------------------------------------------
348
#endif // DOXYGEN_SHOULD_SKIP_THIS
349
//------------------------------------------------------------------------------
350
}
// namespace chai3d
351
//------------------------------------------------------------------------------
352
353
//------------------------------------------------------------------------------
354
#endif
355
//------------------------------------------------------------------------------
chai3d
Definition:
CAudioBuffer.cpp:56
chai3d::cSleepMs
void cSleepMs(const unsigned int a_interval)
This function suspends the execution of the current thread for a specified interval.
Definition:
CGlobals.cpp:60