From ebb8a618377d48e890e7ada5ef4d29b54729164e Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 28 Mar 2022 14:18:11 +0200 Subject: [PATCH] Tech ENABLE_GL_SHADERS_ATTRIBUTES merged into ENABLE_LEGACY_OPENGL_REMOVAL --- src/libslic3r/Technologies.hpp | 6 +- src/slic3r/GUI/3DBed.cpp | 117 ++++---- src/slic3r/GUI/3DBed.hpp | 14 +- src/slic3r/GUI/3DScene.cpp | 66 ++--- src/slic3r/GUI/3DScene.hpp | 17 +- src/slic3r/GUI/GCodeViewer.cpp | 104 ++++---- src/slic3r/GUI/GLCanvas3D.cpp | 250 +++++++----------- src/slic3r/GUI/GLCanvas3D.hpp | 19 +- src/slic3r/GUI/GLModel.cpp | 94 +++---- src/slic3r/GUI/GLSelectionRectangle.cpp | 14 +- src/slic3r/GUI/GLShader.cpp | 4 +- src/slic3r/GUI/GLShader.hpp | 8 +- src/slic3r/GUI/GLShadersManager.cpp | 33 +-- src/slic3r/GUI/GLTexture.cpp | 4 +- src/slic3r/GUI/GLToolbar.cpp | 32 +-- src/slic3r/GUI/GLToolbar.hpp | 16 +- src/slic3r/GUI/Gizmos/GLGizmoBase.cpp | 20 +- src/slic3r/GUI/Gizmos/GLGizmoBase.hpp | 4 +- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 16 +- src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp | 20 +- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 33 ++- .../GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 36 ++- .../GUI/Gizmos/GLGizmoMmuSegmentation.hpp | 4 +- src/slic3r/GUI/Gizmos/GLGizmoMove.cpp | 33 +-- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 80 ++---- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp | 10 +- src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 34 ++- src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp | 4 +- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 14 +- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 20 +- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 52 ++-- src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp | 24 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 16 +- src/slic3r/GUI/Gizmos/GLGizmosManager.hpp | 12 +- src/slic3r/GUI/ImGuiWrapper.cpp | 2 - src/slic3r/GUI/MeshUtils.cpp | 6 +- src/slic3r/GUI/Selection.cpp | 146 +++------- src/slic3r/GUI/Selection.hpp | 9 +- 38 files changed, 551 insertions(+), 842 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 3af9620f3f..6c61e202a5 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -55,12 +55,10 @@ #define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1) // Enable removal of legacy OpenGL calls #define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1) -// Enable using vertex attributes and matrices in shaders -#define ENABLE_GL_SHADERS_ATTRIBUTES (1 && ENABLE_LEGACY_OPENGL_REMOVAL) // Enable rendering imgui using shaders -#define ENABLE_GL_IMGUI_SHADERS (1 && ENABLE_GL_SHADERS_ATTRIBUTES) +#define ENABLE_GL_IMGUI_SHADERS (1 && ENABLE_LEGACY_OPENGL_REMOVAL) // Enable OpenGL core profile context -#define ENABLE_GL_CORE_PROFILE (1 && ENABLE_GL_SHADERS_ATTRIBUTES) +#define ENABLE_GL_CORE_PROFILE (0 && ENABLE_LEGACY_OPENGL_REMOVAL) // Shows an imgui dialog with GLModel statistics data #define ENABLE_GLMODEL_STATISTICS (0 && ENABLE_LEGACY_OPENGL_REMOVAL) // Enable show non-manifold edges diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 19dffd56d6..5da46221fc 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -11,10 +11,10 @@ #include "GUI_App.hpp" #include "GLCanvas3D.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #include "Plater.hpp" #include "Camera.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #include @@ -109,7 +109,7 @@ const float Bed3D::Axes::DefaultTipLength = 5.0f; void Bed3D::Axes::render() { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL auto render_axis = [this](GLShaderProgram* shader, const Transform3d& transform) { const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d matrix = camera.get_view_matrix() * transform; @@ -120,11 +120,11 @@ void Bed3D::Axes::render() auto render_axis = [this](const Transform3f& transform) { glsafe(::glPushMatrix()); glsafe(::glMultMatrixf(transform.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL }; if (!m_arrow.is_initialized()) @@ -142,38 +142,29 @@ void Bed3D::Axes::render() // x axis #if ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.set_color(ColorRGBA::X()); -#else - m_arrow.set_color(-1, ColorRGBA::X()); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES render_axis(shader, Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 })); #else + m_arrow.set_color(-1, ColorRGBA::X()); render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // y axis #if ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.set_color(ColorRGBA::Y()); -#else - m_arrow.set_color(-1, ColorRGBA::Y()); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES render_axis(shader, Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 })); #else + m_arrow.set_color(-1, ColorRGBA::Y()); render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // z axis #if ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.set_color(ColorRGBA::Z()); -#else - m_arrow.set_color(-1, ColorRGBA::Z()); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES render_axis(shader, Geometry::assemble_transform(m_origin)); #else + m_arrow.set_color(-1, ColorRGBA::Z()); render_axis(Geometry::assemble_transform(m_origin).cast()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); @@ -266,7 +257,7 @@ Point Bed3D::point_projection(const Point& point) const return m_polygon.point_projection(point); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture) { render_internal(canvas, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture, false); @@ -286,15 +277,15 @@ void Bed3D::render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_fact { render_internal(canvas, bottom, scale_factor, false, false, true); } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture, bool picking) #else void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture, bool picking) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { m_scale_factor = scale_factor; @@ -311,7 +302,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, switch (m_type) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL case Type::System: { render_system(canvas, view_matrix, projection_matrix, bottom, show_texture); break; } default: case Type::Custom: { render_custom(canvas, view_matrix, projection_matrix, bottom, show_texture, picking); break; } @@ -319,7 +310,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, case Type::System: { render_system(canvas, bottom, show_texture); break; } default: case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } glsafe(::glDisable(GL_DEPTH_TEST)); @@ -504,7 +495,7 @@ void Bed3D::render_axes() m_axes.render(); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture) { if (!bottom) @@ -522,21 +513,21 @@ void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture) if (show_texture) render_texture(bottom, canvas); } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix) #else void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { if (m_texture_filename.empty()) { m_texture.reset(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } @@ -549,11 +540,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) if (m_temp_texture.get_id() == 0 || m_temp_texture.get_source() != m_texture_filename) { // generate a temporary lower resolution texture to show while no main texture levels have been compressed if (!m_temp_texture.load_from_svg_file(m_texture_filename, false, false, false, max_tex_size / 8)) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } canvas.request_extra_frame(); @@ -561,11 +552,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) // starts generating the main texture, compression will run asynchronously if (!m_texture.load_from_svg_file(m_texture_filename, true, true, true, max_tex_size)) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } } @@ -573,11 +564,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) // generate a temporary lower resolution texture to show while no main texture levels have been compressed if (m_temp_texture.get_id() == 0 || m_temp_texture.get_source() != m_texture_filename) { if (!m_temp_texture.load_from_file(m_texture_filename, false, GLTexture::None, false)) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } canvas.request_extra_frame(); @@ -585,20 +576,20 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) // starts generating the main texture, compression will run asynchronously if (!m_texture.load_from_file(m_texture_filename, true, GLTexture::MultiThreaded, true)) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } } else { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, false, view_matrix, projection_matrix); #else render_default(bottom, false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } } @@ -619,10 +610,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) GLShaderProgram* shader = wxGetApp().get_shader("printbed"); if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("view_model_matrix", view_matrix); shader->set_uniform("projection_matrix", projection_matrix); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("transparent_background", bottom); shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg")); @@ -716,11 +705,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) #endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix) #else void Bed3D::render_model() -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { if (m_model_filename.empty()) return; @@ -744,7 +733,7 @@ void Bed3D::render_model() if (shader != nullptr) { shader->start_using(); shader->set_uniform("emission_factor", 0.0f); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d matrix = view_matrix * Geometry::assemble_transform(m_model_offset); shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("projection_matrix", projection_matrix); @@ -752,51 +741,51 @@ void Bed3D::render_model() #else glsafe(::glPushMatrix()); glsafe(::glTranslated(m_model_offset.x(), m_model_offset.y(), m_model_offset.z())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_model.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); } } } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking) #else void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { if (m_texture_filename.empty() && m_model_filename.empty()) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_default(bottom, picking, view_matrix, projection_matrix); #else render_default(bottom, picking); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return; } +#if ENABLE_LEGACY_OPENGL_REMOVAL if (!bottom) -#if ENABLE_GL_SHADERS_ATTRIBUTES render_model(view_matrix, projection_matrix); -#else - render_model(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES if (show_texture) -#if ENABLE_GL_SHADERS_ATTRIBUTES render_texture(bottom, canvas, view_matrix, projection_matrix); #else + if (!bottom) + render_model(); + + if (show_texture) render_texture(bottom, canvas); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void Bed3D::render_default(bool bottom, bool picking, const Transform3d& view_matrix, const Transform3d& projection_matrix) #else void Bed3D::render_default(bool bottom, bool picking) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { m_texture.reset(); @@ -808,10 +797,8 @@ void Bed3D::render_default(bool bottom, bool picking) if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("view_model_matrix", view_matrix); shader->set_uniform("projection_matrix", projection_matrix); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_BLEND)); diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index 7c334cb939..0ca501ba12 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -139,13 +139,13 @@ public: bool contains(const Point& point) const; Point point_projection(const Point& point) const; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture); void render_for_picking(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor); #else void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture); void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL private: // Calculate an extended bounding box from axes and current model for visualization purposes. @@ -158,15 +158,15 @@ private: void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); #endif // ENABLE_LEGACY_OPENGL_REMOVAL static std::tuple detect_type(const Pointfs& shape); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture, bool picking); #else void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture, bool picking); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void render_axes(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture); void render_texture(bool bottom, GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix); void render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix); @@ -178,11 +178,9 @@ private: void render_model(); void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking); void render_default(bool bottom, bool picking); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES -#if !ENABLE_LEGACY_OPENGL_REMOVAL void release_VBOs(); -#endif // !ENABLE_LEGACY_OPENGL_REMOVAL +#endif // ENABLE_LEGACY_OPENGL_REMOVAL }; } // GUI diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 1082595b0b..c31cc07ba8 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -13,9 +13,9 @@ #include "GUI_App.hpp" #include "Plater.hpp" #include "BitmapCache.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #include "Camera.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #include "libslic3r/BuildVolume.hpp" #include "libslic3r/ExtrusionEntity.hpp" @@ -301,7 +301,7 @@ void GLVolume::SinkingContours::render() { update(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); if (shader == nullptr) return; @@ -312,11 +312,11 @@ void GLVolume::SinkingContours::render() #else glsafe(::glPushMatrix()); glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_model.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } void GLVolume::SinkingContours::update() @@ -392,7 +392,7 @@ void GLVolume::NonManifoldEdges::render() #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth(2.0f)); #endif // !ENABLE_GL_CORE_PROFILE -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); if (shader == nullptr) return; @@ -406,19 +406,16 @@ void GLVolume::NonManifoldEdges::render() shader->set_uniform("width", 0.5f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE + m_model.set_color(complementary(m_parent.render_color)); #else glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(m_parent.world_matrix().data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES -#if ENABLE_LEGACY_OPENGL_REMOVAL - m_model.set_color(complementary(m_parent.render_color)); -#else m_model.set_color(-1, complementary(m_parent.render_color)); #endif // ENABLE_LEGACY_OPENGL_REMOVAL m_model.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } void GLVolume::NonManifoldEdges::update() @@ -710,19 +707,15 @@ void GLVolume::render() if (!is_active) return; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); if (shader == nullptr) return; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (this->is_left_handed()) - glFrontFace(GL_CW); + glsafe(::glFrontFace(GL_CW)); glsafe(::glCullFace(GL_BACK)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); - glsafe(::glMultMatrixd(world_matrix().data())); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if ENABLE_LEGACY_OPENGL_REMOVAL if (tverts_range == std::make_pair(0, -1)) @@ -730,15 +723,14 @@ void GLVolume::render() else model.render(this->tverts_range); #else + glsafe(::glPushMatrix()); + glsafe(::glMultMatrixd(world_matrix().data())); this->indexed_vertex_array.render(this->tverts_range, this->qverts_range); + glsafe(::glPopMatrix()); #endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES - if (this->is_left_handed()) - glFrontFace(GL_CCW); + glsafe(::glFrontFace(GL_CCW)); } bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); } @@ -1077,12 +1069,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo return list; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix, std::function filter_func) const #else void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function filter_func) const -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func); if (to_render.empty()) @@ -1135,13 +1127,11 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab sink_shader->stop_using(); } shader->start_using(); +#else + glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); + glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); #endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); - glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES - shader->set_uniform("z_range", m_z_range, 2); shader->set_uniform("clipping_plane", m_clipping_plane, 4); shader->set_uniform("print_volume.type", static_cast(m_print_volume.type)); @@ -1163,15 +1153,13 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab #if ENABLE_LEGACY_OPENGL_REMOVAL volume.first->model.set_color(volume.first->render_color); -#else - shader->set_uniform("uniform_color", volume.first->render_color); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES const Transform3d matrix = view_matrix * volume.first->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_GL_SHADERS_ATTRIBUTES +#else + shader->set_uniform("uniform_color", volume.first->render_color); +#endif // ENABLE_LEGACY_OPENGL_REMOVAL volume.first->render(); #if ENABLE_ENVIRONMENT_MAP @@ -1182,10 +1170,10 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } if (m_show_sinking_contours) { diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 950d447f02..a92bac9617 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -681,28 +681,23 @@ public: #if ENABLE_LEGACY_OPENGL_REMOVAL GLVolume* new_toolpath_volume(const ColorRGBA& rgba); GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba); -#else - GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0); - GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL - // Render the volumes by OpenGL. -#if ENABLE_GL_SHADERS_ATTRIBUTES void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix, std::function filter_func = std::function()) const; #else + GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0); + GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0); + // Render the volumes by OpenGL. void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function filter_func = std::function()) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES - -#if !ENABLE_LEGACY_OPENGL_REMOVAL // Finalize the initialization of the geometry & indices, // upload the geometry and indices to OpenGL VBO objects // and shrink the allocated data, possibly relasing it if it has been loaded into the VBOs. void finalize_geometry(bool opengl_initialized) { for (auto* v : volumes) v->finalize_geometry(opengl_initialized); } // Release the geometry data assigned to the volumes. // If OpenGL VBOs were allocated, an OpenGL context has to be active to release them. - void release_geometry() { for (auto *v : volumes) v->release_geometry(); } -#endif // !ENABLE_LEGACY_OPENGL_REMOVAL + void release_geometry() { for (auto* v : volumes) v->release_geometry(); } +#endif // ENABLE_LEGACY_OPENGL_REMOVAL + // Clear the geometry void clear() { for (auto *v : volumes) delete v; volumes.clear(); } diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 8414cb9f9f..15da6e17f3 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -200,11 +200,11 @@ void GCodeViewer::COG::render() glsafe(::glDisable(GL_DEPTH_TEST)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); Transform3d matrix = camera.get_view_matrix() * Geometry::assemble_transform(cog()); if (m_fixed_size) { - const double inv_zoom = wxGetApp().plater()->get_camera().get_inv_zoom(); + const double inv_zoom = camera.get_inv_zoom(); matrix = matrix * Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), inv_zoom * Vec3d::Ones()); } shader->set_uniform("view_model_matrix", matrix); @@ -221,7 +221,7 @@ void GCodeViewer::COG::render() } m_model.render(); glsafe(::glPopMatrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); @@ -347,7 +347,7 @@ void GCodeViewer::SequentialView::Marker::render() shader->start_using(); shader->set_uniform("emission_factor", 0.0f); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d matrix = camera.get_view_matrix() * m_world_transform.cast(); shader->set_uniform("view_model_matrix", matrix); @@ -356,13 +356,13 @@ void GCodeViewer::SequentialView::Marker::render() #else glsafe(::glPushMatrix()); glsafe(::glMultMatrixf(m_world_transform.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_model.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); @@ -733,7 +733,7 @@ void GCodeViewer::init() } case EMoveType::Travel: { buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL buffer.vertices.format = VBuffer::EFormat::Position; #if ENABLE_GL_CORE_PROFILE buffer.shader = "dashed_thick_lines"; @@ -743,7 +743,7 @@ void GCodeViewer::init() #else buffer.vertices.format = VBuffer::EFormat::PositionNormal3; buffer.shader = "toolpaths_lines"; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL break; } } @@ -1317,14 +1317,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) // format data into the buffers to be rendered as lines auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) { -#if !ENABLE_GL_SHADERS_ATTRIBUTES - // x component of the normal to the current segment (the normal is parallel to the XY plane) - const Vec3f dir = (curr.position - prev.position).normalized(); - Vec3f normal(dir.y(), -dir.x(), 0.0); - normal.normalize(); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES - -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL auto add_vertex = [&vertices](const GCodeProcessorResult::MoveVertex& vertex) { // add position vertices.push_back(vertex.position.x()); @@ -1332,6 +1325,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) vertices.push_back(vertex.position.z()); }; #else + // x component of the normal to the current segment (the normal is parallel to the XY plane) + const Vec3f dir = (curr.position - prev.position).normalized(); + Vec3f normal(dir.y(), -dir.x(), 0.0); + normal.normalize(); + auto add_vertex = [&vertices, &normal](const GCodeProcessorResult::MoveVertex& vertex) { // add position vertices.push_back(vertex.position.x()); @@ -1342,7 +1340,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) vertices.push_back(normal.y()); vertices.push_back(normal.z()); }; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // add previous vertex add_vertex(prev); @@ -2998,19 +2996,19 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool void GCodeViewer::render_toolpaths() { -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL const std::array light_intensity = { 0.25f, 0.70f, 0.75f, 0.75f }; -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); #if !ENABLE_GL_CORE_PROFILE const double zoom = camera.get_zoom(); #endif // !ENABLE_GL_CORE_PROFILE -#if !ENABLE_GL_SHADERS_ATTRIBUTES - auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) { +#if !ENABLE_LEGACY_OPENGL_REMOVAL + auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) { shader.set_uniform("light_intensity", light_intensity); }; -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL auto render_as_lines = [ #if ENABLE_GCODE_VIEWER_STATISTICS this @@ -3084,7 +3082,7 @@ void GCodeViewer::render_toolpaths() } }; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_GCODE_VIEWER_STATISTICS auto render_as_batched_model = [this](TBuffer& buffer, GLShaderProgram& shader, int position_id, int normal_id) { #else @@ -3096,7 +3094,7 @@ void GCodeViewer::render_toolpaths() #else auto render_as_batched_model = [](TBuffer& buffer, GLShaderProgram& shader) { #endif // ENABLE_GCODE_VIEWER_STATISTICS -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL struct Range { @@ -3114,7 +3112,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glBindVertexArray(i_buffer.vao)); #endif // ENABLE_GL_CORE_PROFILE glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (position_id != -1) { glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glEnableVertexAttribArray(position_id)); @@ -3122,10 +3120,10 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL const bool has_normals = buffer.vertices.normal_size_floats() > 0; if (has_normals) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) { glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glEnableVertexAttribArray(normal_id)); @@ -3133,7 +3131,7 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo)); @@ -3157,7 +3155,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) glsafe(::glDisableVertexAttribArray(normal_id)); if (position_id != -1) @@ -3167,7 +3165,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); #if ENABLE_GL_CORE_PROFILE glsafe(::glBindVertexArray(0)); @@ -3197,12 +3195,12 @@ void GCodeViewer::render_toolpaths() shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d& view_matrix = camera.get_view_matrix(); shader->set_uniform("view_model_matrix", view_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) { shader->set_uniform("emission_factor", 0.25f); @@ -3211,23 +3209,23 @@ void GCodeViewer::render_toolpaths() } else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) { shader->set_uniform("emission_factor", 0.25f); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const int position_id = shader->get_attrib_location("v_position"); const int normal_id = shader->get_attrib_location("v_normal"); render_as_batched_model(buffer, *shader, position_id, normal_id); #else render_as_batched_model(buffer, *shader); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->set_uniform("emission_factor", 0.0f); } else { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const int position_id = shader->get_attrib_location("v_position"); const int normal_id = shader->get_attrib_location("v_normal"); #else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Line) shader_init_as_lines(*shader); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL const int uniform_color = shader->get_uniform_location("uniform_color"); auto it_path = buffer.render_paths.begin(); @@ -3243,7 +3241,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glBindVertexArray(i_buffer.vao)); #endif // ENABLE_GL_CORE_PROFILE glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (position_id != -1) { glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glEnableVertexAttribArray(position_id)); @@ -3251,10 +3249,10 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL const bool has_normals = buffer.vertices.normal_size_floats() > 0; if (has_normals) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) { glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glEnableVertexAttribArray(normal_id)); @@ -3262,7 +3260,7 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo)); @@ -3286,7 +3284,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) glsafe(::glDisableVertexAttribArray(normal_id)); if (position_id != -1) @@ -3296,7 +3294,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); #if ENABLE_GL_CORE_PROFILE glsafe(::glBindVertexArray(0)); @@ -3320,7 +3318,7 @@ void GCodeViewer::render_toolpaths() shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d& view_matrix = camera.get_view_matrix(); shader->set_uniform("view_model_matrix", view_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); @@ -3328,13 +3326,13 @@ void GCodeViewer::render_toolpaths() const int position_id = shader->get_attrib_location("v_position"); const int normal_id = shader->get_attrib_location("v_normal"); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_GL_CORE_PROFILE glsafe(::glBindVertexArray(cap.vao)); #endif // ENABLE_GL_CORE_PROFILE glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (position_id != -1) { glsafe(::glVertexAttribPointer(position_id, buffer->vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes())); glsafe(::glEnableVertexAttribArray(position_id)); @@ -3342,10 +3340,10 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glVertexPointer(buffer->vertices.position_size_floats(), GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes())); glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL const bool has_normals = buffer->vertices.normal_size_floats() > 0; if (has_normals) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) { glsafe(::glVertexAttribPointer(normal_id, buffer->vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes())); glsafe(::glEnableVertexAttribArray(normal_id)); @@ -3353,7 +3351,7 @@ void GCodeViewer::render_toolpaths() #else glsafe(::glNormalPointer(GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes())); glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } shader->set_uniform("uniform_color", cap.color); @@ -3366,7 +3364,7 @@ void GCodeViewer::render_toolpaths() ++m_statistics.gl_triangles_calls_count; #endif // ENABLE_GCODE_VIEWER_STATISTICS -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (normal_id != -1) glsafe(::glDisableVertexAttribArray(normal_id)); if (position_id != -1) @@ -3376,7 +3374,7 @@ void GCodeViewer::render_toolpaths() glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); #if ENABLE_GL_CORE_PROFILE @@ -3414,12 +3412,12 @@ void GCodeViewer::render_shells() // glsafe(::glDepthMask(GL_FALSE)); shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, camera.get_view_matrix(), camera.get_projection_matrix()); #else m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); // glsafe(::glDepthMask(GL_TRUE)); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 57f0305628..7e03116bf4 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -263,21 +263,14 @@ 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_active_object_annotations(canvas); render_profile(canvas); #else const Rect& bar_rect = get_bar_rect_viewport(canvas); -#if ENABLE_LEGACY_OPENGL_REMOVAL - m_profile.dirty = m_profile.old_bar_rect != bar_rect; -#endif // ENABLE_LEGACY_OPENGL_REMOVAL render_active_object_annotations(canvas, bar_rect); render_profile(bar_rect); -#if ENABLE_LEGACY_OPENGL_REMOVAL - m_profile.old_bar_rect = bar_rect; - m_profile.dirty = false; #endif // ENABLE_LEGACY_OPENGL_REMOVAL -#endif // ENABLE_GL_SHADERS_ATTRIBUTES } float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) @@ -311,7 +304,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas) return { w - thickness_bar_width(canvas), 0.0f, w, h }; } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas) { const Size& cnv_size = canvas.get_canvas_size(); @@ -320,7 +313,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_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL bool GLCanvas3D::LayersEditing::is_initialized() const { @@ -353,21 +346,20 @@ std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) con return ret; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_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_width = (float)cnv_size.get_width(); const float cnv_height = (float)cnv_size.get_height(); if (cnv_width == 0.0f || cnv_height == 0.0f) return; const float cnv_inv_width = 1.0f / cnv_width; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#else +void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) +{ +#endif // ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height"); if (shader == nullptr) return; @@ -379,23 +371,19 @@ 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL 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_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_GL_SHADERS_ATTRIBUTES m_profile.background.reset(); GLModel::Geometry init_data; @@ -404,17 +392,10 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3 init_data.reserve_indices(6); // vertices -#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; const float b = -1.0f; -#else - const float l = bar_rect.get_left(); - const float r = bar_rect.get_right(); - const float t = bar_rect.get_top(); - const float b = bar_rect.get_bottom(); -#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)); @@ -448,18 +429,18 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3 shader->stop_using(); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas) #else void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { //FIXME show some kind of legend. if (!m_slicing_parameters) return; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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(); @@ -476,15 +457,11 @@ 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL // Baseline -#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_GL_SHADERS_ATTRIBUTES m_profile.baseline.reset(); GLModel::Geometry init_data; @@ -494,15 +471,9 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) init_data.reserve_indices(2); // vertices -#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)); -#else - 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_GL_SHADERS_ATTRIBUTES // indices init_data.add_line(0, 1); @@ -510,11 +481,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) m_profile.baseline.init_from(std::move(init_data)); } -#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_GL_SHADERS_ATTRIBUTES m_profile.old_layer_height_profile = m_layer_height_profile; m_profile.profile.reset(); @@ -526,13 +493,8 @@ 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_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_GL_SHADERS_ATTRIBUTES init_data.add_index(i / 2); } @@ -542,10 +504,8 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) GLShaderProgram* shader = wxGetApp().get_shader("flat"); if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES m_profile.baseline.render(); m_profile.profile.render(); shader->stop_using(); @@ -593,10 +553,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // Initialize the layer height texture mapping. const GLsizei w = (GLsizei)m_layers_texture.width; @@ -616,11 +576,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glvolume->render(); } @@ -1065,11 +1025,11 @@ void GLCanvas3D::SequentialPrintClearance::render() shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_CULL_FACE)); @@ -1701,11 +1661,11 @@ void GLCanvas3D::render() _render_gcode(); _render_sla_slices(); _render_selection(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL _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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL _render_objects(GLVolumeCollection::ERenderType::Transparent); _render_sequential_clearance(); @@ -4329,12 +4289,12 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) ImGuiWrapper* imgui = wxGetApp().imgui(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL std::string title = is_undo ? L("Undo History") : L("Redo History"); imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); @@ -4373,12 +4333,12 @@ bool GLCanvas3D::_render_search_list(float pos_x) bool action_taken = false; ImGuiWrapper* imgui = wxGetApp().imgui(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL std::string title = L("Search"); imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); @@ -4431,13 +4391,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) { ImGuiWrapper *imgui = wxGetApp().imgui(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); @@ -4560,13 +4520,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const camera.set_scene_box(scene_bounding_box()); camera.apply_viewport(0, 0, thumbnail_data.width, thumbnail_data.height); camera.zoom_to_box(volumes_box); -#if !ENABLE_LEGACY_OPENGL_REMOVAL - camera.apply_view_matrix(); -#endif // !ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d& view_matrix = camera.get_view_matrix(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#else + camera.apply_view_matrix(); +#endif // ENABLE_LEGACY_OPENGL_REMOVAL double near_z = -1.0; double far_z = -1.0; @@ -4575,11 +4534,11 @@ 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL near_z = -t_bed_box.max.z(); far_z = -t_bed_box.min.z(); } @@ -4599,9 +4558,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const shader->start_using(); shader->set_uniform("emission_factor", 0.0f); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d& projection_matrix = camera.get_projection_matrix(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL for (GLVolume* vol : visible_volumes) { #if ENABLE_LEGACY_OPENGL_REMOVAL @@ -4612,12 +4571,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL vol->render(); vol->is_active = is_active; } @@ -4627,11 +4586,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const glsafe(::glDisable(GL_DEPTH_TEST)); if (thumbnail_params.show_bed) -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL _render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false); #else _render_bed(!camera.is_looking_downward(), false); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // restore background color if (thumbnail_params.transparent_background) @@ -4898,7 +4857,7 @@ bool GLCanvas3D::_init_main_toolbar() return true; } // init arrow -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg")) #else BackgroundTexture::Metadata arrow_data; @@ -4908,15 +4867,15 @@ bool GLCanvas3D::_init_main_toolbar() arrow_data.right = 0; arrow_data.bottom = 0; if (!m_main_toolbar.init_arrow(arrow_data)) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (!m_gizmos.init_arrow("toolbar_arrow_2.svg")) #else if (!m_gizmos.init_arrow(arrow_data)) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture."; // m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical); @@ -5121,7 +5080,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() } // init arrow -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg")) #else BackgroundTexture::Metadata arrow_data; @@ -5131,7 +5090,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() arrow_data.right = 0; arrow_data.bottom = 0; if (!m_undoredo_toolbar.init_arrow(arrow_data)) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture."; // m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical); @@ -5351,12 +5310,12 @@ void GLCanvas3D::_picking_pass() if (m_camera_clipping_plane.is_active()) ::glDisable(GL_CLIP_PLANE0); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_gizmos.render_current_gizmo_for_picking_pass(); @@ -5412,12 +5371,12 @@ void GLCanvas3D::_rectangular_selection_picking_pass() glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); _render_volumes_for_picking(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (m_multisample_allowed) glsafe(::glEnable(GL_MULTISAMPLE)); @@ -5490,13 +5449,13 @@ void GLCanvas3D::_render_background() use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glLoadIdentity()); glsafe(::glMatrixMode(GL_PROJECTION)); glsafe(::glPushMatrix()); glsafe(::glLoadIdentity()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL // Draws a bottom to top gradient over the complete screen. glsafe(::glDisable(GL_DEPTH_TEST)); @@ -5547,18 +5506,18 @@ void GLCanvas3D::_render_background() glsafe(::glEnable(GL_DEPTH_TEST)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); glsafe(::glMatrixMode(GL_MODELVIEW)); glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { float scale_factor = 1.0; #if ENABLE_RETINA_GL @@ -5572,29 +5531,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { float scale_factor = 1.0; #if ENABLE_RETINA_GL scale_factor = m_retina_helper->get_scale_factor(); #endif // ENABLE_RETINA_GL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type) @@ -5662,7 +5621,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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? @@ -5673,13 +5632,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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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); @@ -5688,7 +5647,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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } // In case a painting gizmo is open, it should render the painted triangles @@ -5707,12 +5666,12 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type) } case GLVolumeCollection::ERenderType::Transparent: { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL break; } } @@ -5820,7 +5779,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() void GLCanvas3D::_render_overlays() { glsafe(::glDisable(GL_DEPTH_TEST)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glLoadIdentity()); // ensure that the textures are renderered inside the frustrum @@ -5829,7 +5788,7 @@ void GLCanvas3D::_render_overlays() // ensure that the overlay fits the frustrum near z plane double gui_scale = camera.get_gui_scale(); glsafe(::glScaled(gui_scale, gui_scale, 1.0)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL _check_and_update_toolbar_icon_scale(); @@ -5868,9 +5827,9 @@ void GLCanvas3D::_render_overlays() } m_labels.render(sorted_instances); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } void GLCanvas3D::_render_volumes_for_picking() const @@ -5884,10 +5843,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_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix(); for (size_t type = 0; type < 2; ++ type) { @@ -5901,14 +5860,12 @@ void GLCanvas3D::_render_volumes_for_picking() const #if ENABLE_LEGACY_OPENGL_REMOVAL volume.first->model.set_color(picking_decode(id)); shader->start_using(); -#else - glsafe(::glColor4fv(picking_decode(id).data())); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#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_GL_SHADERS_ATTRIBUTES +#else + glsafe(::glColor4fv(picking_decode(id).data())); +#endif // ENABLE_LEGACY_OPENGL_REMOVAL volume.first->render(); #if ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); @@ -5916,10 +5873,10 @@ void GLCanvas3D::_render_volumes_for_picking() const } } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glEnable(GL_CULL_FACE)); } @@ -5954,20 +5911,20 @@ void GLCanvas3D::_render_main_toolbar() return; const Size cnv_size = get_canvas_size(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_main_toolbar.set_position(top, left); m_main_toolbar.render(*this); @@ -5981,20 +5938,20 @@ void GLCanvas3D::_render_undoredo_toolbar() return; const Size cnv_size = get_canvas_size(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_undoredo_toolbar.set_position(top, left); m_undoredo_toolbar.render(*this); @@ -6008,7 +5965,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_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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 @@ -6016,7 +5973,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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL collapse_toolbar.set_position(top, left); collapse_toolbar.render(*this); @@ -6040,17 +5997,17 @@ void GLCanvas3D::_render_view_toolbar() const #endif // ENABLE_RETINA_GL const Size cnv_size = get_canvas_size(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL // 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(); + const float top = -0.5f * (float)cnv_size.get_height() + view_toolbar.get_height(); + const float left = -0.5f * (float)cnv_size.get_width(); #else float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); // 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL view_toolbar.set_position(top, left); view_toolbar.render(*this); } @@ -6107,7 +6064,7 @@ void GLCanvas3D::_render_camera_target() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::assemble_transform(m_camera_target.target)); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); @@ -6117,7 +6074,7 @@ void GLCanvas3D::_render_camera_target() shader->set_uniform("width", 0.5f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL for (int i = 0; i < 3; ++i) { m_camera_target.axis[i].render(); } @@ -6296,32 +6253,19 @@ void GLCanvas3D::_render_sla_slices() shader->start_using(); for (const SLAPrintObject::Instance& inst : obj->instances()) { -#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(inst.shift.x()), unscale(inst.shift.y()), 0.0), inst.rotation * Vec3d::UnitZ(), Vec3d::Ones(), - obj->is_left_handed() ? Vec3d(-1.0f, 1.0f, 1.0f) : Vec3d::Ones()); + obj->is_left_handed() ? /* The polygons are mirrored by X */ Vec3d(-1.0f, 1.0f, 1.0f) : Vec3d::Ones()); shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); -#else - glsafe(::glPushMatrix()); - glsafe(::glTranslated(unscale(inst.shift.x()), unscale(inst.shift.y()), 0.0)); - glsafe(::glRotatef(Geometry::rad2deg(inst.rotation), 0.0f, 0.0f, 1.0f)); - if (obj->is_left_handed()) - // The polygons are mirrored by X. - glsafe(::glScalef(-1.0f, 1.0f, 1.0f)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES bottom_obj_triangles.render(); top_obj_triangles.render(); bottom_sup_triangles.render(); top_sup_triangles.render(); - -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES } shader->stop_using(); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 09659faea1..f20de2621e 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -245,15 +245,8 @@ class GLCanvas3D GLModel baseline; GLModel profile; GLModel background; -#if ENABLE_GL_SHADERS_ATTRIBUTES float old_canvas_width{ 0.0f }; -#else - Rect old_bar_rect; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES std::vector old_layer_height_profile; -#if !ENABLE_GL_SHADERS_ATTRIBUTES - bool dirty{ false }; -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES }; Profile m_profile; #endif // ENABLE_LEGACY_OPENGL_REMOVAL @@ -283,9 +276,9 @@ class GLCanvas3D static float get_cursor_z_relative(const GLCanvas3D& canvas); static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y); static Rect get_bar_rect_screen(const GLCanvas3D& canvas); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL static Rect get_bar_rect_viewport(const GLCanvas3D& canvas); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL static float get_overlay_window_width() { return LayersEditing::s_overlay_window_width; } float object_max_z() const { return m_object_max_z; } @@ -295,13 +288,13 @@ class GLCanvas3D private: bool is_initialized() const; void generate_layer_height_texture(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render_active_object_annotations(const GLCanvas3D& canvas); void render_profile(const GLCanvas3D& canvas); #else void render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect); void render_profile(const Rect& bar_rect); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void update_slicing_parameters(); static float thickness_bar_width(const GLCanvas3D &canvas); @@ -953,13 +946,13 @@ private: void _picking_pass(); void _rectangular_selection_picking_pass(); void _render_background(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void _render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes); void _render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom); #else void _render_bed(bool bottom, bool show_axes); void _render_bed_for_picking(bool bottom); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void _render_objects(GLVolumeCollection::ERenderType type); void _render_gcode(); #if ENABLE_SHOW_TOOLPATHS_COG diff --git a/src/slic3r/GUI/GLModel.cpp b/src/slic3r/GUI/GLModel.cpp index 8d5ec70514..c84d4a512a 100644 --- a/src/slic3r/GUI/GLModel.cpp +++ b/src/slic3r/GUI/GLModel.cpp @@ -902,47 +902,30 @@ void GLModel::render(const std::pair& range) #endif // ENABLE_GL_CORE_PROFILE glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id)); -#if ENABLE_GL_SHADERS_ATTRIBUTES int position_id = -1; int normal_id = -1; int tex_coord_id = -1; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES if (position) { -#if ENABLE_GL_SHADERS_ATTRIBUTES position_id = shader->get_attrib_location("v_position"); if (position_id != -1) { glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format))); glsafe(::glEnableVertexAttribArray(position_id)); } -#else - glsafe(::glVertexPointer(Geometry::position_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format))); - glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES } if (normal) { -#if ENABLE_GL_SHADERS_ATTRIBUTES normal_id = shader->get_attrib_location("v_normal"); if (normal_id != -1) { glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format))); glsafe(::glEnableVertexAttribArray(normal_id)); } -#else - glsafe(::glNormalPointer(GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format))); - glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES } if (tex_coord) { -#if ENABLE_GL_SHADERS_ATTRIBUTES tex_coord_id = shader->get_attrib_location("v_tex_coord"); if (tex_coord_id != -1) { glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format))); glsafe(::glEnableVertexAttribArray(tex_coord_id)); } -#else - glsafe(::glTexCoordPointer(Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format))); - glsafe(::glEnableClientState(GL_TEXTURE_COORD_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES } shader->set_uniform("uniform_color", data.color); @@ -955,21 +938,12 @@ void GLModel::render(const std::pair& range) glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); #endif // !ENABLE_GL_CORE_PROFILE -#if ENABLE_GL_SHADERS_ATTRIBUTES if (tex_coord_id != -1) glsafe(::glDisableVertexAttribArray(tex_coord_id)); if (normal_id != -1) glsafe(::glDisableVertexAttribArray(normal_id)); if (position_id != -1) glsafe(::glDisableVertexAttribArray(position_id)); -#else - if (tex_coord) - glsafe(::glDisableClientState(GL_TEXTURE_COORD_ARRAY)); - if (normal) - glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); - if (position) - glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); #if ENABLE_GL_CORE_PROFILE @@ -1466,61 +1440,61 @@ GLModel::Geometry stilized_arrow(unsigned int resolution, float tip_radius, floa } #else append_vertex(entity, { 0.0f, 0.0f, total_height }, Vec3f::UnitZ()); - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f }); } // tip triangles - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { const int v3 = (i < resolution - 1) ? i + 2 : 1; append_indices(entity, 0, i + 1, v3); } // tip cap outer perimeter vertices - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, -Vec3f::UnitZ()); } // tip cap inner perimeter vertices - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, -Vec3f::UnitZ()); } // tip cap triangles - for (int i = 0; i < resolution; ++i) { - const int v2 = (i < resolution - 1) ? i + resolution + 2 : resolution + 1; - const int v3 = (i < resolution - 1) ? i + 2 * resolution + 2 : 2 * resolution + 1; + for (unsigned int i = 0; i < resolution; ++i) { + const unsigned int v2 = (i < resolution - 1) ? i + resolution + 2 : resolution + 1; + const unsigned int v3 = (i < resolution - 1) ? i + 2 * resolution + 2 : 2 * resolution + 1; append_indices(entity, i + resolution + 1, v3, v2); append_indices(entity, i + resolution + 1, i + 2 * resolution + 1, v3); } // stem bottom vertices - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f }); } // stem top vertices - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, { sines[i], cosines[i], 0.0f }); } // stem triangles - for (int i = 0; i < resolution; ++i) { - const int v2 = (i < resolution - 1) ? i + 3 * resolution + 2 : 3 * resolution + 1; - const int v3 = (i < resolution - 1) ? i + 4 * resolution + 2 : 4 * resolution + 1; + for (unsigned int i = 0; i < resolution; ++i) { + const int unsigned v2 = (i < resolution - 1) ? i + 3 * resolution + 2 : 3 * resolution + 1; + const int unsigned v3 = (i < resolution - 1) ? i + 4 * resolution + 2 : 4 * resolution + 1; append_indices(entity, i + 3 * resolution + 1, v3, v2); append_indices(entity, i + 3 * resolution + 1, i + 4 * resolution + 1, v3); } // stem cap vertices append_vertex(entity, Vec3f::Zero(), -Vec3f::UnitZ()); - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, -Vec3f::UnitZ()); } // stem cap triangles - for (int i = 0; i < resolution; ++i) { - const int v3 = (i < resolution - 1) ? i + 5 * resolution + 3 : 5 * resolution + 2; + for (unsigned int i = 0; i < resolution; ++i) { + const unsigned int v3 = (i < resolution - 1) ? i + 5 * resolution + 3 : 5 * resolution + 2; append_indices(entity, 5 * resolution + 1, v3, i + 5 * resolution + 2); } @@ -1768,57 +1742,57 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti // stem // top face vertices - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; append_vertex(entity, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ()); } - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; append_vertex(entity, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ()); } // top face triangles - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_indices(entity, 26 + i, 27 + i, 27 + resolution + i); append_indices(entity, 27 + i, 28 + resolution + i, 27 + resolution + i); } // bottom face vertices - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; append_vertex(entity, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ()); } - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; append_vertex(entity, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ()); } // bottom face triangles - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { append_indices(entity, 28 + 2 * resolution + i, 29 + 3 * resolution + i, 29 + 2 * resolution + i); append_indices(entity, 29 + 2 * resolution + i, 29 + 3 * resolution + i, 30 + 3 * resolution + i); } // side faces vertices and triangles - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; const float c = ::cos(angle); const float s = ::sin(angle); append_vertex(entity, { inner_radius * s, inner_radius * c, -half_thickness }, { -s, -c, 0.0f }); } - for (int i = 0; i <= resolution; ++i) { + for (unsigned int i = 0; i <= resolution; ++i) { const float angle = static_cast(i) * step_angle; const float c = ::cos(angle); const float s = ::sin(angle); append_vertex(entity, { inner_radius * s, inner_radius * c, half_thickness }, { -s, -c, 0.0f }); } - int first_id = 26 + 4 * (resolution + 1); - for (int i = 0; i < resolution; ++i) { - const int ii = first_id + i; + unsigned int first_id = 26 + 4 * (resolution + 1); + for (unsigned int i = 0; i < resolution; ++i) { + const unsigned int ii = first_id + i; append_indices(entity, ii, ii + 1, ii + resolution + 2); append_indices(entity, ii, ii + resolution + 2, ii + resolution + 1); } @@ -1832,14 +1806,14 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti append_indices(entity, first_id, first_id + 1, first_id + 3); append_indices(entity, first_id, first_id + 3, first_id + 2); - for (int i = resolution; i >= 0; --i) { + for (int i = int(resolution); i >= 0; --i) { const float angle = static_cast(i) * step_angle; const float c = ::cos(angle); const float s = ::sin(angle); append_vertex(entity, { outer_radius * s, outer_radius * c, -half_thickness }, { s, c, 0.0f }); } - for (int i = resolution; i >= 0; --i) { + for (int i = int(resolution); i >= 0; --i) { const float angle = static_cast(i) * step_angle; const float c = ::cos(angle); const float s = ::sin(angle); @@ -1847,8 +1821,8 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti } first_id = 30 + 6 * (resolution + 1); - for (int i = 0; i < resolution; ++i) { - const int ii = first_id + i; + for (unsigned int i = 0; i < resolution; ++i) { + const unsigned int ii = first_id + i; append_indices(entity, ii, ii + 1, ii + resolution + 2); append_indices(entity, ii, ii + resolution + 2, ii + resolution + 1); } @@ -2095,8 +2069,8 @@ GLModel::Geometry diamond(unsigned int resolution) data.add_triangle(resolution - 1, resolution + 1, 0); #else // positions - for (int i = 0; i < resolution; ++i) { - float ii = float(i) * step; + for (unsigned int i = 0; i < resolution; ++i) { + const float ii = float(i) * step; entity.positions.emplace_back(0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f); } entity.positions.emplace_back(0.0f, 0.0f, 0.5f); @@ -2109,7 +2083,7 @@ GLModel::Geometry diamond(unsigned int resolution) // triangles // top - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { entity.indices.push_back(i + 0); entity.indices.push_back(i + 1); entity.indices.push_back(resolution); @@ -2119,7 +2093,7 @@ GLModel::Geometry diamond(unsigned int resolution) entity.indices.push_back(resolution); // bottom - for (int i = 0; i < resolution; ++i) { + for (unsigned int i = 0; i < resolution; ++i) { entity.indices.push_back(i + 0); entity.indices.push_back(resolution + 1); entity.indices.push_back(i + 1); diff --git a/src/slic3r/GUI/GLSelectionRectangle.cpp b/src/slic3r/GUI/GLSelectionRectangle.cpp index 6daed2a146..177af97be6 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.cpp +++ b/src/slic3r/GUI/GLSelectionRectangle.cpp @@ -75,7 +75,7 @@ namespace GUI { return; const Size cnv_size = canvas.get_canvas_size(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const float cnv_width = (float)cnv_size.get_width(); const float cnv_height = (float)cnv_size.get_height(); if (cnv_width == 0.0f || cnv_height == 0.0f) @@ -103,7 +103,7 @@ namespace GUI { const float top = (float)std::max(start.y(), end.y()) * inv_zoom; const float right = (float)std::max(start.x(), end.x()) * inv_zoom; const float bottom = (float)std::min(start.y(), end.y()) * inv_zoom; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth(1.5f)); @@ -118,7 +118,7 @@ namespace GUI { glsafe(::glDisable(GL_DEPTH_TEST)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glLoadIdentity()); // ensure that the rectangle is renderered inside the frustrum @@ -126,7 +126,7 @@ namespace GUI { // ensure that the overlay fits the frustrum near z plane const double gui_scale = camera.get_gui_scale(); glsafe(::glScaled(gui_scale, gui_scale, 1.0)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glPushAttrib(GL_ENABLE_BIT)); @@ -202,7 +202,6 @@ namespace GUI { m_rectangle.init_from(std::move(init_data)); } -#if ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity()); #if ENABLE_GL_CORE_PROFILE @@ -212,7 +211,6 @@ namespace GUI { shader->set_uniform("dash_size", 0.01f); shader->set_uniform("gap_size", 0.0075f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f)); m_rectangle.render(); @@ -231,9 +229,9 @@ namespace GUI { glsafe(::glPopAttrib()); #endif // !ENABLE_GL_CORE_PROFILE -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } } // namespace GUI diff --git a/src/slic3r/GUI/GLShader.cpp b/src/slic3r/GUI/GLShader.cpp index 22d6d7aadc..d726386cab 100644 --- a/src/slic3r/GUI/GLShader.cpp +++ b/src/slic3r/GUI/GLShader.cpp @@ -295,12 +295,12 @@ void GLShaderProgram::set_uniform(int id, const Matrix3f& value) const glsafe(::glUniformMatrix3fv(id, 1, GL_FALSE, static_cast(value.data()))); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLShaderProgram::set_uniform(int id, const Matrix3d& value) const { set_uniform(id, (Matrix3f)value.cast()); } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_GL_IMGUI_SHADERS void GLShaderProgram::set_uniform(int id, const Matrix4f& value) const diff --git a/src/slic3r/GUI/GLShader.hpp b/src/slic3r/GUI/GLShader.hpp index 8714d3f5b2..60370eebcb 100644 --- a/src/slic3r/GUI/GLShader.hpp +++ b/src/slic3r/GUI/GLShader.hpp @@ -61,9 +61,9 @@ public: void set_uniform(const char* name, const Transform3f& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Transform3d& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Matrix3f& value) const { set_uniform(get_uniform_location(name), value); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void set_uniform(const char* name, const Matrix3d& value) const { set_uniform(get_uniform_location(name), value); } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_GL_IMGUI_SHADERS void set_uniform(const char* name, const Matrix4f& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Matrix4d& value) const { set_uniform(get_uniform_location(name), value); } @@ -91,9 +91,9 @@ public: void set_uniform(int id, const Transform3f& value) const; void set_uniform(int id, const Transform3d& value) const; void set_uniform(int id, const Matrix3f& value) const; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void set_uniform(int id, const Matrix3d& value) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_GL_IMGUI_SHADERS void set_uniform(int id, const Matrix4f& value) const; void set_uniform(int id, const Matrix4d& value) const; diff --git a/src/slic3r/GUI/GLShadersManager.cpp b/src/slic3r/GUI/GLShadersManager.cpp index 2ac57fea46..80aa400cf3 100644 --- a/src/slic3r/GUI/GLShadersManager.cpp +++ b/src/slic3r/GUI/GLShadersManager.cpp @@ -34,7 +34,6 @@ std::pair GLShadersManager::init() bool valid = true; #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/"; // imgui shader valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" }); @@ -48,24 +47,16 @@ std::pair GLShadersManager::init() // used to render thick and/or dashed lines valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" }); #endif // ENABLE_GL_CORE_PROFILE -#else - // basic shader, used to render all what was previously rendered using the immediate mode - valid &= append_shader("flat", { "flat.vs", "flat.fs" }); - // basic shader for textures, used to render textures - valid &= append_shader("flat_texture", { "flat_texture.vs", "flat_texture.fs" }); - // used to render 3D scene background - valid &= append_shader("background", { "background.vs", "background.fs" }); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES #endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_SHOW_TOOLPATHS_COG // used to render toolpaths center of gravity -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL valid &= append_shader("toolpaths_cog", { prefix + "toolpaths_cog.vs", prefix + "toolpaths_cog.fs" }); #else valid &= append_shader("toolpaths_cog", { "toolpaths_cog.vs", "toolpaths_cog.fs" }); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_SHOW_TOOLPATHS_COG -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL // used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview valid &= append_shader("gouraud_light", { prefix + "gouraud_light.vs", prefix + "gouraud_light.fs" }); // used to render printbed @@ -75,16 +66,16 @@ std::pair GLShadersManager::init() valid &= append_shader("gouraud_light", { "gouraud_light.vs", "gouraud_light.fs" }); // used to render printbed valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" }); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // used to render options in gcode preview if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL valid &= append_shader("gouraud_light_instanced", { prefix + "gouraud_light_instanced.vs", prefix + "gouraud_light_instanced.fs" }); #else valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" }); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL // used to render objects in 3d editor valid &= append_shader("gouraud", { prefix + "gouraud.vs", prefix + "gouraud.fs" } #else @@ -92,12 +83,12 @@ std::pair GLShadersManager::init() valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" }); // used to render objects in 3d editor valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_ENVIRONMENT_MAP , { "ENABLE_ENVIRONMENT_MAP"sv } #endif // ENABLE_ENVIRONMENT_MAP ); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL // used to render variable layers heights in 3d editor valid &= append_shader("variable_layer_height", { prefix + "variable_layer_height.vs", prefix + "variable_layer_height.fs" }); // used to render highlight contour around selected triangles inside the multi-material gizmo @@ -107,14 +98,14 @@ std::pair GLShadersManager::init() valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" }); // used to render highlight contour around selected triangles inside the multi-material gizmo valid &= append_shader("mm_contour", { "mm_contour.vs", "mm_contour.fs" }); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader. // For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction. // Because of this, objects had darker colors inside the multi-material gizmo. // Based on https://stackoverflow.com/a/66206648, the similar behavior was also spotted on some other devices with Arm CPU. // Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed // triangle normals inside fragment shader have the right direction. -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12) valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv }); else @@ -124,7 +115,7 @@ std::pair GLShadersManager::init() valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}, {"FLIP_TRIANGLE_NORMALS"sv}); else valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL return { valid, error }; } diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index a562b65b1f..4619be2210 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -363,10 +363,10 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right, GLShaderProgram* shader = wxGetApp().get_shader("flat_texture"); if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL model.render(); shader->stop_using(); } diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 78fbc084ff..9d7f621ba6 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -85,11 +85,11 @@ bool GLToolbarItem::update_enabled_state() return ret; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLToolbarItem::render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const #else void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs { assert(tex_width != 0 && tex_height != 0); @@ -118,7 +118,7 @@ void GLToolbarItem::render(unsigned int tex_id, float left, float right, float b GLTexture::render_sub_texture(tex_id, left, right, bottom, top, uvs(tex_width, tex_height, icon_size)); if (is_pressed()) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Size cnv_size = parent.get_canvas_size(); const float cnv_w = (float)cnv_size.get_width(); const float cnv_h = (float)cnv_size.get_height(); @@ -136,7 +136,7 @@ void GLToolbarItem::render(unsigned int tex_id, float left, float right, float b m_data.left.render_callback(left, right, bottom, top); else if (m_last_action_type == Right && m_data.right.can_render()) m_data.right.render_callback(left, right, bottom, top); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } } @@ -202,7 +202,7 @@ bool GLToolbar::init(const BackgroundTexture::Metadata& background_texture) return res; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL bool GLToolbar::init_arrow(const std::string& filename) { if (m_arrow_texture.get_id() != 0) @@ -228,7 +228,7 @@ bool GLToolbar::init_arrow(const BackgroundTexture::Metadata& arrow_texture) return res; } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL GLToolbar::Layout::EType GLToolbar::get_layout_type() const { @@ -693,7 +693,7 @@ void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) } } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) { const Size cnv_size = parent.get_canvas_size(); @@ -1108,7 +1108,7 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& } } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL GLToolbarItem* GLToolbar::get_item(const std::string& item_name) { @@ -1135,7 +1135,7 @@ int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) } } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const { const Size cnv_size = parent.get_canvas_size(); @@ -1428,9 +1428,9 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& return -1; } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLToolbar::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const { const unsigned int tex_id = m_background_texture.texture.get_id(); @@ -1584,9 +1584,9 @@ void GLToolbar::render_background(float left, float top, float right, float bott GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } }); } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item) { // arrow texture not initialized @@ -1721,9 +1721,9 @@ void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighte GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } }); } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLToolbar::render_horizontal(const GLCanvas3D& parent) { const Size cnv_size = parent.get_canvas_size(); @@ -1927,7 +1927,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) } } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL bool GLToolbar::generate_icons_texture() { diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index bd3204d632..1a836164c4 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -153,11 +153,11 @@ public: // returns true if the state changes bool update_enabled_state(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const; #else void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL private: void set_visible(bool visible) { m_data.visible = visible; } @@ -251,11 +251,11 @@ private: GLTexture m_icons_texture; bool m_icons_texture_dirty; BackgroundTexture m_background_texture; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLTexture m_arrow_texture; #else BackgroundTexture m_arrow_texture; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL Layout m_layout; ItemsList m_items; @@ -282,11 +282,11 @@ public: bool init(const BackgroundTexture::Metadata& background_texture); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL bool init_arrow(const std::string& filename); #else bool init_arrow(const BackgroundTexture::Metadata& arrow_texture); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL Layout::EType get_layout_type() const; void set_layout_type(Layout::EType type); @@ -357,11 +357,11 @@ private: int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const; #else void render_background(float left, float top, float right, float bottom, float border) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void render_horizontal(const GLCanvas3D& parent); void render_vertical(const GLCanvas3D& parent); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index aacecb6efe..ca2504fbfe 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -5,9 +5,9 @@ #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_ObjectManipulation.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/Plater.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // TODO: Display tooltips quicker on Linux @@ -35,11 +35,11 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = wxGetApp().get_current_shader(); if (shader == nullptr) return; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (!m_cube.is_initialized()) { // This cannot be done in constructor, OpenGL is not yet @@ -57,11 +57,6 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo #if ENABLE_LEGACY_OPENGL_REMOVAL m_cube.set_color(render_color); -#else - m_cube.set_color(-1, render_color); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL - -#if ENABLE_GL_SHADERS_ATTRIBUTES const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d view_model_matrix = camera.get_view_matrix() * matrix * Geometry::assemble_transform(center, angles, fullsize * Vec3d::Ones()); const Transform3d& projection_matrix = camera.get_projection_matrix(); @@ -70,17 +65,18 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo shader->set_uniform("projection_matrix", projection_matrix); shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); #else + m_cube.set_color(-1, render_color); 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cube.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 1453204620..23e542a728 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -49,9 +49,9 @@ protected: bool dragging{ false }; Vec3d center{ Vec3d::Zero() }; Vec3d angles{ Vec3d::Zero() }; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL Transform3d matrix{ Transform3d::Identity() }; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL ColorRGBA color{ ColorRGBA::WHITE() }; Grabber() = default; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index c70bcf89e3..d721e8a41f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -149,11 +149,9 @@ void GLGizmoCut::on_render() m_plane.init_from(std::move(init_data)); } -#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_GL_SHADERS_ATTRIBUTES m_plane.render(); #else @@ -251,25 +249,23 @@ void GLGizmoCut::on_render() shader = wxGetApp().get_shader("flat"); if (shader != nullptr) { shader->start_using(); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES + const Camera& camera = wxGetApp().plater()->get_camera(); shader->set_uniform("view_model_matrix", camera.get_view_matrix()* Geometry::assemble_transform(m_cut_contours.shift)); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); #else - glsafe(::glPushMatrix()); - glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES + glsafe(::glPushMatrix()); + glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z())); +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth(2.0f)); #endif // !ENABLE_GL_CORE_PROFILE m_cut_contours.contours.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); } +#else + glsafe(::glPopMatrix()); #endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // !ENABLE_GL_CORE_PROFILE } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp index aa291f6231..026fa11eab 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp @@ -3,10 +3,8 @@ #include "slic3r/GUI/GLCanvas3D.hpp" #if ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/GUI_App.hpp" -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES #include "slic3r/GUI/Plater.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" @@ -119,7 +117,7 @@ void GLGizmoFlatten::on_render() if (selection.is_single_full_instance()) { const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m; @@ -130,7 +128,7 @@ void GLGizmoFlatten::on_render() glsafe(::glPushMatrix()); glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z())); glsafe(::glMultMatrixd(m.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (this->is_plane_update_necessary()) update_planes(); for (int i = 0; i < (int)m_planes.size(); ++i) { @@ -143,9 +141,9 @@ void GLGizmoFlatten::on_render() m_planes[i].vbo.render(); #endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } glsafe(::glEnable(GL_CULL_FACE)); @@ -173,7 +171,7 @@ void GLGizmoFlatten::on_render_for_picking() if (selection.is_single_full_instance() && !wxGetKeyState(WXK_CONTROL)) { const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m; @@ -184,7 +182,7 @@ void GLGizmoFlatten::on_render_for_picking() glsafe(::glPushMatrix()); glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z())); glsafe(::glMultMatrixd(m.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (this->is_plane_update_necessary()) update_planes(); for (int i = 0; i < (int)m_planes.size(); ++i) { @@ -195,9 +193,9 @@ void GLGizmoFlatten::on_render_for_picking() #endif // ENABLE_LEGACY_OPENGL_REMOVAL m_planes[i].vbo.render(); } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } glsafe(::glEnable(GL_CULL_FACE)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 88b319f252..3eace848a7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -120,7 +120,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); Geometry::Transformation trafo = vol->get_instance_transformation() * vol->get_volume_transformation(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse(); const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * trafo.get_matrix(); @@ -136,7 +136,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) glsafe(::glPushMatrix()); glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift())); glsafe(::glMultMatrixd(instance_matrix.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL ColorRGBA render_color; const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes; @@ -166,27 +166,24 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) #if ENABLE_LEGACY_OPENGL_REMOVAL m_cylinder.set_color(render_color); -#else - const_cast(&m_cylinder)->set_color(-1, render_color); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL - // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. -#if ENABLE_GL_SHADERS_ATTRIBUTES const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast()) * instance_scaling_matrix_inverse; #else + const_cast(&m_cylinder)->set_color(-1, render_color); + // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. glsafe(::glPushMatrix()); glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (vol->is_left_handed()) - glFrontFace(GL_CW); + glsafe(::glFrontFace(GL_CW)); // Matrices set, we can render the point mark now. Eigen::Quaterniond q; q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast()); const Eigen::AngleAxisd aa(q); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) * Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); @@ -196,20 +193,20 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z())); glsafe(::glTranslated(0., 0., -drain_hole.height)); glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cylinder.render(); if (vol->is_left_handed()) - glFrontFace(GL_CCW); + glsafe(::glFrontFace(GL_CCW)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL + glsafe(::glPopMatrix()); +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL + glsafe(::glPopMatrix()); +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } bool GLGizmoHollow::is_mesh_point_clipped(const Vec3d& point) const diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 308100d7fe..03fc242661 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -192,7 +192,7 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const if (is_left_handed) glsafe(::glFrontFace(GL_CW)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d matrix = camera.get_view_matrix() * trafo_matrix; shader->set_uniform("view_model_matrix", matrix); @@ -201,19 +201,17 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const #else glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(trafo_matrix.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->set_uniform("volume_world_matrix", trafo_matrix); shader->set_uniform("volume_mirrored", is_left_handed); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix); #else m_triangle_selectors[mesh_id]->render(m_imgui); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES - -#if !ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL + if (is_left_handed) glsafe(::glFrontFace(GL_CCW)); } @@ -582,11 +580,11 @@ ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const return color; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void TriangleSelectorMmGui::render(ImGuiWrapper* imgui, const Transform3d& matrix) #else void TriangleSelectorMmGui::render(ImGuiWrapper *imgui) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { if (m_update_render_data) update_render_data(); @@ -595,13 +593,13 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui) if (!shader) return; assert(shader->get_name() == "mm_gouraud"); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d view_model_matrix = camera.get_view_matrix() * matrix; 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()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL for (size_t color_idx = 0; color_idx < m_gizmo_scene.triangle_indices.size(); ++color_idx) { if (m_gizmo_scene.has_VBOs(color_idx)) { @@ -615,11 +613,7 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui) } #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES render_paint_contour(matrix); -#else - render_paint_contour(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES #else if (m_paint_contour.has_VBO()) { ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); }); @@ -724,14 +718,14 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const assert(this->vertices_VBO_id != 0); assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLShaderProgram* shader = wxGetApp().get_current_shader(); if (shader == nullptr) return; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const GLint position_id = shader->get_attrib_location("v_position"); if (position_id != -1) { glsafe(::glVertexAttribPointer(position_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (GLvoid*)0)); @@ -747,18 +741,18 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const // Render using the Vertex Buffer Objects. if (this->triangle_indices_sizes[triangle_indices_idx] > 0) { -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->triangle_indices_VBO_ids[triangle_indices_idx])); glsafe(::glDrawElements(GL_TRIANGLES, GLsizei(this->triangle_indices_sizes[triangle_indices_idx]), GL_UNSIGNED_INT, nullptr)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (position_id != -1) glsafe(::glDisableVertexAttribArray(position_id)); #else glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index 5d23973379..2ed03e85f0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -66,13 +66,13 @@ public: : TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {} ~TriangleSelectorMmGui() override = default; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render(ImGuiWrapper* imgui, const Transform3d& matrix) override; #else // Render current selection. Transformation matrices are supposed // to be already set. void render(ImGuiWrapper* imgui) override; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL private: void update_render_data(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp index a4978ddbb6..75e6cf9def 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.cpp @@ -2,9 +2,9 @@ #include "GLGizmoMove.hpp" #include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GUI_App.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/Plater.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #include @@ -163,9 +163,6 @@ void GLGizmoMove3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL - -#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()); @@ -175,7 +172,7 @@ void GLGizmoMove3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // draw axes for (unsigned int i = 0; i < 3; ++i) { @@ -215,7 +212,6 @@ void GLGizmoMove3D::on_render() if (shader != nullptr) { shader->start_using(); -#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()); @@ -225,7 +221,6 @@ void GLGizmoMove3D::on_render() shader->set_uniform("width", 0.5f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES render_grabber_connection(m_hover_id); shader->stop_using(); @@ -307,15 +302,6 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box m_cone.set_color((!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color); shader->start_using(); shader->set_uniform("emission_factor", 0.1f); -#else - m_cone.set_color(-1, (!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color); - if (!picking) { - shader->start_using(); - shader->set_uniform("emission_factor", 0.1f); - } -#endif // ENABLE_LEGACY_OPENGL_REMOVAL - -#if ENABLE_GL_SHADERS_ATTRIBUTES const Camera& camera = wxGetApp().plater()->get_camera(); Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(m_grabbers[axis].center); if (axis == X) @@ -328,6 +314,12 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box 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 + m_cone.set_color(-1, (!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color); + if (!picking) { + shader->start_using(); + shader->set_uniform("emission_factor", 0.1f); + } + glsafe(::glPushMatrix()); glsafe(::glTranslated(m_grabbers[axis].center.x(), m_grabbers[axis].center.y(), m_grabbers[axis].center.z())); if (axis == X) @@ -337,13 +329,12 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL + m_cone.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if !ENABLE_LEGACY_OPENGL_REMOVAL + glsafe(::glPopMatrix()); if (! picking) #endif // !ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index e448c323f9..d71495a34f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -105,7 +105,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const if (is_left_handed) glsafe(::glFrontFace(GL_CW)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d matrix = camera.get_view_matrix() * trafo_matrix; shader->set_uniform("view_model_matrix", matrix); @@ -114,7 +114,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const #else glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(trafo_matrix.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // For printers with multiple extruders, it is necessary to pass trafo_matrix // to the shader input variable print_box.volume_world_matrix before @@ -122,13 +122,13 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const // wrong transformation matrix is used for "Clipping of view". shader->set_uniform("volume_world_matrix", trafo_matrix); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix); #else m_triangle_selectors[mesh_id]->render(m_imgui); glsafe(::glPopMatrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (is_left_handed) glsafe(::glFrontFace(GL_CCW)); } @@ -163,14 +163,14 @@ void GLGizmoPainterBase::render_cursor() void GLGizmoPainterBase::render_cursor_circle() { -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL const Camera &camera = wxGetApp().plater()->get_camera(); const float zoom = float(camera.get_zoom()); const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL const Size cnv_size = m_parent.get_canvas_size(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const float cnv_width = float(cnv_size.get_width()); const float cnv_height = float(cnv_size.get_height()); if (cnv_width == 0.0f || cnv_height == 0.0f) @@ -189,7 +189,7 @@ void GLGizmoPainterBase::render_cursor_circle() const Vec2d mouse_pos(m_parent.get_local_mouse_position().x(), m_parent.get_local_mouse_position().y()); Vec2d center(mouse_pos.x() - cnv_half_width, cnv_half_height - mouse_pos.y()); center = center * inv_zoom; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth(1.5f)); @@ -200,7 +200,7 @@ void GLGizmoPainterBase::render_cursor_circle() #endif // !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glDisable(GL_DEPTH_TEST)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glLoadIdentity()); // ensure that the circle is renderered inside the frustrum @@ -208,7 +208,7 @@ void GLGizmoPainterBase::render_cursor_circle() // ensure that the overlay fits the frustrum near z plane const double gui_scale = camera.get_gui_scale(); glsafe(::glScaled(gui_scale, gui_scale, 1.0)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glPushAttrib(GL_ENABLE_BIT)); @@ -217,13 +217,8 @@ void GLGizmoPainterBase::render_cursor_circle() #endif // !ENABLE_GL_CORE_PROFILE #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) { m_old_cursor_radius = radius; -#else - if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - m_cursor_radius) > EPSILON) { - m_old_cursor_radius = m_cursor_radius; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES m_old_center = center; m_circle.reset(); @@ -250,10 +245,6 @@ void GLGizmoPainterBase::render_cursor_circle() #endif // ENABLE_GL_CORE_PROFILE for (unsigned int i = 0; i < StepsCount; ++i) { -#if !ENABLE_GL_CORE_PROFILE - const float angle = float(i) * StepSize; -#endif // !ENABLE_GL_CORE_PROFILE -#if ENABLE_GL_SHADERS_ATTRIBUTES #if ENABLE_GL_CORE_PROFILE const float angle_i = float(i) * StepSize; const unsigned int j = (i + 1) % StepsCount; @@ -263,16 +254,11 @@ void GLGizmoPainterBase::render_cursor_circle() init_data.add_vertex(Vec4f(v_i.x(), v_i.y(), 0.0f, perimeter)); perimeter += (v_j - v_i).norm(); init_data.add_vertex(Vec4f(v_j.x(), v_j.y(), 0.0f, perimeter)); -#else - init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f), - -2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f))); -#endif // ENABLE_GL_CORE_PROFILE -#else - init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES -#if ENABLE_GL_CORE_PROFILE init_data.add_line(i * 2 + 0, i * 2 + 1); #else + const float angle = float(i) * StepSize; + init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f), + -2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f))); init_data.add_index(i); #endif // ENABLE_GL_CORE_PROFILE } @@ -287,7 +273,6 @@ void GLGizmoPainterBase::render_cursor_circle() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES shader->set_uniform("view_model_matrix", Transform3d::Identity()); shader->set_uniform("projection_matrix", Transform3d::Identity()); #if ENABLE_GL_CORE_PROFILE @@ -297,7 +282,6 @@ void GLGizmoPainterBase::render_cursor_circle() shader->set_uniform("dash_size", 0.01f); shader->set_uniform("gap_size", 0.0075f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES m_circle.render(); shader->stop_using(); } @@ -311,9 +295,9 @@ void GLGizmoPainterBase::render_cursor_circle() #if !ENABLE_GL_CORE_PROFILE glsafe(::glPopAttrib()); #endif // !ENABLE_GL_CORE_PROFILE -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glEnable(GL_DEPTH_TEST)); } @@ -338,17 +322,17 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse(); const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(trafo.data())); // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. glsafe(::glTranslatef(m_rr.hit.x(), m_rr.hit.y(), m_rr.hit.z())); glsafe(::glMultMatrixd(complete_scaling_matrix_inverse.data())); glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL if (is_left_handed) - glFrontFace(GL_CW); + glsafe(::glFrontFace(GL_CW)); ColorRGBA render_color = { 0.0f, 0.0f, 0.0f, 0.25f }; if (m_button_down == Button::Left) @@ -358,7 +342,6 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const #if ENABLE_LEGACY_OPENGL_REMOVAL shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES const Camera& camera = wxGetApp().plater()->get_camera(); Transform3d view_model_matrix = camera.get_view_matrix() * trafo * Geometry::assemble_transform(m_rr.hit.cast()) * complete_scaling_matrix_inverse * @@ -366,7 +349,6 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES assert(s_sphere != nullptr); s_sphere->set_color(render_color); @@ -382,11 +364,11 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const #endif // ENABLE_LEGACY_OPENGL_REMOVAL if (is_left_handed) - glFrontFace(GL_CCW); + glsafe(::glFrontFace(GL_CCW)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } @@ -945,11 +927,11 @@ ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color) return saturate(base_color, 0.75f); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void TriangleSelectorGUI::render(ImGuiWrapper* imgui, const Transform3d& matrix) #else void TriangleSelectorGUI::render(ImGuiWrapper* imgui) -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { static const ColorRGBA enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f }; static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 1.0f }; @@ -1002,11 +984,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui) #endif // ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES render_paint_contour(matrix); -#else - render_paint_contour(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES #else if (m_paint_contour.has_VBO()) { ScopeGuard guard_gouraud([shader]() { shader->start_using(); }); @@ -1325,11 +1303,9 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui) if (shader != nullptr) { shader->start_using(); -#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_GL_SHADERS_ATTRIBUTES #endif // ENABLE_LEGACY_OPENGL_REMOVAL ::glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); @@ -1377,10 +1353,8 @@ void TriangleSelectorGUI::update_paint_contour() init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 }; init_data.reserve_vertices(2 * contour_edges.size()); init_data.reserve_indices(2 * contour_edges.size()); -#if ENABLE_GL_SHADERS_ATTRIBUTES init_data.color = ColorRGBA::WHITE(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES -// + // vertices + indices unsigned int vertices_count = 0; for (const Vec2i& edge : contour_edges) { @@ -1394,11 +1368,7 @@ void TriangleSelectorGUI::update_paint_contour() m_paint_contour.init_from(std::move(init_data)); } -#if ENABLE_GL_SHADERS_ATTRIBUTES void TriangleSelectorGUI::render_paint_contour(const Transform3d& matrix) -#else -void TriangleSelectorGUI::render_paint_contour() -#endif // ENABLE_GL_SHADERS_ATTRIBUTES { auto* curr_shader = wxGetApp().get_current_shader(); if (curr_shader != nullptr) @@ -1408,11 +1378,9 @@ void TriangleSelectorGUI::render_paint_contour() if (contour_shader != nullptr) { contour_shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES const Camera& camera = wxGetApp().plater()->get_camera(); contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix); contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glDepthFunc(GL_LEQUAL)); m_paint_contour.render(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index 64f5317937..1c57339670 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -77,7 +77,7 @@ public: : TriangleSelector(mesh) {} virtual ~TriangleSelectorGUI() = default; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL virtual void render(ImGuiWrapper* imgui, const Transform3d& matrix); void render(const Transform3d& matrix) { this->render(nullptr, matrix); } #else @@ -85,7 +85,7 @@ public: // to be already set. virtual void render(ImGuiWrapper *imgui); void render() { this->render(nullptr); } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void request_update_render_data() { m_update_render_data = true; } @@ -119,14 +119,10 @@ private: protected: #if ENABLE_LEGACY_OPENGL_REMOVAL - GLModel m_paint_contour; + GLModel m_paint_contour; void update_paint_contour(); -#if ENABLE_GL_SHADERS_ATTRIBUTES void render_paint_contour(const Transform3d& matrix); -#else - void render_paint_contour(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES #else GLPaintContour m_paint_contour; #endif // ENABLE_LEGACY_OPENGL_REMOVAL diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 7e35ab3453..cb61f4c9dd 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -163,12 +163,12 @@ void GLGizmoRotate::on_render() glsafe(::glEnable(GL_DEPTH_TEST)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL m_grabbers.front().matrix = local_transform(selection); #else glsafe(::glPushMatrix()); transform_to_local(selection); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); @@ -182,7 +182,6 @@ void GLGizmoRotate::on_render() if (shader != nullptr) { shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix; shader->set_uniform("view_model_matrix", view_model_matrix); @@ -193,7 +192,6 @@ void GLGizmoRotate::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON; m_old_radius = m_radius; @@ -233,9 +231,9 @@ void GLGizmoRotate::on_render() render_grabber(box); render_grabber_extension(box, false); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } void GLGizmoRotate::on_render_for_picking() @@ -244,20 +242,20 @@ void GLGizmoRotate::on_render_for_picking() glsafe(::glDisable(GL_DEPTH_TEST)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL m_grabbers.front().matrix = local_transform(selection); #else glsafe(::glPushMatrix()); transform_to_local(selection); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL const BoundingBoxf3& box = selection.get_bounding_box(); render_grabbers_for_picking(box); render_grabber_extension(box, true); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit) @@ -606,7 +604,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick const Vec3d& center = m_grabbers.front().center; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d& view_matrix = camera.get_view_matrix(); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); @@ -624,9 +622,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cone.render(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL view_model_matrix = view_matrix * m_grabbers.front().matrix * Geometry::assemble_transform(center, Vec3d(-0.5 * PI, 0.0, m_angle)) * Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size)); @@ -641,19 +639,17 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0)); glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cone.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if !ENABLE_LEGACY_OPENGL_REMOVAL + glsafe(::glPopMatrix()); if (! picking) #endif // !ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL Transform3d GLGizmoRotate::local_transform(const Selection& selection) const { Transform3d ret; @@ -715,7 +711,7 @@ void GLGizmoRotate::transform_to_local(const Selection& selection) const } } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp index b58fde1eec..545fc9eb7f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp @@ -106,11 +106,11 @@ private: void render_grabber(const BoundingBoxf3& box); void render_grabber_extension(const BoundingBoxf3& box, bool picking); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL Transform3d local_transform(const Selection& selection) const; #else void transform_to_local(const Selection& selection) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL // returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 1c9384323d..6512a0ac52 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -2,9 +2,9 @@ #include "GLGizmoScale.hpp" #include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GUI_App.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/Plater.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #include @@ -274,7 +274,6 @@ void GLGizmoScale3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#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()); @@ -284,7 +283,6 @@ void GLGizmoScale3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES if (m_grabbers[0].enabled && m_grabbers[1].enabled) render_grabbers_connection(0, 1, m_grabbers[0].color); if (m_grabbers[2].enabled && m_grabbers[3].enabled) @@ -331,7 +329,6 @@ void GLGizmoScale3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#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()); @@ -341,7 +338,6 @@ void GLGizmoScale3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES render_grabbers_connection(0, 1, m_grabbers[0].color); shader->stop_using(); } @@ -374,7 +370,6 @@ void GLGizmoScale3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#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()); @@ -384,7 +379,6 @@ void GLGizmoScale3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES render_grabbers_connection(2, 3, m_grabbers[2].color); shader->stop_using(); } @@ -417,7 +411,6 @@ void GLGizmoScale3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#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()); @@ -427,7 +420,6 @@ void GLGizmoScale3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES render_grabbers_connection(4, 5, m_grabbers[4].color); shader->stop_using(); } @@ -460,7 +452,6 @@ void GLGizmoScale3D::on_render() #endif // ENABLE_GL_CORE_PROFILE if (shader != nullptr) { shader->start_using(); -#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()); @@ -470,7 +461,6 @@ void GLGizmoScale3D::on_render() shader->set_uniform("width", 0.25f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES render_grabbers_connection(6, 7, m_drag_color); render_grabbers_connection(7, 8, m_drag_color); render_grabbers_connection(8, 9, m_drag_color); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 08f6100938..3ad4d2d83c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -737,10 +737,10 @@ void GLGizmoSimplify::on_render() GLModel &glmodel = it->second; const Transform3d trafo_matrix = selected_volume->world_matrix(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPushMatrix()); glsafe(::glMultMatrixd(trafo_matrix.data())); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL auto* gouraud_shader = wxGetApp().get_shader("gouraud_light"); #if ENABLE_GL_CORE_PROFILE bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST); @@ -749,34 +749,34 @@ void GLGizmoSimplify::on_render() #endif // ENABLE_GL_CORE_PROFILE glsafe(::glEnable(GL_DEPTH_TEST)); gouraud_shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL glmodel.render(); gouraud_shader->stop_using(); if (m_show_wireframe) { auto *contour_shader = wxGetApp().get_shader("mm_contour"); contour_shader->start_using(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL contour_shader->set_uniform("view_model_matrix", view_model_matrix); contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); const ColorRGBA color = glmodel.get_color(); glmodel.set_color(ColorRGBA::WHITE()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_GL_CORE_PROFILE glsafe(::glLineWidth(1.0f)); #endif // !ENABLE_GL_CORE_PROFILE glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)); glmodel.render(); glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL glmodel.set_color(color); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL contour_shader->stop_using(); } #if ENABLE_GL_CORE_PROFILE @@ -785,9 +785,9 @@ void GLGizmoSimplify::on_render() #else glsafe(::glPopAttrib()); #endif // ENABLE_GL_CORE_PROFILE -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 7c61673b45..21ccea5a3c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -149,7 +149,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); Geometry::Transformation transformation(vol->get_instance_transformation().get_matrix() * vol->get_volume_transformation().get_matrix()); const Transform3d& instance_scaling_matrix_inverse = transformation.get_matrix(true, true, false, true).inverse(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * transformation.get_matrix(); const Camera& camera = wxGetApp().plater()->get_camera(); const Transform3d& view_matrix = camera.get_view_matrix(); @@ -162,7 +162,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) glsafe(::glPushMatrix()); glsafe(::glTranslated(0.0, 0.0, z_shift)); glsafe(::glMultMatrixd(instance_matrix.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL ColorRGBA render_color; for (size_t i = 0; i < cache_size; ++i) { @@ -206,16 +206,16 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) shader->set_uniform("emission_factor", 0.5f); // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d support_matrix = Geometry::assemble_transform(support_point.pos.cast()) * instance_scaling_matrix_inverse; #else glsafe(::glPushMatrix()); glsafe(::glTranslatef(support_point.pos.x(), support_point.pos.y(), support_point.pos.z())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (vol->is_left_handed()) - glFrontFace(GL_CW); + glsafe(::glFrontFace(GL_CW)); // Matrices set, we can render the point mark now. // If in editing mode, we'll also render a cone pointing to the sphere. @@ -229,7 +229,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const Eigen::AngleAxisd aa(q); const double cone_radius = 0.25; // mm const double cone_height = 0.75; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix * Transform3d(aa.toRotationMatrix()) * Geometry::assemble_transform((cone_height + support_point.head_front_radius * RenderPointScale) * Vec3d::UnitZ(), Vec3d(PI, 0.0, 0.0), Vec3d(cone_radius, cone_radius, cone_height)); @@ -242,15 +242,15 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) glsafe(::glTranslatef(0.f, 0.f, cone_height + support_point.head_front_radius * RenderPointScale)); glsafe(::glRotated(180., 1., 0., 0.)); glsafe(::glScaled(cone_radius, cone_radius, cone_height)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cone.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } const double radius = (double)support_point.head_front_radius * RenderPointScale; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix * Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), radius * Vec3d::Ones()); @@ -259,18 +259,18 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) #else glsafe(::glPushMatrix()); glsafe(::glScaled(radius, radius, radius)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_sphere.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL if (vol->is_left_handed()) - glFrontFace(GL_CCW); + glsafe(::glFrontFace(GL_CCW)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } // Now render the drain holes: @@ -287,23 +287,23 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) if (is_mesh_point_clipped(drain_hole.pos.cast())) continue; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast()) * instance_scaling_matrix_inverse; #else // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. glsafe(::glPushMatrix()); glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (vol->is_left_handed()) - glFrontFace(GL_CW); + glsafe(::glFrontFace(GL_CW)); // Matrices set, we can render the point mark now. Eigen::Quaterniond q; q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast()); const Eigen::AngleAxisd aa(q); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) * Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); @@ -313,20 +313,20 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z())); glsafe(::glTranslated(0., 0., -drain_hole.height)); glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_cylinder.render(); if (vol->is_left_handed()) - glFrontFace(GL_CCW); -#if !ENABLE_GL_SHADERS_ATTRIBUTES + glsafe(::glFrontFace(GL_CCW)); +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp b/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp index add0f320a7..35d0c3d39e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp @@ -213,10 +213,8 @@ void InstancesHider::render_cut() const else clipper->set_limiting_plane(ClippingPlane::ClipsNothing()); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if !ENABLE_LEGACY_OPENGL_REMOVAL + glsafe(::glPushMatrix()); if (mv->is_model_part()) glsafe(::glColor3f(0.8f, 0.3f, 0.0f)); else { @@ -241,9 +239,9 @@ void InstancesHider::render_cut() const #else glsafe(::glPopAttrib()); #endif // ENABLE_GL_CORE_PROFILE -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL ++clipper_id; } @@ -436,18 +434,14 @@ void ObjectClipper::render_cut() const clipper->set_plane(*m_clp); clipper->set_transformation(trafo); clipper->set_limiting_plane(ClippingPlane(Vec3d::UnitZ(), -SINKING_Z_THRESHOLD)); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if ENABLE_LEGACY_OPENGL_REMOVAL clipper->render_cut({ 1.0f, 0.37f, 0.0f, 1.0f }); #else + glsafe(::glPushMatrix()); glsafe(::glColor3f(1.0f, 0.37f, 0.0f)); clipper->render_cut(); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if !ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL ++clipper_id; } @@ -557,18 +551,14 @@ void SupportsClipper::render_cut() const m_clipper->set_plane(*ocl->get_clipping_plane()); m_clipper->set_transformation(supports_trafo); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPushMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES #if ENABLE_LEGACY_OPENGL_REMOVAL m_clipper->render_cut({ 1.0f, 0.f, 0.37f, 1.0f }); #else + glsafe(::glPushMatrix()); glsafe(::glColor3f(1.0f, 0.f, 0.37f)); m_clipper->render_cut(); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if !ENABLE_GL_SHADERS_ATTRIBUTES glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 21b55ea694..749ad5f038 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -124,7 +124,7 @@ bool GLGizmosManager::init() return true; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL bool GLGizmosManager::init_arrow(const std::string& filename) { if (m_arrow_texture.get_id() != 0) @@ -149,7 +149,7 @@ bool GLGizmosManager::init_arrow(const BackgroundTexture::Metadata & arrow_textu return res; } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void GLGizmosManager::set_overlay_icon_size(float size) { @@ -676,7 +676,7 @@ void GLGizmosManager::update_after_undo_redo(const UndoRedo::Snapshot& snapshot) dynamic_cast(m_gizmos[SlaSupports].get())->reslice_SLA_supports(true); } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLGizmosManager::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const { const unsigned int tex_id = m_background_texture.texture.get_id(); @@ -782,9 +782,9 @@ void GLGizmosManager::render_background(float left, float top, float right, floa GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } }); } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_type) const { const std::vector selectable_idxs = get_selectable_idxs(); @@ -870,9 +870,9 @@ void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_t zoomed_top_y -= zoomed_stride_y; } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void GLGizmosManager::do_render_overlay() const { const std::vector selectable_idxs = get_selectable_idxs(); @@ -1017,7 +1017,7 @@ void GLGizmosManager::do_render_overlay() const m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top); } } -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL float GLGizmosManager::get_scaled_total_height() const { diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index 187afd889f..9f66d7c680 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -105,11 +105,11 @@ private: GLTexture m_icons_texture; bool m_icons_texture_dirty; BackgroundTexture m_background_texture; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL GLTexture m_arrow_texture; #else BackgroundTexture m_arrow_texture; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL Layout m_layout; EType m_current; EType m_hover; @@ -137,11 +137,11 @@ public: bool init(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL bool init_arrow(const std::string& filename); #else bool init_arrow(const BackgroundTexture::Metadata& arrow_texture); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL template void load(Archive& ar) @@ -242,11 +242,11 @@ private: bool alt_down = false, bool control_down = false); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const; #else void render_background(float left, float top, float right, float bottom, float border) const; -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL void do_render_overlay() const; diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index ab38d25b66..41adbe0a1f 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -32,9 +32,7 @@ #include "I18N.hpp" #include "Search.hpp" #include "BitmapCache.hpp" -#if ENABLE_GL_IMGUI_SHADERS #include "GUI_App.hpp" -#endif // ENABLE_GL_IMGUI_SHADERS #include "../Utils/MacDarkMode.hpp" diff --git a/src/slic3r/GUI/MeshUtils.cpp b/src/slic3r/GUI/MeshUtils.cpp index bbdcdeb346..f9a437883c 100644 --- a/src/slic3r/GUI/MeshUtils.cpp +++ b/src/slic3r/GUI/MeshUtils.cpp @@ -8,11 +8,9 @@ #if ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/GUI_App.hpp" +#include "slic3r/GUI/Plater.hpp" #endif // ENABLE_LEGACY_OPENGL_REMOVAL #include "slic3r/GUI/Camera.hpp" -#if ENABLE_GL_SHADERS_ATTRIBUTES -#include "slic3r/GUI/Plater.hpp" -#endif // ENABLE_GL_SHADERS_ATTRIBUTES #include @@ -90,11 +88,9 @@ void MeshClipper::render_cut() GLShaderProgram* shader = wxGetApp().get_shader("flat"); if (shader != nullptr) { shader->start_using(); -#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_GL_SHADERS_ATTRIBUTES m_model.set_color(color); m_model.render(); shader->stop_using(); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 0e090a08cf..11cd20d14d 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -1286,30 +1286,25 @@ void Selection::render_center(bool gizmo_is_dragging) glsafe(::glDisable(GL_DEPTH_TEST)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Camera& camera = wxGetApp().plater()->get_camera(); Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(center); shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); + m_vbo_sphere.set_color(ColorRGBA::WHITE()); #else glsafe(::glPushMatrix()); glsafe(::glTranslated(center.x(), center.y(), center.z())); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES - -#if ENABLE_LEGACY_OPENGL_REMOVAL - m_vbo_sphere.set_color(ColorRGBA::WHITE()); -#else m_vbo_sphere.set_color(-1, ColorRGBA::WHITE()); #endif // ENABLE_LEGACY_OPENGL_REMOVAL - m_vbo_sphere.render(); -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glPopMatrix()); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES + m_vbo_sphere.render(); #if ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); +#else + glsafe(::glPopMatrix()); #endif // ENABLE_LEGACY_OPENGL_REMOVAL } #endif // ENABLE_RENDER_SELECTION_CENTER @@ -1340,27 +1335,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) glsafe(::glEnable(GL_DEPTH_TEST)); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL const Transform3d base_matrix = Geometry::assemble_transform(get_bounding_box().center()); Transform3d orient_matrix = Transform3d::Identity(); #else glsafe(::glPushMatrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (!boost::starts_with(sidebar_field, "layer")) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL shader->set_uniform("emission_factor", 0.05f); #else const Vec3d& center = get_bounding_box().center(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) { -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glTranslated(center.x(), center.y(), center.z())); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL if (!boost::starts_with(sidebar_field, "position")) { -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL Transform3d orient_matrix = Transform3d::Identity(); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL 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")) { @@ -1374,27 +1369,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ())); } } -#if !ENABLE_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glMultMatrixd(orient_matrix.data())); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } } else if (is_single_volume() || is_single_modifier()) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#if !ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glMultMatrixd(orient_matrix.data())); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES +#endif // !ENABLE_LEGACY_OPENGL_REMOVAL } else { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL if (requires_local_axes()) orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); #else @@ -1403,16 +1398,14 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } } #if ENABLE_LEGACY_OPENGL_REMOVAL if (!boost::starts_with(sidebar_field, "layer")) glsafe(::glClear(GL_DEPTH_BUFFER_BIT)); -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_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")) @@ -1432,11 +1425,9 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) render_sidebar_layers_hints(sidebar_field); glsafe(::glPopMatrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES -#if !ENABLE_LEGACY_OPENGL_REMOVAL if (!boost::starts_with(sidebar_field, "layer")) -#endif // !ENABLE_LEGACY_OPENGL_REMOVAL +#endif // ENABLE_LEGACY_OPENGL_REMOVAL shader->stop_using(); } @@ -2020,7 +2011,6 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con return; shader->start_using(); -#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()); @@ -2030,7 +2020,6 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con shader->set_uniform("width", 1.5f); shader->set_uniform("gap_size", 0.0f); #endif // ENABLE_GL_CORE_PROFILE -#endif // ENABLE_GL_SHADERS_ATTRIBUTES m_box.set_color(to_rgba(color)); m_box.render(); shader->stop_using(); @@ -2078,46 +2067,34 @@ static ColorRGBA get_color(Axis axis) return AXES_COLOR[axis]; } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES if (boost::ends_with(sidebar_field, "x")) { -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(X)); m_arrow.render(); } else if (boost::ends_with(sidebar_field, "y")) { -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(Y)); m_arrow.render(); } else if (boost::ends_with(sidebar_field, "z")) { -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES m_arrow.set_color(get_color(Z)); m_arrow.render(); } @@ -2139,14 +2116,13 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field) #endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { #if ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_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); @@ -2161,43 +2137,18 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) 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_GL_SHADERS_ATTRIBUTES if (boost::ends_with(sidebar_field, "x")) { -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glRotated(90.0, 0.0, 1.0, 0.0)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES m_curved_arrow.set_color(get_color(X)); -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES } else if (boost::ends_with(sidebar_field, "y")) { -#if !ENABLE_GL_SHADERS_ATTRIBUTES - glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0)); -#endif // !ENABLE_GL_SHADERS_ATTRIBUTES m_curved_arrow.set_color(get_color(Y)); -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES } else if (boost::ends_with(sidebar_field, "z")) { m_curved_arrow.set_color(get_color(Z)); -#if ENABLE_GL_SHADERS_ATTRIBUTES render_sidebar_rotation_hint(shader, view_matrix); -#else - render_sidebar_rotation_hint(); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES } #else auto render_sidebar_rotation_hint = [this]() { @@ -2223,93 +2174,86 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) #endif // ENABLE_LEGACY_OPENGL_REMOVAL } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { const bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling(); -#if ENABLE_GL_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_GL_SHADERS_ATTRIBUTES #if ENABLE_LEGACY_OPENGL_REMOVAL + auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) { 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_LEGACY_OPENGL_REMOVAL - -#if ENABLE_GL_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 + auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) { + m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis)); 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.render(); -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL m_arrow.render(); }; -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL if (boost::ends_with(sidebar_field, "x") || uniform_scale) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } if (boost::ends_with(sidebar_field, "y") || uniform_scale) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL render_sidebar_scale_hint(Y, shader, view_matrix); #else glsafe(::glPushMatrix()); render_sidebar_scale_hint(Y); glsafe(::glPopMatrix()); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } if (boost::ends_with(sidebar_field, "z") || uniform_scale) { -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL } } -#if ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_LEGACY_OPENGL_REMOVAL 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_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL { static const float Margin = 10.0f; @@ -2407,11 +2351,9 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) m_planes.models[1].init_from(std::move(init_data)); } -#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_GL_SHADERS_ATTRIBUTES m_planes.models[0].set_color((camera_on_top && type == 1) || (!camera_on_top && type == 2) ? SOLID_PLANE_COLOR : TRANSPARENT_PLANE_COLOR); m_planes.models[0].render(); diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index c9e55cf828..e77ca8715b 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -372,21 +372,18 @@ private: void render_synchronized_volumes(); #if ENABLE_LEGACY_OPENGL_REMOVAL void render_bounding_box(const BoundingBoxf3& box, const ColorRGB& color); -#else - void render_selected_volumes() const; - void render_bounding_box(const BoundingBoxf3& box, float* color) const; -#endif // ENABLE_LEGACY_OPENGL_REMOVAL -#if ENABLE_GL_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_selected_volumes() const; + void render_bounding_box(const BoundingBoxf3& box, float* color) const; 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); void render_sidebar_layers_hints(const std::string& sidebar_field); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES +#endif // ENABLE_LEGACY_OPENGL_REMOVAL public: enum SyncRotationType {