Skip to content

Commit

Permalink
Merge pull request #914 from hekno25/main
Browse files Browse the repository at this point in the history
Disable mesh and debug rendering checkboxes if line drawing is unavailable
  • Loading branch information
hannobraun authored Aug 4, 2022
2 parents b68b6c1 + 82c1b75 commit cf76fee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
20 changes: 16 additions & 4 deletions crates/fj-viewer/src/graphics/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,23 @@ impl Renderer {
info
}

let line_drawing_available = self.is_line_drawing_available();
egui::SidePanel::left("fj-left-panel").show(&self.egui.context, |ui| {
ui.add_space(16.0);

ui.group(|ui| {
ui.checkbox(&mut config.draw_model, "Render model")
.on_hover_text_at_pointer("Toggle with 1");
ui.checkbox(&mut config.draw_mesh, "Render mesh")
.on_hover_text_at_pointer("Toggle with 2");
ui.checkbox(&mut config.draw_debug, "Render debug")
.on_hover_text_at_pointer("Toggle with 3");
ui.add_enabled(line_drawing_available, egui::Checkbox::new(&mut config.draw_mesh, "Render mesh"))
.on_hover_text_at_pointer("Toggle with 2")
.on_disabled_hover_text(
"Rendering device does not have line rendering feature support",
);
ui.add_enabled(line_drawing_available, egui::Checkbox::new(&mut config.draw_debug, "Render debug"))
.on_hover_text_at_pointer("Toggle with 3")
.on_disabled_hover_text(
"Rendering device does not have line rendering feature support"
);
ui.checkbox(
&mut self.egui.options.show_original_ui,
"Render original UI",
Expand Down Expand Up @@ -636,6 +643,11 @@ impl Renderer {
),
});
}

/// Returns true if the renderer's adapter can draw lines
pub fn is_line_drawing_available(&self) -> bool {
self.features.contains(wgpu::Features::POLYGON_MODE_LINE)
}
}

/// Error describing the set of render surface initialization errors
Expand Down
8 changes: 6 additions & 2 deletions crates/fj-window/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,14 @@ pub fn run(
draw_config.draw_model = !draw_config.draw_model
}
VirtualKeyCode::Key2 => {
draw_config.draw_mesh = !draw_config.draw_mesh
if renderer.is_line_drawing_available() {
draw_config.draw_mesh = !draw_config.draw_mesh
}
}
VirtualKeyCode::Key3 => {
draw_config.draw_debug = !draw_config.draw_debug
if renderer.is_line_drawing_available() {
draw_config.draw_debug = !draw_config.draw_debug
}
}
_ => {}
},
Expand Down

0 comments on commit cf76fee

Please sign in to comment.