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

Element Buffer Object (EBO) wrapper. More...

#include <index_buffer.hpp>

Public Member Functions

 index_buffer ()=default
 
 index_buffer (std::span< const std::uint32_t > indices) noexcept
 Construct a new index buffer object.
 
 ~index_buffer ()
 Destroy the index buffer object.
 
 index_buffer (const index_buffer &)=delete
 
auto operator= (const index_buffer &) -> index_buffer &=delete
 
 index_buffer (index_buffer &&) noexcept
 Construct a new index buffer object.
 
auto operator= (index_buffer &&) noexcept -> index_buffer &
 Move assignment operator.
 
void bind () const
 Bind the index buffer object.
 
void unbind () const
 Unbind the index buffer object.
 
constexpr auto count () const -> std::int32_t
 Get the number of indices in the index buffer object.
 
constexpr auto id () const -> std::uint32_t
 Get the ID of the index buffer object.
 

Private Attributes

std::uint32_t m_id {}
 
std::int32_t m_count {}
 

Detailed Description

Element Buffer Object (EBO) wrapper.

Element Buffer Objects are OpenGL objects that store indices that OpenGL uses to render primitives, they can be bound to a VAO to specify the order in which to render the vertices contained in its VBOs.

EBOs are used to reduce the amount of data that needs to be sent to the GPU, by allowing the reuse of vertices.

See also
vertex_array
vertex_buffer
https://www.khronos.org/opengl/wiki/Vertex_Specification#Element_Buffer_Object
Examples
batches.cpp, sandbox.cpp, and teapot.cpp.

Definition at line 44 of file index_buffer.hpp.

Constructor & Destructor Documentation

◆ index_buffer() [1/4]

staplegl::index_buffer::index_buffer ( )
default

◆ index_buffer() [2/4]

staplegl::index_buffer::index_buffer ( std::span< const std::uint32_t >  indices)
inlinenoexcept

Construct a new index buffer object.

Parameters
indicesa pointer to the indices array, can be any contiguous container of std::uint32_t.
countthe number of indices in the array.

Definition at line 115 of file index_buffer.hpp.

◆ ~index_buffer()

staplegl::index_buffer::~index_buffer ( )
inline

Destroy the index buffer object.

Definition at line 127 of file index_buffer.hpp.

◆ index_buffer() [3/4]

staplegl::index_buffer::index_buffer ( const index_buffer )
delete

◆ index_buffer() [4/4]

staplegl::index_buffer::index_buffer ( index_buffer &&  other)
inlinenoexcept

Construct a new index buffer object.

Parameters
otherthe other index buffer object to move from.

Moving from an index buffer object is cheap, as it only involves copying the internal OpenGL ID, the other object is therefore left with an ID of 0.

Definition at line 134 of file index_buffer.hpp.

Member Function Documentation

◆ bind()

void staplegl::index_buffer::bind ( ) const
inline

Bind the index buffer object.

Definition at line 153 of file index_buffer.hpp.

◆ count()

constexpr auto staplegl::index_buffer::count ( ) const -> std::int32_t
constexpr

Get the number of indices in the index buffer object.

Returns
std::int32_t, the number of indices.

Definition at line 163 of file index_buffer.hpp.

◆ id()

constexpr auto staplegl::index_buffer::id ( ) const -> std::uint32_t
constexpr

Get the ID of the index buffer object.

Returns
std::uint32_t the ID of the index buffer object.

◆ operator=() [1/2]

auto staplegl::index_buffer::operator= ( const index_buffer ) -> index_buffer &=delete
delete

◆ operator=() [2/2]

auto staplegl::index_buffer::operator= ( index_buffer &&  other) -> index_buffer&
inlinenoexcept

Move assignment operator.

Parameters
otherthe other index buffer object to move from.
Returns
index_buffer& The moved object.

Definition at line 141 of file index_buffer.hpp.

◆ unbind()

void staplegl::index_buffer::unbind ( ) const
inline

Unbind the index buffer object.

Definition at line 158 of file index_buffer.hpp.

Member Data Documentation

◆ m_count

std::int32_t staplegl::index_buffer::m_count {}
private

Definition at line 112 of file index_buffer.hpp.

◆ m_id

std::uint32_t staplegl::index_buffer::m_id {}
private

Definition at line 111 of file index_buffer.hpp.


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