#[non_exhaustive]pub struct Window {
pub title: &'static str,
pub width: i32,
pub height: i32,
pub icon: Option<Icon>,
pub vsync: bool,
}Expand description
The window a game opens. Build it with Window::new: a struct
literal doesn’t compile outside this crate, so a new field never breaks
a game (ADR-0039).
let window = shuyi_app::Window {
title: "A game",
width: 640,
height: 480,
icon: None,
vsync: true,
};Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.title: &'static strThe title bar’s text.
width: i32The window’s size at start, in pixels (the window is resizable).
height: i32See width.
icon: Option<Icon>The window’s icon, if the game has one.
vsync: boolWhether the window asks the display’s driver for vsync: on by
default (Window::new), so frames don’t tear. The driver may
ignore it, and it is read only when the window opens, so it is the
developer’s choice, not the player’s.
The frame cap (shuyi_ui::frame_cap, 60 frames a second unless the
game or the player says) limits the rate either way, and never
waits on top of vsync: on a 60 Hz display with vsync on, a cap of 60
leaves vsync to it. On a VRR display (G-Sync, FreeSync, adaptive
sync) with vsync on, a cap a few frames under the display’s refresh
(141 on a 144 Hz display) keeps it in its variable range, and the
display follows the frames. A tick stage steps 60 times a second, so
above 60 each step shows for whole frames: evenly at 120 and 240, but
2 and 3 frames in turn at 144 and 165; a cap that is a multiple of 60
avoids it.
Implementations§
Source§impl Window
impl Window
Sourcepub const fn new(title: &'static str, width: i32, height: i32) -> Self
pub const fn new(title: &'static str, width: i32, height: i32) -> Self
A window titled title, width × height pixels at start, with
no icon (with_icon gives one) and vsync on
(with_vsync turns it off).
Sourcepub const fn with_icon(self, icon: Option<Icon>) -> Self
pub const fn with_icon(self, icon: Option<Icon>) -> Self
The window with icon (None for none): usable in a const
item.
Sourcepub const fn with_vsync(self, vsync: bool) -> Self
pub const fn with_vsync(self, vsync: bool) -> Self
The window asking for vsync or not (vsync):
usable in a const item.