13 #ifndef OGLPLUS_SHAPES_WRAPPER_1202020923_HPP
14 #define OGLPLUS_SHAPES_WRAPPER_1202020923_HPP
16 #include <oglplus/config/compiler.hpp>
17 #include <oglplus/config/basic.hpp>
54 Optional<VertexArray> _vao;
60 std::vector<GLuint> _npvs;
63 std::vector<String> _names;
68 template <
class ShapeBuilder,
class ShapeIndices,
typename Iterator>
70 const ShapeBuilder& builder,
71 const ShapeIndices& shape_indices,
77 typename ShapeBuilder::VertexAttribs vert_attr_info;
79 std::vector<GLfloat> data;
82 auto getter = vert_attr_info.VertexAttribGetter(
88 _vbos[i].Bind(Buffer::Target::Array);
89 _npvs[i] = getter(builder, data);
92 Buffer::Data(Buffer::Target::Array, data);
98 if(!shape_indices.empty())
100 assert((i+1) == _npvs.size());
101 assert((i+1) == _vbos.
size());
104 _vbos[i].Bind(Buffer::Target::ElementArray);
106 Buffer::Target::ElementArray,
111 builder.BoundingSphere(_bounding_sphere);
114 template <
typename Iterator,
class ShapeBuilder,
class Selector>
116 Iterator names_begin,
118 const ShapeBuilder& builder,
120 ): _face_winding(builder.FaceWinding())
121 , _shape_instr(builder.Instructions(selector))
122 , _index_info(builder)
123 , _vbos(std::distance(names_begin, names_end)+1)
124 , _npvs(std::distance(names_begin, names_end)+1, 0)
125 , _names(std::distance(names_begin, names_end))
129 builder.Indices(selector),
136 : _face_winding(temp._face_winding)
137 , _shape_instr(std::move(temp._shape_instr))
138 , _index_info(temp._index_info)
139 , _gl(std::move(temp._gl))
140 , _vao(std::move(temp._vao))
141 , _vbos(std::move(temp._vbos))
142 , _npvs(std::move(temp._npvs))
143 , _names(std::move(temp._names))
146 #if !OGLPLUS_NO_DELETED_FUNCTIONS
158 _vao = VAOForProgram(prog);
168 return _face_winding;
171 void Draw(
void)
const
174 _shape_instr.Draw(_index_info, 1, 0);
177 void Draw(GLuint inst_count)
const
180 _shape_instr.Draw(_index_info, inst_count, 0);
183 void Draw(GLuint inst_count, GLuint base_inst)
const
186 _shape_instr.Draw(_index_info, inst_count, base_inst);
189 void Draw(
const std::function<
bool (GLuint)>& drawing_driver)
const
192 _shape_instr.Draw(_index_info, 1, 0, drawing_driver);
195 const Spheref& BoundingSphere(
void)
const
197 return _bounding_sphere;
202 template <
typename Selector>
207 static Selector _sel(
void) {
return Selector(); }
213 template <
typename StdRange,
class ShapeBuilder>
215 const StdRange& names,
216 const ShapeBuilder& builder
220 template <
typename StdRange,
class ShapeBuilder>
222 const StdRange& names,
223 const ShapeBuilder& builder,
230 #if !OGLPLUS_NO_INITIALIZER_LISTS
231 template <
class ShapeBuilder>
233 const std::initializer_list<const GLchar*>& names,
234 const ShapeBuilder& builder
238 template <
class ShapeBuilder>
240 const std::initializer_list<const GLchar*>& names,
241 const ShapeBuilder& builder,
249 template <
class ShapeBuilder>
251 const GLchar** names,
253 const ShapeBuilder& builder
257 template <
class ShapeBuilder>
259 const GLchar** names,
261 const ShapeBuilder& builder,
268 template <
class ShapeBuilder>
271 const ShapeBuilder& builder
275 template <
class ShapeBuilder>
278 const ShapeBuilder& builder,
292 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
293 #include <oglplus/shapes/wrapper.ipp>
294 #endif // OGLPLUS_LINK_LIBRARY
296 #endif // include guard
Implementation of shape draw instructions.
Wraps instructions and VBOs and VAO used to render a shape built by a ShapeBuilder.
Definition: wrapper.hpp:203
static void FrontFace(FaceOrientation orientation)
Sets the polygon facing mode.
Definition: rasterization.hpp:37
String type definition and related functions.
Declaration of OpenGL's state wrapper.
Helper class storing information about shape element index datatype.
Definition: draw.hpp:30
Template wrapper for Objects, making them optional.
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
Wrapper for the current OpenGL context operations.
Definition: context.hpp:61
Wraps instructions and VAO+VBOs used to render a shape built by a ShapeBuilder.
Definition: wrapper.hpp:41
std::size_t size(void) const
Returns the number of instances in the array.
Definition: array.hpp:102
ObjectZero< ObjZeroOps< tag::ImplicitSel, tag::VertexArray > > NoVertexArray
An oglplus_object encapsulating vertex array zero functionality.
Definition: vertex_array.hpp:144
Classes providing additional information about the shape builders.
Class encapsulating the instructions for drawing of a shape.
Definition: draw.hpp:219
Class wrapping program functions (with direct state access)
Definition: program.hpp:176
Object< VertexArrayOps > VertexArray
An oglplus_object encapsulating vertex array object functionality.
Definition: vertex_array.hpp:150