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

source

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.

source

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.

source

pub fn get(&self, index: u32) -> Option<&[f32]>

Returns the values of the variable at the given index if inside the range of variables, otherwise None.

Trait Implementations§

source§

impl Drop for UniformBuffer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.