Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

global.h 3.4KB

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