RayTracing / gpu-tracing

Ray tracing on GPU systems
https://raytracing.github.io/gpu-tracing
Creative Commons Attribution 4.0 International
100 stars 6 forks source link

Close window with escape key #12

Open trevordblack opened 2 months ago

trevordblack commented 2 months ago
         Event::WindowEvent {
             event: WindowEvent::KeyboardInput { input, .. },
             window_id,
         } if window_id == window.id() => {
             if input.virtual_keycode == Some(VirtualKeyCode::Escape) {
                 *control_flow = ControlFlow::Exit
             }
         }
armansito commented 2 months ago

In newer versions of winit (0.29) this is done slightly differently:

event_loop.run(|event, control_target| {
        control_target.set_control_flow(ControlFlow::Poll);
        match event {
            Event::WindowEvent { event, .. } => match event {
                WindowEvent::CloseRequested => control_target.exit(),
                ...
            }
        ...

I.e., you can replace *control_flow = ControlFlow::Exit with control_target.exit().