3#include "spark/render/Export.h"
4#include "spark/render/Format.h"
6#include "spark/base/Macros.h"
7#include "spark/math/Vector4.h"
12namespace spark::render
17 enum class RenderTargetType
23 DepthStencil = 0x00000002,
33 enum class BlendFactor
38 OneMinusSourceColor = 3,
40 OneMinusDestinationColor = 5,
42 OneMinusSourceAlpha = 7,
44 OneMinusDestinationAlpha = 9,
46 OneMinusConstantColor = 11,
48 OneMinusConstantAlpha = 13,
49 SourceAlphaSaturate = 14,
51 OneMinusSource1Color = 16,
53 OneMinusSource1Alpha = 18
74 SPARK_DEFINE_ENUM_FLAGS(WriteMask)
79 enum class BlendOperation
83 ReverseSubtract = 0x03,
108 BlendFactor sourceColor {BlendFactor::One};
111 BlendFactor destinationColor {BlendFactor::Zero};
114 BlendFactor sourceAlpha {BlendFactor::One};
117 BlendFactor destinationAlpha {BlendFactor::Zero};
120 BlendOperation colorOperation {BlendOperation::Add};
123 BlendOperation alphaOperation {BlendOperation::Add};
126 WriteMask writeMask {WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A};
133 [[nodiscard]]
virtual std::string
name() const noexcept = 0;
142 [[nodiscard]] virtual
unsigned int location() const noexcept = 0;
148 [[nodiscard]] virtual RenderTargetType type() const noexcept = 0;
154 [[nodiscard]] virtual Format format() const noexcept = 0;
161 virtual
bool clearBuffer() const noexcept = 0;
168 virtual
bool clearStencil() const noexcept = 0;
177 [[nodiscard]] virtual math::Vector4<
float> clearValues() const noexcept = 0;
188 [[nodiscard]] virtual
bool isVolatile() const noexcept = 0;
194 [[nodiscard]] virtual
BlendState blendState() const noexcept = 0;
220 RenderTargetType type,
223 const math::Vector4<
float>& clear_values = {0.f, 0.f, 0.f, 0.f},
224 bool clear_stencil =
true,
225 bool is_volatile =
false,
226 const BlendState& blend_state = {});
241 unsigned int location,
242 RenderTargetType type,
246 bool clear_stencil =
true,
247 bool is_volatile =
false,
248 const BlendState& blend_state = {});
249 ~RenderTarget() noexcept override;
251 RenderTarget(const RenderTarget& other);
252 RenderTarget(RenderTarget&& other) noexcept;
253 RenderTarget& operator=(const RenderTarget& other);
254 RenderTarget& operator=(RenderTarget&& other) noexcept;
257 [[nodiscard]] std::
string name() const noexcept override;
260 [[nodiscard]]
unsigned location() const noexcept override;
263 [[nodiscard]] RenderTargetType type() const noexcept override;
266 [[nodiscard]] Format format() const noexcept override;
269 bool clearBuffer() const noexcept override;
272 bool clearStencil() const noexcept override;
275 [[nodiscard]] math::Vector4<
float> clearValues() const noexcept override;
278 [[nodiscard]]
bool isVolatile() const noexcept override;
281 [[nodiscard]] BlendState blendState() const noexcept override;
285 std::unique_ptr<Impl> m_impl;
A vector with four components.
Definition Vector4.h:13
Represents a render target, which is an abstract view of the output of a RenderPass....
Definition RenderTarget.h:94
virtual std::string name() const noexcept=0
Gets the name of the render target.
Implements a IRenderTarget.
Definition RenderTarget.h:201
RenderTarget(const std::string &name, unsigned int location, RenderTargetType type, Format format, bool clear_buffer, const math::Vector4< float > &clear_values={0.f, 0.f, 0.f, 0.f}, bool clear_stencil=true, bool is_volatile=false, const BlendState &blend_state={})
Initializes the RenderTarget.
RenderTarget() noexcept
Initializes a default RenderTarget.
Describes the blend state of a render target.
Definition RenderTarget.h:102