diff --git a/src/state.rs b/src/state.rs index d467d3f..5ae35b6 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use pollster::FutureExt; -use wgpu::{util::DeviceExt, DynamicOffset}; +use wgpu::util::DeviceExt; use winit::{ event::{ElementState, WindowEvent}, keyboard::Key, @@ -62,6 +62,7 @@ pub struct State<'a> { pub spotlight_info: SpotlightInfo, pub zoom: f32, pub camera_controller: CameraController, + hide_cursor: bool, } impl<'a> State<'a> { @@ -204,6 +205,7 @@ impl<'a> State<'a> { spotlight_info, camera_controller, zoom: 1.0, + hide_cursor: false, } } @@ -220,6 +222,7 @@ impl<'a> State<'a> { pub fn input(&mut self, event: &winit::event::WindowEvent) -> bool { self.camera_controller.process_events(self.wsize, event); self.spotlight.process_events(event); + match event { WindowEvent::KeyboardInput { event: key_event, .. @@ -230,6 +233,9 @@ impl<'a> State<'a> { if char == "r" { self.camera_controller.reset_camera(&mut self.camera); } + else if char == "h" { + self.hide_cursor = !self.hide_cursor; + } } return true; } @@ -261,6 +267,8 @@ impl<'a> State<'a> { } pub fn render(&mut self) -> Result<(), wgpu::SurfaceError> { + self.window.set_cursor_visible(!self.hide_cursor); + let output = self.surface.get_current_texture()?; let view = output .texture