pub struct Mesh {
pub indices: Vec<u32, Global>,
pub vertices: Vec<Vertex, Global>,
pub texture_id: TextureId,
}
Expand description
Textured triangles in two dimensions.
Fields
indices: Vec<u32, Global>
Draw as triangles (i.e. the length is always multiple of three).
If you only support 16-bit indices you can use Mesh::split_to_u16
.
egui is NOT consistent with what winding order it uses, so turn off backface culling.
vertices: Vec<Vertex, Global>
The vertex data indexed by indices
.
texture_id: TextureId
The texture to use when drawing these triangles.
Implementations
sourceimpl Mesh
impl Mesh
pub fn with_texture(texture_id: TextureId) -> Mesh
pub fn bytes_used(&self) -> usize
pub fn is_empty(&self) -> bool
sourcepub fn calc_bounds(&self) -> Rect
pub fn calc_bounds(&self) -> Rect
Calculate a bounding rectangle.
sourcepub fn append_ref(&mut self, other: &Mesh)
pub fn append_ref(&mut self, other: &Mesh)
Append all the indices and vertices of other
to self
without
taking ownership.
pub fn colored_vertex(&mut self, pos: Pos2, color: Color32)
sourcepub fn add_triangle(&mut self, a: u32, b: u32, c: u32)
pub fn add_triangle(&mut self, a: u32, b: u32, c: u32)
Add a triangle.
sourcepub fn reserve_triangles(&mut self, additional_triangles: usize)
pub fn reserve_triangles(&mut self, additional_triangles: usize)
Make room for this many additional triangles (will reserve 3x as many indices).
See also reserve_vertices
.
sourcepub fn reserve_vertices(&mut self, additional: usize)
pub fn reserve_vertices(&mut self, additional: usize)
Make room for this many additional vertices.
See also reserve_triangles
.
sourcepub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32)
pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32)
Rectangle with a texture and color.
sourcepub fn add_colored_rect(&mut self, rect: Rect, color: Color32)
pub fn add_colored_rect(&mut self, rect: Rect, color: Color32)
Uniformly colored rectangle.
sourcepub fn split_to_u16(self) -> Vec<Mesh16, Global>
pub fn split_to_u16(self) -> Vec<Mesh16, Global>
This is for platforms that only support 16-bit index buffers.
Splits this mesh into many smaller meshes (if needed) where the smaller meshes have 16-bit indices.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Mesh
impl<'de> Deserialize<'de> for Mesh
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Mesh, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Mesh, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl PartialEq<Mesh> for Mesh
impl PartialEq<Mesh> for Mesh
sourceimpl Serialize for Mesh
impl Serialize for Mesh
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Mesh
Auto Trait Implementations
impl RefUnwindSafe for Mesh
impl Send for Mesh
impl Sync for Mesh
impl Unpin for Mesh
impl UnwindSafe for Mesh
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more