-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
111 lines (95 loc) · 2.51 KB
/
common.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
#pragma once
#include <stdint.h>
#define ArrayCount(Array) sizeof((Array)) / sizeof(Array[0])
#define Kibibytes(Count) (1024 * (Count))
#define Mibibytes(Count) (1024 * Kibibytes(Count))
#define Gibibytes(Count) (1024 * Mibibytes(Count))
#define FRAME_TIME_MS 8
#define SLOW_MOTION_COEFFICIENT 0.2f
#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1080
struct game_button_state
{
uint8_t EndedDown;
uint8_t Changed;
};
struct game_input
{
int32_t MouseScreenX;
int32_t MouseScreenY;
int32_t dMouseScreenX;
int32_t dMouseScreenY;
int32_t MouseX;
int32_t MouseY;
int32_t dMouseX;
int32_t dMouseY;
float dt;
float NormMouseX;
float NormMouseY;
float NormdMouseX;
float NormdMouseY;
int32_t MouseWheelScreen;
int32_t dMouseWheelScreen;
bool IsMouseInEditorMode;
bool ToggledEditorMode;
union {
game_button_state Buttons[34];
struct
{
game_button_state a;
game_button_state b;
game_button_state c;
game_button_state d;
game_button_state e;
game_button_state f;
game_button_state g;
game_button_state h;
game_button_state i;
game_button_state j;
game_button_state k;
game_button_state m;
game_button_state n;
game_button_state o;
game_button_state p;
game_button_state r;
game_button_state s;
game_button_state t;
game_button_state v;
game_button_state w;
game_button_state x;
game_button_state LeftCtrl;
game_button_state LeftShift;
game_button_state Space;
game_button_state Tab;
game_button_state Delete;
game_button_state ArrowUp;
game_button_state ArrowDown;
game_button_state ArrowLeft;
game_button_state ArrowRight;
game_button_state MouseLeft;
game_button_state MouseRight;
game_button_state MouseMiddle;
game_button_state Escape;
};
};
};
struct game_memory
{
bool HasBeenInitialized;
uint32_t PersistentMemorySize;
void* PersistentMemory;
uint32_t TemporaryMemorySize;
void* TemporaryMemory;
};
namespace Platform
{
void InitPerformanceFrequency();
int64_t GetCurrentCounter();
float GetTimeInSeconds();
float GetTimeInSeconds(int64_t Start, int64_t End);
void SetHighDPIAwareness();
}
#define GAME_UPDATE_AND_RENDER(name) \
void name(game_memory GameMemory, const game_input* const Input)
typedef GAME_UPDATE_AND_RENDER(game_update_and_render);
game_update_and_render GameUpdateAndRender;