glpp::core::object::vertex_array_t class

class for creating and managing vertex arrays in OpenGL

vertex_array_t is a storage class for OpenGL vertex arrays, that creates, owns and manages vertex arrays objects.

Constructors, destructors, conversion operators

vertex_array_t()
default constructor
vertex_array_t(vertex_array_t&& mov) defaulted
move constructor
vertex_array_t(const vertex_array_t& cpy) deleted
copy constructor

Public functions

template<class T>
void attach(const buffer_t<T>& buffer, GLuint index, GLuint binding_point, size_t stride = 0, GLuint elements_per_vertex = attribute_properties<T>::elements_per_vertex, GLenum type = attribute_properties<T>::type, GLintptr offset = 0, bool normalized = false)
attach a buffer object to the vertex array object.
template<class T>
void attach(const buffer_t<T>& buffer, GLuint index, size_t stride = 0, GLuint elements_per_vertex = attribute_properties<T>::elements_per_vertex, GLenum type = attribute_properties<T>::type, GLintptr offset = 0, bool normalized = false)
attach a buffer object to the vertex array object.
void attach_buffer(GLuint binding_point, GLuint index, GLuint elements_per_vertex, GLenum type, GLintptr offset = 0, bool normalized = false)
enable vertex attribute and specify attribute format of a bound buffer
void bind() const
bind vertex array object to OpenGL context
template<class T>
void bind_buffer(const buffer_t<T>& buffer, GLuint binding_point = 0, size_t stride = sizeof(T))
bind a buffer object to a specified binding point
auto operator=(vertex_array_t&& mov) -> vertex_array_t& defaulted
move assignment operator.
auto operator=(const vertex_array_t& cpy) -> vertex_array_t& deleted
copy assignment operator

Function documentation

glpp::core::object::vertex_array_t::vertex_array_t()

default constructor

The default constructor will create an empty vertex array object for later use.

glpp::core::object::vertex_array_t::vertex_array_t(vertex_array_t&& mov) defaulted

move constructor

vertex_array_t is move constructible. mov is invalid after completed move construction.

glpp::core::object::vertex_array_t::vertex_array_t(const vertex_array_t& cpy) deleted

copy constructor

vertex_array_t is not copy constructible.

template<class T>
void glpp::core::object::vertex_array_t::attach(const buffer_t<T>& buffer, GLuint index, GLuint binding_point, size_t stride = 0, GLuint elements_per_vertex = attribute_properties<T>::elements_per_vertex, GLenum type = attribute_properties<T>::type, GLintptr offset = 0, bool normalized = false)

attach a buffer object to the vertex array object.

Parameters
buffer [in] buffer that shall be bound
index [in] index of the vertex attribute that shall be linked to the buffer.
binding_point [in] binding point the buffer shall be bound to. This param has no effect on the binding of index buffers.
stride [in] distance of elements inside the buffer . This param has no effect on the binding of index buffers.
elements_per_vertex [in] elements per vertex. Must be 1, 2, 3 or 4.
type [in] base type
offset [in] offset of the first vertex from the beginning of the buffer.
normalized [in] specify if integral types shall be interpreted as normalized values. This parameter has no effect if base type is a floating point type.

This function will bind and attach a buffer object.

template<class T>
void glpp::core::object::vertex_array_t::attach(const buffer_t<T>& buffer, GLuint index, size_t stride = 0, GLuint elements_per_vertex = attribute_properties<T>::elements_per_vertex, GLenum type = attribute_properties<T>::type, GLintptr offset = 0, bool normalized = false)

attach a buffer object to the vertex array object.

Parameters
buffer [in] buffer that shall be bound
index [in] index of the vertex attribute that shall be linked to the buffer.
stride [in] distance of elements inside the buffer . This param has no effect on the binding of index buffers.
elements_per_vertex [in] elements per vertex. Must be 1, 2, 3 or 4.
type [in] base type
offset [in] offset of the first vertex from the beginning of the buffer.
normalized [in] specify if integral types shall be interpreted as normalized values. This parameter has no effect if base type is a floating point type.

This function will bind and attach a buffer object. This overload will use the attribute index provided as binding point.

void glpp::core::object::vertex_array_t::attach_buffer(GLuint binding_point, GLuint index, GLuint elements_per_vertex, GLenum type, GLintptr offset = 0, bool normalized = false)

enable vertex attribute and specify attribute format of a bound buffer

Parameters
binding_point [in] binding point of bound buffer.
index [in] index of the vertex attribute that shall be linked to the buffer.
elements_per_vertex [in] elements per vertex. Must be 1, 2, 3 or 4.
type [in] base type
offset [in] offset of the first vertex from the beginning of the buffer.
normalized [in] specify if integral types shall be interpreted as normalized values. This parameter has no effect if base type is a floating point type.

After completion of bind_buffer the vertex attribute is not fully initialised and activated. Therefore a call to attatch_buffer is needed. This function will enable the vertex attribute and specify the internal attribute format. If no control over binding_point or the internal data layout is needed, the attach member function should be used over the bind_buffer/attatch_buffer approach.

void glpp::core::object::vertex_array_t::bind() const

bind vertex array object to OpenGL context

This function will bind the underlying vao of the OpenGL state machiene. After completion of the bind following buffer operations will be bound to this vertex array object.

template<class T>
void glpp::core::object::vertex_array_t::bind_buffer(const buffer_t<T>& buffer, GLuint binding_point = 0, size_t stride = sizeof(T))

bind a buffer object to a specified binding point

Parameters
buffer [in] buffer that shall be bound
binding_point [in] binding point the buffer shall be bound to. This param has no effect on the binding of index buffers.
stride [in] distance of elements inside the buffer . This param has no effect on the binding of index buffers.

This member function will bind a buffer object to the vertex array object. After binding the format of the data must be specified with a call to attach_buffer. If no control over binding_point or the internal data layout is needed, the attach member function should be used over the bind_buffer/attatch_buffer approach.

vertex_array_t& glpp::core::object::vertex_array_t::operator=(vertex_array_t&& mov) defaulted

move assignment operator.

vertex_array_t is move assignable. mov is invalid after completed move operation.

vertex_array_t& glpp::core::object::vertex_array_t::operator=(const vertex_array_t& cpy) deleted

copy assignment operator

vertex_array_t is not copy assignable.