summary refs log tree commit diff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-11 04:52:24 +0200
committerMel <einebeere@gmail.com>2023-07-11 04:52:24 +0200
commit0ce26f2a49fd6d64a690b84b1932126edfbfbee6 (patch)
treef0846f7f0e394d3c213986a2f85e0240dc8e5402 /src/main.cpp
parente6812d2df6bd8a0a71375096abe46f8039d8c570 (diff)
downloadmeowcraft-0ce26f2a49fd6d64a690b84b1932126edfbfbee6.tar.zst
meowcraft-0ce26f2a49fd6d64a690b84b1932126edfbfbee6.zip
Add simple scrolling non-tiling 2D clouds
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3d193c2..1688dac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,6 +10,7 @@
 #include "GFX/Shading/Program.hpp"
 #include "GFX/Texture.hpp"
 #include "GFX/Image/PPMParser.hpp"
+#include "World/Clouds.hpp"
 #include "World/World.hpp"
 
 #define APP_NAME "Meowcraft"
@@ -80,6 +81,8 @@ void run() {
     Vector<3, F32> sky_color{0.85, 0.85, 0.85}; // #DBDBDB
     sky_color_uniform.set(sky_color);
 
+    MC::World::Clouds clouds{ASPECT, FOV, 0.1f, 1000.0f, sky_color};
+
     glEnable(GL_DEPTH_TEST);
     glDepthFunc(GL_LEQUAL);
 
@@ -100,27 +103,32 @@ void run() {
 #endif
 
         process_input(window, camera);
+        clouds.update(time);
+
+        glClearColor(sky_color.x(), sky_color.y(), sky_color.z(), 1.0f); // #DBDBDB
+        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
         program.bind();
 
         auto view = Math::MVP::view<F32>(camera.position(), camera.angles());
         view_uniform.set(view);
 
-        glClearColor(sky_color.x(), sky_color.y(), sky_color.z(), 1.0f); // #DBDBDB
-        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
         for (auto chunk : world.get_visible_chunks(camera.position())) {
             mesh_alpha_uniform.set(1.0);
-            auto land_model = Math::MVP::model<F32>(chunk->chunk.value().position(), {});
+            auto land_model = Math::MVP::model<F32>(chunk->chunk.value().position(), Vector<3>::one(), {});
             model_uniform.set(land_model);
             render(chunk->land_mesh.value(), texture);
 
             mesh_alpha_uniform.set(0.4);
-            auto water_model = Math::MVP::model<F32>(chunk->chunk.value().position() - Vector<3>{0, 0.2, 0}, {});
+            auto water_model = Math::MVP::model<F32>(chunk->chunk.value().position() - Vector<3>{0, 0.2, 0}, Vector<3>::one(), {});
             model_uniform.set(water_model);
             render(chunk->water_mesh.value(), texture);
         }
 
+        program.unbind();
+
+        clouds.render(camera);
+
         time++;
     }
 }