From 2d72931fac4d53d3759d6bcbf8962bb2bd5e89ba Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 3 Mar 2022 13:30:22 +0100 Subject: [PATCH] Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - Use vertex attributes and matrices in shaders. Shader: gouraud_light - Gizmo Scale hovered grabbers --- src/slic3r/GUI/Gizmos/GLGizmoBase.cpp | 27 ++++++++++---------------- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 16 +++++++++++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 2db5aeec8..afcebb986 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -39,9 +39,6 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo GLShaderProgram* shader = wxGetApp().get_current_shader(); if (shader == nullptr) return; - - bool use_attributes = boost::algorithm::iends_with(shader->get_name(), "_attr"); -// assert(use_attributes); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES if (!m_cube.is_initialized()) { @@ -74,22 +71,18 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); // picking render shader->set_uniform("projection_view_model_matrix", projection_matrix * view_model_matrix); - if (!use_attributes) { -#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); - glsafe(::glTranslated(center.x(), center.y(), center.z())); - glsafe(::glRotated(Geometry::rad2deg(angles.z()), 0.0, 0.0, 1.0)); - glsafe(::glRotated(Geometry::rad2deg(angles.y()), 0.0, 1.0, 0.0)); - glsafe(::glRotated(Geometry::rad2deg(angles.x()), 1.0, 0.0, 0.0)); - glsafe(::glScaled(fullsize, fullsize, fullsize)); -#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - } +#else + glsafe(::glPushMatrix()); + glsafe(::glTranslated(center.x(), center.y(), center.z())); + glsafe(::glRotated(Geometry::rad2deg(angles.z()), 0.0, 0.0, 1.0)); + glsafe(::glRotated(Geometry::rad2deg(angles.y()), 0.0, 1.0, 0.0)); + glsafe(::glRotated(Geometry::rad2deg(angles.x()), 1.0, 0.0, 0.0)); + glsafe(::glScaled(fullsize, fullsize, fullsize)); #endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES m_cube.render(); -#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - if (!use_attributes) -#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); +#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + glsafe(::glPopMatrix()); +#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES } GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 915b76a20..15b59d5ea 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -329,7 +329,11 @@ void GLGizmoScale3D::on_render() } // draw grabbers +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader = wxGetApp().get_shader("gouraud_light_attr"); +#else shader = wxGetApp().get_shader("gouraud_light"); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #else // draw connection glsafe(::glColor4fv(m_grabbers[0].color.data())); @@ -364,7 +368,11 @@ void GLGizmoScale3D::on_render() } // draw grabbers +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader = wxGetApp().get_shader("gouraud_light_attr"); +#else shader = wxGetApp().get_shader("gouraud_light"); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #else // draw connection glsafe(::glColor4fv(m_grabbers[2].color.data())); @@ -399,7 +407,11 @@ void GLGizmoScale3D::on_render() } // draw grabbers +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader = wxGetApp().get_shader("gouraud_light_attr"); +#else shader = wxGetApp().get_shader("gouraud_light"); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #else // draw connection glsafe(::glColor4fv(m_grabbers[4].color.data())); @@ -437,7 +449,11 @@ void GLGizmoScale3D::on_render() } // draw grabbers +#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES + shader = wxGetApp().get_shader("gouraud_light_attr"); +#else shader = wxGetApp().get_shader("gouraud_light"); +#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #else // draw connection glsafe(::glColor4fv(m_drag_color.data()));