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

drawing.hpp
Go to the documentation of this file.
1 
9 #ifndef OGLPLUS_SHAPES_DRAWING_HPP
10 #define OGLPLUS_SHAPES_DRAWING_HPP
11 
12 #include "../config/basic.hpp"
13 #include "../gl_api.hpp"
15 #include <eagine/span.hpp>
16 
17 namespace eagine::oglp {
18 //------------------------------------------------------------------------------
22 template <typename A>
23 auto translate(const basic_gl_api<A>&, shapes::primitive_type) noexcept
24  -> primitive_type;
25 //------------------------------------------------------------------------------
29 template <typename A>
30 auto translate(const basic_gl_api<A>&, shapes::attrib_data_type) noexcept
31  -> data_type;
32 //------------------------------------------------------------------------------
36 template <typename A>
37 auto translate(const basic_gl_api<A>&, shapes::index_data_type) noexcept
38  -> index_data_type;
39 //------------------------------------------------------------------------------
43 template <typename A>
44 auto type_size(const basic_gl_api<A>&, shapes::attrib_data_type) noexcept
45  -> span_size_t;
46 //------------------------------------------------------------------------------
50 template <typename A>
51 auto type_size(const basic_gl_api<A>&, shapes::index_data_type) noexcept
52  -> span_size_t;
53 //------------------------------------------------------------------------------
59 public:
61  constexpr shape_draw_operation() noexcept = default;
62 
64  template <typename A>
66  const basic_gl_api<A>& api,
67  const shapes::draw_operation& draw_op) noexcept;
68 
70  auto offset_first(span_size_t offs) noexcept -> auto& {
71  _first += offs;
72  return *this;
73  }
74 
76  auto phase() const noexcept {
77  return _phase;
78  }
79 
81  template <typename A>
82  auto is_indexed(const basic_gl_api<A>& api) const noexcept -> bool {
83  const basic_gl_constants<A>& GL = api;
84  return _idx_type != GL.none;
85  }
86 
88  template <typename A>
89  void draw(const basic_gl_api<A>& api) const noexcept;
90 
92  template <typename A>
93  void draw_instanced(
94  const basic_gl_api<A>& api,
95  gl_types::sizei_type inst_count) const noexcept;
96 
97 private:
98  primitive_type _mode{0};
99  index_data_type _idx_type{0};
100  gl_types::int_type _first{0};
101  gl_types::sizei_type _count{0};
102  gl_types::uint_type _phase{0};
103  gl_types::uint_type _primitive_restart_index{0};
104  gl_types::int_type _patch_vertices{3};
105  bool _primitive_restart{false};
106  bool _cw_face_winding{false};
107 
108  auto _idx_ptr() const noexcept -> gl_types::const_void_ptr_type;
109 
110  template <typename A>
111  void _prepare(const basic_gl_api<A>& api) const noexcept;
112 };
113 //------------------------------------------------------------------------------
119  span_size_t first{0};
121  span_size_t count{0};
122 };
123 //------------------------------------------------------------------------------
128 template <typename A>
130  const basic_gl_api<A>& api,
131  span<const shape_draw_operation> ops) noexcept;
132 //------------------------------------------------------------------------------
137 template <typename A>
139  const basic_gl_api<A>& api,
140  span<const shape_draw_operation> ops,
141  gl_types::sizei_type inst_count) noexcept;
142 //------------------------------------------------------------------------------
147 template <typename A>
149  const basic_gl_api<A>& api,
150  span<const shape_draw_operation> ops,
151  const shape_draw_subset& subs) noexcept;
152 //------------------------------------------------------------------------------
157 template <typename A>
159  const basic_gl_api<A>& api,
160  span<const shape_draw_operation> ops,
161  const shape_draw_subset& subs,
162  gl_types::sizei_type inst_count) noexcept;
163 //------------------------------------------------------------------------------
164 } // namespace eagine::oglp
165 
166 #include <oglplus/shapes/drawing.inl>
167 
168 #endif // OGLPLUS_SHAPES_DRAWING_HPP
GLsizei sizei_type
Signed integer size type.
Definition: config.hpp:88
Draw operation parameters.
Definition: drawing.hpp:162
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
auto offset_first(span_size_t offs) noexcept -> auto &
Moves the first index by the specified offset.
Definition: drawing.hpp:70
primitive_type
The shape primitive type enumeration.
Definition: drawing.hpp:22
void draw_using_instructions(const basic_gl_api< A > &api, span< const shape_draw_operation > ops, const shape_draw_subset &subs) noexcept
Takes a sequence of draw operations from a shape generator and draws them.
GLint int_type
Signed integer type.
Definition: config.hpp:70
auto type_size(const basic_gl_api< A > &, shapes::index_data_type) noexcept -> span_size_t
Returns the byte size of a shape index data type.
Typed enumeration for GL primitive type constants.
Definition: enum_types.hpp:458
Shape draw operation parameters, translated to GL representation.
Definition: drawing.hpp:58
GLuint uint_type
Unsigned integer type.
Definition: config.hpp:73
constexpr shape_draw_operation() noexcept=default
Default constructor.
auto is_indexed(const basic_gl_api< A > &api) const noexcept -> bool
Indicates if indexed drawing is enabled.
Definition: drawing.hpp:82
auto translate(const basic_gl_api< A > &, shapes::index_data_type) noexcept -> index_data_type
Translates from shape index data type to GL data type.
void draw(const basic_gl_api< A > &api) const noexcept
Invokes the appropriate draw operation on the specified GL api.
void draw_instanced(const basic_gl_api< A > &api, gl_types::sizei_type inst_count) const noexcept
Invokes the appropriate instanced draw operation on the given GL api.
Class wrapping the constants from the GL API.
Definition: constants.hpp:26
opt_c_api_constant< mp_list< support_level, surface_buffer, sl_data_type, index_data_type, oglp::texture_compare_mode, oglp::context_release_behavior, oglp::path_join_style_nv, oglp::path_gen_mode_nv, oglp::path_transform_type_nv >, bitfield_type_i > none
Definition: constants.hpp:12810
attrib_data_type
Shape vertex attribute data type enumeration.
Definition: drawing.hpp:67
auto phase() const noexcept
Returns the drawing phase.
Definition: drawing.hpp:76
Combined wrapper for the GL API operations and constants.
Definition: basic_gl_api.hpp:27
Holds the first index and count of a subset of drawn shape elements.
Definition: drawing.hpp:117
Typed enumeration for GL index data type constants.
Definition: enum_types.hpp:574
index_data_type
Shape element index type enumeration.
Definition: drawing.hpp:111
void draw_instanced_using_instructions(const basic_gl_api< A > &api, span< const shape_draw_operation > ops, const shape_draw_subset &subs, gl_types::sizei_type inst_count) noexcept
Takes a sequence of draw operations from a shape generator and draws them.

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