[−][src]Struct polystrip::renderer::Renderer
An accelerated 2D renderer.
A renderer 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, using winit
:
let window_size = window.inner_size().to_logical(window.scale_factor()); let mut renderer = Renderer::new(&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-- } });
Implementations
impl Renderer
[src]
pub fn new(window: &impl HasRawWindowHandle, size: (u32, u32)) -> Renderer
[src]
Creates a new renderer, initialising the wgpu backend. This method just calls and blocks on new_async
Arguments
window
: A valid window compatible withraw_window_handle
.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 async fn new_async<'_>(
window: &'_ impl HasRawWindowHandle,
size: (u32, u32)
) -> Renderer
[src]
window: &'_ impl HasRawWindowHandle,
size: (u32, u32)
) -> Renderer
Creates a new renderer asynchronously, initialising the wgpu backend. 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.
Arguments
window
: A valid window compatible withraw_window_handle
.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 get_next_frame(&mut self) -> Frame<'_>
[src]
Returns the next Frame
, which can be drawn to and will present on drop. This Renderer
is borrowed mutably while the
frame is alive. Any operations on this renderer must be done through the Frame
, which implements Dever<Target = Renderer>
.
pub fn resize(&mut self, size: (u32, u32))
[src]
Resizes the internal swapchain
For correctness, 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 pixel(&self, x: i32, y: i32) -> GpuPos
[src]
Converts pixel coordinates to Gpu coordinates
Auto Trait Implementations
impl !RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
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> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[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>,