diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:20 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:20 +0100 |
commit | 83c67f8e304d7e6baf85aa0ea285d7664a4f90cd (patch) | |
tree | 27581a0fb4b094bd4d4185cdcec3ca6a78602525 /examples | |
parent | de0f306ffcdf540c16ff2f89d99790c7f2b541fc (diff) |
feat(render): handle resizing properly
Diffstat (limited to 'examples')
-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(); + } } _ => () } |