Struct luminance::buffer::Buffer
[−]
[src]
pub struct Buffer<T> { /* fields omitted */ }
A Buffer
is a GPU region you can picture as an array. It has a static size and cannot be
resized. The size is expressed in number of elements lying in the buffer, not in bytes.
Methods
impl<T> Buffer<T>
[src]
fn new(len: usize) -> Buffer<T>
Create a new Buffer
with a given number of elements.
fn len(&self) -> usize
Get the length of the buffer.
fn at(&self, i: usize) -> Option<T> where T: Copy
Retrieve an element from the Buffer
.
Checks boundaries.
fn whole(&self) -> Vec<T> where T: Copy
Retrieve the whole content of the Buffer
.
fn set(&mut self, i: usize, x: T) -> Result<(), BufferError> where T: Copy
Set a value at a given index in the Buffer
.
Checks boundaries.
fn write_whole(&self, values: &[T]) -> Result<(), BufferError>
Write a whole slice into a buffer.
If the slice you pass in as less items than the length of the buffer, you’ll get a
BufferError::TooFewValues
. If it has more, you’ll get BufferError::TooManyValues
.
In all cases, the copy will be performed and clamped to reasonable length.
fn clear(&self, x: T) where T: Copy
Fill the Buffer
with a single value.
fn fill(&self, values: &[T])
Fill the whole buffer with an array.
unsafe fn from_raw(raw: RawBuffer) -> Self
Create a new buffer from its raw representation.
This function is unsafe becomes it assumes that the representation is compliant to the type you want it to be.
fn to_raw(self) -> RawBuffer
Convert a buffer to its raw representation.
Methods from Deref<Target=RawBuffer>
fn as_slice<T>(&self) -> Result<BufferSlice<T>, BufferError>
Obtain an immutable slice view into the buffer.
fn as_slice_mut<T>(&mut self) -> Result<BufferSliceMut<T>, BufferError>
Obtain a mutable slice view into the buffer.
unsafe fn handle(&self) -> GLuint
Trait Implementations
impl<T: Debug> Debug for Buffer<T>
[src]
impl<T> Deref for Buffer<T>
[src]
type Target = RawBuffer
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value