reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofConstants.h
Go to the documentation of this file.
1#pragma once
2
3// version: ------------------------
4#define OF_VERSION_MAJOR 0
5#define OF_VERSION_MINOR 12
6#define OF_VERSION_PATCH 0
7#define OF_VERSION_PRE_RELEASE "master"
8
9// core: ---------------------------
10#include <stdint.h>
11#include <cstdio>
12#include <cstdlib>
13#include <string>
14#include <cstring>
15#include <iostream>
16#include <vector>
17#include <memory>
18#include <functional>
19
20// Set to 1 for compatibility with old projects using ofVec instead of glm
21#ifndef OF_USE_LEGACY_VECTOR_MATH
22 #define OF_USE_LEGACY_VECTOR_MATH 0
23#endif
24
25// This enables glm's old behavior of initializing with non garbage values
26#define GLM_FORCE_CTOR_INIT
27
28//-------------------------------
29
55
56
57#ifndef OF_TARGET_IPHONE
58 #define OF_TARGET_IPHONE OF_TARGET_IOS
59#endif
60
61
62// Cross-platform deprecation warning
63#ifdef __GNUC__
64 // clang also has this defined. deprecated(message) is only for gcc>=4.5
65 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || __GNUC__ > 4
66 #define OF_DEPRECATED_MSG(message, ...) __VA_ARGS__ __attribute__ ((deprecated(message)))
67 #else
68 #define OF_DEPRECATED_MSG(message, ...) __VA_ARGS__ __attribute__ ((deprecated))
69 #endif
70 #define OF_DEPRECATED(...) __VA_ARGS__ __attribute__ ((deprecated))
71 #define OF_INTERNAL_DEPRECATED(...) __VA_ARGS__ __attribute__ ((deprecated("OF core deprecated")))
72#elif defined(_MSC_VER)
73 #define OF_DEPRECATED_MSG(message, ...) __declspec(deprecated(message)) __VA_ARGS__
74 #define OF_DEPRECATED(...) __declspec(deprecated) __VA_ARGS__
75 #define OF_INTERNAL_DEPRECATED(...) __declspec(deprecated("OF core deprecated")) __VA_ARGS__
76#else
77 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
78 #define OF_DEPRECATED_MSG(message, ...) __VA_ARGS__
79 #define OF_DEPRECATED(...) __VA_ARGS__
80#endif
81
82//-------------------------------
83// find the system type --------
84//-------------------------------
85
86// helpful:
87// http://www.ogre3d.org/docs/api/html/OgrePlatform_8h-source.html
88
89#if defined( __WIN32__ ) || defined( _WIN32 )
90 #define OF_OS_WINDOWS
91 #define TARGET_WIN32
92 #if defined(_MSC_VER)
93 #define TARGET_WINVS
94 #endif
95 #if defined(__MINGW32__) || defined(__MINGW64__)
96 #define TARGET_MINGW
97 #endif
98#elif defined( __APPLE_CC__)
99 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
100 #include <TargetConditionals.h>
101 #if (TARGET_OS_IPHONE || TARGET_OS_IOS || TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR) && !TARGET_OS_TV && !TARGET_OS_WATCH
102 #define TARGET_OF_IPHONE
103 #define TARGET_OF_IOS
104 #define TARGET_OPENGLES
105 #include <unistd.h>
106 #elif TARGET_OS_TV
107 #define TARGET_OF_IOS
108 #define TARGET_OF_TVOS
109 #define TARGET_OPENGLES
110 #include <unistd.h>
111 #elif TARGET_OS_WATCH
112 #define TARGET_OF_IOS
113 #define TARGET_OF_WATCHOS
114 #define TARGET_OPENGLES
115 #include <unistd.h>
116 #else
117 #define TARGET_OSX
118 #endif
119#elif defined (__ANDROID__)
120 #define TARGET_ANDROID
121 #define TARGET_OPENGLES
122#elif defined(__ARMEL__)
123 #define TARGET_LINUX
124 #define TARGET_OPENGLES
125 #define TARGET_LINUX_ARM
126#elif defined(__EMSCRIPTEN__)
127 #define TARGET_EMSCRIPTEN
128 #define TARGET_OPENGLES
129 #define TARGET_PROGRAMMABLE_GL
130 #define TARGET_IMPLEMENTS_URL_LOADER
131#else
132 #define TARGET_LINUX
133#endif
134//-------------------------------
135
136
137// then the the platform specific includes:
138#ifdef TARGET_WIN32
139 #define GLEW_STATIC
140 #define GLEW_NO_GLU
141 #include "GL/glew.h"
142 #include "GL/wglew.h"
143 #define __WINDOWS_DS__
144 #define __WINDOWS_MM__
145 #if (_MSC_VER) // microsoft visual studio
146 //TODO: Fix this in the code instead of disabling the warnings
147 #define _CRT_SECURE_NO_WARNINGS
148 #define _WINSOCK_DEPRECATED_NO_WARNINGS
149
150 #include <stdint.h>
151 #include <functional>
152 #pragma warning(disable : 4068) // unknown pragmas
153 #pragma warning(disable : 4756) // overflow in constant arithmetic
154 #pragma warning(disable : 4800) // 'Boolean' : forcing value to bool 'true' or 'false'
155
156 // make microsoft visual studio complain less about double / float conversion and
157 // truncation
158 #pragma warning(disable : 4244)
159 #pragma warning(disable : 4305)
160 // warnings: http://msdn.microsoft.com/library/2c8f766e.aspx
161
162 // NOMINMAX doesn't seem to work anymore in vs2015 so let's just remove them
163 #undef min
164 #undef max
165 #endif
166
167 #define TARGET_LITTLE_ENDIAN // intel cpu
168
169 // some gl.h files, like dev-c++, are old - this is pretty universal
170 #ifndef GL_BGR_EXT
171 #define GL_BGR_EXT 0x80E0
172 #endif
173
174 #define WIN32_HIGH_RES_TIMING
175
176 // note: this is experimental!
177 // uncomment to turn this on (only for windows machines)
178 // if you want to try setting the timer to be high resolution
179 // this could make camera grabbing and other low level
180 // operations quicker, but you must quit the app normally,
181 // ie, using "esc", rather than killing the process or closing
182 // the console window in order to set the timer resolution back
183 // to normal (since the high res timer might give the OS
184 // problems)
185 // info: http://www.geisswerks.com/ryan/FAQS/timing.html
186
187#endif
188
189#ifdef TARGET_OSX
190 #ifndef __MACOSX_CORE__
191 #define __MACOSX_CORE__
192 #endif
193 #include <unistd.h>
194 #include "GL/glew.h"
195 #include <ApplicationServices/ApplicationServices.h>
196
197 #if defined(__LITTLE_ENDIAN__)
198 #define TARGET_LITTLE_ENDIAN // intel cpu
199 #endif
200
201 #if defined(__OBJC__) && !__has_feature(objc_arc)
202 #warning "Please enable ARC (Automatic Reference Counting) at the project level"
203 #endif
204#endif
205
206#ifdef TARGET_LINUX
207
208 #include <unistd.h>
209
210 #ifdef TARGET_LINUX_ARM
211 #ifdef TARGET_RASPBERRY_PI
212 #include "bcm_host.h"
213 // rpi firmware headers define countof
214 // which messes up other libraries like glm
215 #undef countof
216 #endif
217
218 #include "GLES/gl.h"
219 #include "GLES/glext.h"
220 #include "GLES2/gl2.h"
221 #include "GLES2/gl2ext.h"
222
223 #define EGL_EGLEXT_PROTOTYPES
224 #include "EGL/egl.h"
225 #include "EGL/eglext.h"
226 #else // desktop linux
227 #include <GL/glew.h>
228 #endif
229
230 // for some reason, this isn't defined at compile time,
231 // so this hack let's us work
232 // for 99% of the linux folks that are on intel
233 // everyone one else will have RGB / BGR issues.
234 //#if defined(__LITTLE_ENDIAN__)
235 #define TARGET_LITTLE_ENDIAN // intel cpu
236 //#endif
237
238 // some things for serial compilation:
239 #define B14400 14400
240 #define B28800 28800
241
242#endif
243
244
245#ifdef TARGET_OF_IOS
246 #import <OpenGLES/ES1/gl.h>
247 #import <OpenGLES/ES1/glext.h>
248
249 #import <OpenGLES/ES2/gl.h>
250 #import <OpenGLES/ES2/glext.h>
251
252
253 #define TARGET_LITTLE_ENDIAN // arm cpu
254
255 #if defined(__OBJC__) && !__has_feature(objc_arc)
256 #error "Please enable ARC (Automatic Reference Counting) at the project level"
257 #endif
258
259#endif
260
261#ifdef TARGET_ANDROID
262 #include <typeinfo>
263 #include <unistd.h>
264 #include <GLES/gl.h>
265 #define GL_GLEXT_PROTOTYPES
266 #include <GLES/glext.h>
267
268 #include <GLES2/gl2.h>
269 #include <GLES2/gl2ext.h>
270
271 #define TARGET_LITTLE_ENDIAN
272#endif
273
274#ifdef TARGET_EMSCRIPTEN
275 #define GL_GLEXT_PROTOTYPES
276 #include <GLES/gl.h>
277 #include <GLES/glext.h>
278 #include <GLES2/gl2.h>
279 #include <GLES2/gl2ext.h>
280 #include <GLES3/gl3.h>
281 #include <GL/glew.h>
282
283 #include "EGL/egl.h"
284 #include "EGL/eglext.h"
285
286 #define TARGET_LITTLE_ENDIAN
287#endif
288
289#include "tesselator.h"
290typedef TESSindex ofIndexType;
291
292
293
294#define OF_EXIT_APP(val) std::exit(val);
295
296
297
298//------------------------------------------------ capture
299// check if any video capture system is already defined from the compiler
300#if !defined(OF_VIDEO_CAPTURE_GSTREAMER) && !defined(OF_VIDEO_CAPTURE_QUICKTIME) && !defined(OF_VIDEO_CAPTURE_DIRECTSHOW) && !defined(OF_VIDEO_CAPTURE_ANDROID) && !defined(OF_VIDEO_CAPTURE_IOS)
301 #ifdef TARGET_LINUX
302
303 #define OF_VIDEO_CAPTURE_GSTREAMER
304
305 #elif defined(TARGET_OSX)
306 //on 10.6 and below we can use the old grabber
307 #ifndef MAC_OS_X_VERSION_10_7
308 #define OF_VIDEO_CAPTURE_QUICKTIME
309 //if we are below 10.12 or targeting below 10.12 we use QTKit
310 #elif !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
311 #define OF_VIDEO_CAPTURE_QTKIT
312 #else
313 #define OF_VIDEO_CAPTURE_AVF
314 #endif
315
316 #elif defined (TARGET_WIN32)
317
318 // comment out this following line, if you'd like to use the
319 // quicktime capture interface on windows
320 // if not, we default to videoInput library for
321 // direct show capture...
322
323 #define OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP
324
325 #ifdef OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP
326 #define OF_VIDEO_CAPTURE_DIRECTSHOW
327 #else
328 #define OF_VIDEO_CAPTURE_QUICKTIME
329 #endif
330
331 #elif defined(TARGET_ANDROID)
332
333 #define OF_VIDEO_CAPTURE_ANDROID
334
335 #elif defined(TARGET_EMSCRIPTEN)
336
337 #define OF_VIDEO_CAPTURE_EMSCRIPTEN
338
339 #elif defined(TARGET_OF_IOS)
340
341 #define OF_VIDEO_CAPTURE_IOS
342
343 #endif
344#endif
345
346//------------------------------------------------ video player
347// check if any video player system is already defined from the compiler
348#if !defined(OF_VIDEO_PLAYER_GSTREAMER) && !defined(OF_VIDEO_PLAYER_IOS) && !defined(OF_VIDEO_PLAYER_DIRECTSHOW) && !defined(OF_VIDEO_PLAYER_MEDIA_FOUNDATION) && !defined(OF_VIDEO_PLAYER_QUICKTIME) && !defined(OF_VIDEO_PLAYER_AVFOUNDATION) && !defined(OF_VIDEO_PLAYER_EMSCRIPTEN)
349 #ifdef TARGET_LINUX
350 #define OF_VIDEO_PLAYER_GSTREAMER
351 #elif defined(TARGET_ANDROID)
352 #define OF_VIDEO_PLAYER_ANDROID
353 #elif defined(TARGET_OF_IOS)
354 #define OF_VIDEO_PLAYER_IOS
355 #elif defined(TARGET_WIN32)
356 #ifdef _MSC_VER //use MF Foundation player for VS as mingw doesn't have needed symbols
357 #define OF_VIDEO_PLAYER_MEDIA_FOUNDATION
358 #else
359 #define OF_VIDEO_PLAYER_DIRECTSHOW
360 #endif
361 #elif defined(TARGET_OSX)
362 //for 10.8 and 10.9 users we use AVFoundation, for 10.7 we use QTKit, for 10.6 users we use QuickTime
363 #ifndef MAC_OS_X_VERSION_10_7
364 #define OF_VIDEO_PLAYER_QUICKTIME
365 #elif !defined(MAC_OS_X_VERSION_10_8)
366 #define OF_VIDEO_PLAYER_QTKIT
367 #else
368 #define OF_VIDEO_PLAYER_AVFOUNDATION
369 #endif
370 #elif defined(TARGET_EMSCRIPTEN)
371 #define OF_VIDEO_PLAYER_EMSCRIPTEN
372 #else
373 #define OF_VIDEO_PLAYER_QUICKTIME
374 #endif
375#endif
376
377//------------------------------------------------ soundstream
378// check if any soundstream api is defined from the compiler
379#if !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) && !defined(OF_SOUNDSTREAM_IOS) && !defined(OF_SOUNDSTREAM_EMSCRIPTEN)
380 #if defined(TARGET_LINUX) || defined(TARGET_WIN32) || defined(TARGET_OSX)
381 #define OF_SOUNDSTREAM_RTAUDIO
382 #elif defined(TARGET_ANDROID)
383 #define OF_SOUNDSTREAM_ANDROID
384 #elif defined(TARGET_OF_IOS)
385 #define OF_SOUNDSTREAM_IOS
386 #elif defined(TARGET_EMSCRIPTEN)
387 #define OF_SOUNDSTREAM_EMSCRIPTEN
388 #endif
389#endif
390
391//------------------------------------------------ soundplayer
392//MAC_OS and IOS uncomment to enable AVEnginePlayer
393#ifdef OF_NO_FMOD
394 #undef USE_FMOD
395 #if defined(TARGET_OF_IOS) || defined(TARGET_OSX)
396 #define OF_SOUND_PLAYER_AV_ENGINE
397 #elif defined(TARGET_WIN32)
398 #define OF_SOUND_PLAYER_MEDIA_FOUNDATION
399 #endif
400#endif
401
402// check if any soundplayer api is defined from the compiler
403
404#if !defined(TARGET_NO_SOUND)
405#if !defined(OF_SOUND_PLAYER_QUICKTIME) && !defined(OF_SOUND_PLAYER_FMOD) && !defined(OF_SOUND_PLAYER_OPENAL) && !defined(OF_SOUND_PLAYER_EMSCRIPTEN) && !defined(OF_SOUND_PLAYER_AV_ENGINE) && !defined(OF_SOUND_PLAYER_MEDIA_FOUNDATION)
406 #ifdef TARGET_OF_IOS
407 #define OF_SOUND_PLAYER_IPHONE
408 #elif defined(TARGET_LINUX) || defined(TARGET_MINGW)
409 #define OF_SOUND_PLAYER_OPENAL
410 #elif defined(TARGET_EMSCRIPTEN)
411 #define OF_SOUND_PLAYER_EMSCRIPTEN
412 #elif !defined(TARGET_ANDROID) && (!defined(USE_FMOD) || USE_FMOD)
413 #define OF_SOUND_PLAYER_FMOD
414 #endif
415#endif
416
417#endif
418//------------------------------------------------ c++11
419// check if the compiler supports c++11. vs hasn't updated the value
420// of __cplusplus so we need to check for vs >= 2012 (1700)
421#if __cplusplus>=201103 || _MSC_VER >= 1700
422#define HAS_CPP11 1
423#endif
424
425//------------------------------------------------ thread local storage
426// clang has a bug where it won't support tls on some versions even
427// on c++11, this is a workaround that bug
428#ifndef HAS_TLS
429 #if defined(__clang__) && __clang__
430 #if __has_feature(cxx_thread_local) && !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(__ANDROID__) && !defined(TARGET_OF_IOS)
431 #define HAS_TLS 1
432 #endif
433 #elif !defined(TARGET_WIN32) || _MSC_VER
434 #define HAS_TLS 1
435 #endif
436#endif
437
438//------------------------------------------------ make_unique
439// This is a helper method for make unique on platforms that support C++11, but not C++14.
440#if !defined(NO_OF_MAKE_UNIQUE) && (defined(_MSC_VER) && _MSC_VER < 1800) || (!defined(_MSC_VER) && __cplusplus <= 201103L)
441
442// Implementation for C++11 platforms that do not yet have std::make_unique.
443// Implementation from http://stackoverflow.com/a/13512344/1518329
444namespace std {
445
446
447template <typename T, typename... Args>
448std::unique_ptr<T> make_unique_helper(std::false_type, Args&&... args) {
449 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
450}
451
452template <typename T, typename... Args>
453std::unique_ptr<T> make_unique_helper(std::true_type, Args&&... args) {
454 static_assert(std::extent<T>::value == 0,
455 "make_unique<T[N]>() is forbidden, please use make_unique<T[]>().");
456
457 typedef typename std::remove_extent<T>::type U;
458 return std::unique_ptr<T>(new U[sizeof...(Args)]{std::forward<Args>(args)...});
459}
460
461template <typename T, typename... Args>
462std::unique_ptr<T> make_unique(Args&&... args) {
463 return make_unique_helper<T>(std::is_array<T>(), std::forward<Args>(args)...);
464}
465
466
467} // namespace std
468
469#endif
470
471
472// If you are building with c++17 or newer std filesystem will be enabled by default
473#if __cplusplus >= 201500
474 #define OF_HAS_CPP17 1
475 #if __cplusplus < 201703L
476 #define OF_USE_EXPERIMENTAL_FS 1
477 #endif
478#else
479 #define OF_HAS_CPP17 0
480#endif
481
482
483#ifndef OF_USING_STD_FS
484 #if OF_HAS_CPP17
485 #define OF_USING_STD_FS 1
486 #else
487 // Set to 1 to force std filesystem instead of boost's
488 #define OF_USING_STD_FS 0
489 #endif
490#endif
491
492// Some projects will specify OF_USING_STD_FS even if the compiler isn't newer than 201703L
493// This may be okay but we need to test for the way C++17 is including the filesystem
494
495#if OF_USING_STD_FS && !defined(OF_USE_EXPERIMENTAL_FS)
496 #if defined(__cpp_lib_filesystem)
497 #define OF_USE_EXPERIMENTAL_FS 0
498 #elif defined(__cpp_lib_experimental_filesystem)
499 #define OF_USE_EXPERIMENTAL_FS 1
500 #elif !defined(__has_include)
501 #define OF_USE_EXPERIMENTAL_FS 1
502 #elif __has_include(<filesystem>)
503 // If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental
504 #ifdef _MSC_VER
505
506 // Check and include header that defines "_HAS_CXX17"
507 #if __has_include(<yvals_core.h>)
508 #include <yvals_core.h>
509
510 // Check for enabled C++17 support
511 #if defined(_HAS_CXX17) && _HAS_CXX17
512 // We're using C++17, so let's use the normal version
513 #define OF_USE_EXPERIMENTAL_FS 0
514 #endif
515 #endif
516
517 // If the macro isn't defined yet, that means any of the other VS specific checks failed, so we need to use experimental
518 #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
519 #define OF_USE_EXPERIMENTAL_FS 1
520 #endif
521
522 // Not on Visual Studio. Let's use the normal version
523 #else // #ifdef _MSC_VER
524 #define OF_USE_EXPERIMENTAL_FS 0
525 #endif
526 #else
527 #define OF_USE_EXPERIMENTAL_FS 0
528 #endif
529#endif
530
531#if OF_USING_STD_FS
532 #if OF_USE_EXPERIMENTAL_FS
533 // C++17 experimental fs support
534 #include <experimental/filesystem>
535
536 #if OF_HAS_CPP17
537 namespace std {
538 namespace experimental{
539 namespace filesystem {
540 using path = v1::path;
541 }
542 }
543 }
544 #else
545 namespace std {
546 namespace experimental{
547 namespace filesystem {
548 using path = v1::__cxx11::path;
549 }
550 }
551 }
552 #endif
553
554 namespace of {
555 namespace filesystem = std::experimental::filesystem;
556 }
557 #else
558 #include <filesystem>
559 #if OF_HAS_CPP17
560 // Regular C++17 fs support
561 namespace of {
562 namespace filesystem = std::filesystem;
563 }
564 #else
565 namespace of {
566 namespace filesystem = std::filesystem;
567 }
568 #endif
569 #endif
570#else //not OF_USING_STD_FS
571 // No experimental or c++17 filesytem support use boost
572 #if !_MSC_VER
573 #define BOOST_NO_CXX11_SCOPED_ENUMS
574 #define BOOST_NO_SCOPED_ENUMS
575 #endif
576
577 #include <boost/filesystem.hpp>
578 namespace of {
579 namespace filesystem = boost::filesystem;
580 }
581
582#endif
Definition ofEvents.cpp:625
Definition ofPixels.h:1522
std::unique_ptr< T > make_unique(Args &&... args)
Definition ofConstants.h:462
std::unique_ptr< T > make_unique_helper(std::false_type, Args &&... args)
Definition ofConstants.h:448
ofTargetPlatform
This enumerates the targeted operating systems or platforms.
Definition ofConstants.h:31
@ OF_TARGET_IOS
32- and 64-bit armv7, arm64, x86 (simulator) architecture Mac iOS.
Definition ofConstants.h:39
@ OF_TARGET_WINVS
32- and 64-bit x86 architecture using Visual Studio on Windows OS.
Definition ofConstants.h:37
@ OF_TARGET_OSX
32- and 64-bit x86 architecture on Mac OSX.
Definition ofConstants.h:33
@ OF_TARGET_LINUXAARCH64
Definition ofConstants.h:53
@ OF_TARGET_MINGW
32- and 64-bit x86 architecture using MinGW on Windows OS.
Definition ofConstants.h:35
@ OF_TARGET_EMSCRIPTEN
Compiled to javascript using Emscripten.
Definition ofConstants.h:52
@ OF_TARGET_ANDROID
32- and 64-bit armeabi-v7a and x86 Android OS.
Definition ofConstants.h:41
@ OF_TARGET_LINUXARMV6L
32-bit armv6 little endian architecture on Linux OS.
Definition ofConstants.h:47
@ OF_TARGET_LINUX64
64-bit x86 architecture on Linux OS.
Definition ofConstants.h:45
@ OF_TARGET_LINUXARMV7L
32-bit armv7 little endian architecture on Linux OS.
Definition ofConstants.h:49
@ OF_TARGET_LINUX
32-bit x86 architecture on Linux OS.
Definition ofConstants.h:43
TESSindex ofIndexType
Definition ofConstants.h:290