From 106b666e180d23883947648612bfda859e4bcf59 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 28 Mar 2022 15:40:46 +0200 Subject: [PATCH] Tech ENABLE_GL_CORE_PROFILE - Fixed rendering of GLMmSegmentationGizmo3DScene Fixed conflicts during rebase with master --- .../GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 29 +++++++++++++++++++ .../GUI/Gizmos/GLGizmoMmuSegmentation.hpp | 5 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index ddb473a32e..4a91522cda 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -706,6 +706,13 @@ void GLMmSegmentationGizmo3DScene::release_geometry() { glsafe(::glDeleteBuffers(1, &triangle_indices_VBO_id)); triangle_indices_VBO_id = 0; } +#if ENABLE_GL_CORE_PROFILE + if (this->vertices_VAO_id) { + glsafe(::glDeleteVertexArrays(1, &this->vertices_VAO_id)); + this->vertices_VAO_id = 0; + } +#endif // ENABLE_GL_CORE_PROFILE + this->clear(); } @@ -713,6 +720,9 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const { assert(triangle_indices_idx < this->triangle_indices_VBO_ids.size()); assert(this->triangle_indices_sizes.size() == this->triangle_indices_VBO_ids.size()); +#if ENABLE_GL_CORE_PROFILE + assert(this->vertices_VAO_id != 0); +#endif // ENABLE_GL_CORE_PROFILE assert(this->vertices_VBO_id != 0); assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0); @@ -722,6 +732,10 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const return; #endif // ENABLE_LEGACY_OPENGL_REMOVAL +#if ENABLE_GL_CORE_PROFILE + glsafe(::glBindVertexArray(this->vertices_VAO_id)); + // the following binding is needed to set the vertex attributes +#endif // ENABLE_GL_CORE_PROFILE glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id)); #if ENABLE_LEGACY_OPENGL_REMOVAL const GLint position_id = shader->get_attrib_location("v_position"); @@ -753,17 +767,32 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const #endif // ENABLE_LEGACY_OPENGL_REMOVAL glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); +#if ENABLE_GL_CORE_PROFILE + glsafe(::glBindVertexArray(0)); +#endif // ENABLE_GL_CORE_PROFILE } void GLMmSegmentationGizmo3DScene::finalize_vertices() { +#if ENABLE_GL_CORE_PROFILE + assert(this->vertices_VAO_id == 0); +#endif // ENABLE_GL_CORE_PROFILE assert(this->vertices_VBO_id == 0); if (!this->vertices.empty()) { +#if ENABLE_GL_CORE_PROFILE + glsafe(::glGenVertexArrays(1, &this->vertices_VAO_id)); + glsafe(::glBindVertexArray(this->vertices_VAO_id)); +#endif // ENABLE_GL_CORE_PROFILE + glsafe(::glGenBuffers(1, &this->vertices_VBO_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id)); glsafe(::glBufferData(GL_ARRAY_BUFFER, this->vertices.size() * sizeof(float), this->vertices.data(), GL_STATIC_DRAW)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); this->vertices.clear(); + +#if ENABLE_GL_CORE_PROFILE + glsafe(::glBindVertexArray(0)); +#endif // ENABLE_GL_CORE_PROFILE } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index 2ed03e85f0..502db6ebc8 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -55,7 +55,10 @@ public: // IDs of the Vertex Array Objects, into which the geometry has been loaded. // Zero if the VBOs are not sent to GPU yet. - unsigned int vertices_VBO_id{0}; +#if ENABLE_GL_CORE_PROFILE + unsigned int vertices_VAO_id{ 0 }; +#endif // ENABLE_GL_CORE_PROFILE + unsigned int vertices_VBO_id{ 0 }; std::vector triangle_indices_VBO_ids; };