OpenRaider
0.1.4-dev
Open Source Tomb Raider Game Engine implementation
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
include
global.h
Go to the documentation of this file.
1
7
#ifndef _GLOBAL_H_
8
#define _GLOBAL_H_
9
10
#include "config.h"
11
12
void
renderFrame
();
13
14
// Actions that can be bound to a key and sent to the game engine
15
typedef
enum
{
16
menuAction
= 0,
17
debugAction
,
18
consoleAction
,
19
20
forwardAction
,
21
backwardAction
,
22
leftAction
,
23
rightAction
,
24
jumpAction
,
25
crouchAction
,
26
useAction
,
27
holsterAction
,
28
walkAction
,
29
30
ActionEventCount
// Should always be at the end
31
}
ActionEvents
;
32
33
// Keys available for binding
34
typedef
enum
{
35
// Keyboard
36
zeroKey
=
'0'
,
oneKey
=
'1'
,
twoKey
=
'2'
,
37
threeKey
=
'3'
,
fourKey
=
'4'
,
fiveKey
=
'5'
,
38
sixKey
=
'6'
,
sevenKey
=
'7'
,
eightKey
=
'8'
,
39
nineKey
=
'9'
,
aKey
=
'a'
,
bKey
=
'b'
,
40
cKey
=
'c'
,
dKey
=
'd'
,
eKey
=
'e'
,
fKey
=
'f'
,
41
gKey
=
'g'
,
hKey
=
'h'
,
iKey
=
'i'
,
jKey
=
'j'
,
42
kKey
=
'k'
,
lKey
=
'l'
,
mKey
=
'm'
,
nKey
=
'n'
,
43
oKey
=
'o'
,
pKey
=
'p'
,
qKey
=
'q'
,
rKey
=
'r'
,
44
sKey
=
's'
,
tKey
=
't'
,
uKey
=
'u'
,
vKey
=
'v'
,
45
wKey
=
'w'
,
xKey
=
'x'
,
yKey
=
'y'
,
zKey
=
'z'
,
46
quoteKey
,
backslashKey
,
backspaceKey
,
capslockKey
,
47
commaKey
,
delKey
,
upKey
,
downKey
,
leftKey
,
rightKey
,
48
endKey
,
equalsKey
,
escapeKey
,
f1Key
,
f2Key
,
f3Key
,
f4Key
,
f5Key
,
49
f6Key
,
f7Key
,
f8Key
,
f9Key
,
f10Key
,
f11Key
,
f12Key
,
backquoteKey
,
50
homeKey
,
insertKey
,
leftaltKey
,
leftctrlKey
,
leftbracketKey
,
51
leftguiKey
,
leftshiftKey
,
minusKey
,
numlockKey
,
pagedownKey
,
52
pageupKey
,
pauseKey
,
dotKey
,
rightaltKey
,
rightctrlKey
,
enterKey
,
53
rightguiKey
,
rightbracketKey
,
rightshiftKey
,
scrolllockKey
,
54
semicolonKey
,
slashKey
,
spaceKey
,
tabKey
,
55
56
// Mouse
57
leftmouseKey
,
middlemouseKey
,
rightmouseKey
,
58
fourthmouseKey
,
fifthmouseKey
,
59
60
// Game Controller
61
aButton
,
bButton
,
xButton
,
yButton
,
backButton
,
startButton
,
62
guideButton
,
leftStick
,
rightStick
,
leftShoulder
,
rightShoulder
,
63
padUp
,
padDown
,
padLeft
,
padRight
,
64
leftXAxis
,
leftYAxis
,
rightXAxis
,
rightYAxis
,
leftTrigger
,
rightTrigger
,
65
66
unknownKey
// Should always be at the end
67
}
KeyboardButton
;
68
69
// Globally include OpenGL header
70
#ifdef __APPLE__
71
#include <OpenGL/gl3.h>
72
#else // __APPLE__
73
#ifdef _WIN32
74
#include <GL/glew.h>
75
#include <GL/wglew.h>
76
#pragma comment(lib, "glew32.lib")
77
#else // _WIN32
78
#include <GL/gl.h>
80
#include <GL/glext.h>
81
#endif // _WIN32
82
#endif // __APPLE__
83
89
#define NDEBUG
90
#include <glm/glm.hpp>
91
92
// If available, use our own assert that prints the call stack
93
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
94
95
#ifndef NODEBUG
96
97
#include <iostream>
98
#include <execinfo.h>
99
100
template
<
typename
T,
typename
U>
101
[[noreturn]]
void
assertEqualImplementation
(
const
char
* exp, T a, U b,
const
char
* file,
int
line,
102
const
char
* str =
nullptr
) {
103
const
unsigned
int
maxSize = 128;
104
void
* callstack[maxSize];
105
int
frames = backtrace(callstack, maxSize);
106
char
** strs = backtrace_symbols(callstack, frames);
107
108
std::cout << std::endl <<
"assertion failed:"
<< std::endl;
109
std::cout <<
"\t"
<< exp << std::endl;
110
if
(str !=
nullptr
)
111
std::cout <<
"\t("
<< a <<
" "
<< str <<
" "
<< b <<
")"
<< std::endl;
112
std::cout <<
"in "
<< file <<
":"
<< line << std::endl << std::endl;
113
114
for
(
int
i = 0; i < frames; i++)
115
std::cout << strs[i] << std::endl;
116
117
delete
[] strs;
118
abort();
119
}
120
121
// Evaluating x or y could have side-effects
122
// So we only do it once!
123
124
#define assert(x) { \
125
auto assertEvalTemp = x; \
126
if (!assertEvalTemp) \
127
assertEqualImplementation(#x, assertEvalTemp, true, __FILE__, __LINE__); \
128
}
129
130
#define assertEqual(x, y) { \
131
auto assertEvalTemp = x; \
132
auto assertEvalTemp2 = y; \
133
if (assertEvalTemp != assertEvalTemp2) \
134
assertEqualImplementation(#x " == " #y, assertEvalTemp, assertEvalTemp2, \
135
__FILE__, __LINE__, "!="); \
136
}
137
138
#define assertNotEqual(x, y) { \
139
auto assertEvalTemp = x; \
140
auto assertEvalTemp2 = y; \
141
if (assertEvalTemp == assertEvalTemp2) \
142
assertEqualImplementation(#x " != " #y, assertEvalTemp, assertEvalTemp2, \
143
__FILE__, __LINE__, "=="); \
144
}
145
146
#define assertLessThan(x, y) { \
147
auto assertEvalTemp = x; \
148
auto assertEvalTemp2 = y; \
149
if (assertEvalTemp >= assertEvalTemp2) \
150
assertEqualImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
151
__FILE__, __LINE__, ">="); \
152
}
153
154
#define assertLessThanEqual(x, y) { \
155
auto assertEvalTemp = x; \
156
auto assertEvalTemp2 = y; \
157
if (assertEvalTemp > assertEvalTemp2) \
158
assertEqualImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
159
__FILE__, __LINE__, ">"); \
160
}
161
162
#define assertGreaterThan(x, y) { \
163
auto assertEvalTemp = x; \
164
auto assertEvalTemp2 = y; \
165
if (assertEvalTemp <= assertEvalTemp2) \
166
assertEqualImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
167
__FILE__, __LINE__, "<="); \
168
}
169
170
#define assertGreaterThanEqual(x, y) { \
171
auto assertEvalTemp = x; \
172
auto assertEvalTemp2 = y; \
173
if (assertEvalTemp < assertEvalTemp2) \
174
assertEqualImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
175
__FILE__, __LINE__, "<"); \
176
}
177
178
#else // NODEBUG
179
180
#define assert(x)
181
#define assertEqual(x, y)
182
#define assertNotEqual(x, y)
183
#define assertLessThan(x, y)
184
#define assertLessThanEqual(x, y)
185
#define assertGreaterThan(x, y)
186
#define assertGreaterThanEqual(x, y)
187
188
#endif // NODEBUG
189
190
#else // EXECINFO
191
192
// Fall back to the default C assert
193
#include <cassert>
194
#define assertEqual(x, y) assert((x) == (y))
195
#define assertNotEqual(x, y) assert((x) != (y))
196
#define assertLessThan(x, y) assert((x) < (y))
197
#define assertLessThanEqual(x, y) assert((x) <= (y))
198
#define assertGreaterThan(x, y) assert((x) > (y))
199
#define assertGreaterThanEqual(x, y) assert((x) >= (y))
200
201
#endif // EXECINFO
202
203
#endif // _GLOBAL_H_
204
f1Key
Definition:
global.h:48
aButton
Definition:
global.h:61
f5Key
Definition:
global.h:48
guideButton
Definition:
global.h:62
forwardAction
Definition:
global.h:20
bButton
Definition:
global.h:61
tKey
Definition:
global.h:44
fourthmouseKey
Definition:
global.h:58
padUp
Definition:
global.h:63
numlockKey
Definition:
global.h:51
rightYAxis
Definition:
global.h:64
eightKey
Definition:
global.h:38
qKey
Definition:
global.h:43
middlemouseKey
Definition:
global.h:57
f6Key
Definition:
global.h:49
rightmouseKey
Definition:
global.h:57
leftguiKey
Definition:
global.h:51
padRight
Definition:
global.h:63
semicolonKey
Definition:
global.h:54
fKey
Definition:
global.h:40
yButton
Definition:
global.h:61
enterKey
Definition:
global.h:52
capslockKey
Definition:
global.h:46
jKey
Definition:
global.h:41
sevenKey
Definition:
global.h:38
pagedownKey
Definition:
global.h:51
backButton
Definition:
global.h:61
twoKey
Definition:
global.h:36
f9Key
Definition:
global.h:49
cKey
Definition:
global.h:40
slashKey
Definition:
global.h:54
scrolllockKey
Definition:
global.h:53
assertEqualImplementation
void assertEqualImplementation(const char *exp, T a, U b, const char *file, int line, const char *str=nullptr)
Definition:
global.h:101
KeyboardButton
KeyboardButton
Definition:
global.h:34
leftYAxis
Definition:
global.h:64
xKey
Definition:
global.h:45
zeroKey
Definition:
global.h:36
crouchAction
Definition:
global.h:25
oneKey
Definition:
global.h:36
escapeKey
Definition:
global.h:48
leftKey
Definition:
global.h:47
backquoteKey
Definition:
global.h:49
renderFrame
void renderFrame()
Definition:
main.cpp:147
fourKey
Definition:
global.h:37
leftAction
Definition:
global.h:22
mKey
Definition:
global.h:42
oKey
Definition:
global.h:43
backslashKey
Definition:
global.h:46
zKey
Definition:
global.h:45
useAction
Definition:
global.h:26
uKey
Definition:
global.h:44
f8Key
Definition:
global.h:49
yKey
Definition:
global.h:45
aKey
Definition:
global.h:39
debugAction
Definition:
global.h:17
leftStick
Definition:
global.h:62
menuAction
Definition:
global.h:16
fiveKey
Definition:
global.h:37
fifthmouseKey
Definition:
global.h:58
ActionEvents
ActionEvents
Definition:
global.h:15
leftShoulder
Definition:
global.h:62
consoleAction
Definition:
global.h:18
wKey
Definition:
global.h:45
rightaltKey
Definition:
global.h:52
padDown
Definition:
global.h:63
pauseKey
Definition:
global.h:52
rightbracketKey
Definition:
global.h:53
leftbracketKey
Definition:
global.h:50
pKey
Definition:
global.h:43
nineKey
Definition:
global.h:39
rightguiKey
Definition:
global.h:53
rightshiftKey
Definition:
global.h:53
leftXAxis
Definition:
global.h:64
equalsKey
Definition:
global.h:48
rightShoulder
Definition:
global.h:62
upKey
Definition:
global.h:47
rightXAxis
Definition:
global.h:64
spaceKey
Definition:
global.h:54
unknownKey
Definition:
global.h:66
f10Key
Definition:
global.h:49
endKey
Definition:
global.h:48
rightAction
Definition:
global.h:23
kKey
Definition:
global.h:42
homeKey
Definition:
global.h:50
nKey
Definition:
global.h:42
dotKey
Definition:
global.h:52
leftmouseKey
Definition:
global.h:57
insertKey
Definition:
global.h:50
backwardAction
Definition:
global.h:21
hKey
Definition:
global.h:41
minusKey
Definition:
global.h:51
rightTrigger
Definition:
global.h:64
f11Key
Definition:
global.h:49
rightStick
Definition:
global.h:62
holsterAction
Definition:
global.h:27
pageupKey
Definition:
global.h:52
leftaltKey
Definition:
global.h:50
f4Key
Definition:
global.h:48
ActionEventCount
Definition:
global.h:30
lKey
Definition:
global.h:42
leftshiftKey
Definition:
global.h:51
leftTrigger
Definition:
global.h:64
f3Key
Definition:
global.h:48
threeKey
Definition:
global.h:37
f2Key
Definition:
global.h:48
iKey
Definition:
global.h:41
xButton
Definition:
global.h:61
quoteKey
Definition:
global.h:46
tabKey
Definition:
global.h:54
delKey
Definition:
global.h:47
leftctrlKey
Definition:
global.h:50
bKey
Definition:
global.h:39
backspaceKey
Definition:
global.h:46
f7Key
Definition:
global.h:49
f12Key
Definition:
global.h:49
downKey
Definition:
global.h:47
eKey
Definition:
global.h:40
commaKey
Definition:
global.h:47
padLeft
Definition:
global.h:63
sixKey
Definition:
global.h:38
rKey
Definition:
global.h:43
startButton
Definition:
global.h:61
dKey
Definition:
global.h:40
walkAction
Definition:
global.h:28
sKey
Definition:
global.h:44
rightKey
Definition:
global.h:47
jumpAction
Definition:
global.h:24
vKey
Definition:
global.h:44
rightctrlKey
Definition:
global.h:52
gKey
Definition:
global.h:41
Generated by
1.8.9.1