pub struct WindowConfig {
pub title: String,
pub width: u32,
pub height: u32,
pub target_fps: Option<u32>,
pub fill_viewport: bool,
}Expand description
Window configuration for run_windowed / run_app.
Deliberately renderer-agnostic: pixel dimensions, not grid/font/scale.
Use fit to derive the pixel size from a presenter’s own
cell geometry.
Fields§
§title: StringWindow title.
width: u32Initial inner width in physical pixels.
height: u32Initial inner height in physical pixels.
target_fps: Option<u32>Optional frame-rate cap. None = uncapped (native) / display refresh
(wasm, which is always rAF-driven).
fill_viewport: boolOn wasm32, size (and keep resizing) the canvas to fill the browser
viewport instead of width/height – a full-screen, mobile-web-app
feel for games that want it. Has no effect on native, where the OS
window is already sized to width/height and the window manager
owns further resizing either way.
Defaults to false in fit: most demos/examples
should render at their natural grid size (cols x cell_w by rows x cell_h) wherever they land on the page, not stretch to fill
whatever viewport happens to be hosting them. Opt in explicitly for
an app-like, full-screen game.
Implementations§
Source§impl WindowConfig
impl WindowConfig
Sourcepub fn fit<P: Presenter>(
presenter: &P,
title: impl Into<String>,
target_fps: Option<u32>,
) -> Self
pub fn fit<P: Presenter>( presenter: &P, title: impl Into<String>, target_fps: Option<u32>, ) -> Self
Size the window to exactly fit presenter’s grid:
cols x cell_w by rows x cell_h physical pixels.
This is why renderer crates don’t need their own windowing code: the
grid/cell geometry already lives behind Presenter::size and
Presenter::cell_size.
Auto Trait Implementations§
impl Freeze for WindowConfig
impl RefUnwindSafe for WindowConfig
impl Send for WindowConfig
impl Sync for WindowConfig
impl Unpin for WindowConfig
impl UnsafeUnpin for WindowConfig
impl UnwindSafe for WindowConfig
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.