1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
From 0563a95b3bc43e523f26ac024eaac9c18fa41c77 Mon Sep 17 00:00:00 2001
From: Joseph Lenox <lenox.joseph@gmail.com>
Date: Thu, 17 Nov 2016 23:01:15 -0600
Subject: [PATCH 3/3] Added comments and VBO implementation for drawing of cut
plane, which also crashes.
---
lib/Slic3r/GUI/3DScene.pm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm
index 7f6f7ae..ee9e310 100644
--- a/lib/Slic3r/GUI/3DScene.pm
+++ b/lib/Slic3r/GUI/3DScene.pm
@@ -46,6 +46,10 @@ use constant GROUND_Z => -0.02;
use constant DEFAULT_COLOR => [1,1,0];
use constant SELECTED_COLOR => [0,1,0,1];
use constant HOVER_COLOR => [0.4,0.9,0,1];
+
+# Constant to determine if Vertex Buffer objects are used to draw
+# bed grid and the cut plane for object separation.
+# Old Perl (5.10.x) should set to 0.
use constant HAS_VBO => 1;
@@ -755,8 +759,6 @@ sub Render {
# draw ground
my $ground_z = GROUND_Z;
if ($self->bed_triangles) {
- my $norms = OpenGL::Array->new_list(GL_FLOAT,(0.0, 0.0, 1.0)); # common normal for both
-
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
@@ -947,10 +949,26 @@ sub draw_volumes {
glDisable(GL_BLEND);
if (defined $self->cutting_plane_z) {
+ if (HAS_VBO) {
+ # Use Vertex Buffer Object for cutting plane (previous method crashes on modern POGL).
+ my ($cut_vertex) = glGenBuffersARB_p(1);
+ $self->cut_lines_vertices->bind($cut_vertex);
+ glBufferDataARB_p(GL_ARRAY_BUFFER_ARB, $self->cut_lines_vertices, GL_STATIC_DRAW_ARB);
+ glVertexPointer_c(3, GL_FLOAT, 0, 0);
+ } else {
+ # Use legacy method.
+ glVertexPointer_p(3, $self->cut_lines_vertices);
+ }
glLineWidth(2);
glColor3f(0, 0, 0);
- glVertexPointer_p(3, $self->cut_lines_vertices);
glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3);
+
+ if (HAS_VBO) {
+ # Turn off buffer objects to let the rest of the draw code work.
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+ }
+
}
glDisableClientState(GL_VERTEX_ARRAY);
}
--
2.10.2
|