Trait vizia::vg::Renderer

pub trait Renderer {
    type Image;
    type NativeTexture;

    // Required methods
    fn set_size(&mut self, width: u32, height: u32, dpi: f32);
    fn render(
        &mut self,
        images: &mut ImageStore<Self::Image>,
        verts: &[Vertex],
        commands: Vec<Command>
    );
    fn alloc_image(&mut self, info: ImageInfo) -> Result<Self::Image, ErrorKind>;
    fn create_image_from_native_texture(
        &mut self,
        native_texture: Self::NativeTexture,
        info: ImageInfo
    ) -> Result<Self::Image, ErrorKind>;
    fn update_image(
        &mut self,
        image: &mut Self::Image,
        data: ImageSource<'_>,
        x: usize,
        y: usize
    ) -> Result<(), ErrorKind>;
    fn delete_image(&mut self, image: Self::Image, image_id: ImageId);
    fn screenshot(&mut self) -> Result<Img<Vec<Rgba<u8>>>, ErrorKind>;

    // Provided method
    fn get_native_texture(
        &self,
        image: &Self::Image
    ) -> Result<Self::NativeTexture, ErrorKind> { ... }
}
Expand description

This is the main renderer trait that the Canvas draws to.

Required Associated Types§

Required Methods§

fn set_size(&mut self, width: u32, height: u32, dpi: f32)

fn render( &mut self, images: &mut ImageStore<Self::Image>, verts: &[Vertex], commands: Vec<Command> )

fn alloc_image(&mut self, info: ImageInfo) -> Result<Self::Image, ErrorKind>

fn create_image_from_native_texture( &mut self, native_texture: Self::NativeTexture, info: ImageInfo ) -> Result<Self::Image, ErrorKind>

fn update_image( &mut self, image: &mut Self::Image, data: ImageSource<'_>, x: usize, y: usize ) -> Result<(), ErrorKind>

fn delete_image(&mut self, image: Self::Image, image_id: ImageId)

fn screenshot(&mut self) -> Result<Img<Vec<Rgba<u8>>>, ErrorKind>

Provided Methods§

fn get_native_texture( &self, image: &Self::Image ) -> Result<Self::NativeTexture, ErrorKind>

Implementors§

§

impl Renderer for OpenGl

§

type Image = GlTexture

§

type NativeTexture = <Context as HasContext>::Texture

§

impl Renderer for Void

§

type Image = VoidImage

§

type NativeTexture = ()