Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer {
    // Required methods
    fn viewport(&self) -> (f64, f64);
    fn set_camera(&mut self, camera: Camera);
    fn clear(&self, color: &str);
    fn project(&self, world: Vec3) -> Option<ScreenPoint>;
    fn line(
        &self,
        a: ScreenPoint,
        b: ScreenPoint,
        color: &str,
        alpha: f64,
        width: f64,
    );
    fn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64);
    fn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64);
}
Expand description

An immediate-mode renderer for line/point 3D scenes.

Colors are CSS color strings (e.g. "#67e8f9", "rgba(...)") so the CPU backend can pass them straight to Canvas 2D; a GPU backend parses them.

Required Methods§

Source

fn viewport(&self) -> (f64, f64)

Current drawable size in physical pixels.

Source

fn set_camera(&mut self, camera: Camera)

Set the active camera used for Renderer::project.

Source

fn clear(&self, color: &str)

Clear the frame to a solid background color.

Source

fn project(&self, world: Vec3) -> Option<ScreenPoint>

Project a world-space point to screen space (CPU-side cull/fade helper).

Source

fn line( &self, a: ScreenPoint, b: ScreenPoint, color: &str, alpha: f64, width: f64, )

Draw a screen-space line segment.

Source

fn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64)

Draw a filled screen-space disc (billboarded point).

Source

fn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64)

Fill a screen-space polygon (e.g. a depth-shaded quad).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Renderer for NativeRenderer

Available on non-WebAssembly only.