From 6bb5561d66e3db6c22980d756898457b684b7897 Mon Sep 17 00:00:00 2001 From: Tei Leelo Roberts Date: Sun, 20 Oct 2024 13:22:10 +0200 Subject: [PATCH] fix: invalid scissor during resize --- .env | 2 +- violet-wgpu/src/app.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 4a7e80b..53aa8f9 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -# RUST_LOG="[TextRenderer::update_mesh]=debug,error" +RUST_LOG="wgpu=warn,info" # RUST_BACKTRACE=1 diff --git a/violet-wgpu/src/app.rs b/violet-wgpu/src/app.rs index 4eb9e61..5e01383 100644 --- a/violet-wgpu/src/app.rs +++ b/violet-wgpu/src/app.rs @@ -1,5 +1,5 @@ use parking_lot::Mutex; -use std::sync::Arc; +use std::{mem, sync::Arc}; use web_time::Instant; use flax::{components::name, Entity, Schedule, World}; @@ -177,6 +177,7 @@ pub struct AppInstance { pub input_state: InputState, text_system: Arc>, layout_changes_rx: flume::Receiver<(Entity, LayoutUpdateEvent)>, + pub has_resized: bool, } impl AppInstance { @@ -226,6 +227,7 @@ impl AppInstance { input_state, text_system, layout_changes_rx, + has_resized: false, } } @@ -235,6 +237,7 @@ impl AppInstance { pub fn on_resize(&mut self, physical_size: PhysicalSize) { self.window_size = physical_size; + self.has_resized = true; tracing::info!(?physical_size, self.scale_factor, "Resizing window"); @@ -320,6 +323,10 @@ struct WindowEventHandler { impl WindowEventHandler { pub fn draw(&mut self) -> anyhow::Result<()> { puffin::profile_function!(); + if mem::take(&mut self.instance.has_resized) { + self.instance.update(); + } + if let Some(renderer) = &mut self.renderer { renderer.draw(&mut self.instance.frame)?; }