Struct glium::vertex::VertexBufferAny
source · pub struct VertexBufferAny { /* private fields */ }
Expand description
A list of vertices loaded in the graphics card’s memory.
Contrary to VertexBuffer
, this struct doesn’t know about the type of data
inside the buffer. Therefore you can’t map or read it.
This struct is provided for convenience, so that you can have a Vec<VertexBufferAny>
,
or return a VertexBufferAny
instead of a VertexBuffer<MyPrivateVertexType>
.
Implementations§
source§impl VertexBufferAny
impl VertexBufferAny
sourcepub fn get_elements_size(&self) -> usize
pub fn get_elements_size(&self) -> usize
Returns the number of bytes between two consecutive elements in the buffer.
sourcepub fn get_bindings(&self) -> &VertexFormat
pub fn get_bindings(&self) -> &VertexFormat
Returns the associated VertexFormat
.
sourcepub unsafe fn into_vertex_buffer<T: Copy>(self) -> VertexBuffer<T>
pub unsafe fn into_vertex_buffer<T: Copy>(self) -> VertexBuffer<T>
Turns the vertex buffer into a VertexBuffer
without checking the type.
sourcepub fn per_instance(&self) -> Result<PerInstance<'_>, InstancingNotSupported>
pub fn per_instance(&self) -> Result<PerInstance<'_>, InstancingNotSupported>
Creates a marker that instructs glium to use multiple instances.
Instead of calling surface.draw(&vertex_buffer, ...)
you can call
surface.draw(vertex_buffer.per_instance(), ...)
. This will draw one instance of the
geometry for each element in this buffer. The attributes are still passed to the
vertex shader, but each entry is passed for each different instance.
Methods from Deref<Target = BufferAny>§
sourcepub fn as_slice_any(&self) -> BufferAnySlice<'_>
pub fn as_slice_any(&self) -> BufferAnySlice<'_>
Builds a slice-any containing the whole subbuffer.
sourcepub unsafe fn as_typed_slice_mut<T: ?Sized + Content>(
&mut self
) -> BufferMutSlice<'_, T>
pub unsafe fn as_typed_slice_mut<T: ?Sized + Content>( &mut self ) -> BufferMutSlice<'_, T>
Builds a mutable typed slice containing the whole subbuffer, without checking the type.
sourcepub unsafe fn as_typed_slice<T: ?Sized + Content>(&self) -> BufferSlice<'_, T>
pub unsafe fn as_typed_slice<T: ?Sized + Content>(&self) -> BufferSlice<'_, T>
Builds a typed slice containing the whole subbuffer, without checking the type.
sourcepub fn get_elements_size(&self) -> usize
pub fn get_elements_size(&self) -> usize
Returns the size in bytes of each element in the buffer.
sourcepub fn get_elements_count(&self) -> usize
pub fn get_elements_count(&self) -> usize
Returns the number of elements in the buffer.
sourcepub fn get_context(&self) -> &Rc<Context>
pub fn get_context(&self) -> &Rc<Context>
Returns the context corresponding to this buffer.
sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Invalidates the content of the buffer. The data becomes undefined.
This operation is a no-op if the backend doesn’t support it and for persistent-mapped buffers.
sourcepub unsafe fn read<T>(&self) -> Result<T::Owned, ReadError>where
T: Content,
pub unsafe fn read<T>(&self) -> Result<T::Owned, ReadError>where T: Content,
UNSTABLE. This function can be removed at any moment without any further notice.
Considers that the buffer is filled with elements of type T
and reads them.
Panic
Panics if the size of the buffer is not a multiple of the size of the data.
For example, trying to read some (u8, u8, u8, u8)
s from a buffer of 7 bytes will panic.