Graphics/Camera: Add clear color per viewer
This commit is contained in:
parent
a812c69e69
commit
342c053faa
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_GRAPHICS_ABSTRACTVIEWER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
|
||||
|
|
@ -22,6 +23,7 @@ namespace Nz
|
|||
AbstractViewer() = default;
|
||||
~AbstractViewer() = default;
|
||||
|
||||
virtual const Color& GetClearColor() const = 0;
|
||||
virtual UInt32 GetRenderMask() const = 0;
|
||||
virtual const RenderTarget& GetRenderTarget() = 0;
|
||||
virtual ViewerInstance& GetViewerInstance() = 0;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/FramePass.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Renderer/CommandBufferBuilder.hpp>
|
||||
#include <Nazara/Renderer/CommandPool.hpp>
|
||||
#include <Nazara/Renderer/Framebuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderPass.hpp>
|
||||
|
|
@ -72,6 +73,7 @@ namespace Nz
|
|||
std::shared_ptr<RenderPass> renderPass;
|
||||
std::string name;
|
||||
std::vector<std::size_t> outputTextureIndices;
|
||||
std::vector<CommandBufferBuilder::ClearValues> outputClearValues;
|
||||
std::vector<SubpassData> subpasses;
|
||||
std::vector<TextureTransition> transitions;
|
||||
FramePass::ExecutionCallback executionCallback;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace Nz
|
|||
~Camera() = default;
|
||||
|
||||
inline float GetAspectRatio() const;
|
||||
const Color& GetClearColor() const override;
|
||||
inline DegreeAnglef GetFOV() const;
|
||||
UInt32 GetRenderMask() const override;
|
||||
const RenderTarget& GetRenderTarget() override;
|
||||
|
|
@ -39,6 +40,7 @@ namespace Nz
|
|||
inline float GetZFar() const;
|
||||
inline float GetZNear() const;
|
||||
|
||||
inline void UpdateClearColor(Color color);
|
||||
inline void UpdateFOV(DegreeAnglef fov);
|
||||
inline void UpdateProjectionType(ProjectionType projectionType);
|
||||
inline void UpdateRenderMask(UInt32 renderMask);
|
||||
|
|
@ -61,6 +63,7 @@ namespace Nz
|
|||
NazaraSlot(RenderTarget, OnRenderTargetSizeChange, m_onRenderTargetSizeChange);
|
||||
|
||||
const RenderTarget* m_renderTarget;
|
||||
Color m_clearColor;
|
||||
DegreeAnglef m_fov;
|
||||
ProjectionType m_projectionType;
|
||||
Rectf m_targetRegion;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace Nz
|
|||
{
|
||||
inline Camera::Camera(const RenderTarget* renderTarget, ProjectionType projectionType) :
|
||||
m_renderTarget(nullptr),
|
||||
m_clearColor(Color::Black),
|
||||
m_fov(70.f),
|
||||
m_projectionType(projectionType),
|
||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||
|
|
@ -24,6 +25,7 @@ namespace Nz
|
|||
|
||||
inline Camera::Camera(const Camera& camera) :
|
||||
m_renderTarget(nullptr),
|
||||
m_clearColor(camera.m_clearColor),
|
||||
m_fov(camera.m_fov),
|
||||
m_projectionType(camera.m_projectionType),
|
||||
m_targetRegion(camera.m_targetRegion),
|
||||
|
|
@ -39,6 +41,7 @@ namespace Nz
|
|||
|
||||
inline Camera::Camera(Camera&& camera) noexcept :
|
||||
m_renderTarget(nullptr),
|
||||
m_clearColor(camera.m_clearColor),
|
||||
m_fov(camera.m_fov),
|
||||
m_projectionType(camera.m_projectionType),
|
||||
m_targetRegion(camera.m_targetRegion),
|
||||
|
|
@ -82,6 +85,11 @@ namespace Nz
|
|||
return m_zNear;
|
||||
}
|
||||
|
||||
inline void Camera::UpdateClearColor(Color color)
|
||||
{
|
||||
m_clearColor = color;
|
||||
}
|
||||
|
||||
inline void Camera::UpdateFOV(DegreeAnglef fov)
|
||||
{
|
||||
m_fov = fov;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace Nz
|
|||
builder.TextureBarrier(textureTransition.srcStageMask, textureTransition.dstStageMask, textureTransition.srcAccessMask, textureTransition.dstAccessMask, textureTransition.oldLayout, textureTransition.newLayout, *texture);
|
||||
}
|
||||
|
||||
builder.BeginRenderPass(*passData.framebuffer, *passData.renderPass, passData.renderRect);
|
||||
builder.BeginRenderPass(*passData.framebuffer, *passData.renderPass, passData.renderRect, passData.outputClearValues.data(), passData.outputClearValues.size());
|
||||
|
||||
if (!passData.name.empty())
|
||||
builder.BeginDebugRegion(passData.name, Color::Green);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
const Color& Camera::GetClearColor() const
|
||||
{
|
||||
return m_clearColor;
|
||||
}
|
||||
|
||||
UInt32 Camera::GetRenderMask() const
|
||||
{
|
||||
return m_renderMask;
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ namespace Nz
|
|||
forwardPass.SetDepthStencilInput(viewerData.depthStencilAttachment);
|
||||
//forwardPass.SetDepthStencilOutput(viewerData.depthStencilAttachment);
|
||||
|
||||
forwardPass.SetClearColor(0, Color::Black);
|
||||
forwardPass.SetClearColor(0, viewer->GetClearColor());
|
||||
forwardPass.SetDepthStencilClear(1.f, 0);
|
||||
|
||||
forwardPass.SetExecutionCallback([&]()
|
||||
|
|
|
|||
Loading…
Reference in New Issue