From d0db092dd4db768e9419c4a5e6a803f778cc60eb Mon Sep 17 00:00:00 2001 From: ExMix Date: Thu, 30 Oct 2014 15:09:16 +0300 Subject: [PATCH] [core] store clear command to display list --- graphics/display_list.cpp | 6 ++++++ graphics/display_list.hpp | 2 ++ graphics/display_list_renderer.cpp | 11 +++++++++++ graphics/display_list_renderer.hpp | 2 ++ 4 files changed, 21 insertions(+) diff --git a/graphics/display_list.cpp b/graphics/display_list.cpp index 96b665bd42..674334e82b 100644 --- a/graphics/display_list.cpp +++ b/graphics/display_list.cpp @@ -87,6 +87,12 @@ namespace graphics m_parent->processCommand(cmd); } + void DisplayList::clear(shared_ptr const & cmd) + { + cmd->setIsDebugging(m_isDebugging); + m_commands.push_back(cmd); + } + void DisplayList::addCheckPoint() { static_cast(m_parent)->addCheckPoint(); diff --git a/graphics/display_list.hpp b/graphics/display_list.hpp index 7b9e80a10b..c8ef9571df 100644 --- a/graphics/display_list.hpp +++ b/graphics/display_list.hpp @@ -23,6 +23,7 @@ namespace graphics typedef gl::GeometryRenderer::ApplyStates ApplyStatesCmd; typedef gl::GeometryRenderer::ApplySharpStates ApplySharpStatesCmd; typedef gl::GeometryRenderer::UploadData UploadDataCmd; + typedef gl::GeometryRenderer::ClearCommand ClearCommandCmd; list > m_commands; @@ -52,6 +53,7 @@ namespace graphics void freeTexture(shared_ptr const & cmd); void freeStorage(shared_ptr const & cmd); void uploadResources(shared_ptr const & cmd); + void clear(shared_ptr const & cmd); void addCheckPoint(); void draw(DisplayListRenderer * r, diff --git a/graphics/display_list_renderer.cpp b/graphics/display_list_renderer.cpp index d0dc96cb25..b835105a21 100644 --- a/graphics/display_list_renderer.cpp +++ b/graphics/display_list_renderer.cpp @@ -85,6 +85,17 @@ namespace graphics dl->draw(this, m, holder); } + void DisplayListRenderer::clear(Color const & c, bool clearRT, float depth, bool clearDepth) + { + if (isCancelled()) + return; + + if (m_displayList) + m_displayList->clear(make_shared(c, clearRT, depth, clearDepth)); + else + base_t::clear(c, clearRT, depth, clearDepth); + } + void DisplayListRenderer::drawGeometry(shared_ptr const & texture, gl::Storage const & storage, size_t indicesCount, diff --git a/graphics/display_list_renderer.hpp b/graphics/display_list_renderer.hpp index 65216453ef..971b8a707b 100644 --- a/graphics/display_list_renderer.hpp +++ b/graphics/display_list_renderer.hpp @@ -24,6 +24,7 @@ namespace graphics typedef base_t::FreeTexture FreeTextureCmd; typedef base_t::FreeStorage FreeStorageCmd; typedef base_t::DiscardStorage DiscardStorageCmd; + typedef base_t::ClearCommand ClearCommandCmd; typedef gl::BaseTexture const * TextureRef; typedef pair StorageRef; @@ -56,6 +57,7 @@ namespace graphics /// Interceptable commands /// @{ + void clear(Color const & c, bool clearRT = true, float depth = 1.0, bool clearDepth = true); /// draw geometry void drawGeometry(shared_ptr const & texture,