StapleGL
Header-only C++20 OpenGL wrapper
Loading...
Searching...
No Matches
staplegl::vertex_buffer_layout Class Reference

Vertex buffer layout. More...

#include <vertex_buffer_layout.hpp>

Public Member Functions

 vertex_buffer_layout ()=default
 
 vertex_buffer_layout (std::initializer_list< vertex_attribute > attributes)
 Construct a new vertex buffer layout object.
 
constexpr auto stride () const noexcept -> std::size_t
 Get the stride of the vertex buffer layout.
 
constexpr auto stride_elements () const noexcept -> std::size_t
 Get the stride of the vertex buffer layout in elements (assuming float-only data).
 
auto get_attributes () const noexcept -> std::span< const vertex_attribute >
 Get the data of the vertex buffer layout as a non-owning view.
 
auto operator[] (std::size_t index) const -> const vertex_attribute &
 Get a single attribute from the vertex buffer layout.
 

Private Attributes

std::vector< vertex_attributem_attributes
 
std::size_t m_stride {}
 

Detailed Description

Vertex buffer layout.

Represents a vertex buffer layout, that is, a collection of vertex attributes. Through this class one can specify a layout through which a buffer's data can be interpreted by OpenGL.

See also
vertex_attribute
shader_data_type
vertex_buffer.hpp
Examples
batches.cpp, sandbox.cpp, and teapot.cpp.

Definition at line 78 of file vertex_buffer_layout.hpp.

Constructor & Destructor Documentation

◆ vertex_buffer_layout() [1/2]

staplegl::vertex_buffer_layout::vertex_buffer_layout ( )
default

◆ vertex_buffer_layout() [2/2]

staplegl::vertex_buffer_layout::vertex_buffer_layout ( std::initializer_list< vertex_attribute attributes)
inline

Construct a new vertex buffer layout object.

Parameters
attributesa list of vertex attributes.
See also
vertex_attribute

Definition at line 92 of file vertex_buffer_layout.hpp.

Member Function Documentation

◆ get_attributes()

auto staplegl::vertex_buffer_layout::get_attributes ( ) const -> std::span<const vertex_attribute>
inlinenoexcept

Get the data of the vertex buffer layout as a non-owning view.

Returns
std::span<const vertex_attribute>, the data of the vertex buffer layout.

Definition at line 120 of file vertex_buffer_layout.hpp.

◆ operator[]()

auto staplegl::vertex_buffer_layout::operator[] ( std::size_t  index) const -> const vertex_attribute&
inline

Get a single attribute from the vertex buffer layout.

Parameters
indexthe index of the attribute to get.
Returns
const vertex_attribute& the attribute at the specified index.

Definition at line 131 of file vertex_buffer_layout.hpp.

◆ stride()

constexpr auto staplegl::vertex_buffer_layout::stride ( ) const -> std::size_t
inlineconstexprnoexcept

Get the stride of the vertex buffer layout.

Returns
std::size_t, the stride of the vertex buffer layout.

Definition at line 106 of file vertex_buffer_layout.hpp.

◆ stride_elements()

constexpr auto staplegl::vertex_buffer_layout::stride_elements ( ) const -> std::size_t
inlineconstexprnoexcept

Get the stride of the vertex buffer layout in elements (assuming float-only data).

Returns
std::size_t, the number of elements in a vertex.

Definition at line 113 of file vertex_buffer_layout.hpp.

Member Data Documentation

◆ m_attributes

std::vector<vertex_attribute> staplegl::vertex_buffer_layout::m_attributes
private

Definition at line 81 of file vertex_buffer_layout.hpp.

◆ m_stride

std::size_t staplegl::vertex_buffer_layout::m_stride {}
private

Definition at line 82 of file vertex_buffer_layout.hpp.


The documentation for this class was generated from the following file: