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

cube.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SHAPES_CUBE_HPP
10 #define EAGINE_SHAPES_CUBE_HPP
11 
12 #include "gen_base.hpp"
13 #include <eagine/config/basic.hpp>
14 #include <cassert>
15 #include <memory>
16 
17 namespace eagine {
18 namespace shapes {
19 //------------------------------------------------------------------------------
24 public:
25  unit_cube_gen(vertex_attrib_bits attr_bits) noexcept;
26 
27  auto vertex_count() -> span_size_t override;
28 
29  void positions(span<float> dest) noexcept;
30 
31  void normals(span<float> dest) noexcept;
32 
33  void tangentials(span<float> dest) noexcept;
34 
35  void bitangentials(span<float> dest) noexcept;
36 
37  void face_coords(span<float> dest) noexcept;
38 
39  void attrib_values(vertex_attrib_variant, span<float>) override;
40 
41  auto draw_variant_count() -> span_size_t override;
42 
43  auto index_type(drawing_variant) -> index_data_type override;
44 
45  auto index_count(drawing_variant) -> span_size_t override;
46 
47  void indices(drawing_variant, span<std::uint8_t> dest) override;
48 
49  void indices(drawing_variant, span<std::uint16_t> dest) override;
50 
51  void indices(drawing_variant, span<std::uint32_t> dest) override;
52 
54 
55  void instructions(drawing_variant, span<draw_operation> ops) override;
56 
57  auto bounding_sphere() -> math::sphere<float, true> override;
58 
59 private:
61 
62  static auto _attr_mask() noexcept -> vertex_attrib_bits;
63 
64  static auto _shared_attrs() noexcept -> vertex_attrib_bits;
65 
66  auto _only_shared_attribs() noexcept -> bool;
67 
68  static auto _coord_c(span_size_t v, span_size_t c) noexcept -> int;
69 
70  static auto _normal_c(span_size_t f, span_size_t c) noexcept -> int;
71 
72  static auto _tangential_c(span_size_t f, span_size_t c) noexcept -> int;
73 
74  static auto _bitangential_c(span_size_t f, span_size_t c) noexcept -> int;
75 
76  template <typename T>
77  void _indices(drawing_variant, span<T> dest) noexcept;
78 
79  static auto _face_vert(span_size_t f, span_size_t t, span_size_t v) noexcept
80  -> span_size_t;
81 };
82 //------------------------------------------------------------------------------
92 static inline auto unit_cube(vertex_attrib_bits attr_bits) {
93  return std::make_unique<unit_cube_gen>(attr_bits);
94 }
95 //------------------------------------------------------------------------------
96 } // namespace shapes
97 } // namespace eagine
98 
99 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
100 #include <eagine/shapes/cube.inl>
101 #endif
102 
103 #endif // EAGINE_SHAPES_CUBE_HPP
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
bitfield< vertex_attrib_kind > vertex_attrib_bits
Alias for vertex_attrib_kind bitfield type.
Definition: vertex_attrib.hpp:85
Basic template for spheres in N-dimensional space.
Definition: primitives.hpp:122
Common code is placed in this namespace.
Definition: eagine.hpp:21
auto operation_count()
Returns the number of drawing instructions for the default variant.
Definition: gen_base.hpp:179
auto bounding_sphere() -> math::sphere< float, true > override
Returns the bounding sphere for the generated shape.
static auto unit_cube(vertex_attrib_bits attr_bits)
Constructs instances of unit_cube_gen.
Definition: cube.hpp:92
Class designating an vertex attribute variant in a shape generator.
Definition: vertex_attrib.hpp:104
void instructions(drawing_variant, span< draw_operation > ops) override
Fetches the drawing operations for the specified drawing variant.
void indices(drawing_variant, span< std::uint8_t > dest) override
Fetches the index data for the specified drawing variant.
span_size_t drawing_variant
Alias for shape drawing variant index type.
Definition: gen_base.hpp:31
Base class for shape generators re-calculating the center.
Definition: gen_base.hpp:320
auto draw_variant_count() -> span_size_t override
Returns the count of possible shape draw variants.
auto index_type() -> index_data_type
Returns the index data type for the default draw variant.
Definition: gen_base.hpp:139
auto vertex_count() -> span_size_t override
Returns the shaped vertex count.
void attrib_values(vertex_attrib_variant, span< float >) override
Fetches the vertex attribute data for the specified variant as floats.
index_data_type
Shape element index type enumeration.
Definition: drawing.hpp:111
auto index_count()
Returns the index count for the default drawing variant.
Definition: gen_base.hpp:147
Generator of centered cube shape with unit edge size.
Definition: cube.hpp:23

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