Struct three_d::core::buffer::UniformBuffer
source · pub struct UniformBuffer { /* private fields */ }
Expand description
A buffer for transferring a set of uniform variables to the shader program (see also use_uniform_block).
Implementations§
source§impl UniformBuffer
impl UniformBuffer
sourcepub fn new(context: &Context, sizes: &[u32]) -> UniformBuffer
pub fn new(context: &Context, sizes: &[u32]) -> UniformBuffer
Creates a new uniform buffer with room for a set of variables of varying length defined by the sizes
argument.
So for example if you create a uniform buffer with &[3, 1, 4, 16]
as the sizes
argument, you will have a uniform buffer that has four variables:
The first with 3 elements (a Vec3), the second with 1 element (a f32
), the third with four elements (a Vec4) and the last with 16 elements (a Mat4).
The variables are initialized to 0.
sourcepub fn update(&mut self, index: u32, data: &[f32])
pub fn update(&mut self, index: u32, data: &[f32])
Update the values of the variable at the given index with the given data.
§Panic
Will panic if the index is not in the range [0-max]
where max
is the length of the sizes
argument given at construction.
Will panic if the data length does not match the element count of the variable (defined at construction) at the given index.