Struct luminance::buffer::Buffer[][src]

pub struct Buffer<B: ?Sized, T> where
    B: BufferBackend<T>,
    T: Copy
{ /* fields omitted */ }
Expand description

A GPU buffer.

Parametricity

  • B is the backend type. It must implement backend::buffer::Buffer. -T is the type of stored items. No restriction are currently enforced on that type, besides the fact it must be Sized.

Implementations

Create a new buffer with a given length

The buffer will be created on the GPU with a contiguous region large enough to fit len items.

The stored item must be Default, as this function will initialize the whole buffer with the default value.

Errors

That function can fail creating the buffer for various reasons, in which case it returns Err(BufferError::_). Feel free to read the documentation of BufferError for further information.

Notes

You might be interested in the GraphicsContext::new_buffer function instead, which is the exact same function, but benefits from more type inference (based on &mut C).

Create a new buffer from a slice of items.

The buffer will be created with a length equal to the length of the input size, and items will be copied from the slice inside the contiguous GPU region.

Errors

That function can fail creating the buffer for various reasons, in which case it returns Err(BufferError::_). Feel free to read the documentation of BufferError for further information.

Notes

You might be interested in the GraphicsContext::new_buffer_from_vec function instead, which is the exact same function, but benefits from more type inference (based on &mut C).

Create a new buffer by repeating len times a value.

The buffer will be comprised of len items, all equal to value.

Errors

That function can fail creating the buffer for various reasons, in which case it returns Err(BufferError::_). Feel free to read the documentation of BufferError for further information.

Notes

You might be interested in the GraphicsContext::new_buffer_repeating function instead, which is the exact same function, but benefits from more type inference (based on &mut C).

Get the item at the given index.

Get the whole content of the buffer and store it inside a Vec.

Set a value x at index i in the buffer.

Errors

That function returns BufferError::Overflow if i is bigger than the length of the buffer. Other errors are possible; please consider reading the documentation of BufferError for further information.

Set the content of the buffer by using a slice that will be copied at the buffer’s memory location.

Errors

BufferError::TooFewValues is returned if the input slice has less items than the buffer.

BufferError::TooManyValues is returned if the input slice has more items than the buffer.

Clear the content of the buffer by copying the same value everywhere.

Return the length of the buffer (i.e. the number of elements).

Check whether the buffer is empty (i.e. it has no elements).

Note

Since right now, it is not possible to grow vectors, it is highly recommended not to create empty buffers. That function is there only for convenience and demonstration; you shouldn’t really have to use it.

Create a new BufferSlice from a buffer, allowing to get &[T] out of it.

Errors

That function might fail and return a BufferError::MapFailed.

Create a new BufferSliceMut from a buffer, allowing to get &mut [T] out of it.

Errors

That function might fail and return a BufferError::MapFailed.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.