Cumulia Illustrator Rendering Engine v1.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
state.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2024-10-31
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20#include "../variant/image.h"
21#include "../object/object.h"
22#include "sampler.h"
23
24#include <memory>
25#include <vector>
26#include <map>
27
28namespace cil
29{
31 class State : public Object
32 {
33 protected:
34 std::string m_className;
35
36 public:
38
39 const std::string& className() const;
40 };
41
86
88 class ColorMask : public State
89 {
90 public:
91 bool red;
92 bool green;
93 bool blue;
94 bool alpha;
95
96 ColorMask(bool red = true,
97 bool green = true,
98 bool blue = true,
99 bool alpha = true);
100 };
101
103 class Culling : public State
104 {
105 public:
107 enum class Mode
108 {
109 BACK,
110 FRONT,
112 };
114 enum class Face
115 {
116 CCW,
117 CW
118 };
119
123
124 Culling(bool enabled = false,
127 };
128
130 class Depth : public State
131 {
132 public:
135 enum class Function
136 {
137 NEVER,
138 LESS,
139 LEQUAL,
140 EQUAL,
141 NOTEQUAL,
142 GEQUAL,
143 GREATER,
144 ALWAYS
145 };
146
147 bool enabled;
150
151 Depth(bool enabled = false,
153 bool writeMask = true);
154 };
155
157 class Line : public State
158 {
159 public:
160 float width;
161
162 Line(float width = 1.0f);
163 };
164
166 class Point : public State
167 {
168 public:
169 float size;
171
172 Point(float size = 1.0f,
173 bool programmable = false);
174 };
175
177 class Polygon : public State
178 {
179 public:
180 enum class Mode
181 {
182 POINT,
183 LINE,
184 FILL
185 };
186
188
190 };
191
193 class PolygonOffset : public State
194 {
195 public:
197 float factor;
198 float units;
199
200 PolygonOffset(bool enabled = false,
201 float factor = 0.0f,
202 float units = 0.0f);
203 };
204
206 class Scissor : public State
207 {
208 public:
210 int x;
211 int y;
212 int width;
214
215 Scissor(bool enabled = false,
216 int x = 0,
217 int y = 0,
218 int width = 0,
219 int height = 0);
220 };
221
223 class Stencil : public State
224 {
225 public:
226
229 enum class Function
230 {
231 NEVER,
232 LESS,
233 LEQUAL,
234 EQUAL,
235 NOTEQUAL,
236 GEQUAL,
237 GREATER,
238 ALWAYS
239 };
240
242 enum class Operation
243 {
244 KEEP,
245 ZERO,
246 REPLACE,
247 INCR,
248 DECR,
249 INVERT,
250 INCR_WRAP,
252 };
253
255
259
261 int ref;
262 int mask;
263
264 Stencil(bool enabled = false,
269 int ref = 0,
270 int mask = 0xFF);
271 };
272
274 class Texture : public State
275 {
276 public:
277 int unit;
278 std::shared_ptr<Image> image;
279 std::shared_ptr<Sampler> sampler;
280
282 std::shared_ptr<Image> image,
283 std::shared_ptr<Sampler> sampler);
284 };
285}
The Blend class inherits from the State class, describing the blending operation during rendering tra...
Definition state.h:44
Function dstFunc
Definition state.h:78
Function srcFunc
Definition state.h:77
bool enabled
This member allows you to enable/diable blending.
Definition state.h:76
Function
The factors in this enumeration specify how the source and destination color values are combined duri...
Definition state.h:48
Equation
This enumeration defines different operations used in the blend equation. These operations determine ...
Definition state.h:68
Blend(bool enabled=false, Blend::Function srcFunc=Blend::Function::SRC_ALPHA, Blend::Function dstFunc=Blend::Function::ONE_MINUS_SRC_ALPHA, Blend::Equation equation=Blend::Equation::FUNC_ADD)
Equation equation
Definition state.h:79
The ColorMask class represents the color channel writing during rendering.
Definition state.h:89
bool green
Similar to red.
Definition state.h:92
bool alpha
Similar to red.
Definition state.h:94
bool red
This flag determines whether the red color channel is written to the framebuffer.
Definition state.h:91
ColorMask(bool red=true, bool green=true, bool blue=true, bool alpha=true)
bool blue
Similar to red.
Definition state.h:93
The Culling class inherits from the base class State, describing the culling operation during renderi...
Definition state.h:104
Mode
The enumeration defines the type of the face we want to cull.
Definition state.h:108
Mode mode
Definition state.h:122
Face face
Definition state.h:121
Culling(bool enabled=false, Culling::Face face=Culling::Face::CCW, Culling::Mode mode=Culling::Mode::BACK)
Face
The enumeration defines the ordering (counter-clockwise and clockwise) of the front-faces or the back...
Definition state.h:115
bool enabled
Definition state.h:120
The Depth class inherits from the base class State, describing how the depth test is operated during ...
Definition state.h:131
Depth(bool enabled=false, Depth::Function func=Depth::Function::LESS, bool writeMask=true)
Function
This enumeration defines different comparison operators used for the depth test.
Definition state.h:136
Function func
Definition state.h:148
bool writeMask
Definition state.h:149
bool enabled
This member allows you to enable/diable depth test.
Definition state.h:147
The Line class inherits from the base class State, defining width of Line.
Definition state.h:158
float width
Definition state.h:160
Line(float width=1.0f)
Definition object.h:23
The Point class inherits from the base class State, defining size and other properties of Point.
Definition state.h:167
bool programmable
Definition state.h:170
Point(float size=1.0f, bool programmable=false)
float size
Definition state.h:169
The PolygonOffset class inherits from the base class State, defining the polygon offset.
Definition state.h:194
PolygonOffset(bool enabled=false, float factor=0.0f, float units=0.0f)
float units
Definition state.h:198
bool enabled
Definition state.h:196
float factor
Definition state.h:197
The Polygon class inherits from the base class State, defining mode of Polygon.
Definition state.h:178
Polygon(Mode mode=Polygon::Mode::FILL)
Mode
Definition state.h:181
Mode mode
Definition state.h:187
The Scissor class inherits from the base class State, defining a scissor test that discards fragments...
Definition state.h:207
Scissor(bool enabled=false, int x=0, int y=0, int width=0, int height=0)
int height
Definition state.h:213
int y
Definition state.h:211
bool enabled
Definition state.h:209
int x
Definition state.h:210
int width
Definition state.h:212
The State class is a basic class representing the rendering state setting.
Definition state.h:32
std::string m_className
Definition state.h:34
const std::string & className() const
The Stencil class inherits from the base class State, describing how the stencil test is operated dur...
Definition state.h:224
Operation dpfail
Action to take if the stencil test passes, but the depth test fails.
Definition state.h:257
Operation dppass
Action to take if both the stencil and the depth test pass.
Definition state.h:258
bool enabled
Definition state.h:254
Operation sfail
Action to take if the stencil test fails.
Definition state.h:256
Function func
Definition state.h:260
int mask
Definition state.h:262
Function
This enumeration defines different comparison operators used for the stencil test.
Definition state.h:230
Stencil(bool enabled=false, Stencil::Operation sfail=Stencil::Operation::KEEP, Stencil::Operation dpfail=Stencil::Operation::KEEP, Stencil::Operation dppass=Stencil::Operation::KEEP, Stencil::Function func=Stencil::Function::ALWAYS, int ref=0, int mask=0xFF)
int ref
This member specifies the reference value for the stencil test.
Definition state.h:261
Operation
This enumeration defines how to update the stencil buffer after the stencil test.
Definition state.h:243
The Texture class defines the texture image and sampling behaviour when you need to map a texture to ...
Definition state.h:275
std::shared_ptr< Sampler > sampler
Definition state.h:279
int unit
Definition state.h:277
Texture(int unit, std::shared_ptr< Image > image, std::shared_ptr< Sampler > sampler)
std::shared_ptr< Image > image
Definition state.h:278
Definition decal.h:23