Struct Vertices

Source
pub struct Vertices<'vertices, R: Renderable> { /* private fields */ }
Expand description

A set of vertices using one or more crate::BufferData through [BufferAccessor]s.

A number of Vertices is used by an Object, its components and their meshes; one is used for each primitive within a mesh for its elements. The actual elements will be sets of triangles (as stripes or whatever) which use these vertices.

A Vertices object includes a lot of options for vertices, and different renderers (or different render stages) may require different subsets of these indices. As such, in OpenGL for example, a Vertices object may end up with more than one VAO. This data is part of the [VerticesClient] struct associated with the Vertices. In WebGPU there may more than one render pipeline for different shader pipelines for the same set of vertices.

When it comes to creating an instance of a mesh, that instance will have specific transformations and materials for each of its primitives; rendering the instance with a shader will require enabling the Vertices client for that shader, setting appropriate render options (uniforms in OpenGL)

FIXME - change to using VertexDesc instead of VeretxAttr? - this requires removing VertexAttr from here and using that in its BufferDataAccessor

Implementations§

Source§

impl<'vertices, R: Renderable> Vertices<'vertices, R>

ip Vertices

Source

pub fn new( indices: Option<&'vertices BufferIndexAccessor<'vertices, R>>, position: &'vertices BufferDataAccessor<'vertices, R>, ) -> Self

Create a new Vertices object with no additional attributes

Source

pub fn add_attr( &mut self, accessor: &'vertices BufferDataAccessor<'vertices, R>, )

Add a [BufferAccessor] for a particular VertexAttr

On creation the Vertices will have views for indices and positions; this provides a means to add views for things such as normal, tex coords, etc

Source

pub fn borrow_indices<'a>( &'a self, ) -> Option<&'a BufferIndexAccessor<'vertices, R>>

Borrow the indices [BufferAccessor]

Source

pub fn borrow_attr<'a>( &'a self, attr: VertexAttr, ) -> Option<&'a BufferDataAccessor<'vertices, R>>

Borrow an attribute BufferDataAccessor if the Vertices has one

Source

pub fn iter_attrs(&self) -> Iter<'_, &BufferDataAccessor<'vertices, R>>

Iterate through attributes

Source

pub fn create_client(&self, renderer: &mut R)

Create the render buffer required by the BufferAccessor

Source

pub fn borrow_client(&self) -> Ref<'_, R::Vertices>

Borrow the client

Trait Implementations§

Source§

impl<'vertices, R: Debug + Renderable> Debug for Vertices<'vertices, R>
where R::Vertices: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'vertices, R> Display for Vertices<'vertices, R>
where R: Renderable,

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'vertices, R> !Freeze for Vertices<'vertices, R>

§

impl<'vertices, R> !RefUnwindSafe for Vertices<'vertices, R>

§

impl<'vertices, R> !Send for Vertices<'vertices, R>

§

impl<'vertices, R> !Sync for Vertices<'vertices, R>

§

impl<'vertices, R> Unpin for Vertices<'vertices, R>
where <R as Renderable>::Vertices: Unpin,

§

impl<'vertices, R> !UnwindSafe for Vertices<'vertices, R>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.