Skip to content

Commit

Permalink
fix(config_ui): fix warning because of missing finish() call
Browse files Browse the repository at this point in the history
  • Loading branch information
liubog2008 committed Mar 24, 2022
1 parent 40d02f0 commit 438d76f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions fj-app/src/graphics/config_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ use wgpu_glyph::{

use super::draw_config::DrawConfig;

#[derive(Debug)]
pub struct ConfigUi {
glyph_brush: GlyphBrush<()>,
texts: HashMap<(Element, bool), String>,
staging_belt: StagingBelt,
}

impl std::fmt::Debug for ConfigUi {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConfigUi").
field("glyph_brush", &self.glyph_brush).
field("texts", &self.texts).
finish()
}
}

impl ConfigUi {
Expand Down Expand Up @@ -41,7 +50,14 @@ impl ConfigUi {
}
}

Ok(Self { glyph_brush, texts })
// I haven't put any thought into the staging belt's buffer size.
// 1024 just seemed like a good number, and so far it hasn't caused
// any problems.
//
// - @hannobraun
let staging_belt = StagingBelt::new(1024);

Ok(Self { glyph_brush, texts, staging_belt })
}

pub fn draw(
Expand Down Expand Up @@ -84,18 +100,15 @@ impl ConfigUi {
self.glyph_brush.queue(section);
self.glyph_brush.draw_queued(
device,
// I haven't put any thought into the staging belt's buffer size.
// 1024 just seemed like a good number, and so far it hasn't caused
// any problems.
//
// - @hannobraun
&mut StagingBelt::new(1024),
&mut self.staging_belt,
encoder,
view,
surface_config.width,
surface_config.height,
)?;

self.staging_belt.finish();

Ok(())
}
}
Expand Down

0 comments on commit 438d76f

Please sign in to comment.