pub struct Window { /* private fields */ }window only.Expand description
Default window, context and event handling which uses winit.
To get full control over the creation of the winit window, use Window::from_winit_window. To take control over everything, including the context creation and winit event loop, use WindowedContext::from_winit_window and FrameInputGenerator.
Implementations§
Source§impl Window
impl Window
Sourcepub fn new(window_settings: WindowSettings) -> Result<Self, WindowError>
pub fn new(window_settings: WindowSettings) -> Result<Self, WindowError>
Constructs a new Window with the given settings.
Sourcepub fn from_event_loop(
window_settings: WindowSettings,
event_loop: EventLoop<()>,
) -> Result<Self, WindowError>
pub fn from_event_loop( window_settings: WindowSettings, event_loop: EventLoop<()>, ) -> Result<Self, WindowError>
Exactly the same as Window::new() except with the ability to supply
an existing EventLoop.
Sourcepub fn from_winit_window(
winit_window: Window,
event_loop: EventLoop<()>,
surface_settings: SurfaceSettings,
maximized: bool,
) -> Result<Self, WindowError>
pub fn from_winit_window( winit_window: Window, event_loop: EventLoop<()>, surface_settings: SurfaceSettings, maximized: bool, ) -> Result<Self, WindowError>
Creates a new window from a winit window and event loop with the given surface settings, giving the user full control over the creation of the window. This method takes ownership of the winit window and event loop, if this is not desired, use a WindowedContext or HeadlessContext instead.
Sourcepub fn render_loop<F: 'static + FnMut(FrameInput) -> FrameOutput>(
self,
callback: F,
)
pub fn render_loop<F: 'static + FnMut(FrameInput) -> FrameOutput>( self, callback: F, )
Start the main render loop which calls the callback closure each frame.
Sourcepub fn viewport(&self) -> Viewport
pub fn viewport(&self) -> Viewport
Returns the current viewport of the window in physical pixels (the size of the screen returned from FrameInput::screen).
Sourcepub fn device_pixel_ratio(&self) -> f32
pub fn device_pixel_ratio(&self) -> f32
Returns the device pixel ratio for this window.