From 25ad63d33d540616f68be0182699153255a14c40 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 1 Oct 2016 11:03:34 +0200 Subject: [PATCH] scene: add Scene::pre_render and post_render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows actors to perform draw commands in TickDraw(), even if it’s not exactly what we want in the future. --- src/engine/ticker.cpp | 4 ++++ src/scene.cpp | 30 ++++++++++++++++++++---------- src/scene.h | 2 ++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/engine/ticker.cpp b/src/engine/ticker.cpp index ffe29ef7..d2d8a178 100644 --- a/src/engine/ticker.cpp +++ b/src/engine/ticker.cpp @@ -432,6 +432,8 @@ void TickerData::DrawThreadTick() scene.EnableDisplay(); Renderer::Get(idx)->Clear(ClearMask::All); + scene.pre_render(data->deltatime); + /* Tick objects for the draw loop */ for (int g = Entity::DRAWGROUP_BEGIN; g < Entity::DRAWGROUP_END && !data->quit /* Stop as soon as required */; ++g) { @@ -470,6 +472,8 @@ void TickerData::DrawThreadTick() /* Do the render step */ scene.render(data->deltatime); + scene.post_render(data->deltatime); + /* Disable display */ scene.DisableDisplay(); } diff --git a/src/scene.cpp b/src/scene.cpp index b0821510..0e4d9408 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -622,12 +622,11 @@ void Scene::DisableDisplay() data->m_display->Disable(); } -/* Render everything that the scene contains */ -void Scene::render(float seconds) -{ - bool do_pp = true; +static bool do_pp = true; - gpu_marker("Start Render"); +void Scene::pre_render(float seconds) +{ + gpu_marker("Pre Render"); /* First render into the offline buffer */ if (do_pp) @@ -644,12 +643,23 @@ void Scene::render(float seconds) } Renderer::Get()->Clear(ClearMask::Color | ClearMask::Depth); - - // FIXME: get rid of the delta time argument - render_primitives(); - render_tiles(); - render_lines(seconds); } +} + +/* Render everything that the scene contains */ +void Scene::render(float seconds) +{ + gpu_marker("Render"); + + // FIXME: get rid of the delta time argument + render_primitives(); + render_tiles(); + render_lines(seconds); +} + +void Scene::post_render(float seconds) +{ + gpu_marker("Post Render"); if (do_pp) { diff --git a/src/scene.h b/src/scene.h index 6a3aa57e..50b3a471 100644 --- a/src/scene.h +++ b/src/scene.h @@ -251,7 +251,9 @@ public: void EnableDisplay(); void DisableDisplay(); + void pre_render(float seconds); void render(float seconds); + void post_render(float seconds); private: void render_primitives();