Cumulia Illustrator Rendering Engine v2.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
primitivemaker.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 2025-08-05
15// Version V2.1.0
16//##################################################################################################
17
18#pragma once
19
20#include "variantmaker.h"
21#include "../variant/types.h"
22#include "../primitive/types.h"
23#include "../primitive/indices.h"
24#include "../primitive/sampler.h"
25#include "../primitive/state.h"
26
27#include <memory>
28#include <map>
29
30namespace cil
31{
32 // _indices
33 ArrayIndicesPtr _arrayIndices(Indices::Mode mode, int count, int first = 0, int primCount = 0);
34 ArrayIndicesPtr _triangles(int count, int first = 0, int primCount = 0);
35 ArrayIndicesPtr _triangle_fan(int count, int first = 0, int primCount = 0);
36 ArrayIndicesPtr _triangle_strip(int count, int first = 0, int primCount = 0);
37 ArrayIndicesPtr _lines(int count, int first = 0, int primCount = 0);
38 ArrayIndicesPtr _line_strip(int count, int first = 0, int primCount = 0);
39 ArrayIndicesPtr _line_loop(int count, int first = 0, int primCount = 0);
40 ArrayIndicesPtr _points(int count, int first = 0, int primCount = 0);
41
42 ElementIndicesPtr _elementIndices(Indices::Mode mode, const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
43 ElementIndicesPtr _elementIndices(Indices::Mode mode, const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
44 ElementIndicesPtr _elementIndices(Indices::Mode mode, const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
45
46 ElementIndicesPtr _triangles(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
47 ElementIndicesPtr _triangles(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
48 ElementIndicesPtr _triangles(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
49 ElementIndicesPtr _triangles(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
50
51 ElementIndicesPtr _triangle_fan(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
52 ElementIndicesPtr _triangle_fan(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
53 ElementIndicesPtr _triangle_fan(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
54 ElementIndicesPtr _triangle_fan(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
55
56 ElementIndicesPtr _triangle_strip(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
57 ElementIndicesPtr _triangle_strip(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
58 ElementIndicesPtr _triangle_strip(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
59 ElementIndicesPtr _triangle_strip(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
60
61 ElementIndicesPtr _lines(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
62 ElementIndicesPtr _lines(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
63 ElementIndicesPtr _lines(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
64 ElementIndicesPtr _lines(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
65
66 ElementIndicesPtr _line_strip(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
67 ElementIndicesPtr _line_strip(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
68 ElementIndicesPtr _line_strip(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
69 ElementIndicesPtr _line_strip(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
70
71 ElementIndicesPtr _line_loop(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
72 ElementIndicesPtr _line_loop(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
73 ElementIndicesPtr _line_loop(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
74 ElementIndicesPtr _line_loop(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
75
76 ElementIndicesPtr _points(const Uint8ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
77 ElementIndicesPtr _points(const Uint16ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
78 ElementIndicesPtr _points(const Uint32ArrayPtr& buffer, int count = -1, int offset = 0, int primCount = 0);
79 ElementIndicesPtr _points(const std::initializer_list<unsigned int>& array, int count = -1, int offset = 0, int primCount = 0);
80
81 // _vertices
82 VerticesPtr _vertices(const Float32ArrayPtr& buffer, int offset = 0, unsigned int stride = 0, unsigned int divisor = 0);
83 VerticesPtr _vertices(const Int32ArrayPtr& buffer, int offset = 0, unsigned int stride = 0, unsigned int divisor = 0);
84 VerticesPtr _vertices(const std::initializer_list<float>& array, int offset = 0, unsigned int stride = 0, unsigned int divisor = 0);
85
86 // _verticesSet
87 std::shared_ptr<std::map<std::string, VerticesPtr>> _verticesSet(const std::map<std::string, VerticesPtr>& verticesMap = {});
88
89 // _geometry
90 GeometryPtr _geometry(const std::shared_ptr<std::map<std::string, VerticesPtr>>& verticesSet = _verticesSet(),
91 const IndicesPtr& indices = nullptr,
92 const BoundingBoxPtr& boundingBox = nullptr);
93 GeometryPtr _geometry(std::map<std::string, VerticesPtr> verticesSet,
94 const IndicesPtr& indices = nullptr,
95 const BoundingBoxPtr& boundingBox = nullptr);
97 const BoundingBoxPtr& boundingBox = nullptr);
98
99 // _blend
100 BlendPtr _blend(bool enabled = false,
104
105 // _colorMask
106 ColorMaskPtr _colorMask(bool red = true,
107 bool green = true,
108 bool blue = true,
109 bool alpha = true);
110
111 // _culling
112 CullingPtr _culling(bool enabled = false,
115
116 // _depth
117 DepthPtr _depth(bool enabled = false,
119 bool writeMask = true);
120
121 // _line
122 LinePtr _line(float width = 1.0f);
123
124 // _point
125 PointPtr _point(float size = 1.0f,
126 bool programmable = false);
127
128 // _polygon
130
131 // _polygonOffset
132 PolygonOffsetPtr _polygonOffset(bool enabled = false,
133 float factor = 0.0f,
134 float units = 0.0f);
135
136 // _scissor
137 ScissorPtr _scissor(bool enabled = false,
138 int x = 0,
139 int y = 0,
140 int width = 0,
141 int height = 0);
142
143 // _stencil
144 StencilPtr _stencil(bool enabled = false,
149 int ref = 0,
150 int mask = 0xFF);
151
152 // _sampler
162
163 // _texture
165 const ImagePtr& image,
166 const SamplerPtr& sampler = nullptr);
167 TexturePtr _texture0(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
168 TexturePtr _texture1(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
169 TexturePtr _texture2(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
170 TexturePtr _texture3(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
171 TexturePtr _texture4(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
172 TexturePtr _texture5(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
173 TexturePtr _texture6(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
174 TexturePtr _texture7(const ImagePtr& image, const SamplerPtr& sampler = nullptr);
175
176 // _program
178 const VertexSourcePtr& vertex = nullptr,
179 const FragmentSourcePtr& fragment = nullptr,
180 const GeometrySourcePtr& geometry = nullptr);
182 const FragmentSourcePtr& fragment,
183 const GeometrySourcePtr& geometry = nullptr);
185 const GeometrySourcePtr& geometry);
186 ProgramPtr _program(const std::string& vertexString);
187 ProgramPtr _program(const std::string& vertexString, const std::string& fragmentString);
188 ProgramPtr _program(const std::string& vertexString, const std::string& fragmentString, const std::string& geometryString);
189
190 // _parameters
191 std::shared_ptr<std::map<std::string, VariantPtr>> _parameters(const std::map<std::string, VariantPtr>& parameters = {});
192
193 // _states
194 std::shared_ptr<std::vector<StatePtr>> _states(const std::vector<StatePtr>& states = {});
195
196 // _material
198 const ProgramPtr& program = nullptr,
199 const std::shared_ptr<std::map<std::string, VariantPtr>>& parameters = nullptr,
200 const std::shared_ptr<std::vector<StatePtr>>& states = nullptr);
202 const ProgramPtr& program,
203 const std::shared_ptr<std::vector<StatePtr>>& states);
205 const std::shared_ptr<std::map<std::string, VariantPtr>>& parameters,
206 const std::shared_ptr<std::vector<StatePtr>>& states = nullptr);
207
209 const std::vector<SourcePtr>& sources,
210 const std::map<std::string, VariantPtr>& parameters,
211 const std::vector<StatePtr>& states);
213 const std::vector<SourcePtr>& sources,
214 const std::map<std::string, VariantPtr>& parameters);
216 const std::vector<SourcePtr>& sources,
217 const std::vector<StatePtr>& states);
219 const std::vector<SourcePtr>& sources);
220
222 const ProgramPtr& program,
223 const std::map<std::string, VariantPtr>& parameters,
224 const std::vector<StatePtr>& states);
226 const ProgramPtr& program,
227 const std::map<std::string, VariantPtr>& parameters);
229 const ProgramPtr& program,
230 const std::vector<StatePtr>& states);
232 const std::map<std::string, VariantPtr>& parameters,
233 const std::vector<StatePtr>& states);
235 const std::map<std::string, VariantPtr>& parameters);
237 const std::vector<StatePtr>& states);
238
239 // _background
241 const Color4fPtr& colorMask = nullptr,
242 const RealPtr& depthMask = nullptr,
243 const IntegerPtr& stencilMask = nullptr,
244 const Vector2iPtr& coordinate = _ivec2());
246 const Color4fPtr& colorMask = _clr4(0.7, 0.7, 0.7, 1.0),
247 const RealPtr& depthMask = _real(1.0),
248 const IntegerPtr& stencilMask = nullptr,
249 const Vector2iPtr& coordinate = _ivec2());
250
251 // _colorBuf
253
254 // _target
256 TargetPtr _target(const std::vector<ImageBufferPtr>& array);
257
258 // _primitive
260 const GeometryPtr& geometry = nullptr,
261 const MaterialPtr& material = nullptr,
262 int priority = 0);
264 const MaterialPtr& material,
265 int priority = 0);
266}
Function
The factors in this enumeration specify how the source and destination color values are combined duri...
Definition state.h:47
Equation
This enumeration defines different operations used in the blend equation. These operations determine ...
Definition state.h:67
Mode
The enumeration defines the type of the face we want to cull.
Definition state.h:107
Face
The enumeration defines the ordering (counter-clockwise and clockwise) of the front-faces or the back...
Definition state.h:114
Function
This enumeration defines different comparison operators used for the depth test.
Definition state.h:135
Mode
The Mode enumeration defines identifiers corresponding to different ways of rendering geometric primi...
Definition indices.h:36
Mode
Definition state.h:180
WrapMode
The enumeration defines three different wrapping mode.
Definition sampler.h:40
Filter
The enumeration defines how to map the texture pixel to the coordinates.
Definition sampler.h:30
Function
This enumeration defines different comparison operators used for the stencil test.
Definition state.h:229
Operation
This enumeration defines how to update the stencil buffer after the stencil test.
Definition state.h:242
Definition decal.h:23
BlendPtr _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)
std::shared_ptr< Integer > IntegerPtr
Definition types.h:60
std::shared_ptr< BoundingBox > BoundingBoxPtr
Definition types.h:36
TexturePtr _texture4(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
std::shared_ptr< GeometrySource > GeometrySourcePtr
Definition types.h:98
std::shared_ptr< Indices > IndicesPtr
Definition types.h:38
ArrayIndicesPtr _points(int count, int first=0, int primCount=0)
std::shared_ptr< Line > LinePtr
Definition types.h:80
GeometryPtr _geometry(const std::shared_ptr< std::map< std::string, VerticesPtr > > &verticesSet=_verticesSet(), const IndicesPtr &indices=nullptr, const BoundingBoxPtr &boundingBox=nullptr)
std::shared_ptr< PolygonOffset > PolygonOffsetPtr
Definition types.h:83
TexturePtr _texture6(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
VerticesPtr _vertices(const Float32ArrayPtr &buffer, int offset=0, unsigned int stride=0, unsigned int divisor=0)
MaterialPtr _material(const ProgramPtr &program=nullptr, const std::shared_ptr< std::map< std::string, VariantPtr > > &parameters=nullptr, const std::shared_ptr< std::vector< StatePtr > > &states=nullptr)
std::shared_ptr< ArrayIndices > ArrayIndicesPtr
Definition types.h:39
ElementIndicesPtr _elementIndices(Indices::Mode mode, const Uint8ArrayPtr &buffer, int count=-1, int offset=0, int primCount=0)
Vector2iPtr _ivec2()
SamplerPtr _samplerClamp()
ArrayIndicesPtr _line_strip(int count, int first=0, int primCount=0)
ArrayIndicesPtr _line_loop(int count, int first=0, int primCount=0)
ProgramPtr _program(const VertexSourcePtr &vertex=nullptr, const FragmentSourcePtr &fragment=nullptr, const GeometrySourcePtr &geometry=nullptr)
DepthPtr _depth(bool enabled=false, Depth::Function func=Depth::Function::LESS, bool writeMask=true)
SamplerPtr _samplerMirror()
std::shared_ptr< Float32Array > Float32ArrayPtr
Definition types.h:119
std::shared_ptr< std::vector< StatePtr > > _states(const std::vector< StatePtr > &states={})
std::shared_ptr< Blend > BlendPtr
Definition types.h:76
LinePtr _line(float width=1.0f)
PrimitivePtr _primitive(const GeometryPtr &geometry=nullptr, const MaterialPtr &material=nullptr, int priority=0)
SamplerPtr _samplerRepeat()
std::shared_ptr< Culling > CullingPtr
Definition types.h:78
std::shared_ptr< Geometry > GeometryPtr
Definition types.h:32
PolygonPtr _polygon(Polygon::Mode mode=Polygon::Mode::FILL)
std::shared_ptr< Texture > TexturePtr
Definition types.h:86
std::shared_ptr< ElementIndices > ElementIndicesPtr
Definition types.h:40
std::shared_ptr< Vector2i > Vector2iPtr
Definition types.h:136
TexturePtr _texture(int unit, const ImagePtr &image, const SamplerPtr &sampler=nullptr)
std::shared_ptr< Primitive > PrimitivePtr
Definition types.h:48
TexturePtr _texture3(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
std::shared_ptr< Image > ImagePtr
Definition types.h:53
std::shared_ptr< Stencil > StencilPtr
Definition types.h:85
ImageBufferPtr _colorBuf()
TexturePtr _texture2(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
TargetPtr _target()
SamplerPtr _sampler(Sampler::Filter minFilter=Sampler::Filter::LINEAR_MIPMAP_NEAREST, Sampler::Filter magFilter=Sampler::Filter::LINEAR, Sampler::WrapMode wrapS=Sampler::WrapMode::REPEAT, Sampler::WrapMode wrapT=Sampler::WrapMode::REPEAT)
std::shared_ptr< Int32Array > Int32ArrayPtr
Definition types.h:117
std::shared_ptr< Uint16Array > Uint16ArrayPtr
Definition types.h:116
std::shared_ptr< Uint8Array > Uint8ArrayPtr
Definition types.h:114
TexturePtr _texture7(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
TexturePtr _texture0(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
ScissorPtr _scissor(bool enabled=false, int x=0, int y=0, int width=0, int height=0)
std::shared_ptr< Scissor > ScissorPtr
Definition types.h:84
TexturePtr _texture1(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
std::shared_ptr< Real > RealPtr
Definition types.h:88
PointPtr _point(float size=1.0f, bool programmable=false)
std::shared_ptr< Depth > DepthPtr
Definition types.h:79
std::shared_ptr< ColorMask > ColorMaskPtr
Definition types.h:77
std::shared_ptr< Material > MaterialPtr
Definition types.h:44
TexturePtr _texture5(const ImagePtr &image, const SamplerPtr &sampler=nullptr)
PolygonOffsetPtr _polygonOffset(bool enabled=false, float factor=0.0f, float units=0.0f)
SamplerPtr _samplerCube()
ArrayIndicesPtr _triangle_fan(int count, int first=0, int primCount=0)
BackgroundPtr _background(const Vector2iPtr &size, const Color4fPtr &colorMask=nullptr, const RealPtr &depthMask=nullptr, const IntegerPtr &stencilMask=nullptr, const Vector2iPtr &coordinate=_ivec2())
std::shared_ptr< Color4f > Color4fPtr
Definition types.h:45
std::shared_ptr< ImageBuffer > ImageBufferPtr
Definition types.h:56
ArrayIndicesPtr _triangle_strip(int count, int first=0, int primCount=0)
std::shared_ptr< Background > BackgroundPtr
Definition types.h:28
ArrayIndicesPtr _triangles(int count, int first=0, int primCount=0)
std::shared_ptr< Point > PointPtr
Definition types.h:81
RealPtr _real()
CullingPtr _culling(bool enabled=false, Culling::Face face=Culling::Face::CCW, Culling::Mode mode=Culling::Mode::BACK)
std::shared_ptr< FragmentSource > FragmentSourcePtr
Definition types.h:97
ColorMaskPtr _colorMask(bool red=true, bool green=true, bool blue=true, bool alpha=true)
Color4fPtr _clr4()
std::shared_ptr< Polygon > PolygonPtr
Definition types.h:82
std::shared_ptr< Uint32Array > Uint32ArrayPtr
Definition types.h:118
std::shared_ptr< Vertices > VerticesPtr
Definition types.h:94
StencilPtr _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)
ArrayIndicesPtr _arrayIndices(Indices::Mode mode, int count, int first=0, int primCount=0)
std::shared_ptr< Target > TargetPtr
Definition types.h:90
std::shared_ptr< Sampler > SamplerPtr
Definition types.h:60
ArrayIndicesPtr _lines(int count, int first=0, int primCount=0)
std::shared_ptr< Program > ProgramPtr
Definition types.h:52
std::shared_ptr< VertexSource > VertexSourcePtr
Definition types.h:96
BackgroundPtr _simpleBackground(const Vector2iPtr &size, const Color4fPtr &colorMask=_clr4(0.7, 0.7, 0.7, 1.0), const RealPtr &depthMask=_real(1.0), const IntegerPtr &stencilMask=nullptr, const Vector2iPtr &coordinate=_ivec2())
std::shared_ptr< std::map< std::string, VariantPtr > > _parameters(const std::map< std::string, VariantPtr > &parameters={})
std::shared_ptr< std::map< std::string, VerticesPtr > > _verticesSet(const std::map< std::string, VerticesPtr > &verticesMap={})