Skip to content

Commit

Permalink
Set pixels per point every frame
Browse files Browse the repository at this point in the history
This value changing during the runtime of the program is probably a rare
edge case, but still, it's worth to support. In any case, doing it this
way doesn't seem to hurt.
  • Loading branch information
hannobraun committed Oct 25, 2022
1 parent 7f5f78e commit 94ca1df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/fj-viewer/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Gui {
pub(crate) fn new(
device: &wgpu::Device,
texture_format: wgpu::TextureFormat,
pixels_per_point: f32,
_: f32,
) -> Self {
// The implementation of the integration with `egui` is likely to need
// to change "significantly" depending on what architecture approach is
Expand All @@ -51,7 +51,6 @@ impl Gui {
// - https://github.com/emilk/egui/blob/eeae485629fca24a81a7251739460b671e1420f7/README.md#how-do-i-render-3d-stuff-in-an-egui-area

let context = egui::Context::default();
context.set_pixels_per_point(pixels_per_point);

// We need to hold on to this, otherwise it might cause the egui font
// texture to get dropped after drawing one frame.
Expand Down Expand Up @@ -81,12 +80,14 @@ impl Gui {

pub(crate) fn update(
&mut self,
pixels_per_point: f32,
egui_input: egui::RawInput,
config: &mut DrawConfig,
aabb: &Aabb<3>,
status: &StatusReport,
line_drawing_available: bool,
) {
self.context.set_pixels_per_point(pixels_per_point);
self.context.begin_frame(egui_input);

let bounding_box_size = {
Expand Down
1 change: 1 addition & 0 deletions crates/fj-viewer/src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl Viewer {
self.camera.update_planes(&aabb);

self.gui.update(
pixels_per_point,
egui_input,
&mut self.draw_config,
&aabb,
Expand Down

0 comments on commit 94ca1df

Please sign in to comment.