FIX:add "enable_opengl_multi_instance" option
jira: none Change-Id: I424a1914811cc8eb1a7a717a4117453a69111e8b
This commit is contained in:
parent
46cc0df704
commit
6caacd170f
|
@ -176,6 +176,8 @@ void AppConfig::set_defaults()
|
|||
set_bool("show_shells_in_preview", true);
|
||||
if (get("enable_lod").empty())
|
||||
set_bool("enable_lod", true);
|
||||
if (get("enable_opengl_multi_instance").empty())
|
||||
set_bool("enable_opengl_multi_instance", true);
|
||||
if (get("user_bed_type").empty())
|
||||
set_bool("user_bed_type", true);
|
||||
if (get("grabber_size_factor").empty())
|
||||
|
|
|
@ -7081,7 +7081,8 @@ void GLCanvas3D::_render_bed_for_picking(bool bottom)
|
|||
|
||||
void GLCanvas3D::_render_platelist(bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali, bool show_grid) const
|
||||
{
|
||||
wxGetApp().plater()->get_partplate_list().render(bottom, only_current, only_body, hover_id, render_cali, show_grid);
|
||||
wxGetApp().plater()->get_partplate_list().render(bottom, only_current, only_body, hover_id, render_cali, show_grid,
|
||||
wxGetApp().app_config->get_bool("enable_opengl_multi_instance"));
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_plates_for_picking() const
|
||||
|
|
|
@ -40,7 +40,9 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
// used to render first layer for calibration
|
||||
valid &= append_shader("cali", { "cali.vs", "cali.fs"});
|
||||
valid &= append_shader("flat", {"110/flat.vs", "110/flat.fs"});
|
||||
valid &= append_shader("flat_instance", {"110/flat_instance.vs", "110/flat.fs"});
|
||||
if (Slic3r::GUI::wxGetApp().app_config->get_bool("enable_opengl_multi_instance")) {
|
||||
valid &= append_shader("flat_instance", {"110/flat_instance.vs", "110/flat.fs"});
|
||||
}
|
||||
// used to render printbed
|
||||
valid &= append_shader("printbed", {"110/printbed.vs", "110/printbed.fs"});
|
||||
// used to render options in gcode preview
|
||||
|
|
|
@ -4682,15 +4682,19 @@ void PartPlateList::postprocess_arrange_polygon(arrangement::ArrangePolygon& arr
|
|||
}
|
||||
|
||||
/*rendering related functions*/
|
||||
void PartPlateList::render_instance(bool bottom, bool only_current, bool only_body, bool force_background_color, int hover_id, bool show_grid)
|
||||
void PartPlateList::render_instance(bool bottom, bool only_current, bool only_body, bool force_background_color, int hover_id, bool show_grid, bool enable_multi_instance)
|
||||
{
|
||||
if (m_update_plate_mats_vbo) {
|
||||
m_update_plate_mats_vbo = false;
|
||||
GLModel::create_or_update_mats_vbo(m_plate_mats_vbo, m_plate_trans);
|
||||
}
|
||||
if (m_update_unselected_plate_mats_vbo) {
|
||||
m_update_unselected_plate_mats_vbo = false;
|
||||
GLModel::create_or_update_mats_vbo(m_unselected_plate_mats_vbo, m_unselected_plate_trans);
|
||||
if (enable_multi_instance) {
|
||||
if (!only_current) {
|
||||
if (m_update_plate_mats_vbo) {
|
||||
m_update_plate_mats_vbo = false;
|
||||
GLModel::create_or_update_mats_vbo(m_plate_mats_vbo, m_plate_trans);
|
||||
}
|
||||
if (m_update_unselected_plate_mats_vbo) {
|
||||
m_update_unselected_plate_mats_vbo = false;
|
||||
GLModel::create_or_update_mats_vbo(m_unselected_plate_mats_vbo, m_unselected_plate_trans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
|
@ -4699,34 +4703,49 @@ void PartPlateList::render_instance(bool bottom, bool only_current, bool only_bo
|
|||
{
|
||||
auto cur_shader = wxGetApp().get_current_shader();
|
||||
if (cur_shader) {
|
||||
cur_shader->stop_using();
|
||||
}
|
||||
cur_shader->stop_using();
|
||||
}
|
||||
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||
{//for selected
|
||||
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||
shader->start_using();
|
||||
shader->set_uniform("view_model_matrix", view_mat * m_plate_trans[m_current_plate].get_matrix());
|
||||
shader->set_uniform("projection_matrix", proj_mat);
|
||||
if (!bottom) { // draw background
|
||||
render_exclude_area(force_background_color); // for selected_plate
|
||||
}
|
||||
if (show_grid)
|
||||
render_grid(bottom); // for selected_plate
|
||||
|
||||
shader->stop_using();
|
||||
|
||||
}
|
||||
if (show_grid)
|
||||
render_grid(bottom); // for selected_plate
|
||||
}
|
||||
if (enable_multi_instance) {
|
||||
shader->stop_using();
|
||||
}
|
||||
if (!only_current) {
|
||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_instance");
|
||||
shader->start_using();
|
||||
auto res =shader->set_uniform("view_matrix", view_mat);
|
||||
res = shader->set_uniform("projection_matrix", proj_mat);
|
||||
if (!bottom) {// draw background
|
||||
render_instance_background(force_background_color);//for unselected_plate
|
||||
render_instance_exclude_area(force_background_color);//for unselected_plate
|
||||
}
|
||||
render_instance_grid(bottom);//for unselected_plate
|
||||
if (enable_multi_instance) {
|
||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_instance");
|
||||
shader->start_using();
|
||||
auto res = shader->set_uniform("view_matrix", view_mat);
|
||||
res = shader->set_uniform("projection_matrix", proj_mat);
|
||||
if (!bottom) { // draw background
|
||||
render_instance_background(force_background_color); // for unselected_plate
|
||||
render_instance_exclude_area(force_background_color); // for unselected_plate
|
||||
}
|
||||
render_instance_grid(bottom); // for unselected_plate
|
||||
|
||||
shader->stop_using();
|
||||
shader->stop_using();
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < m_unselected_plate_trans.size(); i++) {
|
||||
shader->set_uniform("view_model_matrix", view_mat * m_unselected_plate_trans[i].get_matrix());
|
||||
if (!bottom) { // draw background
|
||||
render_unselected_background(force_background_color); // for unselected_plate
|
||||
render_unselected_exclude_area(force_background_color); // for unselected_plate
|
||||
}
|
||||
render_unselected_grid(bottom); // for unselected_plate
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!enable_multi_instance) {
|
||||
shader->stop_using();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4769,6 +4788,22 @@ void PartPlateList::render_instance_grid(bool bottom)
|
|||
m_gridlines_bolder.render_geometry_instance(m_unselected_plate_mats_vbo, m_unselected_plate_trans.size());
|
||||
}
|
||||
|
||||
void PartPlateList::render_unselected_grid(bool bottom)
|
||||
{
|
||||
glsafe(::glLineWidth(1.0f * m_scale_factor));
|
||||
ColorRGBA color;
|
||||
if (bottom)
|
||||
color = PartPlate::LINE_BOTTOM_COLOR;
|
||||
else {
|
||||
color = m_is_dark ? PartPlate::LINE_TOP_DARK_COLOR : PartPlate::LINE_TOP_COLOR;
|
||||
}
|
||||
m_gridlines.set_color(color);
|
||||
m_gridlines.render_geometry();
|
||||
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
||||
m_gridlines_bolder.set_color(color);
|
||||
m_gridlines_bolder.render_geometry();
|
||||
}
|
||||
|
||||
void PartPlateList::render_instance_background(bool force_default_color)
|
||||
{
|
||||
if (m_unselected_plate_trans.size() == 0) { return; }
|
||||
|
@ -4783,6 +4818,19 @@ void PartPlateList::render_instance_background(bool force_default_color)
|
|||
m_triangles.render_geometry_instance(m_unselected_plate_mats_vbo, m_unselected_plate_trans.size());
|
||||
}
|
||||
|
||||
void PartPlateList::render_unselected_background(bool force_default_color)
|
||||
{
|
||||
// draw background
|
||||
ColorRGBA color;
|
||||
if (!force_default_color) {
|
||||
color = m_is_dark ? PartPlate::UNSELECT_DARK_COLOR : PartPlate::UNSELECT_COLOR;
|
||||
} else {
|
||||
color = PartPlate::DEFAULT_COLOR;
|
||||
}
|
||||
m_triangles.set_color(color);
|
||||
m_triangles.render_geometry();
|
||||
}
|
||||
|
||||
void PartPlateList::render_exclude_area(bool force_default_color)
|
||||
{
|
||||
if (force_default_color || !m_exclude_triangles.is_initialized()) // for thumbnail case
|
||||
|
@ -4804,8 +4852,18 @@ void PartPlateList::render_instance_exclude_area(bool force_default_color)
|
|||
m_exclude_triangles.render_geometry_instance(m_unselected_plate_mats_vbo, m_unselected_plate_trans.size());
|
||||
}
|
||||
|
||||
void PartPlateList::render_unselected_exclude_area(bool force_default_color)
|
||||
{
|
||||
if (force_default_color || !m_exclude_triangles.is_initialized()) // for thumbnail case
|
||||
return;
|
||||
ColorRGBA unselect_color{0.9f, 0.9f, 0.9f, 1.0f};
|
||||
// draw exclude area
|
||||
m_exclude_triangles.set_color(unselect_color);
|
||||
m_exclude_triangles.render_geometry();
|
||||
}
|
||||
|
||||
//render
|
||||
void PartPlateList::render(bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali, bool show_grid)
|
||||
void PartPlateList::render(bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali, bool show_grid, bool enable_multi_instance)
|
||||
{
|
||||
const std::lock_guard<std::mutex> local_lock(m_plates_mutex);
|
||||
std::vector<PartPlate*>::iterator it = m_plate_list.begin();
|
||||
|
@ -4829,7 +4887,7 @@ void PartPlateList::render(bool bottom, bool only_current, bool only_body, int h
|
|||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
glsafe(::glDepthMask(GL_FALSE));
|
||||
|
||||
render_instance(bottom, only_current, only_body, false, m_plate_hover_action, show_grid);
|
||||
render_instance(bottom, only_current, only_body, false, m_plate_hover_action, show_grid, enable_multi_instance);
|
||||
|
||||
for (it = m_plate_list.begin(); it != m_plate_list.end(); it++) {
|
||||
int current_index = (*it)->get_index();
|
||||
|
|
|
@ -816,15 +816,19 @@ public:
|
|||
bool only_body = false,
|
||||
bool force_background_color = false,
|
||||
int hover_id = -1,
|
||||
bool show_grid = true);
|
||||
bool show_grid = true,
|
||||
bool enable_multi_instance = true);
|
||||
void render_instance_grid(bool bottom);
|
||||
void render_unselected_grid(bool bottom);
|
||||
void render_instance_background(bool force_default_color = false);
|
||||
void render_unselected_background(bool force_default_color);
|
||||
void render_grid(bool bottom);
|
||||
void render_exclude_area(bool force_default_color);
|
||||
void render_instance_exclude_area(bool force_default_color);
|
||||
void render_unselected_exclude_area(bool force_default_color);
|
||||
|
||||
void on_change_color_mode(bool is_dark) { m_is_dark = is_dark; }
|
||||
void render(bool bottom, bool only_current = false, bool only_body = false, int hover_id = -1, bool render_cali = false, bool show_grid = true);
|
||||
void render(bool bottom, bool only_current = false, bool only_body = false, int hover_id = -1, bool render_cali = false, bool show_grid = true, bool enable_multi_instance = true);
|
||||
void render_for_picking_pass();
|
||||
void set_render_option(bool bedtype_texture, bool plate_settings);
|
||||
void set_render_cali(bool value = true) { render_cali_logo = value; }
|
||||
|
|
|
@ -846,6 +846,27 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
|||
}
|
||||
}
|
||||
|
||||
if (param == "enable_opengl_multi_instance") {
|
||||
if (wxGetApp().plater()->is_project_dirty()) {
|
||||
auto result = MessageDialog(static_cast<wxWindow *>(this), _L("The current project has unsaved changes, save it before continuing?"),
|
||||
wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Save"), wxYES_NO | wxYES_DEFAULT | wxCENTRE)
|
||||
.ShowModal();
|
||||
if (result == wxID_YES) { wxGetApp().plater()->save_project(); }
|
||||
}
|
||||
MessageDialog msg_wingow(nullptr,
|
||||
_L("Change opengl multi instance rendering requires application restart.") + "\n" +
|
||||
_L("Do you want to continue?"),
|
||||
_L("Enable opengl multi instance rendering"), wxYES | wxYES_DEFAULT | wxCANCEL | wxCENTRE);
|
||||
if (msg_wingow.ShowModal() == wxID_YES) {
|
||||
Close();
|
||||
GetParent()->RemoveChild(this);
|
||||
wxGetApp().recreate_GUI(_L("Enable opengl multi instance rendering"));
|
||||
} else {
|
||||
checkbox->SetValue(!checkbox->GetValue());
|
||||
app_config->set_bool(param, checkbox->GetValue());
|
||||
app_config->save();
|
||||
}
|
||||
}
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
|
@ -1156,6 +1177,8 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
auto enable_lod_settings = create_item_checkbox(_L("Improve rendering performance by lod"), page,
|
||||
_L("Improved rendering performance under the scene of multiple plates and many models."), 50,
|
||||
"enable_lod");
|
||||
auto enable_opengl_multi_instance_rendering = create_item_checkbox(_L("enable multi instance rendering by opengl"), page,
|
||||
_L("If enabled, it can improve certain rendering performance. But for some graphics cards, it may not be applicable, please turn it off."), 50, "enable_opengl_multi_instance");
|
||||
float range_min = 1.0, range_max = 2.5;
|
||||
auto item_grabber_size_settings = create_item_range_input(_L("Grabber scale"), page,
|
||||
_L("Set grabber size for move,rotate,scale tool.") + _L("Value range") + ":[" + std::to_string(range_min) + "," +
|
||||
|
@ -1241,6 +1264,7 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
sizer_page->Add(_3d_settings, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_show_shells_in_preview_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(enable_opengl_multi_instance_rendering, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(enable_lod_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_grabber_size_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
|
|
Loading…
Reference in New Issue