]> git.tdb.fi Git - libs/gl.git/commitdiff
Make EnvironmentMap's pixel format configurable
authorMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 20:18:51 +0000 (23:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 24 Apr 2021 20:18:51 +0000 (23:18 +0300)
source/effects/environmentmap.cpp
source/effects/environmentmap.h

index d9812c49bc0943d508b2f50ee4b5348c8dcd3fde..c714a56f6c300b03da24c2ed1576e55e5ae24c96 100644 (file)
@@ -12,14 +12,28 @@ namespace GL {
 
 EnvironmentMap::EnvironmentMap(Resources &resources, unsigned s, Renderable &r, Renderable &e):
        Effect(r),
-       size(s),
        environment(e),
-       sampler(resources.get<Sampler>("_linear_clamp.samp")),
-       rendered(false),
-       update_interval(1),
-       update_delay(0)
+       sampler(resources.get<Sampler>("_linear_clamp.samp"))
 {
-       env_tex.storage(RGB8, size, 1);
+       init(s, RGB8);
+}
+
+EnvironmentMap::EnvironmentMap(Resources &resources, unsigned s, PixelFormat f, Renderable &r, Renderable &e):
+       Effect(r),
+       environment(e),
+       sampler(resources.get<Sampler>("_linear_clamp.samp"))
+{
+       init(s, f);
+}
+
+void EnvironmentMap::init(unsigned s, PixelFormat f)
+{
+       size = s;
+       rendered = false;
+       update_interval = 1;
+       update_delay = 0;
+
+       env_tex.storage(f, size);
        depth_buf.storage(DEPTH_COMPONENT32F, size, size);
        for(unsigned i=0; i<6; ++i)
        {
index ff3d6c425414c97ddce3d41e0ebbaf29abee90dc..68bce7de51b0879f593091fcbd63999d6cc2cf47 100644 (file)
@@ -46,7 +46,11 @@ private:
 
 public:
        EnvironmentMap(Resources &, unsigned size, Renderable &rend, Renderable &env);
+       EnvironmentMap(Resources &, unsigned size, PixelFormat, Renderable &rend, Renderable &env);
+private:
+       void init(unsigned, PixelFormat, unsigned);
 
+public:
        void set_depth_clip(float, float);
 
        /** Sets the interval in frames between environment map updates.  A value of