pub struct MeshHandle {
pub layouts: Vec<(ATTRInfo, u32)>,
pub draw_mode: DrawMode,
pub has_indices: bool,
pub vert_count: u32,
pub ind_count: u32,
pub vao_id: u32,
pub buf_id: u32,
pub ind_id: u32,
pub vert_stride: u32,
pub instance_buf_id: u32,
pub instance_count: u32,
}Expand description
Low-level OpenGL mesh handle wrapping VAO, VBO, IBO, and instance state.
Created by Mesh3DFile::ship or
Mesh2DFile::ship. Contains the vertex
layouts, draw mode, index state, and instance buffer binding.
Fields§
§layouts: Vec<(ATTRInfo, u32)>§draw_mode: DrawMode§has_indices: bool§vert_count: u32§ind_count: u32§vao_id: u32§buf_id: u32§ind_id: u32§vert_stride: u32§instance_buf_id: u32§instance_count: u32Implementations§
Source§impl MeshHandle
impl MeshHandle
Sourcepub fn draw(&self)
pub fn draw(&self)
Issues the draw call for this mesh (instanced or non-instanced, indexed or array).
Sourcepub fn set_instances(&mut self, buffer: &InstanceBuffer)
pub fn set_instances(&mut self, buffer: &InstanceBuffer)
Binds an instance buffer to this mesh for instanced rendering.
Instance attributes are appended after the vertex attributes using
glVertexAttribDivisor(1).
Sourcepub fn update_vertex<D: DataType>(
&self,
index: u32,
attr_index: usize,
value: D,
) -> OpticResult<()>
pub fn update_vertex<D: DataType>( &self, index: u32, attr_index: usize, value: D, ) -> OpticResult<()>
Updates a single vertex attribute value on the GPU.
The type D must match the attribute’s declared type at creation time.
Sourcepub fn get_vertex<D: DataType>(
&self,
index: u32,
attr_index: usize,
) -> OpticResult<D>
pub fn get_vertex<D: DataType>( &self, index: u32, attr_index: usize, ) -> OpticResult<D>
Reads a single vertex attribute value from the GPU.
Sourcepub fn write_range(&self, start_vertex: u32, data: &[u8]) -> OpticResult<()>
pub fn write_range(&self, start_vertex: u32, data: &[u8]) -> OpticResult<()>
Writes raw vertex data starting at start_vertex.
data length must be a multiple of the vertex stride.
Trait Implementations§
Source§impl Clone for MeshHandle
impl Clone for MeshHandle
Source§fn clone(&self) -> MeshHandle
fn clone(&self) -> MeshHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MeshHandle
impl RefUnwindSafe for MeshHandle
impl Send for MeshHandle
impl Sync for MeshHandle
impl Unpin for MeshHandle
impl UnsafeUnpin for MeshHandle
impl UnwindSafe for MeshHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more