Expand description
Running a game with no window, for tools and tests.
A Session owns a game and an offscreen target, and advances it one
frame at a time: no window, no event loop, no presentation. It draws
exactly as a window would, and one stream of moves drives both the
controls the game reads and its UI.
Needs the offscreen feature, native only and off by default; absent
on wasm32.
use mirage_engine::headless::Session;
use mirage_engine::prelude::*;
let mut session = Session::new(Config::new("probe"), UVec2::new(320, 200), |_ctx| Ok(Probe))?;
for _ in 0..60 {
let started = std::time::Instant::now();
let stats = session.step();
println!("{} draws took {:?}", stats.draw_calls(), started.elapsed());
}
let pixels = session.pixels()?;
assert_eq!(pixels.len(), 320 * 200 * 4);Re-exports§
pub use crate::input::Switch;
Structs§
- Frame
Stats - Counts one
Session::stepturned the game’s draws into. - Session
- A game running against an offscreen target, one frame per
Session::step.