From: Mikko Rasa Date: Sat, 24 Apr 2021 20:18:51 +0000 (+0300) Subject: Make EnvironmentMap's pixel format configurable X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=fea00ed;p=libs%2Fgl.git Make EnvironmentMap's pixel format configurable --- diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index d9812c49..c714a56f 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -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("_linear_clamp.samp")), - rendered(false), - update_interval(1), - update_delay(0) + sampler(resources.get("_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("_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) { diff --git a/source/effects/environmentmap.h b/source/effects/environmentmap.h index ff3d6c42..68bce7de 100644 --- a/source/effects/environmentmap.h +++ b/source/effects/environmentmap.h @@ -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