Enabled tech ENABLE_RENDER_STATISTICS

This commit is contained in:
enricoturri1966 2020-12-04 15:36:30 +01:00
parent 15b56c9950
commit 1445c0ad3a
4 changed files with 53 additions and 19 deletions

View File

@ -12,7 +12,7 @@
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
#define ENABLE_RENDER_SELECTION_CENTER 0
// Shows an imgui dialog with render related data
#define ENABLE_RENDER_STATISTICS 0
#define ENABLE_RENDER_STATISTICS 1
// Shows an imgui dialog with camera related data
#define ENABLE_CAMERA_STATISTICS 0
// Render the picking pass instead of the main scene (use [T] key to toggle between regular rendering and picking pass only rendering)

View File

@ -1675,21 +1675,29 @@ void GLCanvas3D::render()
_render_overlays();
#if ENABLE_RENDER_STATISTICS
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text("Last frame: ");
ImGui::SameLine();
imgui.text(std::to_string(m_render_stats.last_frame));
ImGui::SameLine();
imgui.text(" ms");
ImGui::Separator();
imgui.text("Compressed textures: ");
ImGui::SameLine();
imgui.text(OpenGLManager::are_compressed_textures_supported() ? "supported" : "not supported");
imgui.text("Max texture size: ");
ImGui::SameLine();
imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size()));
imgui.end();
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text("Last frame: ");
ImGui::SameLine();
imgui.text(std::to_string(m_render_stats.last_frame));
ImGui::SameLine();
imgui.text(" ms");
imgui.text("FPS: ");
ImGui::SameLine();
imgui.text(std::to_string(static_cast<int>(1000.0f / static_cast<float>(m_render_stats.last_frame))));
// imgui.text("Imgui FPS: ");
// ImGui::SameLine();
// imgui.text(std::to_string(static_cast<int>(ImGui::GetIO().Framerate)));
ImGui::Separator();
imgui.text("Compressed textures: ");
ImGui::SameLine();
imgui.text(OpenGLManager::are_compressed_textures_supported() ? "supported" : "not supported");
imgui.text("Max texture size: ");
ImGui::SameLine();
imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size()));
imgui.end();
}
#endif // ENABLE_RENDER_STATISTICS
#if ENABLE_CAMERA_STATISTICS
@ -2461,9 +2469,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_QUESTION_MARK));
};
//#ifdef __APPLE__
// ctrlMask |= wxMOD_RAW_CONTROL;
//#endif /* __APPLE__ */
if ((evt.GetModifiers() & ctrlMask) != 0) {
// CTRL is pressed
switch (keyCode) {
@ -2779,7 +2784,15 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
{
if (!m_gizmos.on_key(evt)) {
if (evt.GetEventType() == wxEVT_KEY_UP) {
#if ENABLE_RENDER_STATISTICS
if (evt.ShiftDown() && evt.ControlDown() && keyCode == WXK_SPACE) {
wxGetApp().plater()->toggle_render_statistic_dialog();
m_dirty = true;
}
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
#else
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
#endif // ENABLE_RENDER_STATISTICS
// Enable switching between 3D and Preview with Tab
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
post_event(SimpleEvent(EVT_GLCANVAS_TAB));

View File

@ -1674,6 +1674,10 @@ struct Plater::priv
std::string label_btn_export;
std::string label_btn_send;
#if ENABLE_RENDER_STATISTICS
bool show_render_statistic_dialog{ false };
#endif // ENABLE_RENDER_STATISTICS
static const std::regex pattern_bundle;
static const std::regex pattern_3mf;
static const std::regex pattern_zip_amf;
@ -6300,6 +6304,18 @@ void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); }
void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); }
bool Plater::inside_snapshot_capture() { return p->inside_snapshot_capture(); }
#if ENABLE_RENDER_STATISTICS
void Plater::toggle_render_statistic_dialog()
{
p->show_render_statistic_dialog = !p->show_render_statistic_dialog;
}
bool Plater::is_render_statistic_dialog_visible() const
{
return p->show_render_statistic_dialog;
}
#endif // ENABLE_RENDER_STATISTICS
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos)
{

View File

@ -366,6 +366,11 @@ public:
bool inside_snapshot_capture();
#if ENABLE_RENDER_STATISTICS
void toggle_render_statistic_dialog();
bool is_render_statistic_dialog_visible() const;
#endif // ENABLE_RENDER_STATISTICS
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);
bool PopupMenu(wxMenu *menu, int x, int y) { return this->PopupMenu(menu, wxPoint(x, y)); }