Cumulia Illustrator Rendering Engine v1.0.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 2024-05-01
15// Version V1.0.0
16//##################################################################################################
17
18#pragma once
19
20#include "../primitive/background.h"
21#include "../primitive/vertices.h"
22#include "../primitive/indices.h"
23#include "../primitive/state.h"
24#include "../primitive/geometry.h"
25#include "../primitive/sampler.h"
26#include "../primitive/program.h"
27#include "../primitive/material.h"
28#include "../primitive/primitive.h"
29#include "../primitive/target.h"
30#include "../make/variantmaker.h"
31
32#include <memory>
33#include <map>
34
35namespace cil
36{
37 // _vertices
38 std::shared_ptr<Vertices> _vertices(const std::shared_ptr<Float32Array>& buffer,
39 int offset = 0,
40 unsigned int stride = 0,
41 unsigned int divisor = 0);
42 std::shared_ptr<Vertices> _vertices(const std::shared_ptr<Int32Array>& buffer,
43 int offset = 0,
44 unsigned int stride = 0,
45 unsigned int divisor = 0);
46 std::shared_ptr<Vertices> _vertices(const std::initializer_list<float>& array,
47 int offset = 0,
48 unsigned int stride = 0,
49 unsigned int divisor = 0);
50
51 // _indices
52 std::shared_ptr<ArrayIndices> _arrayIndices(Indices::Mode mode,
53 int count,
54 int first = 0,
55 int primCount = 0);
56
57 std::shared_ptr<ArrayIndices> _triangles(int count,
58 int first = 0,
59 int primCount = 0);
60 std::shared_ptr<ArrayIndices> _triangle_fan(int count,
61 int first = 0,
62 int primCount = 0);
63 std::shared_ptr<ArrayIndices> _triangle_strip(int count,
64 int first = 0,
65 int primCount = 0);
66 std::shared_ptr<ArrayIndices> _lines(int count,
67 int first = 0,
68 int primCount = 0);
69 std::shared_ptr<ArrayIndices> _line_strip(int count,
70 int first = 0,
71 int primCount = 0);
72 std::shared_ptr<ArrayIndices> _line_loop(int count,
73 int first = 0,
74 int primCount = 0);
75 std::shared_ptr<ArrayIndices> _points(int count,
76 int first = 0,
77 int primCount = 0);
78
79 std::shared_ptr<ElementIndices> _elementIndices(Indices::Mode mode,
80 const std::shared_ptr<Uint8Array>& buffer,
81 int count = -1,
82 int offset = 0,
83 int primCount = 0);
84 std::shared_ptr<ElementIndices> _elementIndices(Indices::Mode mode,
85 const std::shared_ptr<Uint16Array>& buffer,
86 int count = -1,
87 int offset = 0,
88 int primCount = 0);
89 std::shared_ptr<ElementIndices> _elementIndices(Indices::Mode mode,
90 const std::shared_ptr<Uint32Array>& buffer,
91 int count = -1,
92 int offset = 0,
93 int primCount = 0);
94
95 std::shared_ptr<ElementIndices> _triangles(const std::shared_ptr<Uint8Array>& buffer,
96 int count = -1,
97 int offset = 0,
98 int primCount = 0);
99 std::shared_ptr<ElementIndices> _triangles(const std::shared_ptr<Uint16Array>& buffer,
100 int count = -1,
101 int offset = 0,
102 int primCount = 0);
103 std::shared_ptr<ElementIndices> _triangles(const std::shared_ptr<Uint32Array>& buffer,
104 int count = -1,
105 int offset = 0,
106 int primCount = 0);
107 std::shared_ptr<ElementIndices> _triangles(const std::initializer_list<unsigned int>& array,
108 int count = -1,
109 int offset = 0,
110 int primCount = 0);
111
112 std::shared_ptr<ElementIndices> _triangle_fan(const std::shared_ptr<Uint8Array>& buffer,
113 int count = -1,
114 int offset = 0,
115 int primCount = 0);
116 std::shared_ptr<ElementIndices> _triangle_fan(const std::shared_ptr<Uint16Array>& buffer,
117 int count = -1,
118 int offset = 0,
119 int primCount = 0);
120 std::shared_ptr<ElementIndices> _triangle_fan(const std::shared_ptr<Uint32Array>& buffer,
121 int count = -1,
122 int offset = 0,
123 int primCount = 0);
124 std::shared_ptr<ElementIndices> _triangle_fan(const std::initializer_list<unsigned int>& array,
125 int count = -1,
126 int offset = 0,
127 int primCount = 0);
128
129 std::shared_ptr<ElementIndices> _triangle_strip(const std::shared_ptr<Uint8Array>& buffer,
130 int count = -1,
131 int offset = 0,
132 int primCount = 0);
133 std::shared_ptr<ElementIndices> _triangle_strip(const std::shared_ptr<Uint16Array>& buffer,
134 int count = -1,
135 int offset = 0,
136 int primCount = 0);
137 std::shared_ptr<ElementIndices> _triangle_strip(const std::shared_ptr<Uint32Array>& buffer,
138 int count = -1,
139 int offset = 0,
140 int primCount = 0);
141 std::shared_ptr<ElementIndices> _triangle_strip(const std::initializer_list<unsigned int>& array,
142 int count = -1,
143 int offset = 0,
144 int primCount = 0);
145
146 std::shared_ptr<ElementIndices> _lines(const std::shared_ptr<Uint8Array>& buffer,
147 int count = -1,
148 int offset = 0,
149 int primCount = 0);
150 std::shared_ptr<ElementIndices> _lines(const std::shared_ptr<Uint16Array>& buffer,
151 int count = -1,
152 int offset = 0,
153 int primCount = 0);
154 std::shared_ptr<ElementIndices> _lines(const std::shared_ptr<Uint32Array>& buffer,
155 int count = -1,
156 int offset = 0,
157 int primCount = 0);
158 std::shared_ptr<ElementIndices> _lines(const std::initializer_list<unsigned int>& array,
159 int count = -1,
160 int offset = 0,
161 int primCount = 0);
162
163 std::shared_ptr<ElementIndices> _line_strip(const std::shared_ptr<Uint8Array>& buffer,
164 int count = -1,
165 int offset = 0,
166 int primCount = 0);
167 std::shared_ptr<ElementIndices> _line_strip(const std::shared_ptr<Uint16Array>& buffer,
168 int count = -1,
169 int offset = 0,
170 int primCount = 0);
171 std::shared_ptr<ElementIndices> _line_strip(const std::shared_ptr<Uint32Array>& buffer,
172 int count = -1,
173 int offset = 0,
174 int primCount = 0);
175 std::shared_ptr<ElementIndices> _line_strip(const std::initializer_list<unsigned int>& array,
176 int count = -1,
177 int offset = 0,
178 int primCount = 0);
179
180 std::shared_ptr<ElementIndices> _line_loop(const std::shared_ptr<Uint8Array>& buffer,
181 int count = -1,
182 int offset = 0,
183 int primCount = 0);
184 std::shared_ptr<ElementIndices> _line_loop(const std::shared_ptr<Uint16Array>& buffer,
185 int count = -1,
186 int offset = 0,
187 int primCount = 0);
188 std::shared_ptr<ElementIndices> _line_loop(const std::shared_ptr<Uint32Array>& buffer,
189 int count = -1,
190 int offset = 0,
191 int primCount = 0);
192 std::shared_ptr<ElementIndices> _line_loop(const std::initializer_list<unsigned int>& array,
193 int count = -1,
194 int offset = 0,
195 int primCount = 0);
196
197 std::shared_ptr<ElementIndices> _points(const std::shared_ptr<Uint8Array>& buffer,
198 int count = -1,
199 int offset = 0,
200 int primCount = 0);
201 std::shared_ptr<ElementIndices> _points(const std::shared_ptr<Uint16Array>& buffer,
202 int count = -1,
203 int offset = 0,
204 int primCount = 0);
205 std::shared_ptr<ElementIndices> _points(const std::shared_ptr<Uint32Array>& buffer,
206 int count = -1,
207 int offset = 0,
208 int primCount = 0);
209 std::shared_ptr<ElementIndices> _points(const std::initializer_list<unsigned int>& array,
210 int count = -1,
211 int offset = 0,
212 int primCount = 0);
213
214 std::shared_ptr<std::map<std::string, std::shared_ptr<Vertices>>> operator|(
215 const std::shared_ptr<std::map<std::string, std::shared_ptr<Vertices>>>& lhs,
216 const std::shared_ptr<std::map<std::string, std::shared_ptr<Vertices>>>& rhs);
217
218 // _verticesSet
219 std::shared_ptr<std::map<std::string, std::shared_ptr<Vertices>>> _verticesSet(const std::map<std::string, std::shared_ptr<Vertices>>& verticesMap);
220
221 // _geometry
222 std::shared_ptr<Geometry> _geometry(const std::shared_ptr<std::map<std::string, std::shared_ptr<Vertices>>>& verticesSet,
223 const std::shared_ptr<Indices>& indices = nullptr,
224 const std::shared_ptr<BoundingBox>& boundingBox = nullptr);
225 std::shared_ptr<Geometry> _geometry(std::map<std::string, std::shared_ptr<Vertices>> verticesSet,
226 const std::shared_ptr<Indices>& indices = nullptr,
227 const std::shared_ptr<BoundingBox>& boundingBox = nullptr);
228 std::shared_ptr<Geometry> _geometry(const std::shared_ptr<Indices>& indices,
229 const std::shared_ptr<BoundingBox>& boundingBox = nullptr);
230
231
232 std::shared_ptr<Geometry> operator|(
233 const std::shared_ptr<Geometry>& lhs,
234 const std::shared_ptr<Geometry>& rhs);
235
236 // _blend
237 std::shared_ptr<Blend> _blend(bool enabled = false,
241
242 // _colorMask
243 std::shared_ptr<ColorMask> _colorMask(bool red = true,
244 bool green = true,
245 bool blue = true,
246 bool alpha = true);
247
248 // _culling
249 std::shared_ptr<Culling> _culling(bool enabled = false,
252
253 // _depth
254 std::shared_ptr<Depth> _depth(bool enabled = false,
256 bool writeMask = true);
257
258 // _line
259 std::shared_ptr<Line> _line(float width = 1.0f);
260
261 // _point
262 std::shared_ptr<Point> _point(float size = 1.0f,
263 bool programmable = false);
264
265 // _polygon
266 std::shared_ptr<Polygon> _polygon(Polygon::Mode mode = Polygon::Mode::FILL);
267
268 // _polygonOffset
269 std::shared_ptr<PolygonOffset> _polygonOffset(bool enabled = false,
270 float factor = 0.0f,
271 float units = 0.0f);
272
273 // _scissor
274 std::shared_ptr<Scissor> _scissor(bool enabled = false,
275 int x = 0,
276 int y = 0,
277 int width = 0,
278 int height = 0);
279
280 // _stencil
281 std::shared_ptr<Stencil> _stencil(bool enabled = false,
286 int ref = 0,
287 int mask = 0xFF);
288
289 // _sampler
294 std::shared_ptr<Sampler> _samplerClamp();
295 std::shared_ptr<Sampler> _samplerRepeat();
296 std::shared_ptr<Sampler> _samplerMirror();
297 std::shared_ptr<Sampler> _samplerCube();
298
299 // _texture
300 std::shared_ptr<Texture> _texture(int unit,
301 const std::shared_ptr<Image>& image,
302 const std::shared_ptr<Sampler>& sampler);
303 std::shared_ptr<Texture> _texture(int unit,
304 const std::shared_ptr<Image>& image);
305 std::shared_ptr<Texture> _texture0(const std::shared_ptr<Image>& image);
306 std::shared_ptr<Texture> _texture1(const std::shared_ptr<Image>& image);
307 std::shared_ptr<Texture> _texture2(const std::shared_ptr<Image>& image);
308 std::shared_ptr<Texture> _texture3(const std::shared_ptr<Image>& image);
309 std::shared_ptr<Texture> _texture4(const std::shared_ptr<Image>& image);
310 std::shared_ptr<Texture> _texture5(const std::shared_ptr<Image>& image);
311 std::shared_ptr<Texture> _texture6(const std::shared_ptr<Image>& image);
312 std::shared_ptr<Texture> _texture7(const std::shared_ptr<Image>& image);
313
314 // _program
315 std::shared_ptr<Program> _program(const std::shared_ptr<VertexSource>& vertex = nullptr,
316 const std::shared_ptr<FragmentSource>& fragment = nullptr,
317 const std::shared_ptr<GeometrySource>& geometry = nullptr);
318 std::shared_ptr<Program> _program(const std::string& vertexString);
319 std::shared_ptr<Program> _program(const std::string& vertexString, const std::string& fragmentString);
320 std::shared_ptr<Program> _program(const std::string& vertexString, const std::string& fragmentString, const std::string& geometryString);
321
322 // _parameters
323 std::shared_ptr<std::map<std::string, std::shared_ptr<Variant>>> _parameters(const std::map<std::string, std::shared_ptr<Variant>>& parameters);
324
325 // _states
326 std::shared_ptr<std::vector<std::shared_ptr<State>>> _states(const std::vector<std::shared_ptr<State>>& states = {});
327
328 std::shared_ptr<Program> operator|(
329 const std::shared_ptr<Program>& lhs,
330 const std::shared_ptr<Program>& rhs);
331
332 std::shared_ptr<std::vector<std::shared_ptr<State>>> operator|(
333 const std::shared_ptr<std::vector<std::shared_ptr<State>>>& lhs,
334 const std::shared_ptr<std::vector<std::shared_ptr<State>>>& rhs);
335
336 std::shared_ptr<std::map<std::string, std::shared_ptr<Variant>>> operator|(
337 const std::shared_ptr<std::map<std::string, std::shared_ptr<Variant>>>& lhs,
338 const std::shared_ptr<std::map<std::string, std::shared_ptr<Variant>>>& rhs);
339
340 // _material
341 std::shared_ptr<Material> _material(const std::shared_ptr<Program>& program = nullptr,
342 const std::shared_ptr<std::map<std::string, std::shared_ptr<Variant>>>& parameters = nullptr,
343 const std::shared_ptr<std::vector<std::shared_ptr<State>>>& states = nullptr);
344 std::shared_ptr<Material> _material(const std::map<std::string, std::shared_ptr<Variant>>& parameters);
345 std::shared_ptr<Material> _material(const std::vector<std::shared_ptr<State>>& states);
346
347 std::shared_ptr<Material> operator|(
348 const std::shared_ptr<Material>& lhs,
349 const std::shared_ptr<Material>& rhs);
350
351 // _background
352 std::shared_ptr<Background> _background(const std::shared_ptr<Vector2i>& size,
353 const std::shared_ptr<Color4f>& colorMask = nullptr,
354 const std::shared_ptr<Real>& depthMask = nullptr,
355 const std::shared_ptr<Integer>& stencilMask = nullptr,
356 const std::shared_ptr<Vector2i>& coordinate = _ivec2());
357 std::shared_ptr<Background> _simpleBackground(const std::shared_ptr<Vector2i>& size,
358 const std::shared_ptr<Color4f>& colorMask = _clr4(0.7, 0.7, 0.7, 1.0),
359 const std::shared_ptr<Real>& depthMask = _real(1.0),
360 const std::shared_ptr<Integer>& stencilMask = nullptr,
361 const std::shared_ptr<Vector2i>& coordinate = _ivec2());
362
363 // _colorBuf
364 std::shared_ptr<ImageBuffer> _colorBuf();
365
366 // _target
367 std::shared_ptr<Target> _target();
368 std::shared_ptr<Target> _target(const std::vector<std::shared_ptr<ImageBuffer>>& array);
369
370 // _primitive
371 std::shared_ptr<Primitive> _primitive(const std::shared_ptr<Geometry>& geometry,
372 const std::shared_ptr<Material>& material,
373 int priority);
374 std::shared_ptr<Primitive> _primitive(const std::shared_ptr<Geometry>& geometry,
375 const std::shared_ptr<Material>& material);
376 std::shared_ptr<Primitive> _primitive(const std::shared_ptr<Geometry>& geometry);
377 std::shared_ptr<Primitive> _primitive(const std::shared_ptr<Material>& material);
378 std::shared_ptr<Primitive> _primitive();
379
380 std::shared_ptr<Primitive> operator|(
381 const std::shared_ptr<Primitive>& lhs,
382 const std::shared_ptr<Primitive>& rhs);
383}
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
Mode
The enumeration defines the type of the face we want to cull.
Definition state.h:108
Face
The enumeration defines the ordering (counter-clockwise and clockwise) of the front-faces or the back...
Definition state.h:115
Function
This enumeration defines different comparison operators used for the depth test.
Definition state.h:136
Mode
The Mode enumeration defines identifiers corresponding to different ways of rendering geometric primi...
Definition indices.h:36
Mode
Definition state.h:181
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:230
Operation
This enumeration defines how to update the stencil buffer after the stencil test.
Definition state.h:243
Definition decal.h:23
std::shared_ptr< Sampler > _samplerRepeat()
std::shared_ptr< Sampler > _samplerClamp()
std::shared_ptr< Vector2i > _ivec2()
std::shared_ptr< std::map< std::string, std::shared_ptr< Vertices > > > _verticesSet(const std::map< std::string, std::shared_ptr< Vertices > > &verticesMap)
std::shared_ptr< Culling > _culling(bool enabled=false, Culling::Face face=Culling::Face::CCW, Culling::Mode mode=Culling::Mode::BACK)
std::shared_ptr< ArrayIndices > _triangle_fan(int count, int first=0, int primCount=0)
std::shared_ptr< Stencil > _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)
std::shared_ptr< Point > _point(float size=1.0f, bool programmable=false)
std::shared_ptr< Texture > _texture6(const std::shared_ptr< Image > &image)
std::shared_ptr< ArrayIndices > _triangles(int count, int first=0, int primCount=0)
std::shared_ptr< ArrayIndices > _line_loop(int count, int first=0, int primCount=0)
std::shared_ptr< Background > _simpleBackground(const std::shared_ptr< Vector2i > &size, const std::shared_ptr< Color4f > &colorMask=_clr4(0.7, 0.7, 0.7, 1.0), const std::shared_ptr< Real > &depthMask=_real(1.0), const std::shared_ptr< Integer > &stencilMask=nullptr, const std::shared_ptr< Vector2i > &coordinate=_ivec2())
std::shared_ptr< Line > _line(float width=1.0f)
std::shared_ptr< Texture > _texture4(const std::shared_ptr< Image > &image)
std::shared_ptr< Sampler > _samplerCube()
std::shared_ptr< Program > _program(const std::shared_ptr< VertexSource > &vertex=nullptr, const std::shared_ptr< FragmentSource > &fragment=nullptr, const std::shared_ptr< GeometrySource > &geometry=nullptr)
std::shared_ptr< Color4f > _clr4()
std::shared_ptr< Vertices > _vertices(const std::shared_ptr< Float32Array > &buffer, int offset=0, unsigned int stride=0, unsigned int divisor=0)
std::shared_ptr< Polygon > _polygon(Polygon::Mode mode=Polygon::Mode::FILL)
std::shared_ptr< Texture > _texture0(const std::shared_ptr< Image > &image)
std::shared_ptr< Geometry > _geometry(const std::shared_ptr< std::map< std::string, std::shared_ptr< Vertices > > > &verticesSet, const std::shared_ptr< Indices > &indices=nullptr, const std::shared_ptr< BoundingBox > &boundingBox=nullptr)
std::shared_ptr< Sampler > _samplerMirror()
std::shared_ptr< Material > _material(const std::shared_ptr< Program > &program=nullptr, const std::shared_ptr< std::map< std::string, std::shared_ptr< Variant > > > &parameters=nullptr, const std::shared_ptr< std::vector< std::shared_ptr< State > > > &states=nullptr)
std::shared_ptr< Texture > _texture(int unit, const std::shared_ptr< Image > &image, const std::shared_ptr< Sampler > &sampler)
std::shared_ptr< Texture > _texture2(const std::shared_ptr< Image > &image)
std::shared_ptr< Scissor > _scissor(bool enabled=false, int x=0, int y=0, int width=0, int height=0)
std::shared_ptr< ArrayIndices > _lines(int count, int first=0, int primCount=0)
std::shared_ptr< PolygonOffset > _polygonOffset(bool enabled=false, float factor=0.0f, float units=0.0f)
std::shared_ptr< std::vector< std::shared_ptr< State > > > _states(const std::vector< std::shared_ptr< State > > &states={})
std::shared_ptr< Texture > _texture5(const std::shared_ptr< Image > &image)
std::shared_ptr< std::map< std::string, std::shared_ptr< Variant > > > _parameters(const std::map< std::string, std::shared_ptr< Variant > > &parameters)
std::shared_ptr< ArrayIndices > _line_strip(int count, int first=0, int primCount=0)
std::shared_ptr< ArrayIndices > _points(int count, int first=0, int primCount=0)
std::shared_ptr< Background > _background(const std::shared_ptr< Vector2i > &size, const std::shared_ptr< Color4f > &colorMask=nullptr, const std::shared_ptr< Real > &depthMask=nullptr, const std::shared_ptr< Integer > &stencilMask=nullptr, const std::shared_ptr< Vector2i > &coordinate=_ivec2())
std::shared_ptr< Texture > _texture1(const std::shared_ptr< Image > &image)
std::shared_ptr< Depth > _depth(bool enabled=false, Depth::Function func=Depth::Function::LESS, bool writeMask=true)
std::shared_ptr< ArrayIndices > _arrayIndices(Indices::Mode mode, int count, int first=0, int primCount=0)
std::shared_ptr< ArrayIndices > _triangle_strip(int count, int first=0, int primCount=0)
std::shared_ptr< ImageBuffer > _colorBuf()
std::shared_ptr< ElementIndices > _elementIndices(Indices::Mode mode, const std::shared_ptr< Uint8Array > &buffer, int count=-1, int offset=0, int primCount=0)
std::shared_ptr< Texture > _texture7(const std::shared_ptr< Image > &image)
std::shared_ptr< ColorMask > _colorMask(bool red=true, bool green=true, bool blue=true, bool alpha=true)
std::shared_ptr< Blend > _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< Target > _target()
std::shared_ptr< Primitive > _primitive()
std::shared_ptr< Sampler > _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< Texture > _texture3(const std::shared_ptr< Image > &image)
std::shared_ptr< std::map< std::string, std::shared_ptr< Vertices > > > operator|(const std::shared_ptr< std::map< std::string, std::shared_ptr< Vertices > > > &lhs, const std::shared_ptr< std::map< std::string, std::shared_ptr< Vertices > > > &rhs)
std::shared_ptr< Real > _real()