NAP
colordepthrendertarget.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 #include "rendertexture2d.h"
10 #include "texturelink.h"
11 
12 // External Includes
13 #include <nap/resource.h>
14 #include <nap/resourceptr.h>
15 #include <vulkan/vulkan_core.h>
16 
17 namespace nap
18 {
19  // Forward Declares
20  class RenderTexture2D;
21  class RenderService;
22 
48  class NAPAPI ColorDepthRenderTarget : public Resource, public IRenderTarget
49  {
50  RTTI_ENABLE(Resource)
51  public:
57 
62 
68  virtual bool init(utility::ErrorState& errorState) override;
69 
88  virtual void beginRendering() override;
89 
107  virtual void endRendering() override;
108 
112  virtual const glm::ivec2 getBufferSize() const override;
113 
118  virtual void setClearColor(const RGBAColorFloat& color) override { mClearColor = color; }
119 
123  virtual const RGBAColorFloat& getClearColor() const override { return mClearColor; }
124 
129 
133  virtual VkRenderPass getRenderPass() const override { return mRenderPass; }
134 
138  RenderTexture2D& getColorTexture();
139 
145  DepthRenderTexture2D& getDepthTexture();
146 
150  virtual VkFormat getColorFormat() const override;
151 
155  virtual VkFormat getDepthFormat() const override;
156 
160  virtual VkSampleCountFlagBits getSampleCount() const override;
161 
165  virtual bool getSampleShadingEnabled() const override;
166 
170  virtual VkImageLayout getFinalLayout() const override { return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; }
171 
172  public:
173  bool mSampleShading = true;
174  RGBAColorFloat mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
175  float mClearDepth = 1.0f;
179 
180  private:
181  RenderService* mRenderService;
182  VkFramebuffer mFramebuffer = VK_NULL_HANDLE;
183  VkRenderPass mRenderPass = VK_NULL_HANDLE;
184  VkSampleCountFlagBits mRasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
185  ImageData mDepthImage;
186  ImageData mColorImage;
187  Texture2DTargetLink mTextureLink;
188  };
189 }
nap::ECullWindingOrder::Clockwise
@ Clockwise
nap::ColorDepthRenderTarget::setClearColor
virtual void setClearColor(const RGBAColorFloat &color) override
Definition: colordepthrendertarget.h:118
nap::IRenderTarget
Definition: irendertarget.h:21
nap::ColorDepthRenderTarget::getClearColor
virtual const RGBAColorFloat & getClearColor() const override
Definition: colordepthrendertarget.h:123
nap::DepthRenderTexture2D
Definition: rendertexture2d.h:67
nap::ERasterizationSamples::One
@ One
nap::ERasterizationSamples
ERasterizationSamples
Definition: renderutils.h:25
nap::RGBAColor< float >
nap::ColorDepthRenderTarget::getFinalLayout
virtual VkImageLayout getFinalLayout() const override
Definition: colordepthrendertarget.h:170
nap::rtti::ObjectPtr
Definition: objectptr.h:150
nap::ECullWindingOrder
ECullWindingOrder
Definition: materialcommon.h:30
nap::utility::ErrorState
Definition: errorstate.h:19
nap::ColorDepthRenderTarget::getWindingOrder
virtual ECullWindingOrder getWindingOrder() const override
Definition: colordepthrendertarget.h:128
nap::ImageData
Definition: imagedata.h:23
nap::RenderService
Definition: renderservice.h:198
nap::Core
Definition: core.h:82
nap
Definition: templateapp.h:17
nap::Resource
Definition: resource.h:19
nap::ColorDepthRenderTarget::mDepthTexture
ResourcePtr< DepthRenderTexture2D > mDepthTexture
Property: 'DepthTexture' depth texture to render to.
Definition: colordepthrendertarget.h:178
nap::ColorDepthRenderTarget::mColorTexture
ResourcePtr< RenderTexture2D > mColorTexture
Property: 'ColorTexture' color texture to render to.
Definition: colordepthrendertarget.h:177
nap::ColorDepthRenderTarget
Definition: colordepthrendertarget.h:48
nap::ColorDepthRenderTarget::getRenderPass
virtual VkRenderPass getRenderPass() const override
Definition: colordepthrendertarget.h:133
nap::RenderTexture2D
Definition: rendertexture2d.h:24