Trait piston_window::prelude::Window
source · pub trait Window {
// Required methods
fn set_should_close(&mut self, value: bool);
fn should_close(&self) -> bool;
fn size(&self) -> Size;
fn swap_buffers(&mut self);
fn wait_event(&mut self) -> Event;
fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>;
fn poll_event(&mut self) -> Option<Event>;
fn draw_size(&self) -> Size;
}
Expand description
Trait representing the minimum requirements for defining a window.
This trait defines all the behavior needed for making an event loop.
An example of a working event loop can be found in the Piston-Tutorials repository under getting-started, or in the event loop examples.
When implementing the Window
trait for a custom window backend,
it is not necessary to emit Event::Loop
variants,
since these are generated by the event loop.
Required Methods§
sourcefn set_should_close(&mut self, value: bool)
fn set_should_close(&mut self, value: bool)
Tells the window to close or stay open.
sourcefn should_close(&self) -> bool
fn should_close(&self) -> bool
Returns true if the window should close.
sourcefn swap_buffers(&mut self)
fn swap_buffers(&mut self)
Swaps render buffers.
When this is set to false, this method must be called manually or through the window backend. By default, it is set to true, so usually it is not needed in application code.
sourcefn wait_event(&mut self) -> Event
fn wait_event(&mut self) -> Event
Wait indefinitely for an input event to be available from the window.
sourcefn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>
fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>
Wait for an input event to be available from the window or for the specified timeout to be reached.
Returns None
only if there is no input event within the timeout.
sourcefn poll_event(&mut self) -> Option<Event>
fn poll_event(&mut self) -> Option<Event>
Polls an input event from the window.
Return None
if no events available.