Trait riddle_renderer_wgpu::RenderContext[][src]

pub trait RenderContext {
    fn set_transform(
        &mut self,
        transform: ColumnMatrix4<f32>
    ) -> Result<(), RendererError>;
fn clear(&mut self, color: Color<f32>) -> Result<(), RendererError>;
fn render_internal<R: WGPURenderable>(
        &mut self,
        renderable: &R
    ) -> Result<(), RendererError>;
fn fill_rect(
        &mut self,
        rect: &Rect<f32>,
        color: Color<f32>
    ) -> Result<(), RendererError>;
fn present(self) -> Result<(), RendererError>; }

Types which accept render calls, tracks current world transform, and are consumed when the calls are presented.

Example

let mut render_ctx /*: impl RenderContext*/ = renderer.begin_render()?;

render_ctx.clear(Color::RED)?;

// Change the current transform matrix, and draw a rect
render_ctx.set_transform(glam::Mat4::from_scale(glam::vec3(2.0, 2.0, 1.0)).into())?;
render_ctx.fill_rect(&Rect::new(vec2(0.0, 0.0), vec2(10.0, 10.0)), Color::GREEN)?;

render_ctx.present()?;

Required methods

fn set_transform(
    &mut self,
    transform: ColumnMatrix4<f32>
) -> Result<(), RendererError>
[src]

Replace the current world transform.

fn clear(&mut self, color: Color<f32>) -> Result<(), RendererError>[src]

Fill the target with a flat color.

fn render_internal<R: WGPURenderable>(
    &mut self,
    renderable: &R
) -> Result<(), RendererError>
[src]

Render a Renderable to the target with the current world transform.

This is only called by internal crate code.

fn fill_rect(
    &mut self,
    rect: &Rect<f32>,
    color: Color<f32>
) -> Result<(), RendererError>
[src]

Draw a solid rect with the given color.

fn present(self) -> Result<(), RendererError>[src]

Consume the context and present any outstanding draw calls.

Loading content...

Implementors

Loading content...