pub struct VertexBuffer { /* private fields */ }
Expand description

A buffer containing per vertex data, for example positions, normals, uv coordinates or colors. To send this data to a shader, use the Program::use_vertex_attribute method.

Implementations§

source§

impl VertexBuffer

source

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

Creates a new empty vertex buffer.

source

pub fn new_with_data<T: BufferDataType>(context: &Context, data: &[T]) -> Self

Creates a new vertex buffer and fills it with the given data. The data should be in the same format as specified in the shader. As an example, if specified as vec3 in the shader it needs to be specified as an array of Vector3<T> where T is a primitive type that implements BufferDataType, for example can be f16 or f32.

source

pub fn fill<T: BufferDataType>(&mut self, data: &[T])

Fills the vertex buffer with the given data. The data should be in the same format as specified in the shader. As an example, if specified as vec3 in the shader it needs to be specified as an array of Vector3<T> where T is a primitive type that implements BufferDataType, for example can be f16 or f32.

source

pub fn count(&self) -> u32

The number of values in the buffer.

source

pub fn vertex_count(&self) -> u32

The number of vertex attributes in the buffer.

Auto Trait Implementations§

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

§

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

§

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.