mirror of
https://github.com/stanislawfortonski/Procedural-Terrain-Generator-OpenGL.git
synced 2025-05-17 15:18:48 +08:00
Config in JSON
This commit is contained in:
39
.gitignore
vendored
Normal file
39
.gitignore
vendored
Normal 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
2
build/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*.dll
|
||||
*.exe
|
15
build/config.json
Normal file
15
build/config.json
Normal 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
|
||||
}
|
@ -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
25447
src/engine/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user