Skip to content

Commit 02f63d9

Browse files
committed
::Spheres load index data to buffers
1 parent f284c6e commit 02f63d9

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/PDL/Graphics/OpenGLQ.pd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pp_addhdr('
5555
int i; \
5656
for (i = 0; i < 3; i++) v[i] *= fac; \
5757
}
58+
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
5859
');
5960

6061
my @internal = (Doc => 'internal', NoPthread => 1);
@@ -88,7 +89,8 @@ EOF
8889
pp_def(
8990
'gl_spheres',
9091
GenericTypes => $F,
91-
Pars => 'coords(tri=3,n); uint stripIdx(nperpart,nstacks);',
92+
Pars => 'coords(tri=3,n);',
93+
OtherPars => 'int dim0; int dim1 => nstacks;',
9294
Code => <<'EOF',
9395
float oldcoord0 = 0.0, oldcoord1 = 0.0, oldcoord2 = 0.0;
9496
glPushMatrix();
@@ -99,7 +101,7 @@ loop(n) %{
99101
$coords(tri=>2) - oldcoord2
100102
);
101103
loop (nstacks) %{
102-
glDrawElements(GL_TRIANGLE_STRIP, $SIZE(nperpart), GL_UNSIGNED_INT, &$stripIdx(nperpart=>0));
104+
glDrawElements(GL_TRIANGLE_STRIP, $COMP(dim0), GL_UNSIGNED_INT, BUFFER_OFFSET(nstacks * $COMP(dim0) * sizeof(PDL_ULong)));
103105
%}
104106
oldcoord0 = $coords(tri=>0), oldcoord1 = $coords(tri=>1), oldcoord2 = $coords(tri=>2);
105107
%}

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,14 @@ sub togl_setup {
313313
@{ $this->{Impl} }{@KEYS} = @SPHERE{@KEYS};
314314
$this->load_buffer(vert_buf => $this->{Impl}{vertices});
315315
$this->load_buffer(norm_buf => $this->{Impl}{normals});
316+
$this->load_idx_buffer(indx_buf => $this->{Impl}{idx});
316317
$this->togl_unbind;
317318
}
318319
sub gdraw {
319320
my($this,$points) = @_;
320321
$this->togl_bind;
321322
glShadeModel(GL_SMOOTH);
322-
PDL::gl_spheres($points, $this->{Impl}{idx});
323+
PDL::gl_spheres($points, $this->{Impl}{idx}->dims);
323324
$this->togl_unbind;
324325
}
325326
}

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ use base qw/PDL::Graphics::TriD::GObject/;
9595
# need to add radius
9696
sub get_valid_options { +{
9797
UseDefcols => 0,
98-
PointSize => 1,
9998
Lighting => 1,
10099
}}
101100

0 commit comments

Comments
 (0)