1
2package PDL::Graphics::TriD::LinesFOOOLD;
3@ISA=qw/PDL::Graphics::TriD::Object/;
4
5BEGIN {
6   use PDL::Config;
7   if ( $PDL::Config{USE_POGL} ) {
8      eval "use OpenGL $PDL::Config{POGL_VERSION} qw(:all)";
9      eval 'use PDL::Graphics::OpenGL::Perl::OpenGL';
10   } else {
11      eval 'use PDL::Graphics::OpenGL';
12   }
13}
14
15use PDL::Lite;
16
17sub new {
18	my($type,$x,$y,$z,$color) = @_;
19	my @xdims = $x->dims;
20	$color = PDL->pdl(1) if !defined $color;
21	my $this = {
22		X => $x, Y => $y, Z => $z,
23		Color => $color,
24	};
25	bless $this,$type;
26}
27
28sub get_boundingbox {
29	my ($this) = @_;
30	my (@mins,@maxs);
31	for (X,Y,Z) {
32		push @mins, $this->{$_}->min();
33		push @maxs, $this->{$_}->max();
34	}
35	print "LineBound: ",(join ',',@mins,@maxs),"\n";
36	return PDL::Graphics::TriD::BoundingBox->new( @mins,@maxs );
37}
38
39# XXX Color is ignored.
40sub togl {
41	my($this) = @_;
42	glDisable(GL_LIGHTING);
43	glBegin(&GL_LINE_STRIP);
44	my $first = 1;
45	PDL::threadover_n($this->{X},$this->{Y},$this->{Z},$this->{Color},sub {
46		if(shift > 0) {
47			if(!$first) {
48			glEnd();
49			glBegin(&GL_LINE_STRIP);
50			} else {$first = 0;}
51		}
52		my $color = pop @_;
53		glColor3f($color,0,1-$color);
54		glVertex3d(@_);
55#		print "VERTEX: ",(join ",",@_),"\n";
56	}) ;
57	glEnd();
58	glEnable(GL_LIGHTING);
59}
60
611;
62