Struct piston_window::PistonWindow
source · pub struct PistonWindow<W: Window = GlutinWindow> {
pub window: W,
pub encoder: GfxEncoder,
pub device: Device,
pub output_color: RenderTargetView<Resources, Srgba8>,
pub output_stencil: DepthStencilView<Resources, DepthStencil>,
pub g2d: Gfx2d<Resources>,
pub events: Events,
pub factory: Factory,
}
Expand description
Contains everything required for controlling window, graphics, event loop.
Fields
window: W
The window.
encoder: GfxEncoder
GFX encoder.
device: Device
GFX device.
output_color: RenderTargetView<Resources, Srgba8>
Output frame buffer.
output_stencil: DepthStencilView<Resources, DepthStencil>
Output stencil buffer.
g2d: Gfx2d<Resources>
Gfx2d.
events: Events
Event loop state.
factory: Factory
The factory that was created along with the device.
Implementations
sourceimpl<W> PistonWindow<W>where
W: Window,
impl<W> PistonWindow<W>where
W: Window,
sourcepub fn new(opengl: OpenGL, samples: u8, window: W) -> Selfwhere
W: OpenGLWindow,
pub fn new(opengl: OpenGL, samples: u8, window: W) -> Selfwhere
W: OpenGLWindow,
Creates a new piston window.
sourcepub fn draw_2d<E, F, U>(&mut self, e: &E, f: F) -> Option<U>where
W: OpenGLWindow,
E: GenericEvent,
F: FnOnce(Context, &mut G2d<'_>) -> U,
pub fn draw_2d<E, F, U>(&mut self, e: &E, f: F) -> Option<U>where
W: OpenGLWindow,
E: GenericEvent,
F: FnOnce(Context, &mut G2d<'_>) -> U,
Renders 2D graphics.
Calls the closure on render events. There is no need to filter events manually, and there is no overhead.
sourcepub fn draw_3d<E, F, U>(&mut self, e: &E, f: F) -> Option<U>where
W: OpenGLWindow,
E: GenericEvent,
F: FnOnce(&mut Self) -> U,
pub fn draw_3d<E, F, U>(&mut self, e: &E, f: F) -> Option<U>where
W: OpenGLWindow,
E: GenericEvent,
F: FnOnce(&mut Self) -> U,
Renders 3D graphics.
Calls the closure on render events. There is no need to filter events manually, and there is no overhead.
sourcepub fn next(&mut self) -> Option<Event>
pub fn next(&mut self) -> Option<Event>
Returns next event. Cleans up after rendering and resizes frame buffers.
sourcepub fn event<E: GenericEvent>(&mut self, event: &E)
pub fn event<E: GenericEvent>(&mut self, event: &E)
Let window handle new event. Cleans up after rendering and resizes frame buffers.
Trait Implementations
sourceimpl<W> AdvancedWindow for PistonWindow<W>where
W: AdvancedWindow,
impl<W> AdvancedWindow for PistonWindow<W>where
W: AdvancedWindow,
sourcefn get_exit_on_esc(&self) -> bool
fn get_exit_on_esc(&self) -> bool
Gets whether to exit when pressing esc. Read more
sourcefn set_exit_on_esc(&mut self, value: bool)
fn set_exit_on_esc(&mut self, value: bool)
Sets whether to exit when pressing esc. Read more
sourcefn set_capture_cursor(&mut self, value: bool)
fn set_capture_cursor(&mut self, value: bool)
Sets whether to capture/grab the cursor. Read more
sourcefn get_position(&self) -> Option<Position>
fn get_position(&self) -> Option<Position>
Gets the position of window. Read more
sourcefn set_position<P: Into<Position>>(&mut self, pos: P)
fn set_position<P: Into<Position>>(&mut self, pos: P)
Sets the position of window. Read more
fn exit_on_esc(self, value: bool) -> Self
fn exit_on_esc(self, value: bool) -> Self
Sets whether to exit when pressing the Esc button. Read more
fn capture_cursor(self, value: bool) -> Self
fn capture_cursor(self, value: bool) -> Self
Sets whether to capture/grab the cursor. Read more
sourceimpl<W> BuildFromWindowSettings for PistonWindow<W>where
W: Window + OpenGLWindow + BuildFromWindowSettings,
impl<W> BuildFromWindowSettings for PistonWindow<W>where
W: Window + OpenGLWindow + BuildFromWindowSettings,
sourcefn build_from_window_settings(
settings: &WindowSettings
) -> Result<PistonWindow<W>, String>
fn build_from_window_settings(
settings: &WindowSettings
) -> Result<PistonWindow<W>, String>
Builds the window from a
WindowSettings
object. Read moresourceimpl<W> EventLoop for PistonWindow<W>where
W: Window,
impl<W> EventLoop for PistonWindow<W>where
W: Window,
sourcefn get_event_settings(&self) -> EventSettings
fn get_event_settings(&self) -> EventSettings
Returns event loop settings.
sourcefn set_event_settings(&mut self, settings: EventSettings)
fn set_event_settings(&mut self, settings: EventSettings)
Sets event loop settings.
fn set_ups_reset(&mut self, frames: u64)
fn set_ups_reset(&mut self, frames: u64)
The number of delayed updates before skipping them to catch up.
When set to
0
, it will always try to catch up. Read morefn ups_reset(self, frames: u64) -> Self
fn ups_reset(self, frames: u64) -> Self
The number of delayed updates before skipping them to catch up.
When set to
0
, it will always try to catch up. Read morefn set_max_fps(&mut self, frames: u64)
fn set_max_fps(&mut self, frames: u64)
The maximum number of frames per second Read more
fn set_swap_buffers(&mut self, enable: bool)
fn set_swap_buffers(&mut self, enable: bool)
Enable or disable automatic swapping of buffers.
fn swap_buffers(self, enable: bool) -> Self
fn swap_buffers(self, enable: bool) -> Self
Enable or disable automatic swapping of buffers.
fn set_bench_mode(&mut self, enable: bool)
fn set_bench_mode(&mut self, enable: bool)
Enable or disable benchmark mode.
When enabled, it will render and update without sleep and ignore input.
Used to test performance by playing through as fast as possible.
Requires
lazy
to be set to false
. Read morefn bench_mode(self, enable: bool) -> Self
fn bench_mode(self, enable: bool) -> Self
Enable or disable benchmark mode.
When enabled, it will render and update without sleep and ignore input.
Used to test performance by playing through as fast as possible.
Requires
lazy
to be set to false
. Read moresourceimpl<W> Window for PistonWindow<W>where
W: Window,
impl<W> Window for PistonWindow<W>where
W: Window,
sourcefn should_close(&self) -> bool
fn should_close(&self) -> bool
Returns true if the window should close.
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 swap_buffers(&mut self)
fn swap_buffers(&mut self)
Swaps render buffers. Read more
sourcefn wait_event(&mut self) -> Input
fn wait_event(&mut self) -> Input
Wait indefinitely for an input event to be available from the window.
sourcefn wait_event_timeout(&mut self, timeout: Duration) -> Option<Input>
fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Input>
Wait for an input event to be available from the window or for the
specified timeout to be reached. Read more
sourcefn poll_event(&mut self) -> Option<Input>
fn poll_event(&mut self) -> Option<Input>
Polls an input event from the window. Read more
Auto Trait Implementations
impl<W = GlutinWindow> !RefUnwindSafe for PistonWindow<W>
impl<W = GlutinWindow> !Send for PistonWindow<W>
impl<W = GlutinWindow> !Sync for PistonWindow<W>
impl<W> Unpin for PistonWindow<W>where
W: Unpin,
impl<W = GlutinWindow> !UnwindSafe for PistonWindow<W>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
Sets
value
as a parameter of self
.