From: Mikko Rasa Date: Mon, 5 Dec 2016 17:20:17 +0000 (+0200) Subject: Use the external Renderer to render ShadowMap and EnvironmentMap X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0991ffd3091d4002fe6e2811219f3a4dae2c41d1;p=libs%2Fgl.git Use the external Renderer to render ShadowMap and EnvironmentMap --- diff --git a/source/environmentmap.cpp b/source/environmentmap.cpp index cbb097ea..9ca4d452 100644 --- a/source/environmentmap.cpp +++ b/source/environmentmap.cpp @@ -39,10 +39,17 @@ void EnvironmentMap::setup_frame(Renderer &renderer) 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); @@ -50,12 +57,9 @@ void EnvironmentMap::setup_frame(Renderer &renderer) 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() diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index f461c88a..6056141f 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -84,8 +84,10 @@ void ShadowMap::setup_frame(Renderer &renderer) 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()