From d6b0a9858bc93a362a9303489d9190fdc07ca109 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 4 Mar 2022 10:52:30 +0100 Subject: [PATCH] Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders. Shader: gouraud_light - Selection sidebar hints --- src/slic3r/GUI/Gizmos/GLGizmoMove.cpp | 1 + src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 2 + src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 1 + src/slic3r/GUI/Selection.cpp | 183 ++++++++++++++++++---- src/slic3r/GUI/Selection.hpp | 20 ++- 5 files changed, 174 insertions(+), 33 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp index 6e2d924b8..453b0c837 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp @@ -320,6 +320,7 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); + shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); #else glsafe(::glPushMatrix()); glsafe(::glTranslated(m_grabbers[axis].center.x(), m_grabbers[axis].center.y(), m_grabbers[axis].center.z())); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 625594e31..8a7d78445 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -612,6 +612,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size)); 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()); #else glsafe(::glPushMatrix()); glsafe(::glTranslated(center.x(), center.y(), center.z())); @@ -627,6 +628,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size)); 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()); #else glsafe(::glPopMatrix()); glsafe(::glPushMatrix()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index f5e3fdcf9..e67a9b7a7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -753,6 +753,7 @@ void GLGizmoSimplify::on_render() const Transform3d view_model_matrix = camera.get_view_matrix() * trafo_matrix; gouraud_shader->set_uniform("view_model_matrix", view_model_matrix); gouraud_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); + gouraud_shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glmodel.render(); gouraud_shader->stop_using(); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 30bebe8ba..97f737907 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1325,7 +1325,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) #if ENABLE_GLBEGIN_GLEND_REMOVAL #if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat_attr" : "gouraud_light"); + GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat_attr" : "gouraud_light_attr"); #else GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat" : "gouraud_light"); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES @@ -1349,16 +1349,26 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) glsafe(::glEnable(GL_DEPTH_TEST)); #if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - if (!boost::starts_with(sidebar_field, "layer")) + const Transform3d base_matrix = Geometry::assemble_transform(get_bounding_box().center()); + Transform3d orient_matrix = Transform3d::Identity(); +#else + glsafe(::glPushMatrix()); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); if (!boost::starts_with(sidebar_field, "layer")) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader->set_uniform("emission_factor", 0.05f); +#else const Vec3d& center = get_bounding_box().center(); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) { +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glsafe(::glTranslated(center.x(), center.y(), center.z())); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (!boost::starts_with(sidebar_field, "position")) { +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES Transform3d orient_matrix = Transform3d::Identity(); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (boost::starts_with(sidebar_field, "scale")) orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); else if (boost::starts_with(sidebar_field, "rotation")) { @@ -1366,30 +1376,42 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); else if (boost::ends_with(sidebar_field, "y")) { const Vec3d& rotation = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation(); - if (rotation(0) == 0.0) + if (rotation.x() == 0.0) orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); else - orient_matrix.rotate(Eigen::AngleAxisd(rotation(2), Vec3d::UnitZ())); + orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ())); } } - +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glsafe(::glMultMatrixd(orient_matrix.data())); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } } else if (is_single_volume() || is_single_modifier()) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); +#else glsafe(::glTranslated(center.x(), center.y(), center.z())); Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (!boost::starts_with(sidebar_field, "position")) orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true); +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glsafe(::glMultMatrixd(orient_matrix.data())); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } else { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + if (requires_local_axes()) + orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); +#else glsafe(::glTranslated(center.x(), center.y(), center.z())); if (requires_local_axes()) { const Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); glsafe(::glMultMatrixd(orient_matrix.data())); } +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } } @@ -1398,6 +1420,16 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) glsafe(::glClear(GL_DEPTH_BUFFER_BIT)); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + if (boost::starts_with(sidebar_field, "position")) + render_sidebar_position_hints(sidebar_field, *shader, base_matrix * orient_matrix); + else if (boost::starts_with(sidebar_field, "rotation")) + render_sidebar_rotation_hints(sidebar_field, *shader, base_matrix * orient_matrix); + else if (boost::starts_with(sidebar_field, "scale") || boost::starts_with(sidebar_field, "size")) + render_sidebar_scale_hints(sidebar_field, *shader, base_matrix * orient_matrix); + else if (boost::starts_with(sidebar_field, "layer")) + render_sidebar_layers_hints(sidebar_field, *shader); +#else if (boost::starts_with(sidebar_field, "position")) render_sidebar_position_hints(sidebar_field); else if (boost::starts_with(sidebar_field, "rotation")) @@ -1405,16 +1437,10 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) else if (boost::starts_with(sidebar_field, "scale") || boost::starts_with(sidebar_field, "size")) render_sidebar_scale_hints(sidebar_field); else if (boost::starts_with(sidebar_field, "layer")) -#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - render_sidebar_layers_hints(sidebar_field, shader); -#else render_sidebar_layers_hints(sidebar_field); -#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES -#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - if (!boost::starts_with(sidebar_field, "layer")) + glsafe(::glPopMatrix()); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); #if !ENABLE_GLBEGIN_GLEND_REMOVAL if (!boost::starts_with(sidebar_field, "layer")) @@ -1424,7 +1450,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) bool Selection::requires_local_axes() const { - return (m_mode == Volume) && is_from_single_instance(); + return m_mode == Volume && is_from_single_instance(); } void Selection::copy_to_clipboard() @@ -1434,8 +1460,7 @@ void Selection::copy_to_clipboard() m_clipboard.reset(); - for (const ObjectIdxsToInstanceIdxsMap::value_type& object : m_cache.content) - { + for (const ObjectIdxsToInstanceIdxsMap::value_type& object : m_cache.content) { ModelObject* src_object = m_model->objects[object.first]; ModelObject* dst_object = m_clipboard.add_object(); dst_object->name = src_object->name; @@ -1448,26 +1473,22 @@ void Selection::copy_to_clipboard() dst_object->layer_height_profile.assign(src_object->layer_height_profile); dst_object->origin_translation = src_object->origin_translation; - for (int i : object.second) - { + for (int i : object.second) { dst_object->add_instance(*src_object->instances[i]); } - for (unsigned int i : m_list) - { + for (unsigned int i : m_list) { // Copy the ModelVolumes only for the selected GLVolumes of the 1st selected instance. const GLVolume* volume = (*m_volumes)[i]; - if ((volume->object_idx() == object.first) && (volume->instance_idx() == *object.second.begin())) - { + if (volume->object_idx() == object.first && volume->instance_idx() == *object.second.begin()) { int volume_idx = volume->volume_idx(); - if ((0 <= volume_idx) && (volume_idx < (int)src_object->volumes.size())) - { + if (0 <= volume_idx && volume_idx < (int)src_object->volumes.size()) { ModelVolume* src_volume = src_object->volumes[volume_idx]; ModelVolume* dst_volume = dst_object->add_volume(*src_volume); dst_volume->set_new_unique_id(); - } else { - assert(false); } + else + assert(false); } } } @@ -2060,20 +2081,46 @@ static ColorRGBA get_color(Axis axis) return AXES_COLOR[axis]; } +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +void Selection::render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) +#else void Selection::render_sidebar_position_hints(const std::string& sidebar_field) +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES { #if ENABLE_GLBEGIN_GLEND_REMOVAL +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + const Camera& camera = wxGetApp().plater()->get_camera(); + const Transform3d view_matrix = camera.get_view_matrix() * matrix; + shader.set_uniform("projection_matrix", camera.get_projection_matrix()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + if (boost::ends_with(sidebar_field, "x")) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ()); + 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()); +#else glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0)); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(X)); m_arrow.render(); } else if (boost::ends_with(sidebar_field, "y")) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader.set_uniform("view_model_matrix", view_matrix); + shader.set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(Y)); m_arrow.render(); } else if (boost::ends_with(sidebar_field, "z")) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX()); + 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()); +#else glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(Z)); m_arrow.render(); } @@ -2095,28 +2142,65 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field) #endif // ENABLE_GLBEGIN_GLEND_REMOVAL } +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) +#else void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES { #if ENABLE_GLBEGIN_GLEND_REMOVAL +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + auto render_sidebar_rotation_hint = [this](GLShaderProgram& shader, const Transform3d& matrix) { + Transform3d view_model_matrix = 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()); + m_curved_arrow.render(); + view_model_matrix = matrix * Geometry::assemble_transform(Vec3d::Zero(), PI * Vec3d::UnitZ()); + 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()); + m_curved_arrow.render(); + }; + + const Camera& camera = wxGetApp().plater()->get_camera(); + const Transform3d view_matrix = camera.get_view_matrix() * matrix; + shader.set_uniform("projection_matrix", camera.get_projection_matrix()); +#else auto render_sidebar_rotation_hint = [this]() { m_curved_arrow.render(); glsafe(::glRotated(180.0, 0.0, 0.0, 1.0)); m_curved_arrow.render(); }; +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (boost::ends_with(sidebar_field, "x")) { +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glsafe(::glRotated(90.0, 0.0, 1.0, 0.0)); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_curved_arrow.set_color(get_color(X)); +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY())); +#else render_sidebar_rotation_hint(); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } else if (boost::ends_with(sidebar_field, "y")) { +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0)); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_curved_arrow.set_color(get_color(Y)); +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX())); +#else render_sidebar_rotation_hint(); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } else if (boost::ends_with(sidebar_field, "z")) { m_curved_arrow.set_color(get_color(Z)); +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_rotation_hint(shader, view_matrix); +#else render_sidebar_rotation_hint(); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } #else auto render_sidebar_rotation_hint = [this]() { @@ -2142,51 +2226,90 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) #endif // ENABLE_GLBEGIN_GLEND_REMOVAL } +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +void Selection::render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) +#else void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES { - bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling(); + const bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling(); +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) { +#else auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) { +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GLBEGIN_GLEND_REMOVAL m_arrow.set_color(uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis)); #else m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis)); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL + +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + Transform3d view_model_matrix = matrix * Geometry::assemble_transform(5.0 * Vec3d::UnitY()); + 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()); +#else GLShaderProgram* shader = wxGetApp().get_current_shader(); if (shader != nullptr) shader->set_uniform("emission_factor", 0.0f); glsafe(::glTranslated(0.0, 5.0, 0.0)); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_arrow.render(); +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + view_model_matrix = matrix * Geometry::assemble_transform(-5.0 * Vec3d::UnitY(), PI * Vec3d::UnitZ()); + 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()); +#else glsafe(::glTranslated(0.0, -10.0, 0.0)); glsafe(::glRotated(180.0, 0.0, 0.0, 1.0)); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_arrow.render(); }; +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + const Camera& camera = wxGetApp().plater()->get_camera(); + const Transform3d view_matrix = camera.get_view_matrix() * matrix; + shader.set_uniform("projection_matrix", camera.get_projection_matrix()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + if (boost::ends_with(sidebar_field, "x") || uniform_scale) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_scale_hint(X, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ())); +#else glsafe(::glPushMatrix()); glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0)); render_sidebar_scale_hint(X); glsafe(::glPopMatrix()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } if (boost::ends_with(sidebar_field, "y") || uniform_scale) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_scale_hint(Y, shader, view_matrix); +#else glsafe(::glPushMatrix()); render_sidebar_scale_hint(Y); glsafe(::glPopMatrix()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } if (boost::ends_with(sidebar_field, "z") || uniform_scale) { +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + render_sidebar_scale_hint(Z, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX())); +#else glsafe(::glPushMatrix()); glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); render_sidebar_scale_hint(Z); glsafe(::glPopMatrix()); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } } #if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES -void Selection::render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram* shader) +void Selection::render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader) #else void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES @@ -2289,8 +2412,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) #if ENABLE_GLBEGIN_GLEND_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()); + 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 m_planes.models[0].set_color((camera_on_top && type == 1) || (!camera_on_top && type == 2) ? SOLID_PLANE_COLOR : TRANSPARENT_PLANE_COLOR); diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index ac18c31bd..521b4d1a9 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -376,14 +376,28 @@ private: void render_selected_volumes() const; void render_bounding_box(const BoundingBoxf3& box, float* color) const; #endif // ENABLE_GLBEGIN_GLEND_REMOVAL +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + void render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); + void render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); + void render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); + void render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader); +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ void render_sidebar_position_hints(const std::string& sidebar_field); void render_sidebar_rotation_hints(const std::string& sidebar_field); void render_sidebar_scale_hints(const std::string& sidebar_field); -#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - void render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram* shader); -#else void render_sidebar_layers_hints(const std::string& sidebar_field); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +// void render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader); +//#else +// void render_sidebar_layers_hints(const std::string& sidebar_field); +//#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ public: enum SyncRotationType {