Fixed crash at startup on Mac OS
This commit is contained in:
parent
a6a0e3e759
commit
22b634ca1d
11 changed files with 95 additions and 110 deletions
src/slic3r/GUI
|
@ -853,11 +853,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
return;
|
||||
|
||||
// sends data to gpu if not done yet
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
if (m_render_data.vao_id == 0) {
|
||||
#else
|
||||
if (m_render_data.vbo_id == 0 || m_render_data.ibo_id == 0) {
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (m_render_data.geometry.vertices_count() > 0 && m_render_data.geometry.indices_count() > 0 && !send_to_gpu())
|
||||
return;
|
||||
}
|
||||
|
@ -873,7 +869,8 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
const bool tex_coord = Geometry::has_tex_coord(data.format);
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
// the following binding is needed to set the vertex attributes
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
|
||||
|
@ -906,9 +903,10 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
if (!OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
|
||||
glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data))));
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
@ -923,7 +921,8 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(0));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
glsafe(::glBindVertexArray(0));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if ENABLE_GLMODEL_STATISTICS
|
||||
|
@ -958,11 +957,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
|||
if (offset_id == -1 || scales_id == -1)
|
||||
return;
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
if (m_render_data.vao_id == 0) {
|
||||
#else
|
||||
if (m_render_data.vbo_id == 0 || m_render_data.ibo_id == 0) {
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (!send_to_gpu())
|
||||
return;
|
||||
}
|
||||
|
@ -981,7 +976,8 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, instances_vbo));
|
||||
|
@ -1097,7 +1093,8 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
|||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(0));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
glsafe(::glBindVertexArray(0));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if ENABLE_GLMODEL_STATISTICS
|
||||
|
@ -1120,8 +1117,10 @@ bool GLModel::send_to_gpu()
|
|||
}
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glGenVertexArrays(1, &m_render_data.vao_id));
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0)) {
|
||||
glsafe(::glGenVertexArrays(1, &m_render_data.vao_id));
|
||||
glsafe(::glBindVertexArray(m_render_data.vao_id));
|
||||
}
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
// vertices
|
||||
|
@ -1163,9 +1162,11 @@ bool GLModel::send_to_gpu()
|
|||
glsafe(::glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.indices_size_bytes(), data.indices.data(), GL_STATIC_DRAW));
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
if (!OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
||||
m_render_data.indices_count = indices_count;
|
||||
#if ENABLE_GLMODEL_STATISTICS
|
||||
s_statistics.gpu_memory.indices.current += data.indices_size_bytes();
|
||||
|
@ -1174,7 +1175,8 @@ bool GLModel::send_to_gpu()
|
|||
data.indices = std::vector<unsigned int>();
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(0));
|
||||
if (OpenGLManager::get_gl_info().is_version_greater_or_equal_to(3, 0))
|
||||
glsafe(::glBindVertexArray(0));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue