Added pause menu, new F3 debug panel, fogCurve setting

This commit is contained in:
MihailRis
2023-11-11 15:35:27 +03:00
parent b9ed7a2b28
commit e48e41c99a
28 changed files with 1267 additions and 324 deletions
+67
View File
@@ -0,0 +1,67 @@
#ifndef SRC_ENGINE_H_
#define SRC_ENGINE_H_
#include <string>
#include <memory>
#include <stdexcept>
#include "typedefs.h"
class Assets;
class Level;
namespace gui {
class GUI;
}
struct EngineSettings {
/* Window width (pixels) */
int displayWidth;
/* Window height (pixels) */
int displayHeight;
/* Anti-aliasing samples */
int displaySamples;
/* GLFW swap interval value, 0 - unlimited fps, 1 - vsync*/
int displaySwapInterval;
/* Window title */
const char* displayTitle;
/* Max milliseconds that engine uses for chunks loading only */
uint chunksLoadSpeed;
/* Radius of chunks loading zone (chunk is unit) */
uint chunksLoadDistance;
/* Buffer zone where chunks are not unloading (chunk is unit)*/
uint chunksPadding;
/* Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
Use values in range [1.0 - 2.0] where 1.0 is linear, 2.0 is quadratic
*/
float fogCurve;
};
void load_settings(EngineSettings& settings, std::string filename);
void save_settings(EngineSettings& settings, std::string filename);
class initialize_error : public std::runtime_error {
public:
initialize_error(const std::string& message) : std::runtime_error(message) {}
};
class Engine {
Assets* assets;
Level* level;
EngineSettings settings;
uint64_t frame = 0;
double lastTime = 0.0;
double delta = 0.0;
bool occlusion = true;
gui::GUI* gui;
public:
Engine(const EngineSettings& settings);
~Engine();
void updateTimers();
void updateHotkeys();
void mainloop();
};
#endif // SRC_ENGINE_H_