Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer {
    // Required methods
    fn begin(
        &mut self,
        width: u32,
        height: u32,
        camera: Camera,
    ) -> &mut dyn Canvas;
    fn present(&mut self) -> Frame;
    fn backend(&self) -> Backend;
}
Expand description

The renderer — opens a Canvas for a frame, then presents it. The 2-category swap (CPU / CPU+GPU) is expressed entirely as which Renderer the host holds; the draw code is written once against Canvas.

Required Methods§

Source

fn begin(&mut self, width: u32, height: u32, camera: Camera) -> &mut dyn Canvas

Begin a frame of width × height pixels under camera, returning the Canvas to push instances into.

Source

fn present(&mut self) -> Frame

Finish the frame and produce the rasterized Frame (straight RGBA8).

Source

fn backend(&self) -> Backend

Which Backend this renderer is.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§