diff --git a/examples/conway/src/main.rs b/examples/conway/src/main.rs index a84d4d3..cfeaa91 100644 --- a/examples/conway/src/main.rs +++ b/examples/conway/src/main.rs @@ -1,7 +1,7 @@ #![deny(clippy::all)] #![forbid(unsafe_code)] -use log::debug; +use log::{debug, error}; use pixels::{Error, Pixels, SurfaceTexture}; use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize}; use winit::event::{Event, VirtualKeyCode}; @@ -30,7 +30,14 @@ fn main() -> Result<(), Error> { // The one and only event that winit_input_helper doesn't have for us... if let Event::RedrawRequested(_) = event { life.draw(pixels.get_frame()); - pixels.render().unwrap(); + if pixels + .render() + .map_err(|e| error!("pixels.render() failed: {}", e)) + .is_err() + { + *control_flow = ControlFlow::Exit; + return; + } } // For everything else, for let winit_input_helper collect events to build its state. diff --git a/examples/invaders/src/main.rs b/examples/invaders/src/main.rs index d4e6f6d..5f764a0 100644 --- a/examples/invaders/src/main.rs +++ b/examples/invaders/src/main.rs @@ -5,7 +5,7 @@ use std::env; use std::time::Instant; use gilrs::{Button, Gilrs}; -use log::debug; +use log::{debug, error}; use pixels::{Error, Pixels, SurfaceTexture}; use simple_invaders::{Controls, Direction, World, SCREEN_HEIGHT, SCREEN_WIDTH}; use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize}; @@ -37,7 +37,14 @@ fn main() -> Result<(), Error> { // The one and only event that winit_input_helper doesn't have for us... if let Event::RedrawRequested(_) = event { invaders.draw(pixels.get_frame()); - pixels.render().unwrap(); + if pixels + .render() + .map_err(|e| error!("pixels.render() failed: {}", e)) + .is_err() + { + *control_flow = ControlFlow::Exit; + return; + } } // Pump the gilrs event loop and find an active gamepad diff --git a/examples/minimal-winit/src/main.rs b/examples/minimal-winit/src/main.rs index 94a2080..5c17dd4 100644 --- a/examples/minimal-winit/src/main.rs +++ b/examples/minimal-winit/src/main.rs @@ -1,6 +1,7 @@ #![deny(clippy::all)] #![forbid(unsafe_code)] +use log::error; use pixels::{wgpu::Surface, Error, Pixels, SurfaceTexture}; use winit::dpi::LogicalSize; use winit::event::{Event, VirtualKeyCode}; @@ -46,7 +47,14 @@ fn main() -> Result<(), Error> { // Draw the current frame if let Event::RedrawRequested(_) = event { world.draw(pixels.get_frame()); - pixels.render().unwrap(); + if pixels + .render() + .map_err(|e| error!("pixels.render() failed: {}", e)) + .is_err() + { + *control_flow = ControlFlow::Exit; + return; + } } // Handle input events