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<Renderer, Error>
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<Vec<TextureFormat>>,
)
pub fn attach_surface( &mut self, surface: Surface<'static>, config: SurfaceConfiguration<Vec<TextureFormat>>, )
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<(), Error>
pub fn render(&mut self, frame: &Frame, viewport: Viewport) -> Result<(), Error>
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>, Error>
pub fn snapshot_png( &mut self, frame: &Frame, viewport: Viewport, width: u32, height: u32, ) -> Result<Vec<u8>, Error>
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§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl !UnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnsafeUnpin for Renderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.