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
impl<'vertices, R: Renderable> Vertices<'vertices, R>
ip Vertices
Sourcepub fn new(
indices: Option<&'vertices BufferIndexAccessor<'vertices, R>>,
position: &'vertices BufferDataAccessor<'vertices, R>,
) -> Self
pub fn new( indices: Option<&'vertices BufferIndexAccessor<'vertices, R>>, position: &'vertices BufferDataAccessor<'vertices, R>, ) -> Self
Create a new Vertices object with no additional attributes
Sourcepub fn add_attr(
&mut self,
accessor: &'vertices BufferDataAccessor<'vertices, R>,
)
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
Sourcepub fn borrow_indices<'a>(
&'a self,
) -> Option<&'a BufferIndexAccessor<'vertices, R>>
pub fn borrow_indices<'a>( &'a self, ) -> Option<&'a BufferIndexAccessor<'vertices, R>>
Borrow the indices [BufferAccessor]
Sourcepub fn borrow_attr<'a>(
&'a self,
attr: VertexAttr,
) -> Option<&'a BufferDataAccessor<'vertices, R>>
pub fn borrow_attr<'a>( &'a self, attr: VertexAttr, ) -> Option<&'a BufferDataAccessor<'vertices, R>>
Borrow an attribute BufferDataAccessor if the Vertices has one
Sourcepub fn iter_attrs(&self) -> Iter<'_, &BufferDataAccessor<'vertices, R>>
pub fn iter_attrs(&self) -> Iter<'_, &BufferDataAccessor<'vertices, R>>
Iterate through attributes
Sourcepub fn create_client(&self, renderer: &mut R)
pub fn create_client(&self, renderer: &mut R)
Create the render buffer required by the BufferAccessor
Sourcepub fn borrow_client(&self) -> Ref<'_, R::Vertices>
pub fn borrow_client(&self) -> Ref<'_, R::Vertices>
Borrow the client