Struct cgl_rs::graphics::MeshGPU

source ·
pub struct MeshGPU { /* private fields */ }

Implementations§

source§

impl MeshGPU

source

pub fn new() -> Result<MeshGPU, &'static str>

Creates a new MeshGPU instance.

Returns

Returns a Result containing a MeshGPU instance if successful, or a &'static str error message if unsuccessful.

Example
cgl_rs::init();
let mut window = cgl_rs::window::Window::new("Test Window", 800, 600).unwrap();
cgl_rs::graphics::init();
{
    let mesh = cgl_rs::graphics::MeshGPU::new().unwrap();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
source

pub fn render(&self)

Renders the mesh using the GPU.

Example
cgl_rs::init();
let mut window = cgl_rs::window::Window::new("Test Window", 800, 600).unwrap();
cgl_rs::graphics::init();
{
    let mesh = cgl_rs::graphics::MeshGPU::new().unwrap();
    mesh.render();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
source

pub fn render_instanced(&self, instance_count: u32)

Renders the mesh using the GPU with instancing.

  • instance_count - The number of instances to render.
Example
cgl_rs::init();
let mut window = cgl_rs::window::Window::new("Test Window", 800, 600).unwrap();
cgl_rs::graphics::init();
{
    let mesh = cgl_rs::graphics::MeshGPU::new().unwrap();
    mesh.render_instanced(10);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
source

pub fn upload(&mut self, mesh_cpu: &MeshCPU, static_draw: bool)

Uploads the mesh data to the GPU.

  • mesh_cpu - The mesh data to upload.
  • static_draw - Whether the mesh data is static or dynamic.
Example
cgl_rs::init();
let mut window = cgl_rs::window::Window::new("Test Window", 800, 600).unwrap();
cgl_rs::graphics::init();
{
    let mut mesh_cpu = cgl_rs::graphics::MeshCPU::new(3, 3).unwrap();
    let mut mesh_gpu = cgl_rs::graphics::MeshGPU::new().unwrap();
    mesh_gpu.upload(&mesh_cpu, true);
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();
source

pub fn destroy(&mut self)

Destroys the mesh GPU handle if it has not already been destroyed.

Example
cgl_rs::init();
let mut window = cgl_rs::window::Window::new("Test Window", 800, 600).unwrap();
cgl_rs::graphics::init();
{
    let mut mesh = cgl_rs::graphics::MeshGPU::new().unwrap();
    mesh.destroy();
}
cgl_rs::graphics::shutdown();
window.destroy();
cgl_rs::shutdown();

Trait Implementations§

source§

impl Clone for MeshGPU

source§

fn clone(&self) -> Self

Returns a copy 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 Drop for MeshGPU

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.