Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config_ui): fix warning because of missing finish() call #397

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 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,18 @@ 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 +104,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