pub struct MeshGPU { /* private fields */ }
Implementations§
source§impl MeshGPU
impl MeshGPU
sourcepub fn new() -> Result<MeshGPU, &'static str>
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();
sourcepub fn render(&self)
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();
sourcepub fn render_instanced(&self, instance_count: u32)
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();
sourcepub fn upload(&mut self, mesh_cpu: &MeshCPU, static_draw: bool)
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();
sourcepub fn destroy(&mut self)
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§
Auto Trait Implementations§
impl RefUnwindSafe for MeshGPU
impl !Send for MeshGPU
impl !Sync for MeshGPU
impl Unpin for MeshGPU
impl UnwindSafe for MeshGPU
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