#include <algorithm>
#include <cmath>
+#include <msp/core/raii.h>
#include <msp/strings/format.h>
#include "environmentmap.h"
#include "error.h"
update_delay = update_interval-1;
environment.setup_frame(renderer);
+ SetFlag set_in(in_setup_frame);
+
Vector3 center;
if(use_fixed_pos)
center = fixed_position;
}
Renderer::Push push(renderer);
- Renderer::Exclude exclude1(renderer, renderable);
- Renderer::Exclude exclude2(renderer, *this);
for(unsigned i=0; i<6; ++i)
{
faces[i].camera.set_position(center);
renderer.set_framebuffer(&faces[i].fbo);
renderer.set_camera(faces[i].camera);
- renderer.render(environment);
+ environment.render(renderer);
}
renderer.set_framebuffer(&irradiance_fbo);
void EnvironmentMap::render(Renderer &renderer, Tag tag) const
{
+ if(in_setup_frame)
+ return;
if(!enabled_methods.count(tag))
- return renderer.render(renderable, tag);
+ return renderable.render(renderer, tag);
Renderer::Push _push_rend(renderer);
renderer.set_texture("environment_map", &env_tex, &mip_sampler);
renderer.set_texture("irradiance_map", &irradiance, &sampler);
renderer.add_shader_data(shdata);
- renderer.render(renderable, tag);
+ renderable.render(renderer, tag);
}
void EnvironmentMap::set_debug_name(const string &name)
const Sampler &mip_sampler;
ProgramData shdata;
bool rendered = false;
+ bool in_setup_frame = false;
unsigned update_interval = 1;
unsigned update_delay = 0;
renderer.set_scissor(&light.region);
renderer.set_camera(v.camera);
- renderer.render(*light.shadow_caster, (v.face>0 ? "noclear" : ""));
+ light.shadow_caster->render(renderer, (v.face>0 ? "noclear" : ""));
}
}
void ShadowMap::render(Renderer &renderer, Tag tag) const
{
if(!enabled_methods.count(tag))
- return renderer.render(renderable, tag);
+ return renderable.render(renderer, tag);
Renderer::Push _push_rend(renderer);
renderer.set_texture("shadow_map", &depth_buf, &sampler);
renderer.add_shader_data(shdata);
- renderer.render(renderable, tag);
+ renderable.render(renderer, tag);
}
void ShadowMap::set_debug_name(const string &name)
if(!camera)
{
for(const OccludedRenderable &o: occluded_cache)
- renderer.render(*o.renderable, tag);
+ o.renderable->render(renderer, tag);
return;
}
i->occluder = true;
if(i->occluder)
- renderer.render(*i->renderable, tag);
+ i->renderable->render(renderer, tag);
}
// Move all objects within the frustum to the beginning of the array
// Render anything that has a chance of being visible
for(auto i=occluded_cache.begin(); (i!=occluded_cache.end() && i->in_frustum); ++i)
if(!i->occluder && queries.get_result(i-occluded_cache.begin()))
- renderer.render(*i->renderable, tag);
+ i->renderable->render(renderer, tag);
}
} // namespace GL
{
for(Renderable *r: renderables)
if(!frustum_cull(*r))
- renderer.render(*r, tag);
+ r->render(renderer, tag);
}
else
{
for(Renderable *r: renderables)
- renderer.render(*r, tag);
+ r->render(renderer, tag);
}
}
*state = State();
shdata_stack.clear();
add_shader_data(standard_shdata);
- excluded.clear();
commands.use_pipeline(0);
}
-void Renderer::exclude(const Renderable &renderable)
-{
- excluded.insert(&renderable);
-}
-
-void Renderer::include(const Renderable &renderable)
-{
- excluded.erase(&renderable);
-}
-
-void Renderer::render(const Renderable &renderable, Tag tag)
-{
- if(!excluded.count(&renderable))
- renderable.render(*this, tag);
-}
-
void Renderer::clear(const ClearValue *values)
{
pipeline_state.set_framebuffer(state->framebuffer);
~Push() { renderer.pop_state(); }
};
- class Exclude
- {
- private:
- Renderer &renderer;
- const Renderable &renderable;
-
- public:
- Exclude(Renderer &r, const Renderable &e): renderer(r), renderable(e) { renderer.exclude(renderable); }
- ~Exclude() { renderer.include(renderable); }
- };
-
private:
struct BoundTexture
{
std::vector<BoundTexture> texture_stack;
ProgramData standard_shdata;
std::vector<BoundProgramData> shdata_stack;
- std::set<const Renderable *> excluded;
PipelineState pipeline_state;
Commands commands;
further rendering. */
void end();
- void exclude(const Renderable &);
- void include(const Renderable &);
-
void clear(const ClearValue *);
- void render(const Renderable &, Tag = Tag());
void draw(const Batch &);
void draw_instanced(const Batch &, unsigned);
renderer.add_shader_data(lighting->get_shader_data());
if(const Renderable *renderable = s.get_renderable())
- renderer.render(*renderable, s.get_tag());
+ renderable->render(renderer, s.get_tag());
}
if(target[0])
{
for(Renderable *r: cache)
if(!frustum_cull(*r))
- renderer.render(*r, tag);
+ r->render(renderer, tag);
}
else
{
for(Renderable *r: cache)
- renderer.render(*r, tag);
+ r->render(renderer, tag);
}
}
void Slot::render(Renderer &renderer, Tag tag) const
{
if(renderable)
- renderer.render(*renderable, tag);
+ renderable->render(renderer, tag);
}
} // namespace GL
if(!camera)
{
for(const SortedRenderable &r: sorted_cache)
- renderer.render(*r.renderable, tag);
+ r.renderable->render(renderer, tag);
return;
}
}
for(auto i=sorted_cache.begin(); (i!=sorted_cache.end() && i->in_frustum); ++i)
- renderer.render(*i->renderable, tag);
+ i->renderable->render(renderer, tag);
}