From 83c67f8e304d7e6baf85aa0ea285d7664a4f90cd Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:20 +0100 Subject: feat(render): handle resizing properly --- examples/render-quad/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'examples/render-quad/src') diff --git a/examples/render-quad/src/main.rs b/examples/render-quad/src/main.rs index 130bc5e..f04fca7 100644 --- a/examples/render-quad/src/main.rs +++ b/examples/render-quad/src/main.rs @@ -107,19 +107,23 @@ fn main() { *flow = ControlFlow::Poll; match event { - // TODO: Handle resize Event::WindowEvent { - event: WindowEvent::CloseRequested, + event: WindowEvent::CloseRequested, .. } => { *flow = ControlFlow::Exit - }, + } Event::MainEventsCleared => { window.request_redraw() }, Event::RedrawRequested(_) => { - ctx.draw_vertices().unwrap(); + if let Err(err) = ctx.draw_vertices() { + unsafe {ctx.handle_surface_change().unwrap()}; + + // If it fails twice, then panic + ctx.draw_vertices().unwrap(); + } } _ => () } -- cgit v1.2.3