Uniform Buffer Object (UBO) wrapper.
More...
#include <uniform_buffer.hpp>
|
static void | unbind () |
| Unbind any uniform from the OpenGL context.
|
|
Uniform Buffer Object (UBO) wrapper.
- Examples
- batches.cpp, and teapot.cpp.
Definition at line 33 of file uniform_buffer.hpp.
◆ attr_ref
◆ uniform_buffer() [1/4]
staplegl::uniform_buffer::uniform_buffer |
( |
std::span< const float > |
contents, |
|
|
vertex_buffer_layout |
layout, |
|
|
int32_t |
binding_point |
|
) |
| |
|
inlinenoexcept |
Construct a new uniform buffer object.
- Warning
- The driver will not respect the given layout 1:1, especially in terms of alignment. It is best to avoid using vec3 (as they might introduce padding) and explicitly specify an alignment standard such as std140 on every GLSL file that uses the uniform.
- Parameters
-
contents | A buffer of floats that will be used to initialize the uniform buffer's contents |
layout | The layout of the UBO |
binding_point | The point on which this UBO will be bound |
Definition at line 158 of file uniform_buffer.hpp.
◆ uniform_buffer() [2/4]
staplegl::uniform_buffer::uniform_buffer |
( |
vertex_buffer_layout const & |
layout, |
|
|
int32_t |
binding_point |
|
) |
| |
|
inlinenoexcept |
Construct a new uniform buffer object.
- Warning
- The driver will not respect the given layout 1:1, especially in terms of alignment. It is best to avoid using vec3 (as they might introduce padding) and explicitly specify an alignment standard such as std140 on every GLSL file that uses the uniform.
- Parameters
-
layout | The layout of the UBO |
binding_point | The point on which this UBO will be bound |
Definition at line 178 of file uniform_buffer.hpp.
◆ uniform_buffer() [3/4]
◆ uniform_buffer() [4/4]
Construct a new uniform buffer object by moving it.
- Note
- the move constructor simply copies the underlying OpenGL identifier, it is very cheap and leaves the other object with an ID of 0.
- Parameters
-
Definition at line 212 of file uniform_buffer.hpp.
◆ ~uniform_buffer()
staplegl::uniform_buffer::~uniform_buffer |
( |
| ) |
|
|
inline |
◆ bind()
void staplegl::uniform_buffer::bind |
( |
| ) |
const |
|
inline |
◆ binding_point()
constexpr auto staplegl::uniform_buffer::binding_point |
( |
| ) |
const -> int32_t |
|
inlineconstexprnoexcept |
Get the binding point.
- Returns
- int32_t the binding point of this UBO.
Definition at line 132 of file uniform_buffer.hpp.
◆ id()
constexpr auto staplegl::uniform_buffer::id |
( |
| ) |
const -> uint32_t |
|
inlineconstexprnoexcept |
Get the OpenGL identifier.
- Returns
- uint32_t the OpenGL identifier
Definition at line 139 of file uniform_buffer.hpp.
◆ layout()
◆ operator=() [1/2]
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
other | the other uniform buffer object |
- Returns
- uniform_buffer& a reference to the uniform buffer object
Definition at line 221 of file uniform_buffer.hpp.
◆ set_attribute_data() [1/4]
void staplegl::uniform_buffer::set_attribute_data |
( |
std::span< const float > |
uniform_data, |
|
|
const std::string & |
name |
|
) |
| |
|
inline |
Set the attribute data object.
- Warning
- This method does NOT bind the UBO, so you should make sure that the UBO is bound before calling this method.
- Parameters
-
attribute | the attribute to set the data of. |
name | the name of the attribute. |
Definition at line 236 of file uniform_buffer.hpp.
◆ set_attribute_data() [2/4]
void staplegl::uniform_buffer::set_attribute_data |
( |
std::span< const float > |
uniform_data, |
|
|
const std::string & |
name, |
|
|
std::size_t |
offset |
|
) |
| |
|
inline |
Sets the data of an attribute of the UBO.
- Warning
- This method does NOT bind the UBO, so you should make sure that the UBO is bound before calling this method.
- Parameters
-
attribute | the name of the attribute to set the data of. |
name | the name of the attribute. |
offset | the offset of the data interval to set inside the attribute (always 0 for non-array attributes, can vary for array attributes). |
Definition at line 241 of file uniform_buffer.hpp.
◆ set_attribute_data() [3/4]
void staplegl::uniform_buffer::set_attribute_data |
( |
std::span< const float > |
uniform_data, |
|
|
size_t |
attribute_index |
|
) |
| |
|
inline |
◆ set_attribute_data() [4/4]
void staplegl::uniform_buffer::set_attribute_data |
( |
std::span< const float > |
uniform_data, |
|
|
size_t |
attribute_index, |
|
|
std::size_t |
offset |
|
) |
| |
|
inline |
◆ unbind()
void staplegl::uniform_buffer::unbind |
( |
| ) |
|
|
inlinestatic |
◆ m_attr_cache
std::unordered_map<std::string_view, attr_ref> staplegl::uniform_buffer::m_attr_cache |
|
private |
◆ m_binding_point
int32_t staplegl::uniform_buffer::m_binding_point {} |
|
private |
◆ m_id
std::uint32_t staplegl::uniform_buffer::m_id {} |
|
private |
◆ m_layout
The documentation for this class was generated from the following file: