Struct glium::index::IndexBufferSlice
source · pub struct IndexBufferSlice<'a, T>where
T: Index + 'a,{ /* private fields */ }
Expand description
Slice of an IndexBuffer
.
Implementations§
source§impl<'a, T> IndexBufferSlice<'a, T>where
T: Index + 'a,
impl<'a, T> IndexBufferSlice<'a, T>where T: Index + 'a,
sourcepub fn get_primitives_type(&self) -> PrimitiveType
pub fn get_primitives_type(&self) -> PrimitiveType
Returns the type of primitives associated with this index buffer.
sourcepub fn get_indices_type(&self) -> IndexType
pub fn get_indices_type(&self) -> IndexType
Returns the data type of the indices inside this index buffer.
sourcepub fn slice<R: RangeArgument<usize>>(
&self,
range: R
) -> Option<IndexBufferSlice<'a, T>>
pub fn slice<R: RangeArgument<usize>>( &self, range: R ) -> Option<IndexBufferSlice<'a, T>>
Returns None
if out of range.
Methods from Deref<Target = BufferSlice<'a, [T]>>§
sourcepub fn get_context(&self) -> &Rc<Context>
pub fn get_context(&self) -> &Rc<Context>
Returns the context corresponding to this buffer.
sourcepub fn write(&self, data: &T)
pub fn write(&self, data: &T)
Uploads some data in this buffer.
Implementation
- For persistent-mapped buffers, waits untils the data is no longer used by the GPU then memcpies the data to the mapping.
- For immutable buffers, creates a temporary buffer that contains the data then calls
glCopyBufferSubData
to copy from the temporary buffer to the real one. - For other types, calls
glBufferSubData
.
Panic
Panics if the length of data
is different from the length of this buffer.
sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Invalidates the content of the slice. The data becomes undefined.
This operation is a no-op if the backend doesn’t support it and for persistent-mapped buffers.
Implementation
Calls glInvalidateBufferSubData
if supported.
sourcepub fn copy_to<S>(&self, target: S) -> Result<(), CopyError>where
S: Into<BufferSlice<'a, T>>,
pub fn copy_to<S>(&self, target: S) -> Result<(), CopyError>where S: Into<BufferSlice<'a, T>>,
Copies the content of this slice to another slice.
Panic
Panics if T
is unsized and the other buffer is too small.
sourcepub unsafe fn slice_custom<F, R>(&self, f: F) -> BufferSlice<'a, R>where
F: for<'r> FnOnce(&'r T) -> &'r R,
R: Content + ?Sized,
pub unsafe fn slice_custom<F, R>(&self, f: F) -> BufferSlice<'a, R>where F: for<'r> FnOnce(&'r T) -> &'r R, R: Content + ?Sized,
Builds a slice that contains an element from inside the buffer.
This method builds an object that represents a slice of the buffer. No actual operation OpenGL is performed.
Example
#[derive(Copy, Clone)]
struct BufferContent {
value1: u16,
value2: u16,
}
let slice = unsafe { buffer.slice_custom(|content| &content.value2) };
Safety
The object whose reference is passed to the closure is uninitialized. Therefore you must not access the content of the object.
You must return a reference to an element from the parameter. The closure must not panic.
sourcepub fn as_slice_any(&self) -> BufferAnySlice<'a>
pub fn as_slice_any(&self) -> BufferAnySlice<'a>
Builds a slice-any containing the whole subbuffer.
This method builds an object that represents a slice of the buffer. No actual operation OpenGL is performed.
sourcepub fn slice<R: RangeArgument<usize>>(
&self,
range: R
) -> Option<BufferSlice<'a, [T]>>
pub fn slice<R: RangeArgument<usize>>( &self, range: R ) -> Option<BufferSlice<'a, [T]>>
Builds a subslice of this slice. Returns None
if out of range.
This method builds an object that represents a slice of the buffer. No actual operation OpenGL is performed.
sourcepub fn read_as_texture_1d<S>(&self) -> Result<S, ReadError>where
S: Texture1dDataSink<T>,
pub fn read_as_texture_1d<S>(&self) -> Result<S, ReadError>where S: Texture1dDataSink<T>,
Reads the content of the buffer.