Struct MainWindow

Source
pub struct MainWindow { /* private fields */ }
Expand description

This type represents a winit window and an OpenGL context.

Implementations§

Source§

impl MainWindow

Source

pub fn new( event_loop: &ActiveEventLoop, wattr: WindowAttributes, ) -> Result<MainWindow>

Creates a MainWindow with default values.

Source

pub fn with_gl_chooser( event_loop: &ActiveEventLoop, wattr: WindowAttributes, f_choose_cfg: impl FnMut(Config, Config) -> Config, ) -> Result<MainWindow>

Creates a MainWindow with your own OpenGL context chooser.

If you don’t have specific OpenGL needs, prefer using MainWindow::new. If you do, consider using a FramebufferObject and do an offscreen rendering instead.

Source

pub fn set_matrix(&mut self, matrix: Option<Matrix3<f32>>)

Sets a custom matrix that converts physical mouse coordinates into logical ones.

Source

pub unsafe fn into_pieces( self, ) -> (PossiblyCurrentContext, Surface<WindowSurface>, Window)

Splits this window into its parts.

§Safety

Do not drop the window without dropping the surface first.

Source

pub fn glutin_context(&self) -> &PossiblyCurrentContext

Returns the glutin context.

Source

pub fn create_gl_context(&self) -> Context

Creates a new glow OpenGL context for this window and the selected configuration.

Source

pub fn window(&self) -> &Window

Gets a reference to the winit window.

Source

pub fn surface(&self) -> &Surface<WindowSurface>

Returns the glutin surface.

Source

pub fn to_logical_size<X: Pixel, Y: Pixel>( &self, size: PhysicalSize<X>, ) -> LogicalSize<Y>

Converts the given physical size to a logical size, using the window scale factor.

Source

pub fn to_physical_size<X: Pixel, Y: Pixel>( &self, size: LogicalSize<X>, ) -> PhysicalSize<Y>

Converts the given logical size to a physical size, using the window scale factor.

Source

pub fn to_logical_pos<X: Pixel, Y: Pixel>( &self, pos: PhysicalPosition<X>, ) -> LogicalPosition<Y>

Converts the given physical position to a logical position, using the window scale factor.

Source

pub fn to_physical_pos<X: Pixel, Y: Pixel>( &self, pos: LogicalPosition<X>, ) -> PhysicalPosition<Y>

Converts the given logical position to a physical position, using the window scale factor.

Trait Implementations§

Source§

impl MainWindowRef for MainWindow

Main implementation of the MainWindowRef trait for an owned MainWindow.

Source§

fn window(&self) -> &Window

Gets the Window.
Source§

fn pre_render(&mut self)

This runs just before rendering. Read more
Source§

fn post_render(&mut self)

This runs just after rendering. Read more
Source§

fn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32>

The window has been resized. Read more
Source§

fn ping_user_input(&mut self)

Notifies of a user interaction, for idling purposes.
Source§

fn about_to_wait(&mut self, pinged: bool)

There are no more messages, going to idle.
Source§

fn transform_position(&self, pos: Vector2) -> Vector2

Transform the given pos by using the current scale factor.
Source§

fn scale_factor(&self) -> f32

Gets the scale factor of the window, (HiDPI).
Source§

fn set_scale_factor(&self, scale: f32) -> f32

Changes the scale factor. Read more
Source§

fn set_cursor(&mut self, cursor: Option<CursorIcon>)

Changes the mouse cursor.

Auto Trait Implementations§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more