Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer { /* private fields */ }
Expand description

Draws frames with a solid pass followed by one textured text pass.

Implementations§

Source§

impl Renderer

Source

pub fn new( device: Device, queue: Queue, format: TextureFormat, atlases: &AtlasSet, scale_factor: f32, ) -> Result<Self>

Source

pub fn set_scale_factor(&mut self, scale_factor: f32)

Updates the device pixel ratio after a monitor or window change.

Source

pub fn attach_surface( &mut self, surface: Surface<'static>, config: SurfaceConfiguration, )

Attaches a window surface and configures the swapchain for it.

Source

pub fn resize(&mut self, width: u32, height: u32)

Reconfigures the swapchain after a window resize.

Source

pub fn format(&self) -> TextureFormat

Source

pub fn upload_atlas(&mut self, atlases: &AtlasSet)

Re-uploads the glyph atlas after new characters were rasterized.

Source

pub fn render(&mut self, frame: &Frame, viewport: Viewport) -> Result<()>

Draws one frame to the attached surface and presents it.

Source

pub fn snapshot_png( &mut self, frame: &Frame, viewport: Viewport, width: u32, height: u32, ) -> Result<Vec<u8>>

Draws one frame into a texture the caller owns, and hands back the pixels as PNG bytes.

A window presents a swapchain image, so render is all it needs. A snapshot has nowhere to present: a doc image, a CI job, or a test on a machine with no display. This runs the same pipelines against the same frame, so what comes back is what the window would have shown.

width and height are the image size in device pixels; the viewport is in logical pixels and is scaled by the device pixel ratio the renderer was built with.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,