From 012c120bf17064540d52f2e5b07c20b530c5d75c Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 May 2014 00:35:28 +0200 Subject: [PATCH] Added Scene::EnableBackground Former-commit-id: 57a3c3e41799703bb72b4980433d7faadc3b1b86 --- include/Nazara/Graphics/Scene.hpp | 4 ++++ src/Nazara/Graphics/DeferredForwardPass.cpp | 2 +- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/Scene.hpp b/include/Nazara/Graphics/Scene.hpp index 625c0e920..d286c4c19 100644 --- a/include/Nazara/Graphics/Scene.hpp +++ b/include/Nazara/Graphics/Scene.hpp @@ -37,6 +37,8 @@ class NAZARA_API NzScene void Cull(); void Draw(); + void EnableBackground(bool enable); + NzColor GetAmbientColor() const; NzAbstractBackground* GetBackground() const; NzAbstractRenderTechnique* GetRenderTechnique() const; @@ -45,6 +47,8 @@ class NAZARA_API NzScene float GetUpdateTime() const; unsigned int GetUpdatePerSecond() const; + bool IsBackgroundEnabled() const; + void RegisterForUpdate(NzUpdatable* object); void SetAmbientColor(const NzColor& color); diff --git a/src/Nazara/Graphics/DeferredForwardPass.cpp b/src/Nazara/Graphics/DeferredForwardPass.cpp index 2adb9c421..368377e08 100644 --- a/src/Nazara/Graphics/DeferredForwardPass.cpp +++ b/src/Nazara/Graphics/DeferredForwardPass.cpp @@ -29,7 +29,7 @@ bool NzDeferredForwardPass::Process(const NzScene* scene, unsigned int workTextu NzRenderer::SetTarget(m_workRTT); NzRenderer::SetViewport(NzRecti(0, 0, m_dimensions.x, m_dimensions.y)); - NzAbstractBackground* background = scene->GetBackground(); + NzAbstractBackground* background = (scene->IsBackgroundEnabled()) ? scene->GetBackground() : nullptr; if (background) background->Draw(scene); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 8435db95e..5789f7489 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -70,7 +70,7 @@ void NzForwardRenderTechnique::Clear(const NzScene* scene) const NzRenderer::Enable(nzRendererParameter_DepthWrite, true); NzRenderer::Clear(nzRendererBuffer_Depth); - NzAbstractBackground* background = scene->GetBackground(); + NzAbstractBackground* background = (scene->IsBackgroundEnabled()) ? scene->GetBackground() : nullptr; if (background) background->Draw(scene); }