-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.h
More file actions
197 lines (143 loc) · 4.78 KB
/
Engine.h
File metadata and controls
197 lines (143 loc) · 4.78 KB
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
#ifndef _ENGINE_H
#define _ENGINE_H
// frame rate calculation based on www.gametutorials.com - see license.txt
#ifdef _WIN32
#include <windows.h>
#endif
#ifndef ELCH_FFMPEG
#define ELCH_FFMPEG
#endif
#include <SDL.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <string>
#include <fstream>
#include "CVector2.h"
#include "CVector3.h"
#include <vector>
#include <stdlib.h>
#include <SDL_net.h>
#include "CTextParser.h"
#include "ForceInline.h"
using namespace std;
#ifdef _MSC_VER
#pragma warning(disable: 4244) // conversion from 'const double' to 'float', possible loss of data
#pragma warning(disable: 4996) // '*' was declared deprecated
#endif
#ifdef __INTEL_COMPILER
#pragma warning(disable: 3291) // invalid narrowing conversion from "int" to "float"
#pragma warning(disable: 1786) // function strcpy was declared deprecated ...
#pragma warning(disable: 279)
#pragma warning(disable: 1478) // function "alutLoadWAVFile" was declared "deprecated"
#pragma warning(disable: 589) // transfer of control bypasses initialization of
#endif
#ifdef _WIN32
#define _ALIGN(sz) __declspec(align(sz))
#define __align(...) __declspec(align(__VA_ARGS__))
#else
#define _ALIGN(...) __attribute__((aligned(__VA_ARGS__)))
#define __align(...) __attribute__((aligned(__VA_ARGS__)))
#endif
#ifndef PI_DEFINED
#define PI_DEFINED
const double PI = 3.1415926535897932384626433832795;
#endif
#ifndef M_180_PI
#define M_180_PI 57.295779513082320876798154814105f
#endif
#ifndef M_PI_180
#define M_PI_180 0.017453292519943295769236907684886f
#endif
#ifndef M_1_PI
#define M_1_PI 0.31830988618379067154f
#endif
#define RAD2DEG(a) (a*M_180_PI)
#define DEG2RAD(a) (a*M_PI_180)
#ifdef ANDROID
const char * const CONFIG_FILE = "/sdcard/qwrt.cfg";
#else
const char * const CONFIG_FILE = "Data/qwrt.cfg";
#endif
static CVector3 NULLVECTOR3f(0.0f, 0.0f, 0.0f);
static const int NETWORK_PROTCOL_MAGICK = 123456;
static const int NETWORK_PROTOCOL_VERSION = 10;
static const int MAX_SERVERS = 16;
static const int PORT_TO_SERVER = 2000;
const char * const MINCLIENT_VERSION = "1.00";
#define NETWORK_ON true
enum class HeadTrackingMethods {
OFF = 1,
ZEISS_VR_ONE = 2,
GOOGLE_CARDBOARD = 3,
};
class Engine {
public:
Engine(){};
~Engine(){};
static void init();
static void calculateFrameRate();
static float getFrameInterval(){ return frameInterval; }
// Networking stuff
static TCPsocket socketDescriptor[MAX_SERVERS];
static IPaddress serverIP[MAX_SERVERS];
static int rectLeftServer[MAX_SERVERS];
static int rectTopServer[MAX_SERVERS];
static int rectRightServer[MAX_SERVERS];
static int rectBottomServer[MAX_SERVERS];
static int rectSizeX[MAX_SERVERS];
static int rectSizeY[MAX_SERVERS];
static bool rectMode;
// variables
static int screenWidthRT;
static int screenHeightRT;
static int screenWidthGL;
static int screenHeightGL;
static int serverFrameBuffers;
//static int RENDERTILE_SIZE;
static bool upscale;
// keys & mouse
static bool upKey;
static bool downKey;
static bool leftKey;
static bool rightKey;
//static bool leftButton;
//static bool rightButton;
static bool jumpKey;
static bool crouchKey;
static CVector2 relativeMouseMotion;
static bool forceScreenResolution;
static bool done;
static bool fullscreen;
static int fontSize;
static float angle;
static float currentTime;
static float currentTimeLastFrame;
static float timeWhenMapWasLoaded;
static float sensitivity;
static float frameTime;
static float framesPerSecond;
static char* startMap;
static char* serverName[MAX_SERVERS];
static int serverPort[MAX_SERVERS];
static int numServers;
static void increaseNumFramesRendered(){ numFramesRendered++; }
static float frameInterval;
static int numFramesRendered;
static char strFrameRate[32];
static void calculateOrthoMatrix(float left, float right, float bottom, float top, float near_, float far_, float result[16]);
static bool serverUseETC1;
static CVector2 buttonLeftCenter;
static CVector2 buttonRightCenter;
static CVector2 buttonCenter;
static CVector2 buttonPressed;
static int clicksPerSecond;
static char debugMessage[64];
static int numAccelerometerHits;
static HeadTrackingMethods headTrackingMethod;
private:
static float lastTime; // This will hold the time from the last frame
static void parseConfigFile();
static void updateGlobalSinus();
};
#endif