Skip to content

Commit

Permalink
fix: invalid scissor during resize
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Oct 20, 2024
1 parent 169d6f9 commit 6bb5561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# RUST_LOG="[TextRenderer::update_mesh]=debug,error"
RUST_LOG="wgpu=warn,info"
# RUST_BACKTRACE=1
9 changes: 8 additions & 1 deletion violet-wgpu/src/app.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -177,6 +177,7 @@ pub struct AppInstance {
pub input_state: InputState,
text_system: Arc<Mutex<TextSystem>>,
layout_changes_rx: flume::Receiver<(Entity, LayoutUpdateEvent)>,
pub has_resized: bool,
}

impl AppInstance {
Expand Down Expand Up @@ -226,6 +227,7 @@ impl AppInstance {
input_state,
text_system,
layout_changes_rx,
has_resized: false,
}
}

Expand All @@ -235,6 +237,7 @@ impl AppInstance {

pub fn on_resize(&mut self, physical_size: PhysicalSize<u32>) {
self.window_size = physical_size;
self.has_resized = true;

tracing::info!(?physical_size, self.scale_factor, "Resizing window");

Expand Down Expand Up @@ -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)?;
}
Expand Down

0 comments on commit 6bb5561

Please sign in to comment.