Struct ElementBuffer

Source
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>

Source

pub fn new(context: &Context) -> Self

Creates a new empty element buffer.

Source

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.

Source

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.

Source

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.

Source

pub fn count(&self) -> u32

The number of values in the buffer.

Source

pub fn triangle_count(&self) -> u32

The number of triangles in the buffer.

Trait Implementations§

Source§

impl<T: ElementBufferDataType> Drop for ElementBuffer<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ElementBuffer<T>

§

impl<T> RefUnwindSafe for ElementBuffer<T>
where T: RefUnwindSafe,

§

impl<T> Send for ElementBuffer<T>
where T: Send,

§

impl<T> Sync for ElementBuffer<T>
where T: Sync,

§

impl<T> Unpin for ElementBuffer<T>
where T: Unpin,

§

impl<T> UnwindSafe for ElementBuffer<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,