Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

global.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*!
  2. * \file include/global.h
  3. * \brief Global typedefs
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _GLOBAL_H_
  8. #define _GLOBAL_H_
  9. #include "config.h"
  10. // Defaults
  11. #define DEFAULT_CONFIG_PATH "~/.OpenRaider"
  12. #define DEFAULT_CONFIG_FILE "OpenRaider.ini"
  13. #define DEFAULT_WIDTH 640
  14. #define DEFAULT_HEIGHT 480
  15. // Supported pixelmap color formats
  16. enum ColorMode {
  17. GREYSCALE,
  18. RGB,
  19. RGBA,
  20. ARGB,
  21. BGR,
  22. BGRA
  23. };
  24. // Colors used where ever needed
  25. const unsigned char BLACK[] = { 0, 0, 0, 255 };
  26. const unsigned char GREY[] = { 128, 128, 128, 255 };
  27. const unsigned char WHITE[] = { 255, 255, 255, 255 };
  28. const unsigned char RED[] = { 255, 0, 0, 255 };
  29. const unsigned char GREEN[] = { 0, 255, 0, 255 };
  30. const unsigned char PURPLE[] = { 77, 77, 128, 255 };
  31. const unsigned char BLUE[] = { 128, 179, 255, 255 };
  32. const unsigned char PINK[] = { 255, 0, 255, 255 };
  33. const unsigned char YELLOW[] = { 255, 255, 0, 255 };
  34. const unsigned char CYAN[] = { 0, 255, 255, 255 };
  35. // Actions that can be bound to a key and sent to the game engine
  36. typedef enum {
  37. menuAction = 0,
  38. consoleAction, // menu and console should always be the first two items
  39. forwardAction,
  40. backwardAction,
  41. leftAction,
  42. rightAction,
  43. jumpAction,
  44. crouchAction,
  45. useAction,
  46. holsterAction,
  47. walkAction,
  48. ActionEventCount // Should always be at the end
  49. } ActionEvents;
  50. // Keys available for binding
  51. typedef enum {
  52. zeroKey = '0', oneKey = '1', twoKey = '2',
  53. threeKey = '3', fourKey = '4', fiveKey = '5',
  54. sixKey = '6', sevenKey = '7', eightKey = '8',
  55. nineKey = '9', aKey = 'a', bKey = 'b',
  56. cKey = 'c', dKey = 'd', eKey = 'e', fKey = 'f',
  57. gKey = 'g', hKey = 'h', iKey = 'i', jKey = 'j',
  58. kKey = 'k', lKey = 'l', mKey = 'm', nKey = 'n',
  59. oKey = 'o', pKey = 'p', qKey = 'q', rKey = 'r',
  60. sKey = 's', tKey = 't', uKey = 'u', vKey = 'v',
  61. wKey = 'w', xKey = 'x', yKey = 'y', zKey = 'z',
  62. quoteKey, backslashKey, backspaceKey, capslockKey,
  63. commaKey, delKey, upKey, downKey, leftKey, rightKey,
  64. endKey, equalsKey, escapeKey, f1Key, f2Key, f3Key, f4Key, f5Key,
  65. f6Key, f7Key, f8Key, f9Key, f10Key, f11Key, f12Key, backquoteKey,
  66. homeKey, insertKey, leftaltKey, leftctrlKey, leftbracketKey,
  67. leftguiKey, leftshiftKey, minusKey, numlockKey, pagedownKey,
  68. pageupKey, pauseKey, dotKey, rightaltKey, rightctrlKey, enterKey,
  69. rightguiKey, rightbracketKey, rightshiftKey, scrolllockKey,
  70. semicolonKey, slashKey, spaceKey, tabKey,
  71. leftmouseKey, middlemouseKey, rightmouseKey,
  72. fourthmouseKey, fifthmouseKey,
  73. unknownKey // Should always be at the end
  74. } KeyboardButton;
  75. ActionEvents stringToActionEvent(const char *action);
  76. KeyboardButton stringToKeyboardButton(const char *key);
  77. // Visual C++ does not understand __attribute__
  78. #ifdef _MSC_VER
  79. #define __attribute__(x)
  80. #endif
  81. //! \todo Replace NULL usage with nullptr
  82. #ifndef NULL
  83. #define NULL nullptr
  84. #endif
  85. // Globally include OpenGL header
  86. #ifdef __APPLE__
  87. #include <OpenGL/gl.h>
  88. #else
  89. #ifdef _WIN32
  90. #include <windows.h>
  91. #endif
  92. #include <GL/gl.h>
  93. #include <GL/glext.h>
  94. #endif
  95. // If available, use our own assert that prints the call stack
  96. #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
  97. #ifndef NDEBUG
  98. [[noreturn]] void assertImplementation(const char *exp, const char *file, int line);
  99. #define assert(x) (void)((x) || (assertImplementation(#x, __FILE__, __LINE__),0))
  100. #else
  101. #define assert(x)
  102. #endif
  103. #else
  104. // Fall back to the default C assert
  105. #include <cassert>
  106. #endif
  107. #endif