mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 06:55:56 +08:00
Tech ENABLE_GL_CORE_PROFILE - Fixed rendering of GLMmSegmentationGizmo3DScene
This commit is contained in:
parent
202ed2b0e0
commit
dff297a3fd
@ -56,7 +56,7 @@
|
||||
// Enable removal of legacy OpenGL calls
|
||||
#define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
|
||||
// Enable OpenGL core profile context
|
||||
#define ENABLE_GL_CORE_PROFILE (0 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
#define ENABLE_GL_CORE_PROFILE (1 && 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
|
||||
|
@ -708,6 +708,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();
|
||||
}
|
||||
|
||||
@ -715,6 +722,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);
|
||||
|
||||
@ -724,6 +734,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");
|
||||
@ -755,17 +769,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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<unsigned int> triangle_indices_VBO_ids;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user