NAP
depthrendertarget.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "irendertarget.h"
9 
10 // External Includes
11 #include <nap/resource.h>
12 #include <nap/resourceptr.h>
13 #include <vulkan/vulkan_core.h>
14 
15 namespace nap
16 {
17  // Forward Declares
18  class DepthRenderTexture2D;
19  class RenderService;
20 
49  class NAPAPI DepthRenderTarget : public Resource, public IRenderTarget
50  {
51  RTTI_ENABLE(Resource)
52  public:
57  DepthRenderTarget(Core& core);
58 
63 
69  virtual bool init(utility::ErrorState& errorState) override;
70 
89  virtual void beginRendering() override;
90 
108  virtual void endRendering() override;
109 
113  virtual const glm::ivec2 getBufferSize() const override;
114 
119  virtual void setClearColor(const RGBAColorFloat& color) override { mClearValue = color.getRed(); }
120 
124  virtual const RGBAColorFloat& getClearColor() const override { return mClearColor; }
125 
130 
134  virtual VkRenderPass getRenderPass() const override { return mRenderPass; }
135 
139  virtual VkSampleCountFlagBits getSampleCount() const override { return VK_SAMPLE_COUNT_1_BIT; }
140 
144  virtual bool getSampleShadingEnabled() const override { return false; };
145 
149  virtual VkFormat getColorFormat() const override { return VK_FORMAT_UNDEFINED; }
150 
154  virtual VkFormat getDepthFormat() const override;
155 
159  DepthRenderTexture2D& getDepthTexture();
160 
161  public:
162  float mClearValue = 1.0f;
163  bool mSampleShading = true;
166 
167  private:
168  RenderService* mRenderService;
169  VkFramebuffer mFramebuffer = VK_NULL_HANDLE;
170  VkRenderPass mRenderPass = VK_NULL_HANDLE;
171  VkSampleCountFlagBits mRasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
172  RGBAColorFloat mClearColor = { 1.0f, 1.0f, 1.0f, 1.0f };
173  };
174 }
nap::ECullWindingOrder::Clockwise
@ Clockwise
nap::IRenderTarget
Definition: irendertarget.h:21
nap::DepthRenderTarget::getRenderPass
virtual VkRenderPass getRenderPass() const override
Definition: depthrendertarget.h:134
nap::DepthRenderTarget::getSampleShadingEnabled
virtual bool getSampleShadingEnabled() const override
Definition: depthrendertarget.h:144
nap::DepthRenderTexture2D
Definition: rendertexture2d.h:69
nap::ERasterizationSamples::One
@ One
nap::ERasterizationSamples
ERasterizationSamples
Definition: renderutils.h:25
nap::RGBAColor< float >
nap::rtti::ObjectPtr
Definition: objectptr.h:154
nap::ECullWindingOrder
ECullWindingOrder
Definition: materialcommon.h:30
nap::utility::ErrorState
Definition: errorstate.h:19
nap::DepthRenderTarget::getSampleCount
virtual VkSampleCountFlagBits getSampleCount() const override
Definition: depthrendertarget.h:139
nap::DepthRenderTarget::mDepthTexture
ResourcePtr< DepthRenderTexture2D > mDepthTexture
Property: 'DepthTexture' depth texture to render to.
Definition: depthrendertarget.h:165
nap::DepthRenderTarget
Definition: depthrendertarget.h:49
nap::DepthRenderTarget::getWindingOrder
virtual ECullWindingOrder getWindingOrder() const override
Definition: depthrendertarget.h:129
nap::DepthRenderTarget::getClearColor
virtual const RGBAColorFloat & getClearColor() const override
Definition: depthrendertarget.h:124
nap::DepthRenderTarget::setClearColor
virtual void setClearColor(const RGBAColorFloat &color) override
Definition: depthrendertarget.h:119
nap::RenderService
Definition: renderservice.h:275
nap::Core
Definition: core.h:82
nap::DepthRenderTarget::getColorFormat
virtual VkFormat getColorFormat() const override
Definition: depthrendertarget.h:149
nap
Definition: templateapp.h:17
nap::Resource
Definition: resource.h:19