GCodeViewer -> Use glMultiDrawElements() in place of glDrawElements() to draw all entities
This commit is contained in:
parent
3267d3368f
commit
d8f6a9179f
@ -661,6 +661,20 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
{
|
{
|
||||||
case GCodeProcessor::EMoveType::Tool_change:
|
case GCodeProcessor::EMoveType::Tool_change:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 1.0f, 1.0f, 1.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 1.0f, 1.0f, 1.0f };
|
std::array<float, 3> color = { 1.0f, 1.0f, 1.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -675,10 +689,25 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Color_change:
|
case GCodeProcessor::EMoveType::Color_change:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 1.0f, 0.0f, 0.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 1.0f, 0.0f, 0.0f };
|
std::array<float, 3> color = { 1.0f, 0.0f, 0.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -693,10 +722,25 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Pause_Print:
|
case GCodeProcessor::EMoveType::Pause_Print:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 0.0f, 1.0f, 0.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 0.0f, 1.0f, 0.0f };
|
std::array<float, 3> color = { 0.0f, 1.0f, 0.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -711,10 +755,25 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Custom_GCode:
|
case GCodeProcessor::EMoveType::Custom_GCode:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 0.0f, 0.0f, 1.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 0.0f, 0.0f, 1.0f };
|
std::array<float, 3> color = { 0.0f, 0.0f, 1.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -729,10 +788,25 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Retract:
|
case GCodeProcessor::EMoveType::Retract:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 1.0f, 0.0f, 1.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 1.0f, 0.0f, 1.0f };
|
std::array<float, 3> color = { 1.0f, 0.0f, 1.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -747,10 +821,25 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Unretract:
|
case GCodeProcessor::EMoveType::Unretract:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
std::array<float, 3> color = { 0.0f, 1.0f, 1.0f };
|
||||||
|
set_color(current_program_id, color);
|
||||||
|
for (const RenderPath& path : buffer.render_paths)
|
||||||
|
{
|
||||||
|
glsafe(::glEnable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
++m_statistics.gl_multi_points_calls_count;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::array<float, 3> color = { 0.0f, 1.0f, 1.0f };
|
std::array<float, 3> color = { 0.0f, 1.0f, 1.0f };
|
||||||
set_color(current_program_id, color);
|
set_color(current_program_id, color);
|
||||||
for (const Path& path : buffer.paths) {
|
for (const Path& path : buffer.paths) {
|
||||||
@ -765,6 +854,7 @@ void GCodeViewer::render_toolpaths() const
|
|||||||
++m_statistics.gl_points_calls_count;
|
++m_statistics.gl_points_calls_count;
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GCodeProcessor::EMoveType::Extrude:
|
case GCodeProcessor::EMoveType::Extrude:
|
||||||
@ -1132,7 +1222,7 @@ void GCodeViewer::render_statistics() const
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
|
ImGui::PushStyleColor(ImGuiCol_Text, ORANGE);
|
||||||
imgui.text(std::string("Results:"));
|
imgui.text(std::string("GCodeProcessor results:"));
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::SameLine(offset);
|
ImGui::SameLine(offset);
|
||||||
imgui.text(std::to_string(m_statistics.results_size) + " bytes");
|
imgui.text(std::to_string(m_statistics.results_size) + " bytes");
|
||||||
|
@ -262,7 +262,15 @@ public:
|
|||||||
void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; }
|
void set_toolpath_role_visibility_flags(unsigned int flags) { m_extrusions.role_visibility_flags = flags; }
|
||||||
unsigned int get_options_visibility_flags() const;
|
unsigned int get_options_visibility_flags() const;
|
||||||
void set_options_visibility_from_flags(unsigned int flags);
|
void set_options_visibility_from_flags(unsigned int flags);
|
||||||
|
#if ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
void set_layers_z_range(const std::array<double, 2>& layers_z_range)
|
||||||
|
{
|
||||||
|
m_layers_z_range = layers_z_range;
|
||||||
|
refresh_render_paths();
|
||||||
|
}
|
||||||
|
#else
|
||||||
void set_layers_z_range(const std::array<double, 2>& layers_z_range) { m_layers_z_range = layers_z_range; }
|
void set_layers_z_range(const std::array<double, 2>& layers_z_range) { m_layers_z_range = layers_z_range; }
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_GL_OPTIMIZATION
|
||||||
|
|
||||||
bool is_legend_enabled() const { return m_legend_enabled; }
|
bool is_legend_enabled() const { return m_legend_enabled; }
|
||||||
void enable_legend(bool enable) { m_legend_enabled = enable; }
|
void enable_legend(bool enable) { m_legend_enabled = enable; }
|
||||||
|
Loading…
Reference in New Issue
Block a user