Struct InstanceBuffer

Source
pub struct InstanceBuffer<T: BufferDataType> { /* private fields */ }
Expand description

A buffer containing per instance data. To send this data to a shader, use the Program::use_instance_attribute method.

Implementations§

Source§

impl<T: BufferDataType> InstanceBuffer<T>

Source

pub fn new(context: &Context) -> Self

Creates a new empty instance buffer.

Source

pub fn new_with_data(context: &Context, data: &[T]) -> Self

Creates a new instance buffer and fills it with the given data. The data should be in the same format as specified in the shader. As an example, if specified as vec3 in the shader it needs to be specified as an array of Vector3<T> where T is a primitive type that implements BufferDataType, for example can be f16 or f32.

Source

pub fn fill(&mut self, data: &[T])

Fills the instance buffer with the given data. The data should be in the same format as specified in the shader. As an example, if specified as vec3 in the shader it needs to be specified as an array of Vector3<T> where T is a primitive type that implements BufferDataType, for example can be f16 or f32. This function will resize the buffer to have the same size as the data, if that is not desired, use fill_subset instead.

Source

pub fn fill_subset(&mut self, offset: u32, data: &[T])

Fills the vertex buffer with the given data starting at the given offset. This will increase the size of the buffer if there’s not enough room. Otherwise, the size will remain unchanged.

Source

pub fn count(&self) -> u32

The number of values in the buffer.

Source

pub fn instance_count(&self) -> u32

The number of instance attributes in the buffer.

Auto Trait Implementations§

§

impl<T> Freeze for InstanceBuffer<T>

§

impl<T> RefUnwindSafe for InstanceBuffer<T>
where T: RefUnwindSafe,

§

impl<T> Send for InstanceBuffer<T>
where T: Send,

§

impl<T> Sync for InstanceBuffer<T>
where T: Sync,

§

impl<T> Unpin for InstanceBuffer<T>
where T: Unpin,

§

impl<T> UnwindSafe for InstanceBuffer<T>
where T: UnwindSafe,

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>,

Source§

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>,

Source§

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.
Source§

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