Config in JSON

This commit is contained in:
Stan Fortonski
2021-01-31 16:29:43 +01:00
parent ee0b861a04
commit e058f5eacb
5 changed files with 25529 additions and 7 deletions

39
.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.exp
*.def
cmake_install.cmake
CMakeCache.txt
Makefile
CMakeFiles/

2
build/.gitignore vendored
View File

@ -1,2 +0,0 @@
*.dll
*.exe

15
build/config.json Normal file
View File

@ -0,0 +1,15 @@
{
"windowWidth": 3440,
"windowHeight": 1440,
"shadowSize": 2048,
"samples": 8,
"cameraPitch": 0,
"cameraYaw": -90,
"cameraSpeed": 7,
"cameraSensitivity": 0.1,
"cameraFov": 45,
"cameraFar": 1000,
"cameraNear": 0.05,
"shadowFar": 500,
"anisotropy": 8
}

View File

@ -1,19 +1,23 @@
/* Copyright (c) 2020 by Stan Fortoński */
/* Copyright (c) 2020 - 2021 by Stan Fortoński */
#ifndef CONFIG_HPP
#define CONFIG_HPP 1
#define DEBUG_ENGINE 0
#include "support/Singleton.hpp"
#include "json.hpp"
#include <fstream>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
using json = nlohmann::json;
namespace Engine
{
class Config: public Singleton<Config>
{
friend class Singleton<Config>;
std::string title = "3D Engine - OpenGL 4.1";
std::string title = "Terrain Generator";
unsigned majorVersion = 4;
unsigned minorVersion = 1;
unsigned windowWidth = 1920;
@ -22,18 +26,37 @@ namespace Engine
unsigned samples = 8;
float cameraPitch = 0;
float cameraYaw = -90;
float cameraSpeed = 10;
float cameraSpeed = 7;
float cameraSensitivity = 0.1;
float cameraFov = 45;
float cameraFar = 1000;
float cameraNear = 0.01;
float cameraNear = 0.05;
float shadowFar = 500;
float anisotropy = 8;
glm::vec3 cameraPosition = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 cameraDirection = glm::vec3(0.0f, 0.0f, -1.0f);
glm::vec3 gravity = glm::vec3(0.0f, -9.81f, 0.0f);
Config(){;}
Config(){
std::ifstream i("config.json");
json json;
i >> json;
i.close();
windowWidth = json["windowWidth"];
windowHeight = json["windowHeight"];
shadowSize = json["shadowSize"];
samples = json["samples"];
cameraPitch = json["cameraPitch"];
cameraYaw = json["cameraYaw"];
cameraSpeed =json["cameraSpeed"];
cameraSensitivity = json["cameraSensitivity"];
cameraFov = json["cameraFov"];
cameraFar = json["cameraFar"];
cameraNear = json["cameraNear"];
shadowFar = json["shadowFar"];
anisotropy = json["anisotropy"];
}
public:
std::string getTitle() const{return title;}

25447
src/engine/json.hpp Normal file

File diff suppressed because it is too large Load Diff