Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES renamed as ENABLE_GL_SHADERS_ATTRIBUTES
This commit is contained in:
parent
5ffe010a9d
commit
46283cfde3
37 changed files with 706 additions and 735 deletions
|
@ -263,7 +263,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas)
|
|||
GLCanvas3D::LayersEditing::s_overlay_window_width = ImGui::GetWindowSize().x /*+ (float)m_layers_texture.width/4*/;
|
||||
imgui.end();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_active_object_annotations(canvas);
|
||||
render_profile(canvas);
|
||||
#else
|
||||
|
@ -277,7 +277,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas)
|
|||
m_profile.old_bar_rect = bar_rect;
|
||||
m_profile.dirty = false;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
|
||||
|
@ -311,7 +311,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
|
|||
return { w - thickness_bar_width(canvas), 0.0f, w, h };
|
||||
}
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
|
@ -320,7 +320,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
|||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
return { (half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom };
|
||||
}
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_initialized() const
|
||||
{
|
||||
|
@ -353,13 +353,13 @@ std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) con
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas)
|
||||
#else
|
||||
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect)
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Size cnv_size = canvas.get_canvas_size();
|
||||
const float cnv_width = (float)cnv_size.get_width();
|
||||
const float cnv_height = (float)cnv_size.get_height();
|
||||
|
@ -371,7 +371,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -382,23 +382,23 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
shader->set_uniform("z_cursor", m_object_max_z * this->get_cursor_z_relative(canvas));
|
||||
shader->set_uniform("z_cursor_band_width", band_width);
|
||||
shader->set_uniform("object_max_z", m_object_max_z);
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)Eigen::Matrix3d::Identity());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
|
||||
|
||||
// Render the color bar
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.background.is_initialized() || m_profile.old_canvas_width != cnv_width) {
|
||||
m_profile.old_canvas_width = cnv_width;
|
||||
#else
|
||||
if (!m_profile.background.is_initialized() || m_profile.dirty) {
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.background.reset();
|
||||
|
||||
GLModel::Geometry init_data;
|
||||
|
@ -407,7 +407,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
init_data.reserve_indices(6);
|
||||
|
||||
// vertices
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float l = 1.0f - 2.0f * THICKNESS_BAR_WIDTH * cnv_inv_width;
|
||||
const float r = 1.0f;
|
||||
const float t = 1.0f;
|
||||
|
@ -417,7 +417,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
const float r = bar_rect.get_right();
|
||||
const float t = bar_rect.get_top();
|
||||
const float b = bar_rect.get_bottom();
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
init_data.add_vertex(Vec2f(l, b), Vec2f(0.0f, 0.0f));
|
||||
init_data.add_vertex(Vec2f(r, b), Vec2f(1.0f, 0.0f));
|
||||
init_data.add_vertex(Vec2f(r, t), Vec2f(1.0f, 1.0f));
|
||||
|
@ -451,18 +451,18 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
shader->stop_using();
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas)
|
||||
#else
|
||||
void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
//FIXME show some kind of legend.
|
||||
|
||||
if (!m_slicing_parameters)
|
||||
return;
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Size cnv_size = canvas.get_canvas_size();
|
||||
const float cnv_width = (float)cnv_size.get_width();
|
||||
const float cnv_height = (float)cnv_size.get_height();
|
||||
|
@ -479,15 +479,15 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
// Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region.
|
||||
const float scale_x = bar_rect.get_width() / float(1.12 * m_slicing_parameters->max_layer_height);
|
||||
const float scale_y = bar_rect.get_height() / m_object_max_z;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// Baseline
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.baseline.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#else
|
||||
if (!m_profile.baseline.is_initialized() || m_profile.dirty) {
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.baseline.reset();
|
||||
|
||||
GLModel::Geometry init_data;
|
||||
|
@ -497,7 +497,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
init_data.reserve_indices(2);
|
||||
|
||||
// vertices
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float axis_x = 2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_slicing_parameters->layer_height) * scale_x) * cnv_inv_width - 0.5f);
|
||||
init_data.add_vertex(Vec2f(axis_x, -1.0f));
|
||||
init_data.add_vertex(Vec2f(axis_x, 1.0f));
|
||||
|
@ -505,7 +505,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
const float x = bar_rect.get_left() + float(m_slicing_parameters->layer_height) * scale_x;
|
||||
init_data.add_vertex(Vec2f(x, bar_rect.get_bottom()));
|
||||
init_data.add_vertex(Vec2f(x, bar_rect.get_top()));
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
// indices
|
||||
init_data.add_ushort_line(0, 1);
|
||||
|
@ -513,11 +513,11 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
m_profile.baseline.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.profile.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#else
|
||||
if (!m_profile.profile.is_initialized() || m_profile.dirty || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.old_layer_height_profile = m_layer_height_profile;
|
||||
m_profile.profile.reset();
|
||||
|
||||
|
@ -529,13 +529,13 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
|
||||
// vertices + indices
|
||||
for (unsigned int i = 0; i < (unsigned int)m_layer_height_profile.size(); i += 2) {
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
init_data.add_vertex(Vec2f(2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_layer_height_profile[i + 1]) * scale_x) * cnv_inv_width - 0.5f),
|
||||
2.0f * (float(m_layer_height_profile[i]) * scale_y * cnv_inv_height - 0.5)));
|
||||
#else
|
||||
init_data.add_vertex(Vec2f(bar_rect.get_left() + float(m_layer_height_profile[i + 1]) * scale_x,
|
||||
bar_rect.get_bottom() + float(m_layer_height_profile[i]) * scale_y));
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
|
||||
init_data.add_ushort_index((unsigned short)i / 2);
|
||||
else
|
||||
|
@ -545,17 +545,17 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
m_profile.profile.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.baseline.render();
|
||||
m_profile.profile.render();
|
||||
shader->stop_using();
|
||||
|
@ -589,11 +589,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
|||
if (current_shader != nullptr)
|
||||
current_shader->stop_using();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -607,10 +607,10 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
|||
shader->set_uniform("z_cursor", float(m_object_max_z) * float(this->get_cursor_z_relative(canvas)));
|
||||
shader->set_uniform("z_cursor_band_width", float(this->band_width));
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
// Initialize the layer height texture mapping.
|
||||
const GLsizei w = (GLsizei)m_layers_texture.width;
|
||||
|
@ -630,11 +630,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
|||
|
||||
shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
|
||||
shader->set_uniform("object_max_z", 0.0f);
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * glvolume->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glvolume->render();
|
||||
}
|
||||
|
@ -1070,11 +1070,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
|
|||
const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -1083,11 +1083,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
|
|||
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
@ -1707,11 +1707,11 @@ void GLCanvas3D::render()
|
|||
_render_gcode();
|
||||
_render_sla_slices();
|
||||
_render_selection();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), true);
|
||||
#else
|
||||
_render_bed(!camera.is_looking_downward(), true);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
_render_objects(GLVolumeCollection::ERenderType::Transparent);
|
||||
|
||||
_render_sequential_clearance();
|
||||
|
@ -4258,12 +4258,12 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
|||
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
imgui->set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
||||
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4302,12 +4302,12 @@ bool GLCanvas3D::_render_search_list(float pos_x)
|
|||
bool action_taken = false;
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
const float x = /*pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + */0.5f * (float)get_canvas_size().get_width();
|
||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
std::string title = L("Search");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4360,13 +4360,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
|||
{
|
||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
auto canvas_w = float(get_canvas_size().get_width());
|
||||
const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w;
|
||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4491,9 +4491,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
camera.zoom_to_box(volumes_box);
|
||||
camera.apply_view_matrix();
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
double near_z = -1.0;
|
||||
double far_z = -1.0;
|
||||
|
@ -4502,22 +4502,22 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
// extends the near and far z of the frustrum to avoid the bed being clipped
|
||||
|
||||
// box in eye space
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(view_matrix);
|
||||
#else
|
||||
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
near_z = -t_bed_box.max.z();
|
||||
far_z = -t_bed_box.min.z();
|
||||
}
|
||||
|
||||
camera.apply_projection(volumes_box, near_z, far_z);
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -4530,9 +4530,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -4543,12 +4543,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
// the volume may have been deactivated by an active gizmo
|
||||
const bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d matrix = view_matrix * vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
vol->render();
|
||||
vol->is_active = is_active;
|
||||
}
|
||||
|
@ -4558,11 +4558,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
if (thumbnail_params.show_bed)
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
_render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false);
|
||||
#else
|
||||
_render_bed(!camera.is_looking_downward(), false);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
// restore background color
|
||||
if (thumbnail_params.transparent_background)
|
||||
|
@ -4823,34 +4823,31 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
background_data.right = 16;
|
||||
background_data.bottom = 16;
|
||||
|
||||
if (!m_main_toolbar.init(background_data))
|
||||
{
|
||||
if (!m_main_toolbar.init(background_data)) {
|
||||
// unable to init the toolbar texture, disable it
|
||||
m_main_toolbar.set_enabled(false);
|
||||
return true;
|
||||
}
|
||||
// init arrow
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
BackgroundTexture::Metadata arrow_data;
|
||||
arrow_data.filename = "toolbar_arrow.svg";
|
||||
arrow_data.left = 0;
|
||||
arrow_data.top = 0;
|
||||
arrow_data.right = 0;
|
||||
arrow_data.bottom = 0;
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
if (!m_main_toolbar.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
BOOST_LOG_TRIVIAL(error) << "Main toolbar failed to load arrow texture.";
|
||||
|
||||
// m_gizmos is created at constructor, thus we can init arrow here.
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_gizmos.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
if (!m_gizmos.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture.";
|
||||
|
||||
// m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
|
@ -5055,19 +5052,17 @@ bool GLCanvas3D::_init_undoredo_toolbar()
|
|||
}
|
||||
|
||||
// init arrow
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
BackgroundTexture::Metadata arrow_data;
|
||||
arrow_data.filename = "toolbar_arrow.svg";
|
||||
arrow_data.left = 0;
|
||||
arrow_data.top = 0;
|
||||
arrow_data.right = 0;
|
||||
arrow_data.bottom = 0;
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
if (!m_undoredo_toolbar.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture.";
|
||||
|
||||
// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
|
@ -5287,12 +5282,12 @@ void GLCanvas3D::_picking_pass()
|
|||
if (m_camera_clipping_plane.is_active())
|
||||
::glDisable(GL_CLIP_PLANE0);
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||
#else
|
||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_gizmos.render_current_gizmo_for_picking_pass();
|
||||
|
||||
|
@ -5348,12 +5343,12 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
|
|||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
_render_volumes_for_picking();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||
#else
|
||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (m_multisample_allowed)
|
||||
glsafe(::glEnable(GL_MULTISAMPLE));
|
||||
|
@ -5426,13 +5421,13 @@ void GLCanvas3D::_render_background()
|
|||
use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
|
||||
}
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
glsafe(::glMatrixMode(GL_PROJECTION));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
// Draws a bottom to top gradient over the complete screen.
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
@ -5461,11 +5456,11 @@ void GLCanvas3D::_render_background()
|
|||
m_background.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("background_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("background");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR);
|
||||
|
@ -5487,18 +5482,18 @@ void GLCanvas3D::_render_background()
|
|||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
glsafe(::glMatrixMode(GL_MODELVIEW));
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void GLCanvas3D::_render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes)
|
||||
#else
|
||||
void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
float scale_factor = 1.0;
|
||||
#if ENABLE_RETINA_GL
|
||||
|
@ -5512,29 +5507,29 @@ void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
|||
&& m_gizmos.get_current_type() != GLGizmosManager::Seam
|
||||
&& m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation);
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_bed.render(*this, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture);
|
||||
#else
|
||||
m_bed.render(*this, bottom, scale_factor, show_axes, show_texture);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void GLCanvas3D::_render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom)
|
||||
#else
|
||||
void GLCanvas3D::_render_bed_for_picking(bool bottom)
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
float scale_factor = 1.0;
|
||||
#if ENABLE_RETINA_GL
|
||||
scale_factor = m_retina_helper->get_scale_factor();
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_bed.render_for_picking(*this, view_matrix, projection_matrix, bottom, scale_factor);
|
||||
#else
|
||||
m_bed.render_for_picking(*this, bottom, scale_factor);
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
||||
|
@ -5591,11 +5586,11 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
m_volumes.set_show_non_manifold_edges(!m_gizmos.is_hiding_instances() && m_gizmos.get_current_type() != GLGizmosManager::Simplify);
|
||||
#endif // ENABLE_SHOW_NON_MANIFOLD_EDGES
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
|
@ -5606,7 +5601,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
{
|
||||
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
|
||||
int object_id = m_layers_editing.last_object_id;
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix(), [object_id](const GLVolume& volume) {
|
||||
// Which volume to paint without the layer height profile shader?
|
||||
|
@ -5617,13 +5612,13 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
// Which volume to paint without the layer height profile shader?
|
||||
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||
});
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
||||
m_layers_editing.render_volumes(*this, m_volumes);
|
||||
}
|
||||
else {
|
||||
// do not cull backfaces to show broken geometry, if any
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
m_volumes.render(type, m_picking_enabled, camera.get_view_matrix(), camera.get_projection_matrix(), [this](const GLVolume& volume) {
|
||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||
|
@ -5632,7 +5627,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
m_volumes.render(type, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) {
|
||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||
});
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
// In case a painting gizmo is open, it should render the painted triangles
|
||||
|
@ -5651,12 +5646,12 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
}
|
||||
case GLVolumeCollection::ERenderType::Transparent:
|
||||
{
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix());
|
||||
#else
|
||||
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5816,11 +5811,11 @@ void GLCanvas3D::_render_overlays()
|
|||
void GLCanvas3D::_render_volumes_for_picking() const
|
||||
{
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -5828,10 +5823,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
// do not cull backfaces to show broken geometry, if any
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix();
|
||||
for (size_t type = 0; type < 2; ++ type) {
|
||||
|
@ -5848,11 +5843,11 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
#else
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * volume.first->world_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
volume.first->render();
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
|
@ -5860,10 +5855,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
}
|
||||
}
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
}
|
||||
|
@ -5898,20 +5893,20 @@ void GLCanvas3D::_render_main_toolbar()
|
|||
return;
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float top = 0.5f * (float)cnv_size.get_height();
|
||||
#else
|
||||
const float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
|
||||
#else
|
||||
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_main_toolbar.set_position(top, left);
|
||||
m_main_toolbar.render(*this);
|
||||
|
@ -5925,20 +5920,20 @@ void GLCanvas3D::_render_undoredo_toolbar()
|
|||
return;
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float top = 0.5f * (float)cnv_size.get_height();
|
||||
#else
|
||||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
|
||||
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float left = m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
|
||||
#else
|
||||
const float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width)) * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_undoredo_toolbar.set_position(top, left);
|
||||
m_undoredo_toolbar.render(*this);
|
||||
|
@ -5952,7 +5947,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
|
|||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
const float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0;
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float top = 0.5f * (float)cnv_size.get_height();
|
||||
const float left = 0.5f * (float)cnv_size.get_width() - collapse_toolbar.get_width() - band;
|
||||
#else
|
||||
|
@ -5960,7 +5955,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
|
|||
|
||||
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
const float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
collapse_toolbar.set_position(top, left);
|
||||
collapse_toolbar.render(*this);
|
||||
|
@ -5984,7 +5979,7 @@ void GLCanvas3D::_render_view_toolbar() const
|
|||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
// places the toolbar on the bottom-left corner of the 3d scene
|
||||
float top = -0.5f * (float)cnv_size.get_height() + view_toolbar.get_height();
|
||||
float left = -0.5f * (float)cnv_size.get_width();
|
||||
|
@ -5994,7 +5989,7 @@ void GLCanvas3D::_render_view_toolbar() const
|
|||
// places the toolbar on the bottom-left corner of the 3d scene
|
||||
float top = (-0.5f * (float)cnv_size.get_height() + view_toolbar.get_height()) * inv_zoom;
|
||||
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
view_toolbar.set_position(top, left);
|
||||
view_toolbar.render(*this);
|
||||
}
|
||||
|
@ -6043,18 +6038,18 @@ void GLCanvas3D::_render_camera_target()
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
m_camera_target.axis[i].render();
|
||||
}
|
||||
|
@ -6232,16 +6227,16 @@ void GLCanvas3D::_render_sla_slices()
|
|||
}
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
for (const SLAPrintObject::Instance& inst : obj->instances()) {
|
||||
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() *
|
||||
Geometry::assemble_transform(Vec3d(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0),
|
||||
|
@ -6257,16 +6252,16 @@ void GLCanvas3D::_render_sla_slices()
|
|||
if (obj->is_left_handed())
|
||||
// The polygons are mirrored by X.
|
||||
glsafe(::glScalef(-1.0f, 1.0f, 1.0f));
|
||||
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
bottom_obj_triangles.render();
|
||||
top_obj_triangles.render();
|
||||
bottom_sup_triangles.render();
|
||||
top_sup_triangles.render();
|
||||
|
||||
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
shader->stop_using();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue