summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-09 04:50:40 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-09 07:37:18 +0200
commitb6dfe86cadaa9e38b4265d69972fb7dff5b73fff (patch)
treef5dcf90197a7b24a70a742c16c4538ae2c3e6fe3 /src
parentRefactored Block (diff)
downloadAltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar.gz
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar.bz2
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar.lz
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar.xz
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.tar.zst
AltCraft-b6dfe86cadaa9e38b4265d69972fb7dff5b73fff.zip
Diffstat (limited to 'src')
-rw-r--r--src/Render.cpp11
-rw-r--r--src/Render.hpp1
-rw-r--r--src/RendererWorld.cpp6
3 files changed, 16 insertions, 2 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index ea3252c..c1f7f2c 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -40,6 +40,7 @@ Render::Render(unsigned int windowWidth, unsigned int windowHeight,
fieldVsync = Settings::ReadBool("vsync", false);
fieldWireframe = Settings::ReadBool("wireframe", false);
fieldFlight = Settings::ReadBool("flight", false);
+ fieldBrightness = Settings::ReadDouble("brightness", 0.2f);
//Apply settings
if (fieldSensetivity != sensetivity)
@@ -66,6 +67,7 @@ Render::~Render() {
Settings::WriteBool("vsync", fieldVsync);
Settings::WriteBool("wireframe", fieldWireframe);
Settings::WriteBool("flight", fieldFlight);
+ Settings::WriteDouble("brightness", fieldBrightness);
Settings::Save();
ImGui_ImplSdlGL3_Shutdown();
@@ -561,6 +563,8 @@ void Render::RenderGui() {
ImGui::SliderFloat("Render distance", &fieldDistance, 1.0f, 16.0f);
+ ImGui::SliderFloat("Brightness", &fieldBrightness, 0.0f, 1.0f);
+
ImGui::SliderFloat("Sensetivity", &fieldSensetivity, 0.01f, 1.0f);
ImGui::SliderFloat("Target FPS", &fieldTargetFps, 1.0f, 300.0f);
@@ -570,7 +574,7 @@ void Render::RenderGui() {
ImGui::Checkbox("VSync", &fieldVsync);
ImGui::Checkbox("Creative flight", &fieldFlight);
-
+
if (ImGui::Button("Apply settings")) {
if (fieldDistance != world->MaxRenderingDistance) {
world->MaxRenderingDistance = fieldDistance;
@@ -590,6 +594,8 @@ void Render::RenderGui() {
} else
SDL_GL_SetSwapInterval(0);
+ PUSH_EVENT("SetMinLightLevel", fieldBrightness);
+
}
ImGui::Separator();
@@ -623,7 +629,7 @@ void Render::InitEvents() {
stateString = "Loading terrain...";
world = std::make_unique<RendererWorld>(GlobalState::GetGameState());
world->MaxRenderingDistance = fieldDistance;
- PUSH_EVENT("UpdateSectionsRender", 0);
+ PUSH_EVENT("UpdateSectionsRender", 0);
});
listener.RegisterHandler("RemoveLoadingScreen", [this](const Event&) {
@@ -632,6 +638,7 @@ void Render::InitEvents() {
GlobalState::SetState(State::Playing);
glClearColor(0, 0, 0, 1.0f);
world->GameStatePtr()->player->isFlying = this->fieldFlight;
+ PUSH_EVENT("SetMinLightLevel", fieldBrightness);
});
listener.RegisterHandler("ConnectionFailed", [this](const Event& eventData) {
diff --git a/src/Render.hpp b/src/Render.hpp
index 272e14f..1157ebb 100644
--- a/src/Render.hpp
+++ b/src/Render.hpp
@@ -41,6 +41,7 @@ class Render {
bool fieldWireframe;
bool fieldVsync;
bool fieldFlight;
+ float fieldBrightness;
void SetMouseCapture(bool IsCaptured);
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index dcfcc24..2ed2620 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -243,6 +243,11 @@ RendererWorld::RendererWorld(GameState* ptr) {
sections.erase(it);
});
+ listener->RegisterHandler("SetMinLightLevel", [this](const Event& eventData) {
+ auto value = eventData.get<float>();
+ glUniform1f(glGetUniformLocation(blockShader->Program, "MinLightLevel"), value);
+ });
+
for (int i = 0; i < numOfWorkers; i++)
workers.push_back(std::thread(&RendererWorld::WorkerFunction, this, i));
@@ -421,6 +426,7 @@ void RendererWorld::PrepareRender() {
blockShader = new Shader("./shaders/face.vs", "./shaders/face.fs");
blockShader->Use();
glUniform1i(glGetUniformLocation(blockShader->Program, "textureAtlas"), 0);
+ glUniform1f(glGetUniformLocation(blockShader->Program, "MinLightLevel"), 0.2f);
entityShader = new Shader("./shaders/entity.vs", "./shaders/entity.fs");