1 /* 2 Copyright (C) 2007, 2010 - Bit-Blot 3 4 This file is part of Aquaria. 5 6 Aquaria is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 15 See the GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 #ifndef __core__ 22 #define __core__ 23 24 /* 25 valid BUILD_ flags 26 WIN32/BUILD_WIN32 27 BUILD_MACOSX 28 BUILD_X360 29 BUILD_LINUX 30 */ 31 32 #include "Base.h" 33 #include "RenderObject.h" 34 #include "SoundManager.h" 35 #include "ActionMapper.h" 36 #include "Event.h" 37 #include "StateManager.h" 38 #include "Light.h" 39 #include "Flags.h" 40 //#include "Scripting.h" 41 #include "Effects.h" 42 #include "Localization.h" 43 44 #include "DarkLayer.h" 45 46 /* 47 #ifdef BBGE_BUILD_WINDOWS 48 #include "Joystick.h" 49 #endif 50 */ 51 52 #include "FrameBuffer.h" 53 #include "Shader.h" 54 55 class ParticleEffect; 56 57 class ParticleManager; 58 59 void initInputCodeMap(); 60 void clearInputCodeMap(); 61 std::string getInputCodeToString(int key); 62 std::string getInputCodeToUserString(int key); 63 int getStringToInputCode(const std::string &string); 64 65 enum TimeUpdateType 66 { 67 TIMEUPDATE_DYNAMIC = 0, 68 TIMEUPDATE_FIXED = 1 69 }; 70 71 struct ScreenMode 72 { ScreenModeScreenMode73 ScreenMode() { idx = x = y = hz = 0; } ScreenModeScreenMode74 ScreenMode(int i, int x, int y, int hz) : idx(i), x(x), y(y), hz(hz) {} 75 76 int idx, x, y, hz; 77 }; 78 79 struct CoreSettings 80 { CoreSettingsCoreSettings81 CoreSettings() { renderOn = true; updateOn = true; runInBackground = false; prebufferSounds = false; } 82 bool renderOn; 83 bool runInBackground; 84 bool updateOn; // NOT IMPLEMENTED YET 85 bool prebufferSounds; 86 }; 87 88 enum CoreFlags 89 { 90 CF_CLEARBUFFERS = 0x00000001, 91 CF_SORTENABLED = 0x00000010 92 }; 93 94 enum CoreLayers 95 { 96 LR_NONE = -1 97 }; 98 99 const int NO_FOLLOW_CAMERA = -999; 100 101 class AfterEffectManager; 102 103 class Texture; 104 105 const int baseVirtualWidth = 800; 106 const int baseVirtualHeight = 600; 107 108 #if (defined(BBGE_BUILD_WINDOWS)) && !defined(BBGE_BUILD_SDL) 109 enum GameKeys 110 { 111 KEY_BACKSPACE = DIK_BACKSPACE, 112 KEY_CAPSLOCK = DIK_CAPSLOCK, 113 KEY_CIRCUMFLEX = DIK_CIRCUMFLEX, 114 KEY_DOWNARROW = DIK_DOWNARROW, 115 KEY_LALT = DIK_LALT, 116 KEY_LEFTARROW = DIK_LEFTARROW, 117 KEY_NUMPADMINUS = DIK_NUMPADMINUS, 118 KEY_NUMPADPERIOD = DIK_NUMPADPERIOD, 119 KEY_NUMPADPLUS = DIK_NUMPADPLUS, 120 KEY_NUMPADSLASH = DIK_NUMPADSLASH, 121 KEY_NUMPADSTAR = DIK_NUMPADSTAR, 122 KEY_PGDN = DIK_PGDN, 123 KEY_PGUP = DIK_PGUP, 124 KEY_RALT = DIK_RALT, 125 KEY_RIGHTARROW = DIK_RIGHTARROW, 126 KEY_UPARROW = DIK_UPARROW, 127 KEY_TILDE = DIK_GRAVE, 128 KEY_0 = DIK_0, 129 KEY_1 = DIK_1, 130 KEY_2 = DIK_2, 131 KEY_3 = DIK_3, 132 KEY_4 = DIK_4, 133 KEY_5 = DIK_5, 134 KEY_6 = DIK_6, 135 KEY_7 = DIK_7, 136 KEY_8 = DIK_8, 137 KEY_9 = DIK_9, 138 KEY_A = DIK_A, 139 KEY_ABNT_C1 = DIK_ABNT_C1, 140 KEY_ABNT_C2 = DIK_ABNT_C2, 141 KEY_ADD = DIK_ADD, 142 KEY_APOSTROPHE = DIK_APOSTROPHE, 143 KEY_APPS = DIK_APPS, 144 KEY_AT = DIK_AT, 145 KEY_AX = DIK_AX, 146 KEY_B = DIK_B, 147 KEY_BACK = DIK_BACK, 148 KEY_BACKSLASH = DIK_BACKSLASH, 149 KEY_C = DIK_C, 150 KEY_CALCULATOR = DIK_CALCULATOR, 151 KEY_CAPITAL = DIK_CAPITAL, 152 KEY_COLON = DIK_COLON, 153 KEY_COMMA = DIK_COMMA, 154 KEY_CONVERT = DIK_CONVERT, 155 KEY_D = DIK_D, 156 KEY_DECIMAL = DIK_DECIMAL, 157 KEY_DELETE = DIK_DELETE, 158 KEY_DIVIDE = DIK_DIVIDE, 159 KEY_DOWN = DIK_DOWN, 160 KEY_E = DIK_E, 161 KEY_END = DIK_END, 162 KEY_EQUALS = DIK_EQUALS, 163 KEY_ESCAPE = DIK_ESCAPE, 164 KEY_F = DIK_F, 165 KEY_F1 = DIK_F1, 166 KEY_F2 = DIK_F2, 167 KEY_F3 = DIK_F3, 168 KEY_F4 = DIK_F4, 169 KEY_F5 = DIK_F5, 170 KEY_F6 = DIK_F6, 171 KEY_F7 = DIK_F7, 172 KEY_F8 = DIK_F8, 173 KEY_F9 = DIK_F9, 174 KEY_F10 = DIK_F10, 175 KEY_F11 = DIK_F11, 176 KEY_F12 = DIK_F12, 177 KEY_F13 = DIK_F13, 178 KEY_F14 = DIK_F14, 179 KEY_F15 = DIK_F15, 180 KEY_G = DIK_G, 181 KEY_GRAVE = DIK_GRAVE, 182 KEY_H = DIK_H, 183 KEY_HOME = DIK_HOME, 184 KEY_I = DIK_I, 185 KEY_INSERT = DIK_INSERT, 186 KEY_J = DIK_J, 187 KEY_K = DIK_K, 188 KEY_KANA = DIK_KANA, 189 KEY_KANJI = DIK_KANJI, 190 KEY_L = DIK_L, 191 KEY_LBRACKET = DIK_LBRACKET, 192 KEY_LCONTROL = DIK_LCONTROL, 193 KEY_LEFT = DIK_LEFT, 194 KEY_LMENU = DIK_LMENU, 195 KEY_LSHIFT = DIK_LSHIFT, 196 KEY_LMETA = DIK_LWIN, 197 KEY_M = DIK_M, 198 KEY_MAIL = DIK_MAIL, 199 KEY_MEDIASELECT = DIK_MEDIASELECT, 200 KEY_MEDIASTOP = DIK_MEDIASTOP, 201 KEY_MINUS = DIK_MINUS, 202 KEY_MULTIPLY = DIK_MULTIPLY, 203 KEY_MUTE = DIK_MUTE, 204 KEY_MYCOMPUTER = DIK_MYCOMPUTER, 205 KEY_N = DIK_N, 206 KEY_NEXT = DIK_NEXT, 207 KEY_NEXTTRACK = DIK_NEXTTRACK, 208 KEY_NOCONVERT = DIK_NOCONVERT, 209 KEY_NUMLOCK = DIK_NUMLOCK, 210 KEY_NUMPAD0 = DIK_NUMPAD0, 211 KEY_NUMPAD1 = DIK_NUMPAD1, 212 KEY_NUMPAD2 = DIK_NUMPAD2, 213 KEY_NUMPAD3 = DIK_NUMPAD3, 214 KEY_NUMPAD4 = DIK_NUMPAD4, 215 KEY_NUMPAD5 = DIK_NUMPAD5, 216 KEY_NUMPAD6 = DIK_NUMPAD6, 217 KEY_NUMPAD7 = DIK_NUMPAD7, 218 KEY_NUMPAD8 = DIK_NUMPAD8, 219 KEY_NUMPAD9 = DIK_NUMPAD9, 220 KEY_NUMPADCOMMA = DIK_NUMPADCOMMA, 221 KEY_NUMPADENTER = DIK_NUMPADENTER, 222 KEY_NUMPADEQUALS = DIK_NUMPADEQUALS, 223 KEY_O = DIK_O, 224 KEY_OEM_102 = DIK_OEM_102, 225 KEY_P = DIK_P, 226 KEY_PAUSE = DIK_PAUSE, 227 KEY_PERIOD = DIK_PERIOD, 228 KEY_PLAYPAUSE = DIK_PLAYPAUSE, 229 KEY_POWER = DIK_POWER, 230 KEY_PREVTRACK = DIK_PREVTRACK, 231 KEY_PRIOR = DIK_PRIOR, 232 KEY_Q = DIK_Q, 233 KEY_R = DIK_R, 234 KEY_RBRACKET = DIK_RBRACKET, 235 KEY_RCONTROL = DIK_RCONTROL, 236 KEY_RETURN = DIK_RETURN, 237 KEY_RIGHT = DIK_RIGHT, 238 KEY_RMENU = DIK_RMENU, 239 KEY_RSHIFT = DIK_RSHIFT, 240 KEY_RMETA = DIK_RWIN, 241 KEY_S = DIK_S, 242 KEY_SCROLL = DIK_SCROLL, 243 KEY_SEMICOLON = DIK_SEMICOLON, 244 KEY_SLASH = DIK_SLASH, 245 KEY_SLEEP = DIK_SLEEP, 246 KEY_SPACE = DIK_SPACE, 247 KEY_STOP = DIK_STOP, 248 KEY_SUBTRACT = DIK_SUBTRACT, 249 KEY_SYSRQ = DIK_SYSRQ, 250 KEY_T = DIK_T, 251 KEY_TAB = DIK_TAB, 252 KEY_U = DIK_U, 253 KEY_UNDERLINE = DIK_UNDERLINE, 254 KEY_UNLABELED = DIK_UNLABELED, 255 KEY_UP = DIK_UP, 256 KEY_V = DIK_V, 257 KEY_VOLUMEDOWN = DIK_VOLUMEDOWN, 258 KEY_VOLUMEUP = DIK_VOLUMEUP, 259 KEY_W = DIK_W, 260 KEY_WAKE = DIK_WAKE, 261 KEY_WEBBACK = DIK_WEBBACK, 262 KEY_WEBFAVORITES = DIK_WEBFAVORITES, 263 KEY_WEBFORWARD = DIK_WEBFORWARD, 264 KEY_WEBHOME = DIK_WEBHOME, 265 KEY_WEBREFRESH = DIK_WEBREFRESH, 266 KEY_WEBSEARCH = DIK_WEBSEARCH, 267 KEY_WEBSTOP = DIK_WEBSTOP, 268 KEY_X = DIK_X, 269 KEY_Y = DIK_Y, 270 KEY_YEN = DIK_YEN, 271 KEY_Z = DIK_Z, 272 KEY_ANYKEY = 4059, 273 KEY_MAXARRAY = 256 274 }; 275 #elif defined(BBGE_BUILD_SDL) 276 enum GameKeys 277 { 278 // replace with GLFW equivalent 279 /* 280 KEY_DOWNARROW = GLFW_KEY_DOWN, 281 KEY_RIGHTARROW = GLFW_KEY_RIGHT, 282 KEY_UPARROW = GLFW_KEY_UP, 283 KEY_LEFTARROW = GLFW_KEY_LEFT, 284 */ 285 286 KEY_LSUPER, 287 KEY_RSUPER, 288 KEY_LMETA, 289 KEY_RMETA, 290 KEY_BACKSPACE, 291 KEY_PRINTSCREEN, 292 293 //KEY_CAPSLOCK, 294 //KEY_CIRCUMFLEX, 295 KEY_LALT, 296 KEY_RALT, 297 KEY_LSHIFT, 298 KEY_RSHIFT, 299 KEY_LCONTROL, 300 KEY_RCONTROL, 301 KEY_NUMPADMINUS, 302 KEY_NUMPADPERIOD, 303 KEY_NUMPADPLUS, 304 KEY_NUMPADSLASH, 305 KEY_NUMPADSTAR, 306 KEY_PGDN, 307 KEY_PGUP, 308 KEY_APOSTROPHE, 309 KEY_EQUALS, 310 KEY_SEMICOLON, 311 KEY_LBRACKET, 312 KEY_RBRACKET, 313 //KEY_RALT, 314 KEY_TILDE, 315 KEY_0, 316 KEY_1, 317 KEY_2, 318 KEY_3, 319 KEY_4, 320 KEY_5, 321 KEY_6, 322 KEY_7, 323 KEY_8, 324 KEY_9, 325 KEY_A, 326 KEY_B, 327 KEY_C, 328 KEY_D, 329 KEY_E, 330 KEY_F, 331 KEY_G, 332 KEY_H, 333 KEY_I, 334 KEY_J, 335 KEY_K, 336 KEY_L, 337 KEY_M, 338 KEY_N, 339 KEY_O, 340 KEY_P, 341 KEY_Q, 342 KEY_R, 343 KEY_S, 344 KEY_T, 345 KEY_U, 346 KEY_V, 347 KEY_W, 348 KEY_X, 349 KEY_Y, 350 KEY_Z, 351 KEY_LEFT, 352 KEY_RIGHT, 353 KEY_UP, 354 KEY_DOWN, 355 KEY_NUMPAD1, 356 KEY_NUMPAD2, 357 KEY_NUMPAD3, 358 KEY_NUMPAD4, 359 KEY_NUMPAD5, 360 KEY_NUMPAD6, 361 KEY_NUMPAD7, 362 KEY_NUMPAD8, 363 KEY_NUMPAD9, 364 KEY_NUMPAD0, 365 KEY_DELETE, 366 KEY_SPACE, 367 KEY_RETURN, 368 KEY_PERIOD, 369 KEY_MINUS, 370 KEY_CAPSLOCK, 371 KEY_SYSRQ, 372 KEY_TAB, 373 KEY_HOME, 374 KEY_END, 375 KEY_COMMA, 376 KEY_SLASH, 377 KEY_F1, 378 KEY_F2, 379 KEY_F3, 380 KEY_F4, 381 KEY_F5, 382 KEY_F6, 383 KEY_F7, 384 KEY_F8, 385 KEY_F9, 386 KEY_F10, 387 KEY_F11, 388 KEY_F12, 389 KEY_F13, 390 KEY_F14, 391 KEY_F15, 392 KEY_ESCAPE, 393 KEY_ANYKEY, 394 KEY_MAXARRAY 395 }; 396 #elif defined(BBGE_BUILD_XINPUT) 397 enum GameKeys 398 { 399 KEY_LSUPER = 0, 400 KEY_RSUPER = 0, 401 KEY_LMETA = 0, 402 KEY_RMETA = 0, 403 KEY_BACKSPACE = 0, 404 KEY_PRINTSCREEN = 0, 405 KEY_LALT = 0, 406 KEY_RALT = 0, 407 KEY_LSHIFT = 0, 408 KEY_RSHIFT = 0, 409 KEY_LCONTROL = 0, 410 KEY_RCONTROL = 0, 411 KEY_NUMPADMINUS = 0, 412 KEY_NUMPADPERIOD = 0, 413 KEY_NUMPADPLUS = 0, 414 KEY_NUMPADSLASH = 0, 415 KEY_NUMPADSTAR = 0, 416 KEY_PGDN = 0, 417 KEY_PGUP = 0, 418 KEY_TILDE = 0, 419 KEY_0 = 0, 420 KEY_1 = 0, 421 KEY_2 = 0, 422 KEY_3 = 0, 423 KEY_4 = 0, 424 KEY_5 = 0, 425 KEY_6 = 0, 426 KEY_7 = 0, 427 KEY_8 = 0, 428 KEY_9 = 0, 429 KEY_A = 0, 430 KEY_B = 0, 431 KEY_C = 0, 432 KEY_D = 0, 433 KEY_E = 0, 434 KEY_F = 0, 435 KEY_G = 0, 436 KEY_H = 0, 437 KEY_I = 0, 438 KEY_J = 0, 439 KEY_K = 0, 440 KEY_L = 0, 441 KEY_M = 0, 442 KEY_N = 0, 443 KEY_O = 0, 444 KEY_P = 0, 445 KEY_Q = 0, 446 KEY_R = 0, 447 KEY_S = 0, 448 KEY_T = 0, 449 KEY_U = 0, 450 KEY_V = 0, 451 KEY_W = 0, 452 KEY_X = 0, 453 KEY_Y = 0, 454 KEY_Z = 0, 455 456 KEY_LEFT = 0, 457 KEY_RIGHT = 0, 458 KEY_UP = 0, 459 KEY_DOWN = 0, 460 461 KEY_NUMPAD1 = 0, 462 KEY_NUMPAD2 = 0, 463 KEY_NUMPAD3 = 0, 464 KEY_NUMPAD4 = 0, 465 KEY_NUMPAD5 = 0, 466 KEY_NUMPAD6 = 0, 467 KEY_NUMPAD7 = 0, 468 KEY_NUMPAD8 = 0, 469 KEY_NUMPAD9 = 0, 470 KEY_NUMPAD0 = 0, 471 472 KEY_DELETE = 0, 473 KEY_SPACE = 0, 474 KEY_RETURN = 0, 475 KEY_PERIOD = 0, 476 KEY_MINUS = 0, 477 KEY_CAPSLOCK = 0, 478 KEY_SYSRQ = 0, 479 KEY_TAB = 0, 480 KEY_HOME = 0, 481 KEY_END = 0, 482 KEY_COMMA = 0, 483 KEY_SLASH = 0, 484 485 KEY_F1 = 0, 486 KEY_F2 = 0, 487 KEY_F3 = 0, 488 KEY_F4 = 0, 489 KEY_F5 = 0, 490 KEY_F6 = 0, 491 KEY_F7 = 0, 492 KEY_F8 = 0, 493 KEY_F9 = 0, 494 KEY_F10 = 0, 495 KEY_F11 = 0, 496 KEY_F12 = 0, 497 KEY_F13 = 0, 498 KEY_F14 = 0, 499 KEY_F15 = 0, 500 501 KEY_ESCAPE = 0, 502 KEY_ANYKEY = 4059, 503 KEY_MAXARRAY = 256 504 }; 505 #elif defined(BBGE_BUILD_GLFW) 506 enum GameKeys 507 { 508 // replace with GLFW equivalent 509 /* 510 KEY_DOWNARROW = GLFW_KEY_DOWN, 511 KEY_RIGHTARROW = GLFW_KEY_RIGHT, 512 KEY_UPARROW = GLFW_KEY_UP, 513 KEY_LEFTARROW = GLFW_KEY_LEFT, 514 */ 515 516 517 KEY_BACKSPACE = GLFW_KEY_BACKSPACE, 518 //KEY_CAPSLOCK = DIK_CAPSLOCK, 519 //KEY_CIRCUMFLEX = DIK_CIRCUMFLEX, 520 KEY_LALT = GLFW_KEY_LALT, 521 KEY_RALT = GLFW_KEY_RALT, 522 KEY_LSHIFT = GLFW_KEY_LSHIFT, 523 KEY_RSHIFT = GLFW_KEY_RSHIFT, 524 KEY_LCONTROL = GLFW_KEY_LCTRL, 525 KEY_RCONTROL = GLFW_KEY_RCTRL, 526 KEY_NUMPADMINUS = GLFW_KEY_KP_SUBTRACT, 527 KEY_NUMPADPERIOD = GLFW_KEY_KP_DECIMAL, 528 KEY_NUMPADPLUS = GLFW_KEY_KP_ADD, 529 KEY_NUMPADSLASH = GLFW_KEY_KP_DIVIDE, 530 KEY_NUMPADSTAR = GLFW_KEY_KP_MULTIPLY, 531 KEY_PGDN = GLFW_KEY_PAGEDOWN, 532 KEY_PGUP = GLFW_KEY_PAGEUP, 533 //KEY_RALT = GLFW_KEY_RALT, 534 KEY_TILDE = '`', 535 KEY_0 = '0', 536 KEY_1 = '1', 537 KEY_2 = '2', 538 KEY_3 = '3', 539 KEY_4 = '4', 540 KEY_5 = '5', 541 KEY_6 = '6', 542 KEY_7 = '7', 543 KEY_8 = '8', 544 KEY_9 = '9', 545 KEY_A = 'A', 546 KEY_B = 'B', 547 KEY_C = 'C', 548 KEY_D = 'D', 549 KEY_E = 'E', 550 KEY_F = 'F', 551 KEY_G = 'G', 552 KEY_H = 'H', 553 KEY_I = 'I', 554 KEY_J = 'J', 555 KEY_K = 'K', 556 KEY_L = 'L', 557 KEY_M = 'M', 558 KEY_N = 'N', 559 KEY_O = 'O', 560 KEY_P = 'P', 561 KEY_Q = 'Q', 562 KEY_R = 'R', 563 KEY_S = 'S', 564 KEY_T = 'T', 565 KEY_U = 'U', 566 KEY_V = 'V', 567 KEY_W = 'W', 568 KEY_X = 'X', 569 KEY_Y = 'Y', 570 KEY_Z = 'Z', 571 572 KEY_LEFT = GLFW_KEY_LEFT, 573 KEY_RIGHT = GLFW_KEY_RIGHT, 574 KEY_UP = GLFW_KEY_UP, 575 KEY_DOWN = GLFW_KEY_DOWN, 576 577 KEY_NUMPAD1 = GLFW_KEY_KP_1, 578 KEY_NUMPAD2 = GLFW_KEY_KP_2, 579 KEY_NUMPAD3 = GLFW_KEY_KP_3, 580 KEY_NUMPAD4 = GLFW_KEY_KP_4, 581 KEY_NUMPAD5 = GLFW_KEY_KP_5, 582 KEY_NUMPAD6 = GLFW_KEY_KP_6, 583 KEY_NUMPAD7 = GLFW_KEY_KP_7, 584 KEY_NUMPAD8 = GLFW_KEY_KP_8, 585 KEY_NUMPAD9 = GLFW_KEY_KP_9, 586 KEY_NUMPAD0 = GLFW_KEY_KP_0, 587 588 KEY_DELETE = GLFW_KEY_DEL, 589 KEY_SPACE = GLFW_KEY_SPACE, 590 // mac os x 591 KEY_RETURN = 13, 592 KEY_PERIOD = '.', 593 KEY_MINUS = '-', 594 KEY_CAPSLOCK = -1, 595 KEY_SYSRQ = '`', 596 KEY_TAB = GLFW_KEY_TAB, 597 KEY_HOME = GLFW_KEY_HOME, 598 KEY_END = GLFW_KEY_END, 599 KEY_COMMA = ',', 600 KEY_SLASH = '/', 601 //KEY_ABNT_C1 = DIK_ABNT_C1, 602 //KEY_ABNT_C2 = DIK_ABNT_C2, 603 /* 604 KEY_ADD = DIK_ADD, 605 KEY_APOSTROPHE = DIK_APOSTROPHE, 606 KEY_APPS = DIK_APPS, 607 KEY_AT = DIK_AT, 608 KEY_AX = DIK_AX, 609 */ 610 /* 611 KEY_B = 'B', 612 KEY_BACK = DIK_BACK, 613 KEY_BACKSLASH = DIK_BACKSLASH, 614 KEY_C = DIK_C, 615 KEY_CALCULATOR = DIK_CALCULATOR, 616 KEY_CAPITAL = DIK_CAPITAL, 617 KEY_COLON = DIK_COLON, 618 KEY_COMMA = DIK_COMMA, 619 KEY_CONVERT = DIK_CONVERT, 620 KEY_D = DIK_D, 621 KEY_DECIMAL = DIK_DECIMAL, 622 KEY_DELETE = DIK_DELETE, 623 KEY_DIVIDE = DIK_DIVIDE, 624 KEY_DOWN = DIK_DOWN, 625 KEY_E = DIK_E, 626 KEY_END = DIK_END, 627 KEY_EQUALS = DIK_EQUALS, 628 KEY_ESCAPE = DIK_ESCAPE, 629 KEY_F = DIK_F, 630 */ 631 KEY_F1 = GLFW_KEY_F1, 632 KEY_F2 = GLFW_KEY_F2, 633 KEY_F3 = GLFW_KEY_F3, 634 KEY_F4 = GLFW_KEY_F4, 635 KEY_F5 = GLFW_KEY_F5, 636 KEY_F6 = GLFW_KEY_F6, 637 KEY_F7 = GLFW_KEY_F7, 638 KEY_F8 = GLFW_KEY_F8, 639 KEY_F9 = GLFW_KEY_F9, 640 KEY_F10 = GLFW_KEY_F10, 641 KEY_F11 = GLFW_KEY_F11, 642 KEY_F12 = GLFW_KEY_F12, 643 KEY_F13 = GLFW_KEY_F13, 644 KEY_F14 = GLFW_KEY_F14, 645 KEY_F15 = GLFW_KEY_F15, 646 /* 647 KEY_G = DIK_G, 648 KEY_GRAVE = DIK_GRAVE, 649 KEY_H = DIK_H, 650 KEY_HOME = DIK_HOME, 651 KEY_I = DIK_I, 652 KEY_INSERT = DIK_INSERT, 653 KEY_J = DIK_J, 654 KEY_K = DIK_K, 655 KEY_KANA = DIK_KANA, 656 KEY_KANJI = DIK_KANJI, 657 KEY_L = DIK_L, 658 KEY_LBRACKET = DIK_LBRACKET, 659 KEY_LCONTROL = DIK_LCONTROL, 660 KEY_LEFT = DIK_LEFT, 661 KEY_LMENU = DIK_LMENU, 662 KEY_LWIN = DIK_LWIN, 663 KEY_M = DIK_M, 664 KEY_MAIL = DIK_MAIL, 665 KEY_MEDIASELECT = DIK_MEDIASELECT, 666 KEY_MEDIASTOP = DIK_MEDIASTOP, 667 KEY_MINUS = DIK_MINUS, 668 KEY_MULTIPLY = DIK_MULTIPLY, 669 KEY_MUTE = DIK_MUTE, 670 KEY_MYCOMPUTER = DIK_MYCOMPUTER, 671 KEY_N = DIK_N, 672 KEY_NEXT = DIK_NEXT, 673 KEY_NEXTTRACK = DIK_NEXTTRACK, 674 KEY_NOCONVERT = DIK_NOCONVERT, 675 KEY_NUMLOCK = DIK_NUMLOCK, 676 KEY_NUMPAD0 = DIK_NUMPAD0, 677 KEY_NUMPAD1 = DIK_NUMPAD1, 678 KEY_NUMPAD2 = DIK_NUMPAD2, 679 KEY_NUMPAD3 = DIK_NUMPAD3, 680 KEY_NUMPAD4 = DIK_NUMPAD4, 681 KEY_NUMPAD5 = DIK_NUMPAD5, 682 KEY_NUMPAD6 = DIK_NUMPAD6, 683 KEY_NUMPAD7 = DIK_NUMPAD7, 684 KEY_NUMPAD8 = DIK_NUMPAD8, 685 KEY_NUMPAD9 = DIK_NUMPAD9, 686 KEY_NUMPADCOMMA = DIK_NUMPADCOMMA, 687 KEY_NUMPADENTER = DIK_NUMPADENTER, 688 KEY_NUMPADEQUALS = DIK_NUMPADEQUALS, 689 KEY_O = DIK_O, 690 KEY_OEM_102 = DIK_OEM_102, 691 KEY_P = DIK_P, 692 KEY_PAUSE = DIK_PAUSE, 693 KEY_PERIOD = DIK_PERIOD, 694 KEY_PLAYPAUSE = DIK_PLAYPAUSE, 695 KEY_POWER = DIK_POWER, 696 KEY_PREVTRACK = DIK_PREVTRACK, 697 KEY_PRIOR = DIK_PRIOR, 698 KEY_Q = DIK_Q, 699 KEY_R = DIK_R, 700 KEY_RBRACKET = DIK_RBRACKET, 701 KEY_RCONTROL = DIK_RCONTROL, 702 KEY_RETURN = DIK_RETURN, 703 KEY_RIGHT = DIK_RIGHT, 704 KEY_RMENU = DIK_RMENU, 705 706 KEY_RWIN = DIK_RWIN, 707 KEY_S = DIK_S, 708 KEY_SCROLL = DIK_SCROLL, 709 KEY_SEMICOLON = DIK_SEMICOLON, 710 KEY_SLASH = DIK_SLASH, 711 KEY_SLEEP = DIK_SLEEP, 712 KEY_SPACE = DIK_SPACE, 713 KEY_STOP = DIK_STOP, 714 KEY_SUBTRACT = DIK_SUBTRACT, 715 KEY_SYSRQ = DIK_SYSRQ, 716 KEY_T = DIK_T, 717 KEY_TAB = DIK_TAB, 718 KEY_U = DIK_U, 719 KEY_UNDERLINE = DIK_UNDERLINE, 720 KEY_UNLABELED = DIK_UNLABELED, 721 KEY_UP = DIK_UP, 722 KEY_V = DIK_V, 723 KEY_VOLUMEDOWN = DIK_VOLUMEDOWN, 724 KEY_VOLUMEUP = DIK_VOLUMEUP, 725 KEY_W = DIK_W, 726 KEY_WAKE = DIK_WAKE, 727 KEY_WEBBACK = DIK_WEBBACK, 728 KEY_WEBFAVORITES = DIK_WEBFAVORITES, 729 KEY_WEBFORWARD = DIK_WEBFORWARD, 730 KEY_WEBHOME = DIK_WEBHOME, 731 KEY_WEBREFRESH = DIK_WEBREFRESH, 732 KEY_WEBSEARCH = DIK_WEBSEARCH, 733 KEY_WEBSTOP = DIK_WEBSTOP, 734 KEY_X = DIK_X, 735 KEY_Y = DIK_Y, 736 KEY_YEN = DIK_YEN, 737 KEY_Z = DIK_Z, 738 */ 739 KEY_ESCAPE = GLFW_KEY_ESC, 740 KEY_ANYKEY = 4059 741 }; 742 #endif 743 744 745 enum ButtonState { UP = 0, DOWN }; 746 747 struct MouseButtons 748 { MouseButtonsMouseButtons749 MouseButtons () 750 { 751 left = UP; 752 right = UP; 753 middle = UP; 754 } 755 756 ButtonState left, right, middle; 757 }; 758 759 struct Mouse 760 { MouseMouse761 Mouse() 762 { 763 scrollWheel = scrollWheelChange = lastScrollWheel = 0; 764 buttonsEnabled = true; 765 movementEnabled = true; 766 } 767 Vector position, lastPosition; 768 MouseButtons buttons; 769 MouseButtons pure_buttons; 770 Vector change; 771 772 773 // movementEnabled is not implemented yet 774 bool buttonsEnabled, movementEnabled; 775 776 int scrollWheel, scrollWheelChange, lastScrollWheel; 777 }; 778 779 const int maxJoyBtns = 64; 780 781 class Joystick 782 { 783 public: 784 Joystick(); 785 void init(int stick=0); 786 void shutdown(); 787 //Ranges from 0 to 65535 (full speed). 788 void rumble(float leftMotor, float rightMotor, float time); 789 void update(float dt); 790 Vector position, lastPosition; 791 ButtonState buttons[maxJoyBtns]; 792 float deadZone1, deadZone2; 793 float clearRumbleTime; 794 795 void callibrate(Vector &vec, float dead); 796 797 float leftTrigger, rightTrigger; 798 bool leftThumb, rightThumb, leftShoulder, rightShoulder, dpadLeft, dpadRight, dpadUp, dpadDown; 799 bool btnStart, btnSelect; 800 Vector rightStick; 801 bool inited, xinited; 802 bool anyButton(); 803 #ifdef BBGE_BUILD_SDL 804 # ifdef BBGE_BUILD_SDL2 805 SDL_GameController *sdl_controller; 806 SDL_Haptic *sdl_haptic; 807 # endif 808 SDL_Joystick *sdl_joy; 809 #endif 810 #if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) 811 int eventfd; 812 int16_t effectid; 813 #endif 814 int stickIndex; 815 816 int s1ax, s1ay, s2ax, s2ay; 817 }; 818 819 enum FollowCameraLock 820 { 821 FCL_NONE = 0, 822 FCL_HORZ = 1, 823 FCL_VERT = 2 824 }; 825 826 //RenderObject Layer Type (enable only one) 827 //#define RLT_DYNAMIC // Dynamic list 828 #define RLT_FIXED // Static array 829 //#define RLT_MAP // Mapping 830 831 typedef std::vector <RenderObject*> RenderObjects; 832 typedef std::list <RenderObject*> RenderObjectList; 833 typedef std::map <intptr_t, RenderObject*> RenderObjectMap; 834 835 class RenderObjectLayer 836 { 837 public: 838 RenderObjectLayer(); 839 ~RenderObjectLayer(); 840 void add(RenderObject* r); 841 void remove(RenderObject* r); 842 void moveToFront(RenderObject *r); 843 void moveToBack(RenderObject *r); 844 void setCull(bool cull); 845 void setOptimizeStatic(bool opt); 846 void sort(); 847 void renderPass(int pass); 848 void reloadDevice(); 849 empty()850 inline bool empty() 851 { 852 #ifdef RLT_FIXED 853 return objectCount == 0; 854 #endif 855 #ifdef RLT_DYNAMIC 856 return renderObjectList.empty(); 857 #endif 858 return false; 859 } 860 getFirst()861 inline RenderObject *getFirst() 862 { 863 #ifdef RLT_DYNAMIC 864 if (renderObjectList.empty()) return 0; 865 iter = renderObjectList.begin(); 866 return *iter; 867 #endif 868 #ifdef RLT_MAP 869 if (renderObjectMap.empty()) return 0; 870 iter = renderObjectMap.begin(); 871 return (*iter).second; 872 #endif 873 #ifdef RLT_FIXED 874 iter = 0; 875 return getNext(); 876 #endif 877 } 878 getNext()879 RenderObject *getNext() 880 { 881 #ifdef RLT_DYNAMIC 882 if (iter == renderObjectList.end()) return 0; 883 iter++; 884 if (iter == renderObjectList.end()) return 0; 885 return *iter; 886 #endif 887 #ifdef RLT_MAP 888 if (iter == renderObjectMap.end()) return 0; 889 iter++; 890 if (iter == renderObjectMap.end()) return 0; 891 return (*iter).second; 892 #endif 893 #ifdef RLT_FIXED 894 const int size = renderObjects.size(); 895 int i; 896 for (i = iter; i < size; i++) 897 { 898 if (renderObjects[i] != 0) 899 break; 900 } 901 if (i < size) 902 { 903 iter = i+1; 904 return renderObjects[i]; 905 } 906 else 907 { 908 iter = i; 909 return 0; 910 } 911 #endif 912 return 0; 913 } 914 915 //inclusive 916 int startPass, endPass; 917 bool visible; 918 float followCamera; 919 920 int followCameraLock; 921 bool cull; 922 bool update; 923 924 int mode; 925 926 Vector color; 927 928 protected: 929 930 void clearDisplayList(); 931 void generateDisplayList(); 932 inline void renderOneObject(RenderObject *robj); 933 934 bool optimizeStatic; 935 bool displayListValid; 936 int displayListGeneration; 937 struct DisplayListElement { DisplayListElementDisplayListElement938 DisplayListElement() {isList = false; u.robj = 0;} 939 bool isList; // True if this is a GL display list 940 union { 941 RenderObject *robj; 942 GLuint listID; 943 } u; 944 }; 945 std::vector<DisplayListElement> displayList; 946 947 #ifdef RLT_DYNAMIC 948 RenderObjectList renderObjectList; 949 RenderObjectList::iterator iter; 950 #endif 951 #ifdef RLT_MAP 952 RenderObjectMap renderObjectMap; 953 RenderObjectMap::iterator iter; 954 #endif 955 #ifdef RLT_FIXED 956 RenderObjects renderObjects; 957 int objectCount; 958 int firstFreeIdx; 959 int iter; 960 #endif 961 }; 962 963 class Core : public ActionMapper, public StateManager 964 { 965 public: 966 967 // init 968 Core(const std::string &filesystem, const std::string& extraDataDir, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder=""); 969 void initPlatform(const std::string &filesystem); 970 ~Core(); 971 972 virtual void init(); 973 974 void initRenderObjectLayers(int num); 975 976 void applyState(const std::string &state); 977 //bool createGlWindow(char* title, int width, int height, int bits, bool fullscreenflag); 978 bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle=""); 979 //void setWindowTitle(const std::string &title); // func not yet written 980 void clearBuffers(); 981 void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true); 982 void showBuffer(); 983 void quit(); 984 bool isShuttingDown(); 985 bool isWindowFocus(); 986 987 void instantQuit(); 988 989 void cacheRender(); 990 991 void setSDLGLAttributes(); 992 993 void reloadResources(); 994 void unloadResources(); 995 996 std::string getPreferencesFolder(); 997 std::string getUserDataFolder(); 998 999 std::string adjustFilenameCase(const char *buf); adjustFilenameCase(const std::string & str)1000 std::string adjustFilenameCase(const std::string &str) { return adjustFilenameCase(str.c_str()); }; 1001 1002 void resetCamera(); 1003 1004 virtual void shutdown(); 1005 1006 void main(float runTime = -1); // can use main 1007 1008 //void adjustWindowPosition(int x, int y); 1009 1010 // state functions 1011 1012 std::string getTextureLoadName(const std::string &texture); 1013 1014 void setMousePosition(const Vector &p); 1015 1016 void toggleScreenMode(int t=0); 1017 1018 void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false); 1019 void addRenderObject(RenderObject *o, int layer=0); 1020 void switchRenderObjectLayer(RenderObject *o, int toLayer); 1021 void addTexture(Texture *r); 1022 CountedPtr<Texture> findTexture(const std::string &name); 1023 void removeTexture(Texture *res); 1024 void clearResources(); 1025 1026 CountedPtr<Texture> addTexture(const std::string &texture, TextureLoadResult *pLoadResult = 0); 1027 1028 PostProcessingFX postProcessingFx; 1029 1030 enum RemoveRenderObjectFlag { DESTROY_RENDER_OBJECT=0, DO_NOT_DESTROY_RENDER_OBJECT }; 1031 void removeRenderObject(RenderObject *r, RemoveRenderObjectFlag flag = DESTROY_RENDER_OBJECT); 1032 1033 void setMouseConstraint(bool on); 1034 void setMouseConstraintCircle(const Vector& pos, float mouseCircle); 1035 1036 void setReentryInputGrab(int on); 1037 action(int id,int state)1038 void action(int id, int state){} 1039 1040 bool exists(const std::string &file); 1041 1042 void enqueueRenderObjectDeletion(RenderObject *object); 1043 void clearGarbage(); 1044 1045 isNested()1046 bool isNested() { return nestedMains > 1; } getNestedMains()1047 int getNestedMains() { return nestedMains; } 1048 void quitNestedMain(); 1049 getWindowWidth()1050 int getWindowWidth() { return width; } getWindowHeight()1051 int getWindowHeight() { return height; } 1052 1053 void updateCursorFromJoystick(float dt, int spd); 1054 1055 uint32 getTicks(); 1056 1057 float stopWatch(int d); 1058 1059 1060 float stopWatchStartTime; 1061 1062 1063 void resetGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1); 1064 1065 /* 1066 #ifdef BBGE_BUILD_OPENGL 1067 void getWindowHeight(int *height) 1068 {glfwGetWindowSize(0, height);} 1069 1070 void getWindowWidth(int *width) 1071 {glfwGetWindowSize(width, 0);} 1072 #endif 1073 */ 1074 1075 void setDockIcon(const std::string &ident); 1076 1077 Vector getGameCursorPosition(); 1078 Vector getGamePosition(const Vector &v); 1079 1080 Vector joystickPosition; 1081 1082 bool coreVerboseDebug; 1083 1084 1085 Vector screenCenter; 1086 void sort(); 1087 void sortLayer(int layer); 1088 1089 void print(int x, int y, const char *str, float sz=1); 1090 1091 // windows variables 1092 #ifdef BBGE_BUILD_WINDOWS 1093 HDC hDC; // Private GDI Device Context 1094 HGLRC hRC; // Permanent Rendering Context 1095 HWND hWnd; // Holds Our Window Handle 1096 HINSTANCE hInstance; // Holds The Instance Of The Application 1097 #endif 1098 1099 std::vector<Texture*> resources; 1100 1101 RenderObjectLayer *getRenderObjectLayer(int i); 1102 std::vector <int> renderObjectLayerOrder; 1103 //typedef std::list<RenderObject*> RenderObjects; 1104 typedef std::vector<RenderObjectLayer> RenderObjectLayers; 1105 RenderObjectLayers renderObjectLayers; 1106 1107 RenderObjectList garbage; 1108 1109 SoundManager *sound; 1110 1111 float aspect; 1112 1113 int width, height; 1114 1115 enum Modes { MODE_NONE=-1, MODE_3D=0, MODE_2D }; 1116 1117 InterpolatedVector globalScale; 1118 Vector globalResolutionScale; 1119 Vector screenCapScale; 1120 onResetScene()1121 virtual void onResetScene(){} 1122 onPlayedVoice(const std::string & name)1123 virtual void onPlayedVoice(const std::string &name){} 1124 1125 Vector cameraPos; 1126 1127 int fps; 1128 bool loopDone; 1129 1130 Mouse mouse; 1131 1132 AfterEffectManager *afterEffectManager; 1133 1134 ParticleManager *particleManager; 1135 1136 //Scripting::Script script; 1137 1138 setBaseTextureDirectory(const std::string & baseTextureDirectory)1139 void setBaseTextureDirectory(const std::string &baseTextureDirectory) 1140 { this->baseTextureDirectory = baseTextureDirectory; } getBaseTextureDirectory()1141 std::string getBaseTextureDirectory() 1142 { 1143 return baseTextureDirectory; 1144 } 1145 1146 1147 virtual bool canChangeState(); 1148 void resetTimer(); 1149 getVirtualWidth()1150 inline int getVirtualWidth() 1151 { 1152 return virtualWidth; 1153 } 1154 getVirtualHeight()1155 inline int getVirtualHeight() 1156 { 1157 return virtualHeight; 1158 } 1159 1160 unsigned char *grabScreenshot(int x, int y, int w, int h); 1161 unsigned char *grabCenteredScreenshot(int w, int h); 1162 int saveScreenshotTGA(const std::string &filename); 1163 void save64x64ScreenshotTGA(const std::string &filename); 1164 void saveSizedScreenshotTGA(const std::string &filename, int sz, int crop34); 1165 void saveCenteredScreenshotTGA(const std::string &filename, int sz); 1166 1167 bool minimized; 1168 std::string getEnqueuedJumpState(); 1169 float cullRadius; 1170 float cullRadiusSqr; 1171 Vector cullCenter; 1172 unsigned int renderObjectCount, processedRenderObjectCount, totalRenderObjectCount; 1173 float invGlobalScale, invGlobalScaleSqr; 1174 1175 void globalScaleChanged(); 1176 1177 void screenshot(); 1178 1179 void clearRenderObjects(); 1180 1181 void applyMatrixStackToWorld(); 1182 void translateMatrixStack(float x, float y, float z=0); 1183 //void translateMatrixStackRelative(float x, float y, float z=0); 1184 void rotateMatrixStack(float x, float y, float z); 1185 void scaleMatrixStack(float x, float y, float z=1); 1186 void rotateMatrixStack(float z); 1187 void setColor(float r, float g, float b, float a); 1188 1189 void bindTexture(int stage, unsigned int handle); 1190 1191 #ifdef BBGE_BUILD_DIRECTX 1192 1193 void blitD3DVerts(IDirect3DTexture9 *texture, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y, float v4x, float v4y); 1194 void blitD3D (IDirect3DTexture9 *texture, int width, int height); 1195 void blitD3DPreTrans (IDirect3DTexture9 *texture, float x, float y, int absWidth, int absHeight); 1196 void blitD3DEx (IDirect3DTexture9 *texture, int width, int height, float u1=0, float v1=0, float u2=1, float v2=1); 1197 void blitD3DGradient(D3DCOLOR ulc0, D3DCOLOR ulc1, D3DCOLOR ulc2, D3DCOLOR ulc3); 1198 LPDIRECT3DDEVICE9 getD3DDevice(); 1199 LPD3DXSPRITE getD3DSprite(); 1200 LPD3DXMATRIXSTACK getD3DMatrixStack(); 1201 #endif 1202 1203 bool getKeyState(int k); 1204 bool getMouseButtonState(int m); 1205 1206 int currentLayerPass; 1207 int keys[KEY_MAXARRAY]; 1208 Flags flags; 1209 virtual void debugLog(const std::string &s); 1210 virtual void errorLog(const std::string &s); 1211 void messageBox(const std::string &title, const std::string &msg); 1212 bool getShiftState(); 1213 bool getAltState(); 1214 bool getCtrlState(); 1215 bool getMetaState(); 1216 generateCollisionMask(RenderObject * r)1217 virtual void generateCollisionMask(RenderObject *r){} 1218 1219 DarkLayer darkLayer; 1220 1221 int redBits, greenBits, blueBits, alphaBits; 1222 1223 void setupRenderPositionAndScale(); 1224 void setupGlobalResolutionScale(); 1225 1226 1227 int particlesPaused; 1228 1229 //JoystickData joystickData[4]; 1230 bool joystickEnabled; 1231 bool joystickOverrideMouse; 1232 /* 1233 int numJoysticks; 1234 DIJOYSTATE2 joystate; 1235 Joystick* joysticks[4]; 1236 */ 1237 1238 bool debugLogTextures; 1239 1240 1241 Joystick joystick; 1242 void setClearColor(const Vector &c); 1243 Vector getClearColor(); 1244 int flipMouseButtons; 1245 void initFrameBuffer(); 1246 FrameBuffer frameBuffer; 1247 void updateRenderObjects(float dt); 1248 bool joystickAsMouse; prepScreen(bool t)1249 virtual void prepScreen(bool t){} 1250 1251 bool updateMouse; 1252 bool frameOutputMode; 1253 1254 int overrideStartLayer, overrideEndLayer; 1255 1256 void setWindowCaption(const std::string &caption, const std::string &icon); 1257 1258 ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0); 1259 1260 std::string secondaryTexturePath; 1261 1262 bool hasFocus(); 1263 1264 EventQueue eventQueue; 1265 1266 float aspectX, aspectY; 1267 get_old_dt()1268 float get_old_dt() { return old_dt; } get_current_dt()1269 float get_current_dt() { return current_dt; } 1270 1271 bool debugLogActive; 1272 1273 void setInputGrab(bool on); 1274 1275 bool isFullscreen(); 1276 1277 int viewOffX, viewOffY; 1278 1279 int getVirtualOffX(); 1280 int getVirtualOffY(); 1281 1282 void centerMouse(); 1283 1284 int vw2, vh2; 1285 Vector center; 1286 1287 void enable2DWide(int rx, int ry); 1288 1289 void enumerateScreenModes(); 1290 1291 std::vector<ScreenMode> screenModes; 1292 1293 void pollEvents(); 1294 1295 CoreSettings settings; 1296 1297 int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData); 1298 int zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData); 1299 1300 volatile int dbg_numThreadDecoders; 1301 static unsigned int dbg_numRenderCalls; 1302 1303 virtual void onBackgroundUpdate(); 1304 1305 void initLocalization(); 1306 1307 protected: 1308 1309 std::string fpsDebugString; 1310 1311 TimeUpdateType timeUpdateType; 1312 int fixedFPS; 1313 1314 void updateCullData(); 1315 1316 std::string userDataFolder; 1317 1318 int grabInputOnReentry; 1319 1320 int virtualOffX, virtualOffY; 1321 1322 void initIcon(); 1323 1324 float old_dt; 1325 float current_dt; 1326 1327 std::string debugLogPath; 1328 1329 virtual void onReloadResources(); 1330 1331 std::pair<CountedPtr<Texture>, TextureLoadResult> doTextureAdd(const std::string &texture, const std::string &name, std::string internalTextureName); 1332 1333 void deleteRenderObjectMemory(RenderObject *r); 1334 bool _hasFocus; 1335 bool lib_graphics, lib_sound, lib_input; 1336 Vector clearColor; 1337 bool updateCursorFromMouse; 1338 virtual void unloadDevice(); 1339 virtual void reloadDevice(); 1340 1341 std::string appName; 1342 bool mouseConstraint; 1343 float mouseCircle; 1344 Vector mouseConstraintCenter; 1345 1346 bool doMouseConstraint(); 1347 onMouseInput()1348 virtual void onMouseInput(){} 1349 bool doScreenshot; 1350 float baseCullRadius; 1351 bool initSoundLibrary(const std::string &defaultDevice); 1352 bool initInputLibrary(); 1353 bool initJoystickLibrary(int numSticks=1); 1354 bool initGraphicsLibrary(int w, int h, bool fullscreen, int vsync, int bpp, bool recreate=true); 1355 void shutdownInputLibrary(); 1356 void shutdownJoystickLibrary(); 1357 void shutdownGraphicsLibrary(bool kill=true); 1358 void shutdownSoundLibrary(); 1359 1360 int afterEffectManagerLayer; 1361 bool sortEnabled; 1362 Vector cameraOffset; 1363 std::vector<float> avgFPS; 1364 float sortTimer; 1365 bool sortFlag; modifyDt(float & dt)1366 virtual void modifyDt(float &dt){} 1367 void setPixelScale(int pixelScaleX, int pixelScaleY); 1368 1369 1370 int virtualHeight, virtualWidth; 1371 1372 bool shuttingDown; 1373 bool quitNestedMainFlag; 1374 bool clearedGarbageFlag; 1375 int nestedMains; 1376 std::string baseTextureDirectory; 1377 #ifdef BBGE_BUILD_WINDOWS 1378 __int64 lastTime, curTime, freq; 1379 #endif 1380 1381 std::ofstream _logOut; 1382 1383 #ifdef BBGE_BUILD_SDL 1384 int nowTicks, thenTicks; 1385 #endif 1386 1387 int _vsync, _bpp; 1388 bool _fullscreen; 1389 1390 int numSavedScreenshots; 1391 1392 CountedPtr<Texture> texError; 1393 1394 //unsigned int windowWidth, windowHeight; 1395 1396 1397 int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData); 1398 virtual void onUpdate(float dt); onRender()1399 virtual void onRender(){} 1400 1401 void setupFileAccess(); 1402 std::string _extraDataDir; 1403 }; 1404 1405 extern Core *core; 1406 1407 #include "RenderObject_inline.h" 1408 1409 #endif 1410