Struct polystrip::WindowTarget [−][src]
A target for drawing to a raw_window_handle
window.
A WindowTarget
can be created for any window compatible with raw_window_handle
. The size of this window must be updated
in the event loop, and specified on creation. For example, in winit
:
let window_size = window.inner_size().to_logical(window.scale_factor()); let mut renderer = WindowTarget::new(Renderer::new().wrap(), &window, (window_size.width, window_size.height)); event_loop.run(move |event, _, control_flow| { match event { Event::WindowEvent { event: WindowEvent::Resized(new_size), .. } => { let window_size = new_size.to_logical(window.scale_factor()); renderer.resize((window_size.width, window_size.height)); }, // --snip-- } });
Fields
context: Rc<Renderer>
Implementations
impl WindowTarget
[src]
pub fn new(
context: Rc<Renderer>,
window: &impl HasRawWindowHandle,
(width, height): (u32, u32)
) -> WindowTarget
[src]
context: Rc<Renderer>,
window: &impl HasRawWindowHandle,
(width, height): (u32, u32)
) -> WindowTarget
Creates a new window target for the given Renderer
.
This method assumes the raw window handle was created legitimately. Technically, that’s my problem, but if
you’re not making your window properly, I’m not going to take responsibility for the resulting crash. (The
only way I’d be able to deal with it anyway would be to mark this method unsafe
)
let renderer = WindowTarget::new( RendererBuilder::new().max_textures(2048).build_rc(), &window, (window_size.width, window_size.height) );
pub fn next_frame(&mut self) -> Frame<'_, WindowFrame<'_>>
[src]
Returns the next Frame
, which can be drawn to and will present on drop. The frame will contain the data from the
previous frame. This Renderer
is borrowed mutably while the Frame
is alive.
pub fn next_frame_clear(
&mut self,
clear_color: Color
) -> Frame<'_, WindowFrame<'_>>
[src]
&mut self,
clear_color: Color
) -> Frame<'_, WindowFrame<'_>>
Returns the next Frame
, which can be drawn to and will present on drop. The frame will be cleared to the specified
clear_color
(converted from sRGB with a gamma of 2.0). This Renderer
is borrowed mutably while the Frame
is alive
pub fn resize(&mut self, (width, height): (u32, u32))
[src]
Resizes the internal swapchain and depth texture
Call this method in your window’s event loop whenever the window gets resized
Arguments
size
: The size of the window in pixels, in the order (width, height). For window implementations which differentiate between physical and logical size, this refers to the logical size
pub fn width(&self) -> u32
[src]
Gets the width of the internal swapchain, which is updated every time resize
is called
pub fn height(&self) -> u32
[src]
Gets the height of the internal swapchain, which is updated every time resize
is called
pub fn pixel(&self, x: i32, y: i32) -> Vector2
[src]
Converts pixel coordinates to screen space coordinates. Alternatively, a PixelTranslator
can be constructed
with the pixel_translator
method.
pub fn pixel_translator(&self) -> PixelTranslator
[src]
Creates a PixelTranslator
for this window’s size. The PixelTranslator
will track this WindowTarget
’s size
even after resize
calls
Trait Implementations
impl Drop for WindowTarget
[src]
impl HasRenderer for WindowTarget
[src]
fn clone_context(&self) -> Rc<Renderer>
[src]
impl<'a> RenderTarget<'a> for WindowTarget
[src]
type FrameDrop = WindowFrame<'a>
fn create_frame(&'a mut self) -> Frame<'_, WindowFrame<'a>>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for WindowTarget
impl !Send for WindowTarget
impl !Sync for WindowTarget
impl Unpin for WindowTarget
impl !UnwindSafe for WindowTarget
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,