Skip to content

Commit 2584d90

Browse files
committed
add gl_line_strip_multi, have Contours use it
1 parent 7dda67d commit 2584d90

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

lib/PDL/Graphics/OpenGLQ.pd

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ sub RPOS { make_tri("glRasterPos3f",'$coords',@_) }
9898

9999
sub make_func {
100100
my ($name) = @_;
101-
for (['_col', ' colors(tri=3,n);', COLOR().VERTEX()]) {
101+
for (['_col', ' colors(tri,n);', COLOR().VERTEX()]) {
102102
pp_def(lc($name).$_->[0],
103103
GenericTypes => $F,
104104
Pars => 'coords(tri=3,n);'.$_->[1],
@@ -114,6 +114,22 @@ sub make_func {
114114

115115
make_func($_) for qw(gl_line_strip gl_lines gl_points);
116116

117+
pp_def('gl_line_strip_multi',
118+
GenericTypes => $F,
119+
Pars => 'coords(tri=3,v); colors(tri,v); uint pathend(n);',
120+
Code => '
121+
PDL_ULong lastend = -1, thisstart = 0, thisend = 0;
122+
loop(n) %{
123+
thisstart = lastend + 1;
124+
lastend = thisend = $pathend();
125+
glBegin(GL_LINE_STRIP);
126+
loop(v=thisstart:thisend) %{'.COLOR().VERTEX().'%}
127+
glEnd();
128+
%}
129+
',
130+
@internal
131+
);
132+
117133
pp_def(
118134
'gl_texts',
119135
GenericTypes => $F,

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,7 @@ sub PDL::Graphics::TriD::Lines::gdraw {
186186

187187
sub PDL::Graphics::TriD::Contours::gdraw {
188188
my ($this,$points) = @_;
189-
my $pi = $this->{PathIndex};
190-
my ($pcnt, $i, $thisind) = (0, 0, 0);
191-
for my $ie (grep defined, @{$this->{ContourPathIndexEnd}}) {
192-
my $colors = $this->{Colors};
193-
$colors = $colors->slice(":,($i)") if $colors->getndims==2;
194-
my $this_pi = $pi->slice("$pcnt:$ie");
195-
for ($this_pi->list) {
196-
PDL::gl_line_strip_col($points->slice(",$thisind:$_"), $colors);
197-
$thisind = $_ + 1;
198-
}
199-
$i++;
200-
$pcnt=$ie+1;
201-
}
189+
PDL::gl_line_strip_multi($points, $this->{Colors}, $this->{PathIndex});
202190
}
203191

204192
# A special construct which always faces the display and takes the entire window

0 commit comments

Comments
 (0)