diff options
| author | Tengu712 <genreihoutengu@gmail.com> | 2026-09-26 19:56:07 +0900 |
|---|---|---|
| committer | Tengu712 <genreihoutengu@gmail.com> | 2026-09-26 19:56:07 +0900 |
| commit | b27234e27bbaf4d7f7f3467de64bd95ff2145c0e (patch) | |
| tree | c80a0ef9c9a18111fb8596ae1017bdfee13750b7 /src/main.rs | |
| parent | 25bdfbcd26901f0857c23af647f5063d6759fdcd (diff) | |
make it better
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 3c7f20d..d78aee7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use winit::{ mod graphics; -use graphics::{RenderResult, Renderer}; +use graphics::{AcquireSurfaceTextureResult, Renderer}; #[derive(Default)] struct App { @@ -30,6 +30,7 @@ impl ApplicationHandler for App { let attributes = Window::default_attributes() .with_title("君は呪われている!") + .with_resizable(false) .with_inner_size(LogicalSize::new(1280, 720)) .with_fullscreen(None); @@ -74,6 +75,17 @@ impl ApplicationHandler for App { WindowEvent::CursorLeft { .. } => { println!("left"); } + WindowEvent::Resized(size) => { + if let Some(renderer) = self.renderer.as_ref() { + renderer.configure_surface(size); + } + } + WindowEvent::ScaleFactorChanged { .. } => { + let (Some(window), Some(renderer)) = (&self.window, &self.renderer) else { + return; + }; + renderer.configure_surface(window.inner_size()); + } WindowEvent::Focused(false) | WindowEvent::Occluded(true) => { println!("focused or occluded"); } @@ -93,13 +105,14 @@ impl ApplicationHandler for App { // NOTE: Presentation modeがFIFOの場合はここでスレッドが停止する。 let current_texture = match renderer.get_current_texture(window) { - RenderResult::Ok(v) => v, - RenderResult::ShouldSkip => { + AcquireSurfaceTextureResult::Ok(v) => v, + AcquireSurfaceTextureResult::ShouldSkip => { event_loop .set_control_flow(ControlFlow::WaitUntil(start + Duration::from_millis(16))); return; } - RenderResult::Lost => panic!("fatal: device or surface lost."), + // TODO: 一応対応する。 + AcquireSurfaceTextureResult::Lost => panic!("fatal: device or surface lost."), }; renderer.render(window, current_texture); |
