You.i Engine
YiRenderTarget.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_RENDER_TARGET_H_
3 #define _YI_RENDER_TARGET_H_
4 
6 #include "renderer/YiViewport.h"
7 #include "utility/YiColor.h"
9 
10 #include <glm/fwd.hpp>
11 #include <memory>
12 
15 
52 {
53  friend class CYISceneBuilder;
54 
55 public:
56  enum class Attribute
57  {
58  None = 0x00,
59  ClearColorBuffer = 0x01,
60  ClearDepthBuffer = 0x02,
61  ClearAll = ClearColorBuffer | ClearDepthBuffer // The rest should go 4, 8, 16, etc...
62  };
63 
67  enum class Type
68  {
69  Screen = 1,
70  OffscreenColorOnly,
71  OffscreenDepthOnly,
72  OffscreenColorAndDepth
73  };
74 
84  static std::unique_ptr<CYIScreenRenderTarget> CreateScreenTarget(const CYIViewport &viewport);
85 
96  static std::unique_ptr<CYIOffscreenRenderTarget> CreateOffscreenTarget(Type targetType, uint32_t targetWidth, uint32_t targetHeight);
97 
98  virtual ~CYIRenderTarget();
99 
109  void SetViewport(const CYIViewport &viewport);
110 
114  const CYIViewport &GetViewport() const;
115 
119  std::shared_ptr<IYIGPUObject> GetFramebuffer() const;
120 
124  std::shared_ptr<CYIAssetFramebuffer> GetFramebufferAsset() const;
125 
129  Type GetTargetType() const;
130 
138  void SetDeviceHorizontalPixelRatio(float devicePixelRatio);
139 
147  void SetDeviceVerticalPixelRatio(float devicePixelRatio);
148 
156  void SetDeviceDiagonalPixelRatio(float devicePixelRatio);
157 
165  float GetDeviceHorizontalPixelRatio() const;
166 
174  float GetDeviceVerticalPixelRatio() const;
175 
183  float GetDeviceDiagonalPixelRatio() const;
184 
188  void SetClearColor(const CYIColor &clearColor);
189 
193  const CYIColor &GetClearColor() const;
194 
198  void SetAttribute(Attribute attribute, bool value);
199  bool GetAttribute(Attribute attribute) const;
200 
201 protected:
202  CYIRenderTarget();
203 
204  std::shared_ptr<CYIAssetFramebuffer> m_pFramebuffer;
205 
206 private:
207  float m_deviceHorizontalPixelRatio;
208  float m_deviceVerticalPixelRatio;
209  float m_deviceDiagonalPixelRatio;
210 
211  CYIViewport m_Viewport;
212  CYIColor m_ClearColor;
213 
214  Type m_Type;
215 
216  Attribute m_AttributeFlags;
217 
219 };
220 
223 template<>
225 {
226  static const bool enable = true;
227 };
228 
229 #endif // _YI_RENDER_TARGET_H_
void SetViewport(const CYIViewport &viewport)
float GetDeviceDiagonalPixelRatio() const
std::shared_ptr< CYIAssetFramebuffer > m_pFramebuffer
Definition: YiRenderTarget.h:204
const CYIViewport & GetViewport() const
static std::unique_ptr< CYIScreenRenderTarget > CreateScreenTarget(const CYIViewport &viewport)
float GetDeviceVerticalPixelRatio() const
static std::unique_ptr< CYIOffscreenRenderTarget > CreateOffscreenTarget(Type targetType, uint32_t targetWidth, uint32_t targetHeight)
bool GetAttribute(Attribute attribute) const
void SetDeviceDiagonalPixelRatio(float devicePixelRatio)
A struct used to enable bitmask operators for an enum class type.
Definition: YiEnumBitmaskOperators.h:26
void SetClearColor(const CYIColor &clearColor)
float GetDeviceHorizontalPixelRatio() const
void SetDeviceVerticalPixelRatio(float devicePixelRatio)
Definition: YiViewport.h:12
Type GetTargetType() const
Defines a target for the rendering results to be sent to.
Definition: YiRenderTarget.h:51
Attribute
Definition: YiRenderTarget.h:56
std::shared_ptr< CYIAssetFramebuffer > GetFramebufferAsset() const
Type
Definition: YiRenderTarget.h:67
Defines an offscreen target for the rendering results to be sent to.
Definition: YiOffscreenRenderTarget.h:26
Definition: YiSceneBuilder.h:22
std::shared_ptr< IYIGPUObject > GetFramebuffer() const
Definition: YiScreenRenderTarget.h:17
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
A class used to represent a color value.
Definition: YiColor.h:31
const CYIColor & GetClearColor() const
void SetDeviceHorizontalPixelRatio(float devicePixelRatio)
void SetAttribute(Attribute attribute, bool value)
virtual ~CYIRenderTarget()