diff options
author | bubnikv <bubnikv@gmail.com> | 2017-03-15 18:33:25 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-03-15 18:33:25 +0300 |
commit | d18e10c7c9454590421c6dd77914427bb8ef14ad (patch) | |
tree | 2efa54e66673f61720f28642ab642068860625cb /lib | |
parent | e7a920fe1676b102d48eb31c9d9aaf8c1eae59ea (diff) |
Rewrote the OpenGL object rendering to indexed triangle / quad sets
for lower memory consumption.
Rewrote the print path 3D preview to generate these indexed triangle / quad
sets, possibly with at least as possible duplication of vertices,
with a crease angle of 45 degrees, leading to maximum 8% overshoots
at the corners.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Slic3r/GUI/3DScene.pm | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index ec6fe575b..b149047c3 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1254,20 +1254,20 @@ sub draw_volumes { glPushMatrix(); glTranslatef(@{$volume->origin}); glCullFace(GL_BACK); - my $qverts_cnt = $volume->qverts_to_render_cnt; - if ($qverts_cnt) { - glVertexPointer_c(3, GL_FLOAT, 0, $volume->qverts_to_render_ptr); - glNormalPointer_c(GL_FLOAT, 0, $volume->qnorms_to_render_ptr); - glDrawArrays(GL_QUADS, 0, $qverts_cnt / 3); - } - my $tverts_cnt = $volume->tverts_to_render_cnt; - if ($tverts_cnt) { - glVertexPointer_c(3, GL_FLOAT, 0, $volume->tverts_to_render_ptr); - glNormalPointer_c(GL_FLOAT, 0, $volume->tnorms_to_render_ptr); - glDrawArrays(GL_TRIANGLES, 0, $tverts_cnt / 3); + if ($volume->indexed) { + my $quads_cnt = $volume->indexed_quads_to_render_cnt; + my $triangles_cnt = $volume->indexed_triangles_to_render_cnt; + if ($quads_cnt + $triangles_cnt > 0) { + glInterleavedArrays_c(GL_N3F_V3F, 0, $volume->triangles_to_render_ptr); + glDrawElements_c(GL_QUADS, $quads_cnt, GL_UNSIGNED_INT, $volume->quad_indices_to_render_ptr ) if ($quads_cnt); + glDrawElements_c(GL_TRIANGLES, $triangles_cnt, GL_UNSIGNED_INT, $volume->triangle_indices_to_render_ptr) if ($triangles_cnt); + glInterleavedArrays_c(GL_N3F_V3F, 0, 0); + } + } elsif (! $volume->empty) { + glInterleavedArrays_c(GL_N3F_V3F, 0, $volume->triangles_to_render_ptr); + glDrawArrays(GL_TRIANGLES, 0, $volume->triangles_to_render_cnt); + glInterleavedArrays_c(GL_N3F_V3F, 0, 0); } - glVertexPointer_c(3, GL_FLOAT, 0, 0); - glNormalPointer_c(GL_FLOAT, 0, 0); glPopMatrix(); if ($shader_active) { |