forked from WWU-cptr143-sprouts/sprouts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.h
243 lines (226 loc) · 6.3 KB
/
platform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#ifndef PLATFORM_H_INCLUDED
#define PLATFORM_H_INCLUDED
#include <GL/gl.h>
#include <string>
#include <memory>
#include "matrix.h"
#include "vector.h"
#include "stream.h"
#ifndef EVENT_H_INCLUDED
class EventHandler;
#endif // EVENT_H_INCLUDED
void glLoadMatrix(Matrix mat);
const float defaultFPS = 60;
shared_ptr<Reader> getResourceReader(wstring resource);
enum KeyboardKey
{
KeyboardKey_Unknown,
KeyboardKey_A,
KeyboardKey_B,
KeyboardKey_C,
KeyboardKey_D,
KeyboardKey_E,
KeyboardKey_F,
KeyboardKey_G,
KeyboardKey_H,
KeyboardKey_I,
KeyboardKey_J,
KeyboardKey_K,
KeyboardKey_L,
KeyboardKey_M,
KeyboardKey_N,
KeyboardKey_O,
KeyboardKey_P,
KeyboardKey_Q,
KeyboardKey_R,
KeyboardKey_S,
KeyboardKey_T,
KeyboardKey_U,
KeyboardKey_V,
KeyboardKey_W,
KeyboardKey_X,
KeyboardKey_Y,
KeyboardKey_Z,
KeyboardKey_Backspace,
KeyboardKey_Tab,
KeyboardKey_Clear,
KeyboardKey_Return,
KeyboardKey_Pause,
KeyboardKey_Escape,
KeyboardKey_Space,
KeyboardKey_SQuote,
KeyboardKey_Equals,
KeyboardKey_Comma,
KeyboardKey_Dash,
KeyboardKey_BQuote,
KeyboardKey_LBracket,
KeyboardKey_RBracket,
KeyboardKey_BSlash,
KeyboardKey_Delete,
KeyboardKey_Period,
KeyboardKey_FSlash,
KeyboardKey_Num0,
KeyboardKey_Num1,
KeyboardKey_Num2,
KeyboardKey_Num3,
KeyboardKey_Num4,
KeyboardKey_Num5,
KeyboardKey_Num6,
KeyboardKey_Num7,
KeyboardKey_Num8,
KeyboardKey_Num9,
KeyboardKey_Colon,
KeyboardKey_F1,
KeyboardKey_F2,
KeyboardKey_F3,
KeyboardKey_F4,
KeyboardKey_F5,
KeyboardKey_F6,
KeyboardKey_F7,
KeyboardKey_F8,
KeyboardKey_F9,
KeyboardKey_F10,
KeyboardKey_F11,
KeyboardKey_F12,
KeyboardKey_Up,
KeyboardKey_Down,
KeyboardKey_Left,
KeyboardKey_Right,
KeyboardKey_Insert,
KeyboardKey_Home,
KeyboardKey_End,
KeyboardKey_PageUp,
KeyboardKey_PageDown,
KeyboardKey_LShift,
KeyboardKey_RShift,
KeyboardKey_LCtrl,
KeyboardKey_RCtrl,
KeyboardKey_KPad0,
KeyboardKey_KPad1,
KeyboardKey_KPad2,
KeyboardKey_KPad3,
KeyboardKey_KPad4,
KeyboardKey_KPad5,
KeyboardKey_KPad6,
KeyboardKey_KPad7,
KeyboardKey_KPad8,
KeyboardKey_KPad9,
KeyboardKey_KPadFSlash,
KeyboardKey_KPadStar,
KeyboardKey_KPadDash,
KeyboardKey_KPadPlus,
KeyboardKey_KPadReturn,
KeyboardKey_KPadPeriod,
KeyboardKey_KPadEquals,
KeyboardKey_NumLock,
KeyboardKey_CapsLock,
KeyboardKey_ScrollLock,
KeyboardKey_LAlt,
KeyboardKey_RAlt,
KeyboardKey_LMeta,
KeyboardKey_RMeta,
KeyboardKey_LSuper,
KeyboardKey_RSuper,
KeyboardKey_AltGr,
KeyboardKey_Menu,
KeyboardKey_Mode,
KeyboardKey_PrintScreen,
KeyboardKey_max = KeyboardKey_PrintScreen,
KeyboardKey_min = KeyboardKey_Unknown,
KeyboardKey_DQuote = KeyboardKey_SQuote,
KeyboardKey_Underline = KeyboardKey_Dash,
KeyboardKey_Tilde = KeyboardKey_BQuote,
KeyboardKey_LBrace = KeyboardKey_LBracket,
KeyboardKey_RBrace = KeyboardKey_RBracket,
KeyboardKey_Pipe = KeyboardKey_BSlash,
KeyboardKey_EMark = KeyboardKey_Num1,
KeyboardKey_Pound = KeyboardKey_Num3,
KeyboardKey_Dollar = KeyboardKey_Num4,
KeyboardKey_Percent = KeyboardKey_Num5,
KeyboardKey_Caret = KeyboardKey_Num6,
KeyboardKey_Amp = KeyboardKey_Num7,
KeyboardKey_Star = KeyboardKey_Num8,
KeyboardKey_LParen = KeyboardKey_Num9,
KeyboardKey_RParen = KeyboardKey_Num0,
KeyboardKey_Semicolon = KeyboardKey_Colon,
KeyboardKey_LAngle = KeyboardKey_Comma,
KeyboardKey_Plus = KeyboardKey_Equals,
KeyboardKey_RAngle = KeyboardKey_Period,
KeyboardKey_QMark = KeyboardKey_FSlash,
KeyboardKey_AtSign = KeyboardKey_Num2,
KeyboardKey_KPadInsert = KeyboardKey_KPad0,
KeyboardKey_KPadEnd = KeyboardKey_KPad1,
KeyboardKey_KPadDown = KeyboardKey_KPad2,
KeyboardKey_KPadPageDown = KeyboardKey_KPad3,
KeyboardKey_KPadLeft = KeyboardKey_KPad4,
KeyboardKey_KPadRight = KeyboardKey_KPad6,
KeyboardKey_KPadHome = KeyboardKey_KPad7,
KeyboardKey_KPadUp = KeyboardKey_KPad8,
KeyboardKey_KPadPageUp = KeyboardKey_KPad9,
KeyboardKey_KPadDelete = KeyboardKey_KPadPeriod,
KeyboardKey_SysRequest = KeyboardKey_PrintScreen,
KeyboardKey_Break = KeyboardKey_Pause,
};
enum KeyboardModifiers
{
KeyboardModifiers_None = 0,
KeyboardModifiers_LShift = 0x1,
KeyboardModifiers_RShift = 0x2,
KeyboardModifiers_LCtrl = 0x4,
KeyboardModifiers_RCtrl = 0x8,
KeyboardModifiers_LAlt = 0x10,
KeyboardModifiers_RAlt = 0x20,
KeyboardModifiers_LMeta = 0x40,
KeyboardModifiers_RMeta = 0x80,
KeyboardModifiers_NumLock = 0x100,
KeyboardModifiers_CapsLock = 0x200,
KeyboardModifiers_Mode = 0x400,
KeyboardModifiers_Ctrl = KeyboardModifiers_LCtrl | KeyboardModifiers_RCtrl,
KeyboardModifiers_Shift = KeyboardModifiers_LShift | KeyboardModifiers_RShift,
KeyboardModifiers_Alt = KeyboardModifiers_LAlt | KeyboardModifiers_RAlt,
KeyboardModifiers_Meta = KeyboardModifiers_LMeta | KeyboardModifiers_RMeta,
};
enum MouseButton
{
MouseButton_None = 0,
MouseButton_Left = 0x1,
MouseButton_Right = 0x2,
MouseButton_Middle = 0x4,
MouseButton_X1 = 0x8,
MouseButton_X2 = 0x10
};
namespace Display
{
wstring title();
void title(wstring newTitle);
void handleEvents(shared_ptr<EventHandler> eventHandler);
void flip(float fps = defaultFPS);
double instantaneousFPS();
double frameDeltaTime();
float averageFPS();
double timer();
double realtimeTimer();
int width();
int height();
float scaleX();
float scaleY();
void initFrame();
void initOverlay();
bool grabMouse();
void grabMouse(bool g);
VectorF transformMouseTo3D(float x, float y, float depth = 1.0f);
MouseButton getMouseState();
bool getKeyState(KeyboardKey key);
bool fullScreen();
void fullScreen(bool fs);
void setSize(int width, int height);
}
void startGraphics();
void endGraphics();
void setPreferredMode(int xRes = -1, int yRes = -1);
bool hasClipboardText();
wstring getClipboardText();
void setClipboardText(wstring text);
size_t currentGraphicsNumber(); // returns a number corresponding to the current graphics run
#include "event.h"
#endif // PLATFORM_H_INCLUDED