renderable.setup_frame(renderer);
environment.setup_frame(renderer);
- Renderer env_renderer(0);
const Matrix *matrix = renderable.get_matrix();
- Vector3 position = (*matrix)*Vector3();
- camera.set_position(position);
+ if(!matrix)
+ return;
+
+ Renderer::Push push(renderer);
+ Renderer::Exclude exclude1(renderer, renderable);
+ Renderer::Exclude exclude2(renderer, *this);
+
+ camera.set_position(*matrix*Vector3());
+
+ BindRestore bind_fbo(fbo[0]);
for(unsigned i=0; i<6; ++i)
{
TextureCubeFace face = TextureCube::enumerate_faces(i);
fbo[i].clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
camera.set_look_direction(env_tex.get_face_direction(face));
camera.set_up_direction(env_tex.get_t_direction(face));
- env_renderer.begin(&camera);
- env_renderer.exclude(renderable);
- env_renderer.exclude(*this);
- env_renderer.render(environment);
+ renderer.set_camera(camera);
+ renderer.render(environment);
}
- Framebuffer::unbind();
}
void EnvironmentMap::finish_frame()
Bind bind_depth(DepthTest::lequal());
fbo.clear(DEPTH_BUFFER_BIT);
- Renderer shadow_renderer(&camera);
- renderable.render(shadow_renderer, "shadow");
+ Renderer::Push push(renderer);
+ renderer.set_camera(camera);
+
+ renderer.render(renderable, "shadow");
}
void ShadowMap::finish_frame()