+#include <algorithm>
#include <cmath>
#include "environmentmap.h"
#include "renderer.h"
#include "texunit.h"
+using namespace std;
+
namespace Msp {
namespace GL {
Effect(r),
size(s),
environment(e),
- rendered(false)
+ rendered(false),
+ update_interval(1),
+ update_delay(0)
{
env_tex.storage(RGB, size);
env_tex.set_wrap(CLAMP_TO_EDGE);
camera.set_depth_clip(n, f);
}
+void EnvironmentMap::set_update_interval(unsigned i)
+{
+ update_interval = i;
+ update_delay = min(update_delay, update_interval-1);
+}
+
+void EnvironmentMap::queue_update()
+{
+ update_delay = 0;
+}
+
void EnvironmentMap::setup_frame(Renderer &renderer)
{
if(rendered)
rendered = true;
renderable.setup_frame(renderer);
+
+ if(update_delay)
+ {
+ if(update_interval)
+ --update_delay;
+ return;
+ }
+ update_delay = update_interval-1;
environment.setup_frame(renderer);
const Matrix *matrix = renderable.get_matrix();
Camera camera;
mutable ProgramData shdata;
bool rendered;
+ unsigned update_interval;
+ unsigned update_delay;
public:
EnvironmentMap(unsigned size, Renderable &rend, Renderable &env);
void set_depth_clip(float, float);
+ void set_update_interval(unsigned);
+ void queue_update();
virtual void setup_frame(Renderer &);
virtual void finish_frame();