From fea00edfb3b4274cb87e131743415e1fd22d0c1a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 24 Apr 2021 23:18:51 +0300 Subject: [PATCH] Make EnvironmentMap's pixel format configurable --- source/effects/environmentmap.cpp | 26 ++++++++++++++++++++------ source/effects/environmentmap.h | 4 ++++ 2 files changed, 24 insertions(+), 6 deletions(-) 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 -- 2.45.2