1 // Hyperbolic Rogue -- set compiler flags, and include all the required system headers 2 // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details 3 4 /** \file sysconfig.h 5 * \brief set compiler flags, and include all the required system headers 6 */ 7 8 #ifdef MAC 9 #define ISMAC 1 10 #endif 11 12 #ifdef LINUX 13 #define ISLINUX 1 14 #endif 15 16 #ifdef WINDOWS 17 #define ISWINDOWS 1 18 #define _WIN32_WINNT 0x0501 19 #endif 20 21 // OS settings 22 23 #ifndef ISMAC 24 #define ISMAC 0 25 #endif 26 27 #ifndef ISLINUX 28 #define ISLINUX 0 29 #endif 30 31 #ifndef ISWINDOWS 32 #define ISWINDOWS 0 33 #endif 34 35 #ifndef ISPANDORA 36 #define ISPANDORA 0 37 #endif 38 39 #ifndef ISIOS 40 #define ISIOS 0 41 #endif 42 43 #ifndef ISANDROID 44 #define ISANDROID 0 45 #endif 46 47 #ifndef CAP_EXTFONT 48 #define CAP_EXTFONT (ISIOS || ISANDROID || ISFAKEMOBILE) 49 #endif 50 51 #ifndef ISSTEAM 52 #define ISSTEAM 0 53 #endif 54 55 #ifndef ISWEB 56 #define ISWEB 0 57 #endif 58 59 #ifndef ISFAKEMOBILE 60 #define ISFAKEMOBILE 0 61 #endif 62 63 #define ISMOBILE (ISIOS || ISANDROID || ISFAKEMOBILE) 64 #define ISMOBWEB (ISMOBILE || ISWEB) 65 66 #ifndef ISMINI 67 #define ISMINI 0 68 #endif 69 70 #ifndef CAP_XGD 71 #define CAP_XGD (ISANDROID || ISFAKEMOBILE) 72 #endif 73 74 #ifndef CAP_THREAD 75 #define CAP_THREAD (!ISMOBILE && !ISWEB) 76 #endif 77 78 #ifndef CAP_ZLIB 79 #define CAP_ZLIB 1 80 #endif 81 82 #ifndef CAP_GMP 83 #define CAP_GMP 0 84 #endif 85 86 #ifndef CAP_URL 87 #define CAP_URL 1 88 #endif 89 90 #define CAP_FRAMELIMIT (!ISMOBWEB) 91 92 #if ISMOBILE 93 #define EXTERNALFONT 94 #endif 95 96 #ifndef NOLICENSE 97 #define NOLICENSE ISSTEAM 98 #endif 99 100 #ifndef CAP_VERTEXBUFFER 101 #define CAP_VERTEXBUFFER (ISWEB) 102 #endif 103 104 #ifndef CAP_SHADER 105 #define CAP_SHADER CAP_GL 106 #endif 107 108 #ifndef CAP_NOSHADER 109 #define CAP_NOSHADER (!ISMOBILE && !ISWEB) 110 #endif 111 112 #ifndef CAP_ANIMATIONS 113 #define CAP_ANIMATIONS (!ISMINI) 114 #endif 115 116 #ifndef CAP_FILES 117 #define CAP_FILES (!ISMINI) 118 #endif 119 120 #ifndef CAP_INV 121 #define CAP_INV (!ISMINI) 122 #endif 123 124 #ifndef CAP_ANDROIDSHARE 125 #define CAP_ANDROIDSHARE (ISANDROID) 126 #endif 127 128 #ifndef CAP_SDL 129 #define CAP_SDL (!ISMOBILE) 130 #endif 131 132 #ifndef CAP_SDL2 133 #define CAP_SDL2 0 134 #endif 135 136 #ifndef CAP_TIMEOFDAY 137 #define CAP_TIMEOFDAY (!CAP_SDL) 138 #endif 139 140 #ifndef CAP_COMPASS 141 #define CAP_COMPASS ISMOBILE 142 #endif 143 144 #ifndef CAP_SDLGFX 145 #define CAP_SDLGFX (CAP_SDL && !ISWEB) 146 #endif 147 148 #ifndef CAP_GL 149 #define CAP_GL (ISMOBILE || CAP_SDL) 150 #endif 151 152 #ifndef CAP_AUDIO 153 #define CAP_AUDIO ((ISMOBILE || CAP_SDL) && !ISWEB && !ISMINI) 154 #endif 155 156 #define CAP_GLORNOT (CAP_GL && !ISWEB && !ISIOS) 157 158 #ifndef CAP_DAILY 159 #if ISSTEAM 160 #define CAP_DAILY 1 161 #endif 162 #endif 163 164 #ifndef CAP_DAILY 165 #define CAP_DAILY 0 166 #endif 167 168 #ifndef CAP_CERTIFY 169 #define CAP_CERTIFY 0 170 #endif 171 172 #ifndef CAP_RUG 173 #define CAP_RUG (!ISMINI && CAP_GL) 174 #endif 175 176 #ifndef CAP_SURFACE 177 #define CAP_SURFACE CAP_RUG 178 #endif 179 180 #ifndef CAP_KUEN_MAP 181 #define CAP_KUEN_MAP 0 182 #endif 183 184 #ifndef CAP_EDIT 185 #define CAP_EDIT (CAP_FILES && !ISMINI) 186 #endif 187 188 #ifndef CAP_SHOT 189 #define CAP_SHOT (CAP_FILES && (CAP_SVG || CAP_PNG)) 190 #endif 191 192 #ifndef CAP_ODS 193 #define CAP_ODS 0 194 #endif 195 196 #ifndef CAP_VIDEO 197 #define CAP_VIDEO (CAP_SHOT && ISLINUX && CAP_SDL) 198 #endif 199 200 #ifndef MAXMDIM 201 #define MAXMDIM 4 202 #endif 203 204 #ifndef CAP_MDIM_FIXED 205 #define CAP_MDIM_FIXED 0 206 #endif 207 208 #ifndef CAP_TEXTURE 209 #define CAP_TEXTURE (CAP_GL && (CAP_PNG || CAP_SDL_IMG) && !ISMINI) 210 #endif 211 212 #ifndef CAP_MODEL 213 #define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDL) 214 #endif 215 216 #ifndef CAP_SAVE 217 #define CAP_SAVE (CAP_FILES && !ISWEB && !ISMINI) 218 #endif 219 220 #ifndef CAP_CONFIG 221 #define CAP_CONFIG (CAP_FILES && !ISWEB && !ISMINI) 222 #endif 223 224 #ifndef CAP_TRANS 225 #define CAP_TRANS (!ISWEB && !ISMINI) 226 #endif 227 228 #ifndef CAP_TOUR 229 #define CAP_TOUR (!ISMINI) 230 #endif 231 232 #ifndef CAP_ROGUEVIZ 233 #define CAP_ROGUEVIZ 0 234 #endif 235 236 #ifndef CAP_PROFILING 237 #define CAP_PROFILING 0 238 #endif 239 240 #define PSEUDOKEY_WHEELDOWN 2501 241 #define PSEUDOKEY_WHEELUP 2502 242 #define PSEUDOKEY_RELEASE 2503 243 #define PSEUDOKEY_EXIT 2504 244 #define PSEUDOKEY_MENU 2505 245 246 #ifndef CAP_PNG 247 #define CAP_PNG (!ISMOBWEB) 248 #endif 249 250 #ifndef CAP_ORIENTATION 251 #define CAP_ORIENTATION (ISMOBILE || ISWEB) 252 #endif 253 254 #ifndef CAP_MOUSEGRAB 255 #define CAP_MOUSEGRAB (!ISMOBILE) 256 #endif 257 258 #ifndef CAP_COMMANDLINE 259 #define CAP_COMMANDLINE (!ISMOBILE) 260 #endif 261 262 #define CAP_SDLAUDIO (CAP_SDL && CAP_AUDIO) 263 264 #ifndef CAP_SVG 265 #define CAP_SVG (CAP_FILES && !ISMOBILE && !ISMINI) 266 #endif 267 268 #ifndef CAP_WRL 269 #define CAP_WRL (CAP_FILES && !ISMOBILE && !ISMINI && !ISWEB) 270 #endif 271 272 #ifndef CAP_POLY 273 #define CAP_POLY (CAP_SDLGFX || CAP_GL || CAP_SVG) 274 #endif 275 276 #ifndef CAP_SHAPES 277 #define CAP_SHAPES 1 278 #endif 279 280 #define CAP_QUEUE CAP_POLY 281 #define CAP_CURVE CAP_POLY 282 283 #ifndef CAP_SDLJOY 284 #define CAP_SDLJOY (CAP_SDL && !ISWEB) 285 #endif 286 287 #ifndef CAP_SDL_IMG 288 #define CAP_SDL_IMG 0 289 #endif 290 291 #ifndef CAP_SDLTTF 292 #define CAP_SDLTTF (CAP_SDL && !ISMOBILE && !ISWEB) 293 #endif 294 295 #define CAP_GLFONT (CAP_GL && !ISMOBILE) 296 297 #ifndef CAP_TABFONT 298 #define CAP_TABFONT (ISWEB) 299 #endif 300 301 #ifndef CAP_CREATEFONT 302 #define CAP_CREATEFONT 0 303 #endif 304 305 #ifndef CAP_FIXEDSIZE 306 #define CAP_FIXEDSIZE (CAP_CREATEFONT || CAP_TABFONT ? 36 : 0) 307 #endif 308 309 #ifndef CAP_SHMUP 310 #define CAP_SHMUP (!ISWEB) 311 #endif 312 313 #ifndef CAP_BITFIELD 314 #define CAP_BITFIELD (!ISWEB) 315 #endif 316 317 #ifndef CAP_ACHIEVE 318 #define CAP_ACHIEVE ISSTEAM 319 #endif 320 321 #ifndef CAP_SHMUP_GOOD 322 #define CAP_SHMUP_GOOD (!ISMOBWEB) 323 #endif 324 325 #ifndef CAP_COMPLEX2 326 #define CAP_COMPLEX2 (!ISMINI) 327 #endif 328 329 #ifndef CAP_RACING 330 #define CAP_RACING (!ISMOBWEB && !ISMINI) 331 #endif 332 333 #ifndef CAP_VR 334 #define CAP_VR (ISSTEAM && !ISMAC) 335 #endif 336 337 #ifndef CAP_LEGACY 338 #define CAP_LEGACY 0 339 #endif 340 341 #if ISMOBILE 342 #define EXTRALICENSE "\n\nHyperRogue soundtrack under the Creative Commons BY-SA 3.0 license, http://creativecommons.org/licenses/by-sa/3.0/\nCrossroads, Graveyard, Land of Eternal Motion, Hall of Mirrors, Hell, R'Lyeh, Living Caves, Jungle, Desert, Icy Lands by Shawn Parrotte (http://www.shawnparrotte.com)\nCaribbean, Ivory Tower, Ocean, Palace by Will Savino (http://www.willsavino.net/)\n\n\n"; 343 #undef XEXTRALICENSE 344 #endif 345 346 #ifndef HYPERPATH 347 #define HYPERPATH "" 348 #endif 349 350 #if ISWINDOWS 351 #define hyper fake_hyper // avoid "hyper" typedef in <_mingw.h> 352 #define WIN32_LEAN_AND_MEAN // avoid "rad1" macro in <windows.h> 353 #define NOMINMAX // avoid "min" and "max" macros in <windows.h> 354 #include <windows.h> 355 #include <shellapi.h> 356 #endif 357 358 #include <stdio.h> 359 360 #if CAP_SDL 361 #if CAP_SDL2 362 #include <SDL2/SDL.h> 363 #define SDL12(x,y) y 364 #define SDLK_KP1 SDLK_KP_1 365 #define SDLK_KP2 SDLK_KP_2 366 #define SDLK_KP3 SDLK_KP_3 367 #define SDLK_KP4 SDLK_KP_4 368 #define SDLK_KP5 SDLK_KP_5 369 #define SDLK_KP6 SDLK_KP_6 370 #define SDLK_KP7 SDLK_KP_7 371 #define SDLK_KP8 SDLK_KP_8 372 #define SDLK_KP9 SDLK_KP_9 373 #define SDLK_KP0 SDLK_KP_0 374 #define SDL12_GetKeyState SDL_GetKeyboardState 375 #define KEYSTATES SDL_NUM_SCANCODES 376 #else 377 #include <SDL/SDL.h> 378 #define SDL12(x,y) x 379 #define SDL12_GetKeyState SDL_GetKeyState 380 #define KEYSTATES SDLK_LAST 381 #endif 382 383 #if !ISMAC 384 #undef main 385 #endif 386 387 #if CAP_SDLAUDIO 388 #if CAP_SDL2 389 #include <SDL2/SDL_mixer.h> 390 #else 391 #include <SDL/SDL_mixer.h> 392 #endif 393 #endif 394 395 #if CAP_SDLTTF 396 #if CAP_SDL2 397 #include <SDL2/SDL_ttf.h> 398 #else 399 #include <SDL/SDL_ttf.h> 400 #endif 401 #endif 402 403 #if CAP_SDLGFX 404 #if CAP_SDL2 405 #include <SDL2/SDL2_gfxPrimitives.h> 406 #else 407 #include <SDL/SDL_gfxPrimitives.h> 408 #endif 409 #endif 410 411 #elif !ISFAKEMOBILE 412 #define SDLK_F1 (123001) 413 #define SDLK_F2 (123002) 414 #define SDLK_F3 (123003) 415 #define SDLK_F4 (123004) 416 #define SDLK_F5 (123005) 417 #define SDLK_F6 (123006) 418 #define SDLK_F7 (123007) 419 #define SDLK_F8 (123008) 420 #define SDLK_F9 (123009) 421 #define SDLK_F10 (123010) 422 #define SDLK_ESCAPE (123099) 423 #define SDLK_F12 (123012) 424 #define SDLK_HOME (123013) 425 #define SDLK_LEFT (123014) 426 #define SDLK_RIGHT (123015) 427 #define SDLK_END (123016) 428 #define MIX_MAX_VOLUME 128 429 #define SDLK_UP (123021) 430 #define SDLK_DOWN (123022) 431 #define SDLK_PAGEUP (123023) 432 #define SDLK_PAGEDOWN (123024) 433 #define SDLK_RETURN (123025) 434 #define SDLK_KP1 (123031) 435 #define SDLK_KP2 (123032) 436 #define SDLK_KP3 (123033) 437 #define SDLK_KP4 (123034) 438 #define SDLK_KP5 (123035) 439 #define SDLK_KP6 (123036) 440 #define SDLK_KP7 (123037) 441 #define SDLK_KP8 (123038) 442 #define SDLK_KP9 (123039) 443 #define SDLK_KP_PERIOD (123051) 444 #define SDLK_KP_MINUS (123053) 445 #define SDLK_DELETE (123052) 446 #define SDLK_DELETE (123052) 447 #define SDLK_KP_ENTER (123054) 448 #define SDLK_BACKSPACE (123055) 449 #define FAKE_SDL 450 typedef int SDL_Event; 451 typedef unsigned int Uint32; 452 #endif 453 454 #if ISWEB 455 extern "C" { 456 Uint8 *SDL_GetKeyState(void*); 457 } 458 // inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; } 459 #endif 460 461 462 #ifndef CAP_GLEW 463 #define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB) 464 #endif 465 466 #if ISWEB 467 #define GLES_ONLY 468 #endif 469 470 #if CAP_GL 471 #if CAP_GLEW 472 #include <GL/glew.h> 473 #else 474 #define GL_GLEXT_PROTOTYPES 1 475 #if ISMAC 476 #define GL_SILENCE_DEPRECATION 1 477 #include <OpenGL/gl.h> 478 #include <OpenGL/glu.h> 479 #include <OpenGL/glext.h> 480 #elif ISIOS 481 // already included 482 #elif ISANDROID 483 #include <GLES/gl.h> 484 #include <GLES/glext.h> 485 #include <GLES2/gl2.h> 486 #include <GLES3/gl3.h> 487 #define GLES_ONLY 488 #else 489 #include <GL/gl.h> 490 #include <GL/glu.h> 491 #include <GL/glext.h> 492 #endif 493 #endif 494 #else 495 typedef int GLint; 496 typedef unsigned GLuint; 497 #endif 498 499 #include <functional> 500 #include <memory> 501 #include <cmath> 502 #include <time.h> 503 #include <vector> 504 #include <algorithm> 505 #include <stdio.h> 506 #include <stdlib.h> 507 #include <string.h> 508 #include <string> 509 #include <cassert> 510 #include <map> 511 #include <queue> 512 #include <sstream> 513 #include <stdexcept> 514 #include <array> 515 #include <set> 516 #include <random> 517 #include <complex> 518 #include <new> 519 #include <limits.h> 520 521 #if CAP_VR 522 #ifdef __MINGW32__ 523 #include "openvr_mingw.hpp" 524 #else 525 #include "openvr.h" 526 #endif 527 #endif 528 529 #if CAP_VIDEO 530 #include <sys/wait.h> 531 #endif 532 533 #if CAP_ZLIB 534 #include <zlib.h> 535 #endif 536 537 #if ISWEB 538 #include <emscripten.h> 539 #include <emscripten/html5.h> 540 #endif 541 542 #if CAP_GMP 543 #include <gmpxx.h> 544 #endif 545 546 #if CAP_THREAD 547 #if OLD_MINGW 548 #include "mingw.thread.h" 549 #include "mingw.mutex.h" 550 #include "mingw.condition_variable.h" 551 #else 552 #include <thread> 553 #include <mutex> 554 #include <condition_variable> 555 #endif 556 #endif 557 558 #include <stdint.h> 559 560 #if ISWINDOWS 561 #include "direntx.h" 562 #else 563 #include <dirent.h> 564 #endif 565 566 #if CAP_TEXTURE 567 #if CAP_SDL_IMG 568 #include <SDL/SDL_image.h> 569 #elif CAP_PNG 570 #include <png.h> 571 #endif 572 #endif 573 574 #if CAP_FILES 575 #include <unistd.h> 576 #include <sys/types.h> 577 #include <sys/stat.h> 578 #endif 579 580 #if CAP_TIMEOFDAY 581 #include <sys/time.h> 582 #endif 583 584 #ifdef BACKTRACE 585 #include <execinfo.h> 586 #endif 587 588 #if CAP_SDL 589 union SDL_Event; 590 #endif 591 592 #if ISWINDOWS 593 #undef hyper // avoid "hyper" typedef in <_mingw.h> 594 #endif 595 596 #ifndef MINIMIZE_GL_CALLS 597 #ifdef EMSCRIPTEN 598 #define MINIMIZE_GL_CALLS 1 599 #else 600 #define MINIMIZE_GL_CALLS 0 601 #endif 602 #endif 603 604 #ifndef CAP_GEOMETRY 605 #define CAP_GEOMETRY (!(ISMINI)) 606 #endif 607 608 #ifndef CAP_IRR 609 #define CAP_IRR CAP_GEOMETRY 610 #endif 611 612 #ifndef CAP_GP 613 #define CAP_GP CAP_GEOMETRY 614 #endif 615 616 #ifndef CAP_ARCM 617 #define CAP_ARCM CAP_GEOMETRY 618 #endif 619 620 #ifndef CAP_CRYSTAL 621 #define CAP_CRYSTAL CAP_GEOMETRY 622 #endif 623 624 #ifndef CAP_HISTORY 625 #define CAP_HISTORY 1 626 #endif 627 628 #ifndef CAP_BT 629 #define CAP_BT CAP_GEOMETRY 630 #endif 631 632 #ifndef CAP_STARTANIM 633 #define CAP_STARTANIM (!(ISMINI)) 634 #endif 635 636 #ifndef CAP_SOLV 637 #define CAP_SOLV (MAXMDIM >= 4 && !ISWEB && !ISMOBILE) 638 #endif 639 640 #ifndef CAP_FIELD 641 #define CAP_FIELD (!(ISMINI)) 642 #endif 643 644 #ifndef CAP_RAY 645 #define CAP_RAY (MAXMDIM >= 4 && CAP_GL && !ISMOBILE && !ISWEB) 646 #endif 647 648 #ifndef CAP_MEMORY_RESERVE 649 #define CAP_MEMORY_RESERVE (!ISMOBILE && !ISWEB) 650 #endif 651 652 #undef TRANSPARENT 653