Tech ENABLE_GLBEGIN_GLEND_REMOVAL - Another refactoring to simplify client code of GLModel::Geometry

(cherry picked from commit prusa3d/PrusaSlicer@fa1ff1c357)
This commit is contained in:
enricoturri1966 2023-10-23 11:23:24 +08:00 committed by Noisyfox
parent 8107057e17
commit 12dbbf2d1c
8 changed files with 26 additions and 26 deletions

View file

@ -497,8 +497,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
m_profile.profile.reset();
GLModel::Geometry init_data;
const GLModel::Geometry::EIndexType index_type = (m_layer_height_profile.size() / 2 < 65536) ? GLModel::Geometry::EIndexType::USHORT : GLModel::Geometry::EIndexType::UINT;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P2, index_type };
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P2, GLModel::Geometry::index_type(m_layer_height_profile.size() / 2) };
init_data.color = ColorRGBA::BLUE();
init_data.reserve_vertices(m_layer_height_profile.size() / 2);
init_data.reserve_indices(m_layer_height_profile.size() / 2);
@ -507,7 +506,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
for (unsigned int i = 0; i < (unsigned int)m_layer_height_profile.size(); i += 2) {
init_data.add_vertex(Vec2f(bar_rect.get_left() + float(m_layer_height_profile[i + 1]) * scale_x,
bar_rect.get_bottom() + float(m_layer_height_profile[i]) * scale_y));
if (index_type == GLModel::Geometry::EIndexType::USHORT)
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_index((unsigned short)i / 2);
else
init_data.add_uint_index(i / 2);