Răsfoiți Sursa

Added support for g_Daytime in shaders

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
Alexis Maiquez 3 ani în urmă
părinte
comite
73ef4d6dbf

+ 7 - 0
src/WallpaperEngine/Application/CWallpaperApplication.cpp

@@ -17,6 +17,7 @@
 
 float g_Time;
 float g_TimeLast;
+float g_Daytime;
 
 namespace WallpaperEngine::Application
 {
@@ -313,9 +314,15 @@ namespace WallpaperEngine::Application
             ));
 
         float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS;
+        time_t seconds;
+        struct tm* timeinfo;
 
         while (!videoDriver.closeRequested () && this->m_context.state.general.keepRunning)
         {
+            // update g_Daytime
+            time (&seconds);
+            timeinfo = localtime(&seconds);
+            g_Daytime = ((timeinfo->tm_hour * 60) + timeinfo->tm_min) / (24.0 * 60.0);
             // update audio recorder
             audioDriver.update ();
             // update input information

+ 2 - 0
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -21,6 +21,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables;
 using namespace WallpaperEngine::Render::Objects::Effects;
 
 extern float g_Time;
+extern float g_Daytime;
 
 CPass::CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass) :
     Helpers::CContextAware (material),
@@ -602,6 +603,7 @@ void CPass::setupUniforms ()
     this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ());
     // add some external variables
     this->addUniform ("g_Time", &g_Time);
+    this->addUniform ("g_Daytime", &g_Daytime);
     // add model-view-projection matrix
     this->addUniform ("g_ModelViewProjectionMatrix", &this->m_modelViewProjectionMatrix);
     this->addUniform ("g_ModelMatrix", &this->m_modelMatrix);