diff options
Diffstat (limited to 'examples/render-quad/src')
-rw-r--r-- | examples/render-quad/src/main.rs | 12 |
1 files changed, 8 insertions, 4 deletions
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(); + } } _ => () } |