Skip to main content

Offscreen

Struct Offscreen 

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

A game drawn offscreen, a frame at a time, with no window. Made by App::offscreen.

Implementations§

Source§

impl Offscreen

Source

pub fn frame( &mut self, elapsed: Duration, events: &[Event], ) -> Result<Vec<u8>, Error>

Runs one frame that comes elapsed after the last, with the events that came before it, as App::update does. Then draws it as App::run does, waits for every asset loaded so far and makes it, and returns the frame’s pixels: RGBA8, sRGB-encoded, from the top row, 4 bytes a pixel.

Unlike App::run, it waits for the asset server’s workers, so that each frame shows every asset loaded before it, and a recording is the same each time. The assets loaded before the first frame are made after it is drawn, so it shows none of them. A first frame of Duration::ZERO makes them without a tick.

§Errors

Error::Render if the frame cannot be drawn or read back.

Source

pub fn app(&self) -> &App

The game.

Source

pub fn size(&self) -> UVec2

The size of each frame, in pixels.

Source

pub fn renderer(&self) -> &str

The renderer that draws the frames, as the driver names it: for instance llvmpipe (LLVM 20.1.2, 256 bits).

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> 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.