OGLplus  (0.59.0) a C++ wrapper for rendering APIs

drawing.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SHAPES_DRAWING_HPP
10 #define EAGINE_SHAPES_DRAWING_HPP
11 
12 #include "../identifier.hpp"
13 #include "../reflect/map_enumerators.hpp"
14 #include "../tags.hpp"
15 #include "../types.hpp"
16 
17 namespace eagine {
18 namespace shapes {
19 //------------------------------------------------------------------------------
22 enum class primitive_type : std::uint8_t {
24  points,
26  lines,
28  line_strip,
30  line_loop,
32  triangles,
40  quads,
44  patches
45 };
46 //------------------------------------------------------------------------------
47 template <typename Selector>
48 constexpr auto
49 enumerator_mapping(type_identity<primitive_type>, Selector) noexcept {
50  return enumerator_map_type<primitive_type, 11>{
51  {{"points", primitive_type::points},
52  {"lines", primitive_type::lines},
53  {"line_strip", primitive_type::line_strip},
54  {"line_loop", primitive_type::line_loop},
55  {"triangles", primitive_type::triangles},
56  {"triangle_strip", primitive_type::triangle_strip},
57  {"triangle_fan", primitive_type::triangle_fan},
58  {"triangles_adjacency", primitive_type::triangles_adjacency},
59  {"quads", primitive_type::quads},
60  {"tetrahedrons", primitive_type::tetrahedrons},
61  {"patches", primitive_type::patches}}};
62 }
63 //------------------------------------------------------------------------------
67 enum class attrib_data_type {
69  none,
71  ubyte,
73  int_16,
75  int_32,
77  uint_16,
79  uint_32,
81  float_
82 };
83 //------------------------------------------------------------------------------
84 template <typename Selector>
85 constexpr auto
86 enumerator_mapping(type_identity<attrib_data_type>, Selector) noexcept {
87  return enumerator_map_type<attrib_data_type, 7>{
88  {{"none", attrib_data_type::none},
89  {"ubyte", attrib_data_type::ubyte},
90  {"int_16", attrib_data_type::int_16},
91  {"int_32", attrib_data_type::int_32},
92  {"uint_16", attrib_data_type::uint_16},
93  {"uint_32", attrib_data_type::uint_32},
94  {"float_", attrib_data_type::float_}}};
95 }
96 //------------------------------------------------------------------------------
97 constexpr auto
98 enumerator_mapping(type_identity<attrib_data_type>, value_tree_tag) noexcept {
99  return enumerator_map_type<attrib_data_type, 6>{
100  {{"ubyte", attrib_data_type::ubyte},
101  {"int_16", attrib_data_type::int_16},
102  {"int_32", attrib_data_type::int_32},
103  {"uint_16", attrib_data_type::uint_16},
104  {"uint_32", attrib_data_type::uint_32},
105  {"float", attrib_data_type::float_}}};
106 }
107 //------------------------------------------------------------------------------
111 enum class index_data_type : std::uint8_t {
113  none = 0,
115  unsigned_8 = 8,
117  unsigned_16 = 16,
119  unsigned_32 = 32
120 };
121 //------------------------------------------------------------------------------
122 template <typename Selector>
123 constexpr auto
124 enumerator_mapping(type_identity<index_data_type>, Selector) noexcept {
125  return enumerator_map_type<index_data_type, 4>{
126  {{"none", index_data_type::none},
127  {"unsigned_8", index_data_type::unsigned_8},
128  {"unsigned_16", index_data_type::unsigned_16},
129  {"unsigned_32", index_data_type::unsigned_32}}};
130 }
131 //------------------------------------------------------------------------------
132 constexpr auto
133 enumerator_mapping(type_identity<index_data_type>, value_tree_tag) noexcept {
134  return enumerator_map_type<index_data_type, 3>{
135  {{"none", index_data_type::none},
136  {"unsigned_16", index_data_type::unsigned_16},
137  {"unsigned_32", index_data_type::unsigned_32}}};
138 }
139 //------------------------------------------------------------------------------
140 static inline auto operator<(index_data_type l, index_data_type r) noexcept {
141  using UT = std::underlying_type_t<index_data_type>;
142  return UT(l) < UT(r);
143 }
144 //------------------------------------------------------------------------------
145 static inline auto operator>(index_data_type l, index_data_type r) noexcept {
146  using UT = std::underlying_type_t<index_data_type>;
147  return UT(l) > UT(r);
148 }
149 //------------------------------------------------------------------------------
150 static inline auto operator<=(index_data_type l, index_data_type r) noexcept {
151  using UT = std::underlying_type_t<index_data_type>;
152  return UT(l) <= UT(r);
153 }
154 //------------------------------------------------------------------------------
155 static inline auto operator>=(index_data_type l, index_data_type r) noexcept {
156  using UT = std::underlying_type_t<index_data_type>;
157  return UT(l) >= UT(r);
158 }
159 //------------------------------------------------------------------------------
165 
168 
170  std::uint32_t phase{0};
171 
173  std::uint32_t primitive_restart_index{0};
174 
176  std::uint16_t patch_vertices{3};
177 
180 
183 
186 
188  bool cw_face_winding : 1;
189 
191  constexpr draw_operation() noexcept
192  : primitive_restart(false)
193  , cw_face_winding(false) {}
194 };
195 //------------------------------------------------------------------------------
196 } // namespace shapes
197 } // namespace eagine
198 
199 #endif // EAGINE_SHAPES_DRAWING_HPP
span_size_t first
The index of the first element.
Definition: drawing.hpp:164
Draw operation parameters.
Definition: drawing.hpp:162
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
primitive_type
The shape primitive type enumeration.
Definition: drawing.hpp:22
std::uint16_t patch_vertices
The number of vertices per patch.
Definition: drawing.hpp:176
@ unsigned_16
Unsigned 16-bit integer.
Common code is placed in this namespace.
Definition: eagine.hpp:21
span_size_t count
The count of elements.
Definition: drawing.hpp:167
@ line_loop
Close line loops.
@ lines
Individual line segments.
bool cw_face_winding
Whether the shape faces have clockwise winding (or counterclockwise).
Definition: drawing.hpp:188
@ unsigned_32
Unsigned 32-bit integer.
@ triangles_adjacency
Individual triangles with adjacency.
@ uint_16
Unsigned 16-bit integer.
primitive_type mode
The primitive type.
Definition: drawing.hpp:179
std::uint32_t primitive_restart_index
The primitive restart index value.
Definition: drawing.hpp:173
@ uint_32
Unsigned 32-bit integer.
@ triangle_strip
Triangle strips.
std::uint32_t phase
The drawing phase (shader-dependent).
Definition: drawing.hpp:170
@ tetrahedrons
Tetrahedrons (represented as lines with adjacency).
@ int_32
Signed 32-bit integer.
attrib_data_type
Shape vertex attribute data type enumeration.
Definition: drawing.hpp:67
@ int_16
Signed 16-bit integer.
Template type used mostly for function type-tag dispatching.
Definition: type_identity.hpp:19
@ points
Individual points.
index_data_type idx_type
The index data type.
Definition: drawing.hpp:182
@ quads
Quadrilaterals (represented as lines with adjacency).
bool primitive_restart
Whether primitive restart is enabled.
Definition: drawing.hpp:185
@ triangles
Individual triangles.
index_data_type
Shape element index type enumeration.
Definition: drawing.hpp:111
constexpr draw_operation() noexcept
Default constructor.
Definition: drawing.hpp:191
@ unsigned_8
Unsigned 8-bit integer.

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).