Skip to main content

RenderMesh

Struct RenderMesh 

Source
pub struct RenderMesh<V> {
    pub glyphs: Vec<GlyphMesh<V>>,
    pub total_vertices: usize,
    pub total_indices: usize,
}
Expand description

A collection of glyph meshes ready for GPU rendering.

This is the Stage 5 output format for GPU pipelines. Each glyph has its own mesh with position offset applied.

§Memory Layout

All vertex types are #[repr(C)] with documented sizes:

  • Vertex2D: 8 bytes (2 × f32)
  • VertexUV: 16 bytes (4 × f32)
  • VertexColor: 24 bytes (6 × f32)
  • Indices: 4 bytes each (u32)

§Merging Meshes

For batch rendering, use merge_all() to combine glyphs into a single mesh:

let render_mesh = RenderMesh::<Vertex2D>::new();
// ... add glyph meshes ...
let (vertices, indices) = render_mesh.merge_all();

Fields§

§glyphs: Vec<GlyphMesh<V>>

Individual glyph meshes

§total_vertices: usize

Total vertex count across all glyphs

§total_indices: usize

Total index count across all glyphs

Implementations§

Source§

impl<V> RenderMesh<V>

Source

pub fn new() -> Self

Creates a new empty render mesh.

Source

pub fn with_capacity(glyph_count: usize) -> Self

Creates a render mesh with pre-allocated capacity.

Source

pub fn push(&mut self, mesh: GlyphMesh<V>)

Adds a glyph mesh to the render mesh.

Source

pub fn glyph_count(&self) -> usize

Returns the number of glyphs in this mesh.

Source

pub fn is_empty(&self) -> bool

Returns true if no geometry has been added.

Source

pub fn total_triangles(&self) -> usize

Returns the total triangle count across all glyphs.

Source§

impl<V: Copy> RenderMesh<V>

Source

pub fn merge_all(&self) -> (Vec<V>, Vec<u32>)

Merges all glyph meshes into single vertex and index buffers.

Index values are adjusted to account for the merged vertex offset. This is the most efficient format for GPU rendering.

Returns (vertices, indices) ready for buffer upload.

Source

pub fn merge_to_bytes(&self) -> (Vec<u8>, Vec<u8>)

Merges all meshes and returns byte slices for direct GPU upload.

This avoids intermediate allocations when possible.

Trait Implementations§

Source§

impl<V: Clone> Clone for RenderMesh<V>

Source§

fn clone(&self) -> RenderMesh<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for RenderMesh<V>

Source§

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

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

impl<V> Default for RenderMesh<V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<V> Freeze for RenderMesh<V>

§

impl<V> RefUnwindSafe for RenderMesh<V>
where V: RefUnwindSafe,

§

impl<V> Send for RenderMesh<V>
where V: Send,

§

impl<V> Sync for RenderMesh<V>
where V: Sync,

§

impl<V> Unpin for RenderMesh<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for RenderMesh<V>

§

impl<V> UnwindSafe for RenderMesh<V>
where V: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.