pub struct GlyphMesh<V> {
pub vertices: Vec<V>,
pub indices: Vec<u32>,
pub glyph_id: u32,
}Expand description
A mesh of triangles for GPU rendering.
Contains vertices and indices suitable for indexed drawing.
Indices reference vertices by their position in the vertices array.
§Zero-Copy Upload
Use vertices_bytes() and indices_bytes() to get byte slices
that can be directly uploaded to GPU buffers without copying:
ⓘ
let mesh: GlyphMesh<Vertex2D> = /* ... */;
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Glyph Vertices"),
contents: mesh.vertices_bytes(),
usage: wgpu::BufferUsages::VERTEX,
});
let index_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Glyph Indices"),
contents: mesh.indices_bytes(),
usage: wgpu::BufferUsages::INDEX,
});Fields§
§vertices: Vec<V>Vertex data (position, optionally UV/color)
indices: Vec<u32>Triangle indices (3 indices per triangle)
glyph_id: u32Glyph ID this mesh represents
Implementations§
Source§impl<V> GlyphMesh<V>
impl<V> GlyphMesh<V>
Sourcepub fn with_capacity(
glyph_id: u32,
vertex_capacity: usize,
index_capacity: usize,
) -> Self
pub fn with_capacity( glyph_id: u32, vertex_capacity: usize, index_capacity: usize, ) -> Self
Creates a mesh with pre-allocated capacity.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Returns the number of triangles in this mesh.
Trait Implementations§
Auto Trait Implementations§
impl<V> Freeze for GlyphMesh<V>
impl<V> RefUnwindSafe for GlyphMesh<V>where
V: RefUnwindSafe,
impl<V> Send for GlyphMesh<V>where
V: Send,
impl<V> Sync for GlyphMesh<V>where
V: Sync,
impl<V> Unpin for GlyphMesh<V>where
V: Unpin,
impl<V> UnsafeUnpin for GlyphMesh<V>
impl<V> UnwindSafe for GlyphMesh<V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more