]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/sky.cpp
Render a sky in the upper hemisphere of a view's background
[r2c2.git] / source / 3d / sky.cpp
diff --git a/source/3d/sky.cpp b/source/3d/sky.cpp
new file mode 100644 (file)
index 0000000..332b6d2
--- /dev/null
@@ -0,0 +1,20 @@
+#include <msp/gl/renderer.h>
+#include "catalogue.h"
+#include "sky.h"
+
+using namespace Msp;
+
+namespace R2C2 {
+
+Sky3D::Sky3D(Catalogue3D &cat):
+       GL::ObjectInstance(cat.get<GL::Object>("sky.object"))
+{ }
+
+void Sky3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
+{
+       GL::Vector4 sky_dir = renderer.matrix_stack().top()*GL::Vector4(0, 0 ,1, 0);
+       shdata.uniform("eye_sky_dir", sky_dir.x, sky_dir.y, sky_dir.z);
+       renderer.add_shader_data(shdata);
+}
+
+} // namespace R2C2