pub struct MainWindow { /* private fields */ }Expand description
This type represents a winit window and an OpenGL context.
Implementations§
Source§impl MainWindow
impl MainWindow
Sourcepub fn new(
event_loop: &ActiveEventLoop,
wattr: WindowAttributes,
) -> Result<MainWindow>
pub fn new( event_loop: &ActiveEventLoop, wattr: WindowAttributes, ) -> Result<MainWindow>
Creates a MainWindow with default values.
Sourcepub fn with_gl_chooser(
event_loop: &ActiveEventLoop,
wattr: WindowAttributes,
f_choose_cfg: impl FnMut(Config, Config) -> Config,
) -> Result<MainWindow>
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.
Sourcepub fn set_matrix(&mut self, matrix: Option<Matrix3<f32>>)
pub fn set_matrix(&mut self, matrix: Option<Matrix3<f32>>)
Sets a custom matrix that converts physical mouse coordinates into logical ones.
Sourcepub unsafe fn into_pieces(
self,
) -> (PossiblyCurrentContext, Surface<WindowSurface>, Window)
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.
Sourcepub fn glutin_context(&self) -> &PossiblyCurrentContext
pub fn glutin_context(&self) -> &PossiblyCurrentContext
Returns the glutin context.
Sourcepub fn create_gl_context(&self) -> Context
pub fn create_gl_context(&self) -> Context
Creates a new glow OpenGL context for this window and the selected configuration.
Sourcepub fn surface(&self) -> &Surface<WindowSurface>
pub fn surface(&self) -> &Surface<WindowSurface>
Returns the glutin surface.
Sourcepub fn to_logical_size<X: Pixel, Y: Pixel>(
&self,
size: PhysicalSize<X>,
) -> LogicalSize<Y>
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.
Sourcepub fn to_physical_size<X: Pixel, Y: Pixel>(
&self,
size: LogicalSize<X>,
) -> PhysicalSize<Y>
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.
Sourcepub fn to_logical_pos<X: Pixel, Y: Pixel>(
&self,
pos: PhysicalPosition<X>,
) -> LogicalPosition<Y>
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.
Sourcepub fn to_physical_pos<X: Pixel, Y: Pixel>(
&self,
pos: LogicalPosition<X>,
) -> PhysicalPosition<Y>
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.
impl MainWindowRef for MainWindow
Main implementation of the MainWindowRef trait for an owned MainWindow.
Source§fn pre_render(&mut self)
fn pre_render(&mut self)
Source§fn post_render(&mut self)
fn post_render(&mut self)
Source§fn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32>
fn resize(&mut self, size: PhysicalSize<u32>) -> LogicalSize<f32>
Source§fn ping_user_input(&mut self)
fn ping_user_input(&mut self)
Source§fn about_to_wait(&mut self, pinged: bool)
fn about_to_wait(&mut self, pinged: bool)
Source§fn transform_position(&self, pos: Vector2) -> Vector2
fn transform_position(&self, pos: Vector2) -> Vector2
pos by using the current scale factor.Source§fn scale_factor(&self) -> f32
fn scale_factor(&self) -> f32
Source§fn set_cursor(&mut self, cursor: Option<CursorIcon>)
fn set_cursor(&mut self, cursor: Option<CursorIcon>)
Auto Trait Implementations§
impl Freeze for MainWindow
impl !RefUnwindSafe for MainWindow
impl !Send for MainWindow
impl !Sync for MainWindow
impl Unpin for MainWindow
impl !UnwindSafe for MainWindow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more