pub struct ElementBuffer<T: ElementBufferDataType> { /* private fields */ }
Expand description
A buffer containing 3 indices for each triangle to be rendered, which is why it is also known as an index buffer. The three indices refer to three places in a set of VertexBuffer where the data (position, normal etc.) is found for the three vertices of the triangle. See for example Program::draw_elements to use this for drawing.
Implementations§
Source§impl<T: ElementBufferDataType> ElementBuffer<T>
impl<T: ElementBufferDataType> ElementBuffer<T>
Sourcepub fn new_with_data(context: &Context, data: &[T]) -> Self
pub fn new_with_data(context: &Context, data: &[T]) -> Self
Creates a new element buffer and fills it with the given indices which must be divisable by 3.
Sourcepub fn fill(&mut self, indices: &[T])
pub fn fill(&mut self, indices: &[T])
Fills the buffer with the given indices which must be divisable by 3. This function will resize the buffer to have the same size as the indices array, if that is not desired, use fill_subset instead.
Sourcepub fn fill_subset(&mut self, offset: u32, indices: &[T])
pub fn fill_subset(&mut self, offset: u32, indices: &[T])
Fills the buffer with the given indices starting at the given offset. This will increase the size of the buffer if there’s not enough room. Otherwise, the size will remain unchanged.
Sourcepub fn triangle_count(&self) -> u32
pub fn triangle_count(&self) -> u32
The number of triangles in the buffer.