Window

Struct Window 

Source
pub struct Window { /* private fields */ }
Available on crate feature 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

Source

pub fn new(window_settings: WindowSettings) -> Result<Self, WindowError>

Constructs a new Window with the given settings.

Source

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.

Source

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.

Source

pub fn render_loop<F: 'static + FnMut(FrameInput) -> FrameOutput>( self, callback: F, )

Start the main render loop which calls the callback closure each frame.

Source

pub fn size(&self) -> (u32, u32)

Return the current logical size of the window.

Source

pub fn viewport(&self) -> Viewport

Returns the current viewport of the window in physical pixels (the size of the screen returned from FrameInput::screen).

Source

pub fn device_pixel_ratio(&self) -> f32

Returns the device pixel ratio for this window.

Source

pub fn gl(&self) -> Context

Returns the graphics context for this window.

Auto Trait Implementations§

§

impl Freeze for Window

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl !UnwindSafe for Window

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,