root / CCV-HAND / libs / openFrameworks / utils / ofConstants.h @ 59
View | Annotate | Download (10.5 KB)
| 1 | #ifndef OF_CONSTANTS
|
|---|---|
| 2 | #define OF_CONSTANTS
|
| 3 | |
| 4 | //-------------------------------
|
| 5 | #define OF_VERSION 6 |
| 6 | //-------------------------------
|
| 7 | |
| 8 | //-------------------------------
|
| 9 | // find the system type --------
|
| 10 | //-------------------------------
|
| 11 | |
| 12 | // helpful:
|
| 13 | // http://www.ogre3d.org/docs/api/html/OgrePlatform_8h-source.html
|
| 14 | |
| 15 | #if defined( __WIN32__ ) || defined( _WIN32 )
|
| 16 | #define TARGET_WIN32
|
| 17 | #elif defined( __APPLE_CC__)
|
| 18 | #include <TargetConditionals.h> |
| 19 | |
| 20 | #if (TARGET_OF_IPHONE_SIMULATOR) || (TARGET_OS_IPHONE) || (TARGET_IPHONE)
|
| 21 | #define TARGET_OF_IPHONE
|
| 22 | #define TARGET_OPENGLES
|
| 23 | #else
|
| 24 | #define TARGET_OSX
|
| 25 | #endif
|
| 26 | #else
|
| 27 | #define TARGET_LINUX
|
| 28 | #endif
|
| 29 | //-------------------------------
|
| 30 | |
| 31 | |
| 32 | // then the the platform specific includes:
|
| 33 | #ifdef TARGET_WIN32
|
| 34 | //this is for TryEnterCriticalSection
|
| 35 | //http://www.zeroc.com/forums/help-center/351-ice-1-2-tryentercriticalsection-problem.html
|
| 36 | #ifndef _WIN32_WINNT
|
| 37 | # define _WIN32_WINNT 0x400 |
| 38 | #endif
|
| 39 | #define WIN32_LEAN_AND_MEAN
|
| 40 | #include <windows.h> |
| 41 | #include "GLee.h" |
| 42 | #include "glu.h" |
| 43 | #define __WINDOWS_DS__
|
| 44 | #define __WINDOWS_MM__
|
| 45 | #if (_MSC_VER) // microsoft visual studio |
| 46 | #pragma warning(disable : 4996) // disable all deprecation warnings |
| 47 | #pragma warning(disable : 4068) // unknown pragmas |
| 48 | #pragma warning(disable : 4101) // unreferenced local variable |
| 49 | #pragma warning(disable : 4312) // type cast conversion (in qt vp) |
| 50 | #pragma warning(disable : 4311) // type cast pointer truncation (qt vp) |
| 51 | #pragma warning(disable : 4018) // signed/unsigned mismatch (since vector.size() is a size_t) |
| 52 | #pragma warning(disable : 4267) // conversion from size_t to Size warning... possible loss of data |
| 53 | #pragma warning(disable : 4800) // 'Boolean' : forcing value to bool 'true' or 'false' |
| 54 | #pragma warning(disable : 4099) // for debug, PDB 'vc80.pdb' was not found with... |
| 55 | #endif
|
| 56 | |
| 57 | #define TARGET_LITTLE_ENDIAN // intel cpu |
| 58 | |
| 59 | // some gl.h files, like dev-c++, are old - this is pretty universal
|
| 60 | #ifndef GL_BGR_EXT
|
| 61 | #define GL_BGR_EXT 0x80E0 |
| 62 | #endif
|
| 63 | |
| 64 | // #define WIN32_HIGH_RES_TIMING
|
| 65 | |
| 66 | // note: this is experimental!
|
| 67 | // uncomment to turn this on (only for windows machines)
|
| 68 | // if you want to try setting the timer to be high resolution
|
| 69 | // this could make camera grabbing and other low level
|
| 70 | // operations quicker, but you must quit the app normally,
|
| 71 | // ie, using "esc", rather than killing the process or closing
|
| 72 | // the console window in order to set the timer resolution back
|
| 73 | // to normal (since the high res timer might give the OS
|
| 74 | // problems)
|
| 75 | // info: http://www.geisswerks.com/ryan/FAQS/timing.html
|
| 76 | |
| 77 | #endif
|
| 78 | |
| 79 | #ifdef TARGET_OSX
|
| 80 | #ifndef __MACOSX_CORE__
|
| 81 | #define __MACOSX_CORE__
|
| 82 | #endif
|
| 83 | #include <unistd.h> |
| 84 | #include "GLee.h" |
| 85 | #include <OpenGL/glu.h> |
| 86 | #include <ApplicationServices/ApplicationServices.h> |
| 87 | |
| 88 | #if defined(__LITTLE_ENDIAN__)
|
| 89 | #define TARGET_LITTLE_ENDIAN // intel cpu |
| 90 | #endif
|
| 91 | #endif
|
| 92 | |
| 93 | #ifdef TARGET_LINUX
|
| 94 | #include <unistd.h> |
| 95 | #include "GLee.h" |
| 96 | #include <GL/glu.h> |
| 97 | |
| 98 | // for some reason, this isn't defined at compile time,
|
| 99 | // so this hack let's us work
|
| 100 | // for 99% of the linux folks that are on intel
|
| 101 | // everyone one else will have RGB / BGR issues.
|
| 102 | //#if defined(__LITTLE_ENDIAN__)
|
| 103 | #define TARGET_LITTLE_ENDIAN // intel cpu |
| 104 | //#endif
|
| 105 | |
| 106 | // some things for serial compilation:
|
| 107 | #define B14400 14400 |
| 108 | #define B28800 28800 |
| 109 | |
| 110 | |
| 111 | #endif
|
| 112 | |
| 113 | |
| 114 | #ifdef TARGET_OF_IPHONE
|
| 115 | #import <OpenGLES/ES1/gl.h>
|
| 116 | #import <OpenGLES/ES1/glext.h>
|
| 117 | #endif
|
| 118 | |
| 119 | |
| 120 | #ifndef __MWERKS__
|
| 121 | #define OF_EXIT_APP(val) std::exit(val);
|
| 122 | #else
|
| 123 | #define OF_EXIT_APP(val) std::exit(val);
|
| 124 | #endif
|
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | //------------------------------------------------ capture
|
| 130 | // if are linux
|
| 131 | |
| 132 | #ifdef TARGET_LINUX
|
| 133 | |
| 134 | |
| 135 | // some cameras don't seem to work in unicap, so we keep
|
| 136 | // V4l code here. comment out this next line, to switch to the older
|
| 137 | // V4l code...
|
| 138 | |
| 139 | // (if you change this, you might need to clean and rebuild, in CB build->rebuild)
|
| 140 | |
| 141 | #define OF_SWITCH_TO_UNICAP_FOR_LINUX_VIDCAP
|
| 142 | |
| 143 | |
| 144 | |
| 145 | #ifdef OF_SWITCH_TO_UNICAP_FOR_LINUX_VIDCAP
|
| 146 | #define OF_VIDEO_CAPTURE_UNICAP
|
| 147 | #else
|
| 148 | #define OF_VIDEO_CAPTURE_V4L
|
| 149 | #endif
|
| 150 | |
| 151 | |
| 152 | |
| 153 | #else
|
| 154 | |
| 155 | // non - linux, pc or osx
|
| 156 | |
| 157 | // comment out this following line, if you'd like to use the
|
| 158 | // quicktime capture interface on windows
|
| 159 | // if not, we default to videoInput library for
|
| 160 | // direct show capture...
|
| 161 | |
| 162 | #define OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP
|
| 163 | |
| 164 | #ifdef OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP
|
| 165 | #ifdef TARGET_OSX
|
| 166 | #define OF_VIDEO_CAPTURE_QUICKTIME
|
| 167 | #else
|
| 168 | #define OF_VIDEO_CAPTURE_DIRECTSHOW
|
| 169 | #endif
|
| 170 | #else
|
| 171 | // all quicktime, all the time
|
| 172 | #define OF_VIDEO_CAPTURE_QUICKTIME
|
| 173 | #endif
|
| 174 | #endif
|
| 175 | |
| 176 | |
| 177 | #ifdef TARGET_LINUX
|
| 178 | #define OF_VIDEO_PLAYER_GSTREAMER
|
| 179 | #else
|
| 180 | #define OF_VIDEO_PLAYER_QUICKTIME
|
| 181 | #endif
|
| 182 | |
| 183 | // comment out this line to disable all poco related code
|
| 184 | #ifndef TARGET_OF_IPHONE
|
| 185 | #define OF_USING_POCO
|
| 186 | #endif
|
| 187 | |
| 188 | //we don't want to break old code that uses ofSimpleApp
|
| 189 | //so we forward declare ofBaseApp and make ofSimpleApp mean the same thing
|
| 190 | class ofBaseApp; |
| 191 | typedef ofBaseApp ofSimpleApp;
|
| 192 | |
| 193 | enum ofLogLevel{
|
| 194 | OF_LOG_VERBOSE, |
| 195 | OF_LOG_NOTICE, |
| 196 | OF_LOG_WARNING, |
| 197 | OF_LOG_ERROR, |
| 198 | OF_LOG_FATAL_ERROR, |
| 199 | OF_LOG_SILENT //this one is special and should always be last - set ofSetLogLevel to OF_SILENT to not recieve any messages
|
| 200 | }; |
| 201 | |
| 202 | #define OF_DEFAULT_LOG_LEVEL OF_LOG_WARNING;
|
| 203 | |
| 204 | // serial error codes
|
| 205 | #define OF_SERIAL_NO_DATA -2 |
| 206 | #define OF_SERIAL_ERROR -1 |
| 207 | |
| 208 | // core: ---------------------------
|
| 209 | #include <stdio.h> |
| 210 | #include <stdarg.h> |
| 211 | #include <math.h> |
| 212 | #include <time.h> |
| 213 | #include <stdlib.h> |
| 214 | #include <string.h> |
| 215 | #include <iostream> |
| 216 | #include <vector> |
| 217 | #include <string> |
| 218 | #include <sstream> //for ostringsream |
| 219 | #include <iomanip> //for setprecision |
| 220 | using namespace std; |
| 221 | |
| 222 | #ifndef PI
|
| 223 | #define PI 3.14159265358979323846 |
| 224 | #endif
|
| 225 | |
| 226 | #ifndef TWO_PI
|
| 227 | #define TWO_PI 6.28318530717958647693 |
| 228 | #endif
|
| 229 | |
| 230 | #ifndef M_TWO_PI
|
| 231 | #define M_TWO_PI 6.28318530717958647693 |
| 232 | #endif
|
| 233 | |
| 234 | #ifndef FOUR_PI
|
| 235 | #define FOUR_PI 12.56637061435917295385 |
| 236 | #endif
|
| 237 | |
| 238 | #ifndef HALF_PI
|
| 239 | #define HALF_PI 1.57079632679489661923 |
| 240 | #endif
|
| 241 | |
| 242 | #ifndef DEG_TO_RAD
|
| 243 | #define DEG_TO_RAD (PI/180.0) |
| 244 | #endif
|
| 245 | |
| 246 | #ifndef RAD_TO_DEG
|
| 247 | #define RAD_TO_DEG (180.0/PI) |
| 248 | #endif
|
| 249 | |
| 250 | #ifndef MIN
|
| 251 | #define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
| 252 | #endif
|
| 253 | |
| 254 | #ifndef MAX
|
| 255 | #define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
| 256 | #endif
|
| 257 | |
| 258 | #ifndef CLAMP
|
| 259 | #define CLAMP(val,min,max) (MAX(MIN(val,max),min))
|
| 260 | #endif
|
| 261 | |
| 262 | #ifndef ABS
|
| 263 | #define ABS(x) (((x) < 0) ? -(x) : (x)) |
| 264 | #endif
|
| 265 | |
| 266 | #define OF_FILLED 0x01 |
| 267 | #define OF_OUTLINE 0x02 |
| 268 | #define OF_WINDOW 0 |
| 269 | #define OF_FULLSCREEN 1 |
| 270 | #define OF_GAME_MODE 2 |
| 271 | |
| 272 | #define OF_RECTMODE_CORNER 0 |
| 273 | #define OF_RECTMODE_CENTER 1 |
| 274 | |
| 275 | #define OF_IMAGE_GRAYSCALE 0x00 |
| 276 | #define OF_IMAGE_COLOR 0x01 |
| 277 | #define OF_IMAGE_COLOR_ALPHA 0x02 |
| 278 | #define OF_IMAGE_UNDEFINED 0x03 |
| 279 | |
| 280 | #define OF_MAX_STYLE_HISTORY 32 |
| 281 | #define OF_MAX_CIRCLE_PTS 1024 |
| 282 | |
| 283 | // these are straight out of glu, but renamed and included here
|
| 284 | // for convenience
|
| 285 | //
|
| 286 | // we don't mean to wrap the whole glu library (or any other library for that matter)
|
| 287 | // but these defines are useful to give people flexability over the polygonizer
|
| 288 | //
|
| 289 | // some info:
|
| 290 | // http://glprogramming.com/red/images/Image128.gif
|
| 291 | //
|
| 292 | // also: http://glprogramming.com/red/chapter11.html
|
| 293 | // (CSG ideas)
|
| 294 | |
| 295 | #define OF_POLY_WINDING_ODD 100130 |
| 296 | #define OF_POLY_WINDING_NONZERO 100131 |
| 297 | #define OF_POLY_WINDING_POSITIVE 100132 |
| 298 | #define OF_POLY_WINDING_NEGATIVE 100133 |
| 299 | #define OF_POLY_WINDING_ABS_GEQ_TWO 100134 |
| 300 | |
| 301 | #define OF_CLOSE (true) |
| 302 | |
| 303 | |
| 304 | //--------------------------------------------
|
| 305 | //
|
| 306 | // Keyboard definitions
|
| 307 | //
|
| 308 | // ok -- why this?
|
| 309 | // glut key commands have some annoying features,
|
| 310 | // in that some normal keys have the same value as special keys,
|
| 311 | // but we want ONE key routine, so we need to redefine several,
|
| 312 | // so that we get some normalacy across keys routines
|
| 313 | //
|
| 314 | // (everything that comes through "glutSpecialKeyFunc" will get 256 added to it,
|
| 315 | // to avoid conflicts, before, values like "left, right up down" (ie, 104, 105, 106) were conflicting with
|
| 316 | // letters.. now they will be 256 + 104, 256 + 105....)
|
| 317 | |
| 318 | |
| 319 | #define OF_KEY_MODIFIER 0x0100 |
| 320 | #define OF_KEY_RETURN 13 |
| 321 | #define OF_KEY_ESC 27 |
| 322 | |
| 323 | // http://www.openframeworks.cc/forum/viewtopic.php?t=494
|
| 324 | // some issues with keys across platforms:
|
| 325 | |
| 326 | #ifdef TARGET_OSX
|
| 327 | #define OF_KEY_BACKSPACE 127 |
| 328 | #define OF_KEY_DEL 8 |
| 329 | #else
|
| 330 | #define OF_KEY_BACKSPACE 8 |
| 331 | #define OF_KEY_DEL 127 |
| 332 | #endif
|
| 333 | |
| 334 | // zach - there are more of these keys, we can add them here...
|
| 335 | // these are keys that are not coming through "special keys"
|
| 336 | // via glut, but just other keys on your keyboard like
|
| 337 | |
| 338 | #define OF_KEY_F1 (1 | OF_KEY_MODIFIER) |
| 339 | #define OF_KEY_F2 (2 | OF_KEY_MODIFIER) |
| 340 | #define OF_KEY_F3 (3 | OF_KEY_MODIFIER) |
| 341 | #define OF_KEY_F4 (4 | OF_KEY_MODIFIER) |
| 342 | #define OF_KEY_F5 (5 | OF_KEY_MODIFIER) |
| 343 | #define OF_KEY_F6 (6 | OF_KEY_MODIFIER) |
| 344 | #define OF_KEY_F7 (7 | OF_KEY_MODIFIER) |
| 345 | #define OF_KEY_F8 (8 | OF_KEY_MODIFIER) |
| 346 | #define OF_KEY_F9 (9 | OF_KEY_MODIFIER) |
| 347 | #define OF_KEY_F10 (10 | OF_KEY_MODIFIER) |
| 348 | #define OF_KEY_F11 (11 | OF_KEY_MODIFIER) |
| 349 | #define OF_KEY_F12 (12 | OF_KEY_MODIFIER) |
| 350 | #define OF_KEY_LEFT (100 | OF_KEY_MODIFIER) |
| 351 | #define OF_KEY_UP (101 | OF_KEY_MODIFIER) |
| 352 | #define OF_KEY_RIGHT (102 | OF_KEY_MODIFIER) |
| 353 | #define OF_KEY_DOWN (103 | OF_KEY_MODIFIER) |
| 354 | #define OF_KEY_PAGE_UP (104 | OF_KEY_MODIFIER) |
| 355 | #define OF_KEY_PAGE_DOWN (105 | OF_KEY_MODIFIER) |
| 356 | #define OF_KEY_HOME (106 | OF_KEY_MODIFIER) |
| 357 | #define OF_KEY_END (107 | OF_KEY_MODIFIER) |
| 358 | #define OF_KEY_INSERT (108 | OF_KEY_MODIFIER) |
| 359 | |
| 360 | // not sure what to do in the case of non-glut apps....
|
| 361 | |
| 362 | |
| 363 | //--------------------------------------------
|
| 364 | //console colors for our logger - shame this doesn't work with the xcode console
|
| 365 | |
| 366 | #ifdef TARGET_WIN32
|
| 367 | |
| 368 | #define OF_CONSOLE_COLOR_RESTORE (0 | (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) ) |
| 369 | #define OF_CONSOLE_COLOR_BLACK (0) |
| 370 | #define OF_CONSOLE_COLOR_RED (FOREGROUND_RED)
|
| 371 | #define OF_CONSOLE_COLOR_GREEN (FOREGROUND_GREEN)
|
| 372 | #define OF_CONSOLE_COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN)
|
| 373 | #define OF_CONSOLE_COLOR_BLUE (FOREGROUND_BLUE)
|
| 374 | #define OF_CONSOLE_COLOR_PURPLE (FOREGROUND_RED | FOREGROUND_BLUE )
|
| 375 | #define OF_CONSOLE_COLOR_CYAN (FOREGROUND_GREEN | FOREGROUND_BLUE)
|
| 376 | #define OF_CONSOLE_COLOR_WHITE (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
| 377 | |
| 378 | #else
|
| 379 | |
| 380 | #define OF_CONSOLE_COLOR_RESTORE (0) |
| 381 | #define OF_CONSOLE_COLOR_BLACK (30) |
| 382 | #define OF_CONSOLE_COLOR_RED (31) |
| 383 | #define OF_CONSOLE_COLOR_GREEN (32) |
| 384 | #define OF_CONSOLE_COLOR_YELLOW (33) |
| 385 | #define OF_CONSOLE_COLOR_BLUE (34) |
| 386 | #define OF_CONSOLE_COLOR_PURPLE (35) |
| 387 | #define OF_CONSOLE_COLOR_CYAN (36) |
| 388 | #define OF_CONSOLE_COLOR_WHITE (37) |
| 389 | |
| 390 | #endif
|
| 391 | |
| 392 | //--------------------------------------------
|
| 393 | |
| 394 | #endif
|
