pub struct AppConfig {Show 13 fields
pub title: String,
pub width: u32,
pub height: u32,
pub vsync: bool,
pub fixed_timestep: Option<Duration>,
pub max_frame_time: Duration,
pub asset_root: PathBuf,
pub web_preload: Option<Vec<String>>,
pub canvas_id: Option<String>,
pub random_seed: u64,
pub depth_format: Option<TextureFormat>,
pub msaa_samples: u32,
pub touch_emulates_mouse: bool,
}Expand description
Runtime configuration passed to run.
Construct it with ..Default::default() so new fields added in future minor releases don’t
break your call site: AppConfig { title: "game".into(), ..Default::default() }.
Fields§
§title: String§width: u32§height: u32§vsync: bool§fixed_timestep: Option<Duration>Some(step) calls update with a fixed dt of step: zero, one or several times per
frame, as many as the real time elapsed allows. None (default) calls it once per
frame with the frame’s dt. Either way render runs once per frame; with a fixed
step, Time::alpha says how far the frame is into the next step,
for interpolating motion between steps.
Leave this None if the game steps a simulation itself, e.g. a sillyecs world whose
apply_system_phases runs its own fixed phases from real time; otherwise those fixed
phases nest inside the toolkit’s steps.
Input edges (key_pressed, mouse_delta, …) are seen by the first update of a
frame and carried over to the next frame when no step ran, so presses aren’t dropped.
max_frame_time: DurationUpper bound on the time one frame advances the game (default 250 ms). After a long
frame - the window was dragged, the tab was in the background, a breakpoint hit - the
game slows down for that frame instead of fast-forwarding through the gap: dt is
capped at this, and with a fixed timestep at most max_frame_time / step updates run.
Time::delta still reports the real frame time.
Duration::ZERO disables the cap.
asset_root: PathBufAsset root directory. Defaults to ./assets. On the web it is a URL path relative to
the page, and the files listed in its manifest.txt are fetched before Game::init.
web_preload: Option<Vec<String>>Web only: asset paths to preload instead of reading manifest.txt. Ignored natively.
canvas_id: Option<String>Web only: id of an existing <canvas> to render into. None (default) appends a new
canvas to <body>. Ignored natively.
random_seed: u64Seed for deterministic runtime RNG (ctx.rng).
depth_format: Option<TextureFormat>Depth attachment format. None (default) keeps the 2D path depth-less; Some(fmt)
(e.g. wgpu::TextureFormat::Depth32Float) allocates a depth buffer for depth-tested
rendering. The built-in 2D pipelines never write depth, so enabling it is harmless.
msaa_samples: u32MSAA sample count for the surface. 1 (default) disables MSAA; 2/4/8 enable it
(the value must be supported by the adapter for the surface format).
touch_emulates_mouse: boolLet the first finger on a touchscreen act as the mouse: it moves the cursor and
presses, holds and releases MouseButton::Left,
so a game written for the mouse also works on a phone. Off by default; toggle later
with Input::set_touch_emulates_mouse,
which has the details. No effect on Windows, where the OS already does this.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppConfig
impl RefUnwindSafe for AppConfig
impl Send for AppConfig
impl Sync for AppConfig
impl Unpin for AppConfig
impl UnsafeUnpin for AppConfig
impl UnwindSafe for AppConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.