Skip to content

Commit

Permalink
Config in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Jan 31, 2021
1 parent 9ceed7b commit 0c9094f
Show file tree
Hide file tree
Showing 5 changed files with 25,527 additions and 5 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 2 deletions build/.gitignore

This file was deleted.

15 changes: 15 additions & 0 deletions build/config.json
Original file line number Diff line number Diff line change
@@ -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
}
29 changes: 26 additions & 3 deletions src/engine/config.hpp
Original file line number Diff line number Diff line change
@@ -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 = "StickMan 3D: First Round";
unsigned majorVersion = 4;
unsigned minorVersion = 1;
unsigned windowWidth = 1920;
Expand All @@ -33,7 +37,26 @@ namespace Engine
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;}
Expand Down
Loading

0 comments on commit 0c9094f

Please sign in to comment.