pub struct BufferData<'a, R: Renderable> { /* private fields */ }
Expand description
A data buffer for use with vertex data. It may be indices or vertex coordinates etc.
A data buffer may contain a lot of data per vertex, such as
position, normal, tangent, color etc. a GPU BufferView
on the data is
then a subset of this data - perhaps picking out just the
position, for example, for a set of vertices
The data buffer may, indeed, contain data for more than one object
- and the objects may have different data per vertex.
A data buffer may then be used by many GPU BufferView
s. Each
BufferView
may be used by many primitives for a single model;
alternatively, primitives may have their own individual
BufferViews
.
To allow a Renderable to use the BufferData for multiple views, it supports a ‘client’ field that can be initialized using the ‘init_buffer_data_client’ method of the Renderable, and then borrowed as required during render programming.
Implementations§
Source§impl<'a, R: Renderable> BufferData<'a, R>
impl<'a, R: Renderable> BufferData<'a, R>
Sourcepub fn byte_length(&self) -> u32
pub fn byte_length(&self) -> u32
Get the byte length of the BufferData
Sourcepub fn byte_offset(&self) -> u32
pub fn byte_offset(&self) -> u32
Get the byte offset within the underlying data of the BufferData
Sourcepub fn new<B: ByteBuffer + ?Sized>(
data: &'a B,
byte_offset: u32,
byte_length: u32,
) -> Self
pub fn new<B: ByteBuffer + ?Sized>( data: &'a B, byte_offset: u32, byte_length: u32, ) -> Self
Create a new BufferData given a buffer, offset and length; if the length is zero then the whole of the data buffer post offset is used
If offset and length are both zero, then all the data is used
Sourcepub fn create_client(&self, renderable: &mut R)
pub fn create_client(&self, renderable: &mut R)
Replace the client data with one of this data
Sourcepub fn borrow_client(&self) -> Ref<'_, R::Buffer>
pub fn borrow_client(&self) -> Ref<'_, R::Buffer>
Borrow the client immutably