libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Member Functions | List of all members
donut::graphics::ShaderArray< T, N > Class Template Reference

Fixed-size array of uniform shader variable identifiers representing an array inside a ShaderProgram. More...

#include <donut/graphics/ShaderParameter.hpp>

Public Member Functions

 ShaderArray (const ShaderProgram &program, const char *name)
 Construct an array of uniform shader variable identifiers for a specific shader array. More...
 
std::size_t size () const noexcept
 Get the size of the array. More...
 
T & operator[] (std::size_t i)
 Access an element of the array. More...
 
const T & operator[] (std::size_t i) const
 Access an element of the array. More...
 
decltype(auto) begin () const noexcept
 Get an iterator to the beginning of the array. More...
 
decltype(auto) end () const noexcept
 Get an iterator to the end of the array. More...
 

Detailed Description

template<typename T, std::size_t N>
class donut::graphics::ShaderArray< T, N >

Fixed-size array of uniform shader variable identifiers representing an array inside a ShaderProgram.

Template Parameters
Tthe type of uniform shader variable identifier to use for each element of the array.
Nthe number of elements in the array.
Examples
example_game.cpp.

Constructor & Destructor Documentation

◆ ShaderArray()

template<typename T , std::size_t N>
donut::graphics::ShaderArray< T, N >::ShaderArray ( const ShaderProgram program,
const char *  name 
)
inline

Construct an array of uniform shader variable identifiers for a specific shader array.

Parameters
programshader program in which the array resides.
namename of the array.
Exceptions
std::bad_allocon allocation failure.
Note
If the array elements are not found, the resulting identifiers will be invalid.

Member Function Documentation

◆ size()

template<typename T , std::size_t N>
std::size_t donut::graphics::ShaderArray< T, N >::size ( ) const
inlinenoexcept

Get the size of the array.

Returns
the number of elements in the array, which is always equal to template parameter N.

◆ operator[]() [1/2]

template<typename T , std::size_t N>
T& donut::graphics::ShaderArray< T, N >::operator[] ( std::size_t  i)
inline

Access an element of the array.

Parameters
ithe index of the element to get. Must be less than the size of the array.
Returns
a reference to the element at index i.

◆ operator[]() [2/2]

template<typename T , std::size_t N>
const T& donut::graphics::ShaderArray< T, N >::operator[] ( std::size_t  i) const
inline

Access an element of the array.

Parameters
ithe index of the element to get. Must be less than the size of the array.
Returns
a read-only reference to the element at index i.

◆ begin()

template<typename T , std::size_t N>
decltype(auto) donut::graphics::ShaderArray< T, N >::begin ( ) const
inlinenoexcept

Get an iterator to the beginning of the array.

Returns
the begin iterator.

◆ end()

template<typename T , std::size_t N>
decltype(auto) donut::graphics::ShaderArray< T, N >::end ( ) const
inlinenoexcept

Get an iterator to the end of the array.

Returns
the end iterator.

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