Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

global.h 3.1KB

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