pub struct Context<A: App> { /* private fields */ }
Expand description
The main entry point into the engine context. All state is initialized by this type.
Implementations
sourceimpl<A: App> Context<A>
impl<A: App> Context<A>
Asset related functions.
sourcepub fn request_read<C: FnMut(&mut Context<A>, &mut A, Vec<Asset>) + Send + 'static>(
&mut self,
relative_paths: &[&str],
callback: C
)
pub fn request_read<C: FnMut(&mut Context<A>, &mut A, Vec<Asset>) + Send + 'static>(
&mut self,
relative_paths: &[&str],
callback: C
)
Requests a read of an asset. This produces an AssetRead event with the result of the read once it has completed.
Platform-specific
- Non-web: The path is relative to the current working directory.
- Web: The path is relative to the current url’s root.
sourceimpl<A: App> Context<A>
impl<A: App> Context<A>
Graphics and window related functions.
sourcepub fn default_texture(&self) -> Texture
pub fn default_texture(&self) -> Texture
Returns a simple 1x1 white texture. This texture is reused globally.
sourcepub fn max_texture_size(&self) -> i32
pub fn max_texture_size(&self) -> i32
Gets the max texture size supported on the GPU.
sourcepub fn max_texture_anisotropy(&self) -> Option<f32>
pub fn max_texture_anisotropy(&self) -> Option<f32>
Gets the max anisotropic texture filtering supported by the GPU. Returns None if unsupported.
sourcepub fn set_window_title(&self, title: &str)
pub fn set_window_title(&self, title: &str)
sourcepub fn set_window_display_mode(&self, display_mode: DisplayMode)
pub fn set_window_display_mode(&self, display_mode: DisplayMode)
Sets the display mode of the window.
sourcepub fn window_logical_size(&self) -> Vector2<f32>
pub fn window_logical_size(&self) -> Vector2<f32>
Gets the logical size of the window. This may differ from the viewport’s logical size.
sourcepub fn window_physical_size(&self) -> Vector2<f32>
pub fn window_physical_size(&self) -> Vector2<f32>
Gets the physical size of the window. This may differ from the viewport’s physical size.
sourcepub fn window_cursor_grab(&self, grab: bool)
pub fn window_cursor_grab(&self, grab: bool)
Grabs the cursor, preventing it from leaving the window.
Platform-specific
- macOS: This locks the cursor in a fixed location, which looks visually awkward.
sourcepub fn window_cursor_visibility(&self, grab: bool)
pub fn window_cursor_visibility(&self, grab: bool)
Sets the visibility of the cursor.
Platform-specific
- Windows: The cursor is only hidden within the confines of the window.
- X11: The cursor is only hidden within the confines of the window.
- Wayland: The cursor is only hidden within the confines of the window.
- macOS: The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window.
sourcepub fn viewport_logical_size(&self) -> Vector2<f32>
pub fn viewport_logical_size(&self) -> Vector2<f32>
Gets the logical size of the viewport. This may differ from the window’s logical size.
sourcepub fn viewport_physical_size(&self) -> Vector2<f32>
pub fn viewport_physical_size(&self) -> Vector2<f32>
Gets the physical size of the viewport. This may differ from the window’s physical size.
sourceimpl<A: App> Context<A>
impl<A: App> Context<A>
Event loop related functions.
sourcepub fn request_stop(&mut self)
pub fn request_stop(&mut self)
Stops the context after the next update.
sourcepub fn wait_for(&mut self, duration: Duration)
pub fn wait_for(&mut self, duration: Duration)
Prevents the update event from being sent for at least the duration. If a periodic wait is active, this wait will temporarily override only if it causes the next update event to happen later than the periodic wait would have.
sourcepub fn wait_until(&mut self, instant: Instant)
pub fn wait_until(&mut self, instant: Instant)
Prevents the update event from being sent until at least the given instant. If a periodic wait is active, this wait will temporarily override only if it causes the next update event to happen later than the periodic wait would have.
sourcepub fn wait_periodic(&mut self, duration: Option<Duration>)
pub fn wait_periodic(&mut self, duration: Option<Duration>)
Prevents the update event from being sent more frequently than the given duration. Set this to None to disable the periodic wait.
Auto Trait Implementations
impl<A> !RefUnwindSafe for Context<A>
impl<A> Send for Context<A>
impl<A> !Sync for Context<A>
impl<A> Unpin for Context<A>
impl<A> !UnwindSafe for Context<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more