pub struct Renderer { /* private fields */ }Expand description
Draws frames with a solid pass followed by one textured text pass.
Implementations§
Source§impl Renderer
impl Renderer
pub fn new( device: Device, queue: Queue, format: TextureFormat, atlases: &AtlasSet, scale_factor: f32, ) -> Result<Self>
Sourcepub fn set_scale_factor(&mut self, scale_factor: f32)
pub fn set_scale_factor(&mut self, scale_factor: f32)
Updates the device pixel ratio after a monitor or window change.
Sourcepub fn attach_surface(
&mut self,
surface: Surface<'static>,
config: SurfaceConfiguration,
)
pub fn attach_surface( &mut self, surface: Surface<'static>, config: SurfaceConfiguration, )
Attaches a window surface and configures the swapchain for it.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Reconfigures the swapchain after a window resize.
pub fn format(&self) -> TextureFormat
Sourcepub fn upload_atlas(&mut self, atlases: &AtlasSet)
pub fn upload_atlas(&mut self, atlases: &AtlasSet)
Re-uploads the glyph atlas after new characters were rasterized.
Sourcepub fn render(&mut self, frame: &Frame, viewport: Viewport) -> Result<()>
pub fn render(&mut self, frame: &Frame, viewport: Viewport) -> Result<()>
Draws one frame to the attached surface and presents it.
Sourcepub fn snapshot_png(
&mut self,
frame: &Frame,
viewport: Viewport,
width: u32,
height: u32,
) -> Result<Vec<u8>>
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.