// Create a window for the game.
///
/// Automatically scales the window to cover about 2/3 of the monitor height.
///
/// # Returns
///
/// Tuple of `(window, surface, width, height, hidpi_factor)`
/// `width` and `height` are in `PhysicalSize` units.
Create a window for the game.
Automatically scales the window to cover about 2/3 of the monitor height.
Create a window for the game . Automatically scales the window to cover about 2 / 3 of the monitor height .
pub(crate) fn create_window(
    title: &str,
    event_loop: &EventLoop<()>,
) -> (winit::window::Window, u32, u32, f64) {
    // Create a hidden window so we can estimate a good default window size
    let window = winit::window::WindowBuilder::new()
        .with_visible(false)
        .with_title(title)
        .build(event_loop)
        .unwrap();
    let hidpi_factor = window.scale_factor();
    // Get dimensions
    let width = SCREEN_WIDTH as f64;
    let height = SCREEN_HEIGHT as f64;
    let (monitor_width, monitor_height) = {
        if let Some(monitor) = window.current_monitor() {
            let size = monitor.size().to_logical(hidpi_factor);
            (size.width, size.height)
        } else {
            (width, height)
        }
    };
    let scale = (monitor_height / height * 2.0 / 3.0).round().max(1.0);
    // Resize, center, and display the window
    let min_size: winit::dpi::LogicalSize<f64> =
        winit::dpi::PhysicalSize::new(width, height).to_logical(hidpi_factor);
    let default_size = LogicalSize::new(width * scale, height * scale);
    let center = LogicalPosition::new(
        (monitor_width - width * scale) / 2.0,
        (monitor_height - height * scale) / 2.0,
    );
    window.set_inner_size(default_size);
    window.set_min_inner_size(Some(min_size));
    window.set_outer_position(center);
    window.set_visible(true);
    let size = default_size.to_physical::<f64>(hidpi_factor);
    (
        window,
        size.width.round() as u32,
        size.height.round() as u32,
        hidpi_factor,
    )
}
pub ( crate ) fn create_window ( title : & str , event_loop : & EventLoop < ( ) > , ) -> ( winit :: window :: Window , u32 , u32 , f64 ) { // Create a hidden window so we can estimate a good default window size let window = winit :: window :: WindowBuilder :: new ( ) . with_visible ( false ) . with_title ( title ) . build ( event_loop ) . unwrap ( ) ; let hidpi_factor = window . scale_factor ( ) ; // Get dimensions let width = SCREEN_WIDTH as f64 ; let height = SCREEN_HEIGHT as f64 ; let ( monitor_width , monitor_height ) = { if let Some ( monitor ) = window . current_monitor ( ) { let size = monitor . size ( ) . to_logical ( hidpi_factor ) ; ( size . width , size . height ) } else { ( width , height ) } } ; let scale = ( monitor_height / height * 2.0 / 3.0 ) . round ( ) . max ( 1.0 ) ; // Resize, center, and display the window let min_size : winit :: dpi :: LogicalSize < f64 > = winit :: dpi :: PhysicalSize :: new ( width , height ) . to_logical ( hidpi_factor ) ; let default_size = LogicalSize :: new ( width * scale , height * scale ) ; let center = LogicalPosition :: new ( ( monitor_width - width * scale ) / 2.0 , ( monitor_height - height * scale ) / 2.0 , ) ; window . set_inner_size ( default_size ) ; window . set_min_inner_size ( Some ( min_size ) ) ; window . set_outer_position ( center ) ; window . set_visible ( true ) ; let size = default_size . to_physical :: < f64 > ( hidpi_factor ) ; ( window , size . width . round ( ) as u32 , size . height . round ( ) as u32 , hidpi_factor , ) }
Create a window for the game.
Create a window for the game .
Tuple of `(window, surface, width, height, hidpi_factor)`
`width` and `height` are in `PhysicalSize` units.
Tuple of ` ( window surface width height hidpi_factor ) ` ` width ` and ` height ` are in ` PhysicalSize ` units .
title
&str
event_loop
&EventLoop<()>