SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
DepthStencilState.h
1#pragma once
2
3#include "spark/render/Export.h"
4
5#include <memory>
6
7namespace spark::render
8{
13 enum class CompareOperation
14 {
16 Never = 0x00000000,
17
19 Less = 0x00000001,
20
22 Greater = 0x0000002,
23
25 Equal = 0x00000003,
26
28 LessEqual = 0x00000004,
29
31 GreaterEqual = 0x00000005,
32
34 NotEqual = 0x00000006,
35
37 Always = 0x00000007
38 };
39
44 enum class StencilOperation
45 {
47 Keep = 0x00000000,
48
50 Zero = 0x00000001,
51
53 Replace = 0x00000002,
54
56 IncrementClamp = 0x00000003,
57
59 DecrementClamp = 0x00000004,
60
62 Invert = 0x00000005,
63
65 IncrementWrap = 0x00000006,
66
68 DecrementWrap = 0x00000007
69 };
70
74 class SPARK_RENDER_EXPORT DepthStencilState final
75 {
76 public:
81 {
82 public:
84 bool enable = true;
85
87 bool write = true;
88
90 CompareOperation operation = CompareOperation::Always;
91 };
92
101 {
102 public:
104 bool enable = false;
105
107 float clamp = 0.f;
108
110 float slopeFactor = 0.f;
111
113 float constantFactor = 0.f;
114 };
115
120 {
121 public:
123 StencilOperation stencilFailOp = StencilOperation::Keep;
124
126 StencilOperation stencilPassOp = StencilOperation::Replace;
127
129 StencilOperation depthFailOp = StencilOperation::Keep;
130
132 CompareOperation operation = CompareOperation::Never;
133 };
134
139 {
140 public:
142 bool enable = false;
143
145 unsigned char writeMask = 0xFF;
146
148 unsigned char readMask = 0xFF;
149
151 StencilTest frontFace = {};
152
154 StencilTest backFace = {};
155 };
156
157 public:
161 explicit DepthStencilState() noexcept;
162
169 explicit DepthStencilState(const DepthState& depth_state, const DepthBias& depth_bias, const StencilState& stencil_state) noexcept;
170 ~DepthStencilState() noexcept;
171
173 DepthStencilState(DepthStencilState&& other) noexcept;
174 DepthStencilState& operator=(const DepthStencilState& other);
175 DepthStencilState& operator=(DepthStencilState&& other) noexcept;
176
181 [[nodiscard]] DepthState& depthState() const noexcept;
182
187 [[nodiscard]] DepthBias& depthBias() const noexcept;
188
193 [[nodiscard]] StencilState& stencilState() const noexcept;
194
195 private:
196 struct Impl;
197 std::unique_ptr<Impl> m_impl;
198 };
199}
Stores the depth/stencil state of a see IRasterizer.
Definition DepthStencilState.h:75
Describes the rasterizer depth bias.
Definition DepthStencilState.h:101
Describes the depth test state.
Definition DepthStencilState.h:81
Describes the rasterizer stencil state.
Definition DepthStencilState.h:139
Describes a stencil test for either front or back faces.
Definition DepthStencilState.h:120