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

Disable mesh and debug rendering checkboxes if line drawing is unavailable #914

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
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
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