aboutsummaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp
index cedaabb1b..af744dcbb 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -809,15 +809,31 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
bool *m_force_fog_off;
f32 *m_fog_range;
Client *m_client;
+ bool m_fogEnabled;
public:
+
+ void onSettingsChange(const std::string &name)
+ {
+ if (name == "enable_fog")
+ m_fogEnabled = g_settings->getBool("enable_fog");
+ }
+
+ static void SettingsCallback(const std::string name, void *userdata)
+ {
+ reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
+ }
+
GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
f32 *fog_range, Client *client) :
m_sky(sky),
m_force_fog_off(force_fog_off),
m_fog_range(fog_range),
m_client(client)
- {}
+ {
+ g_settings->registerChangedCallback("enable_fog", SettingsCallback, this);
+ }
+
~GameGlobalShaderConstantSetter() {}
virtual void onSetConstants(video::IMaterialRendererServices *services,
@@ -840,7 +856,7 @@ public:
// Fog distance
float fog_distance = 10000 * BS;
- if (g_settings->getBool("enable_fog") && !*m_force_fog_off)
+ if (m_fogEnabled && !*m_force_fog_off)
fog_distance = *m_fog_range;
services->setPixelShaderConstant("fogDistance", &fog_distance, 1);