Fixed crash at startup on Mac OS

This commit is contained in:
enricoturri1966 2022-07-13 08:56:00 +02:00
parent a6a0e3e759
commit 22b634ca1d
11 changed files with 95 additions and 110 deletions
src/slic3r/GUI

View file

@ -1486,7 +1486,9 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
GLuint last_program; glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program));
GLuint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture));
GLuint last_array_buffer; glsafe(::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer));
GLuint last_vertex_array_object; glsafe(::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object));
GLuint last_vertex_array_object = 0;
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
glsafe(::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object));
GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport));
GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box));
GLenum last_blend_src_rgb; glsafe(::glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb));
@ -1583,8 +1585,10 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
#if ENABLE_GL_CORE_PROFILE
GLuint vao_id = 0;
glsafe(::glGenVertexArrays(1, &vao_id));
glsafe(::glBindVertexArray(vao_id));
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) {
glsafe(::glGenVertexArrays(1, &vao_id));
glsafe(::glBindVertexArray(vao_id));
}
#endif // ENABLE_GL_CORE_PROFILE
GLuint vbo_id;
@ -1669,6 +1673,7 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
glsafe(::glDeleteBuffers(1, &ibo_id));
glsafe(::glDeleteBuffers(1, &vbo_id));
#if ENABLE_GL_CORE_PROFILE
if (vao_id > 0)
glsafe(::glDeleteVertexArrays(1, &vao_id));
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -1678,7 +1683,8 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
// Restore modified GL state
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
glsafe(::glActiveTexture(last_active_texture));
glsafe(::glBindVertexArray(last_vertex_array_object));
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
glsafe(::glBindVertexArray(last_vertex_array_object));
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer));
glsafe(::glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha));
glsafe(::glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha));