GCodeViewer -> 2nd attempt to fix rendering of toolpaths on Mac

This commit is contained in:
enricoturri1966 2020-07-17 12:10:55 +02:00
parent 0df1d11780
commit a35f72442e

View File

@ -1221,13 +1221,7 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE)); glsafe(::glEnable(GL_POINT_SPRITE));
for (const RenderPath& path : buffer.render_paths) { for (const RenderPath& path : buffer.render_paths) {
#ifdef __APPLE__
for (size_t i = 0; i < path.sizes.size(); ++i) {
glsafe(::glDrawElements(GL_POINTS, (GLsizei)path.sizes[i], GL_UNSIGNED_INT, (const void*)path.offsets[i]));
}
#else
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
#endif // __APPLE__
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
++m_statistics.gl_multi_points_calls_count; ++m_statistics.gl_multi_points_calls_count;
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
@ -1241,13 +1235,7 @@ void GCodeViewer::render_toolpaths() const
for (const RenderPath& path : buffer.render_paths) for (const RenderPath& path : buffer.render_paths)
{ {
shader.set_uniform("uniform_color", path.color); shader.set_uniform("uniform_color", path.color);
#ifdef __APPLE__
for (size_t i = 0; i < path.sizes.size(); ++i) {
glsafe(::glDrawElements(GL_LINES, (GLsizei)path.sizes[i], GL_UNSIGNED_INT, (const void*)path.offsets[i]));
}
#else
glsafe(::glMultiDrawElements(GL_LINES, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); glsafe(::glMultiDrawElements(GL_LINES, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
#endif // __APPLE__
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
++m_statistics.gl_multi_line_strip_calls_count; ++m_statistics.gl_multi_line_strip_calls_count;
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
@ -1255,7 +1243,11 @@ void GCodeViewer::render_toolpaths() const
}; };
auto line_width = [zoom]() { auto line_width = [zoom]() {
return (zoom < 5.0) ? 1.0 : (1.0 + 5.0 * (zoom - 5.0) / (100.0 - 5.0)); #ifdef WIN32
return (zoom < 5.0) ? 1.0 : (1.0 + 5.0 * (zoom - 5.0) / (100.0 - 5.0));
#else
return 3.0f;
#endif // WIN32
}; };
glsafe(::glCullFace(GL_BACK)); glsafe(::glCullFace(GL_BACK));