-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
43 lines (35 loc) · 1.02 KB
/
config.cpp
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
#include "config.h"
#include "json/json.h"
namespace Config
{
int SCREEN_WIDTH{ 1280 };
int SCREEN_HEIGHT{ 800 };
bool FULL_SCREEN{ false };
float NEAR_PLANE{ 1.0f };
float FAR_PLANE{ 1000.0f };
float FOV{ 60.0f };
int WATER_TEX_SIZE{ 512 };
int BOUNCE_TEX_SIZE{ 256 };
int SHADOW_TEX_SIZE{ 4096 };
bool load() noexcept
{
try
{
auto configJson = Json::LoadFile("config.json");
SCREEN_WIDTH = std::stoi(configJson["SCREEN_WIDTH"].value);
SCREEN_HEIGHT = std::stoi(configJson["SCREEN_HEIGHT"].value);
FULL_SCREEN = static_cast<bool>(std::stoi(configJson["FULL_SCREEN"].value));
NEAR_PLANE = std::stof(configJson["NEAR_PLANE"].value);
FAR_PLANE = std::stof(configJson["FAR_PLANE"].value);
FOV = std::stof(configJson["FOV"].value);
WATER_TEX_SIZE = std::stoi(configJson["WATER_TEX_SIZE"].value);
BOUNCE_TEX_SIZE = std::stoi(configJson["BOUNCE_TEX_SIZE"].value);
SHADOW_TEX_SIZE = std::stoi(configJson["SHADOW_TEX_SIZE"].value);
}
catch (...)
{
return false;
}
return true;
}
}