"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Graphics/TriD/TriD/GL.pm" between
PDL-2.077.tar.gz and PDL-2.078.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

GL.pm  (PDL-2.077):GL.pm  (PDL-2.078)
skipping to change at line 13 skipping to change at line 13
# - clean up # - clean up
# #
#package PDL::Graphics::TriD::GL; #package PDL::Graphics::TriD::GL;
use strict; use strict;
use warnings; use warnings;
no warnings 'redefine'; no warnings 'redefine';
use OpenGL qw/ :glfunctions :glconstants gluPerspective gluOrtho2D /; use OpenGL qw/ :glfunctions :glconstants gluPerspective gluOrtho2D /;
use OpenGL::GLUT qw( :all ); use OpenGL::GLUT qw( :all );
use PDL::Graphics::OpenGL::Perl::OpenGL; use PDL::Graphics::OpenGL::Perl::OpenGL;
use PDL::Core qw(barf);
$PDL::Graphics::TriD::create_window_sub = # warnings $PDL::Graphics::TriD::create_window_sub = # warnings
$PDL::Graphics::TriD::create_window_sub = sub { $PDL::Graphics::TriD::create_window_sub = sub {
return PDL::Graphics::TriD::GL::Window->new(@_); return PDL::Graphics::TriD::GL::Window->new(@_);
}; };
sub PDL::Graphics::TriD::Material::togl{ sub PDL::Graphics::TriD::Material::togl{
my $this = shift; my $this = shift;
my $shin = pack "f*",$this->{Shine}; my $shin = pack "f*",$this->{Shine};
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,$shin); glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,$shin);
skipping to change at line 40 skipping to change at line 41
$PDL::Graphics::TriD::any_cannots = 0; $PDL::Graphics::TriD::any_cannots = 0;
$PDL::Graphics::TriD::verbose //= 0; $PDL::Graphics::TriD::verbose //= 0;
sub PDL::Graphics::TriD::Object::cannot_mklist { sub PDL::Graphics::TriD::Object::cannot_mklist {
return 0; return 0;
} }
sub PDL::Graphics::TriD::Object::gl_update_list { sub PDL::Graphics::TriD::Object::gl_update_list {
my($this) = @_; my($this) = @_;
if($this->{List}) { glDeleteLists($this->{List},1) if $this->{List};
glDeleteLists($this->{List},1); $this->{List} = my $lno = glGenLists(1);
}
my $lno = glGenLists(1);
$this->{List} = $lno;
print "GENLIST $lno\n" if($PDL::Graphics::TriD::verbose); print "GENLIST $lno\n" if($PDL::Graphics::TriD::verbose);
glNewList($lno,GL_COMPILE); glNewList($lno,GL_COMPILE);
if ($PDL::Graphics::TriD::any_cannots) { eval {
for(@{$this->{Objects}}) { my @objs = @{$this->{Objects}};
if(!$_->cannot_mklist()) { @objs = grep !$_->cannot_mklist(), @objs if $PDL::Graphics::TriD::any_cannot
$_->togl(); s;
} $_->togl() for @objs;
} print "EGENLIST $lno\n" if($PDL::Graphics::TriD::verbose);
} else { # pdltotrianglemesh($pdl, 0, 1, 0, ($pdl->{Dims}[1]-1)*$mult);
for (@{$this->{Objects}}) { };
$_->togl() { local $@; glEndList(); }
} die if $@;
}
print "EGENLIST $lno\n" if($PDL::Graphics::TriD::verbose);
# pdltotrianglemesh($pdl, 0, 1, 0, ($pdl->{Dims}[1]-1)*$mult);
glEndList();
print "VALID1 $this\n" if($PDL::Graphics::TriD::verbose); print "VALID1 $this\n" if($PDL::Graphics::TriD::verbose);
$this->{ValidList} = 1; $this->{ValidList} = 1;
} }
sub PDL::Graphics::TriD::Object::gl_call_list { sub PDL::Graphics::TriD::Object::gl_call_list {
my($this) = @_; my($this) = @_;
print "CALLIST ",$this->{List}//'undef',"!\n" if($PDL::Graphics::TriD::ve print "CALLIST ",$this->{List}//'undef',"!\n" if $PDL::Graphics::TriD::ve
rbose); rbose;
print "CHECKVALID $this\n" if($PDL::Graphics::TriD::verbose); print "CHECKVALID $this=$this->{ValidList}\n" if $PDL::Graphics::TriD::ve
rbose;
$this->gl_update_list if !$this->{ValidList}; $this->gl_update_list if !$this->{ValidList};
glCallList($this->{List}); glCallList($this->{List});
if ($PDL::Graphics::TriD::any_cannots) { return if !$PDL::Graphics::TriD::any_cannots;
for(@{$this->{Objects}}) { for (grep $_->cannot_mklist, @{$this->{Objects}}) {
if($_->cannot_mklist()) { print ref($_)," cannot mklist\n";
print ref($_)," cannot mklist\n"; $_->togl();
$_->togl(); }
}
}
}
} }
sub PDL::Graphics::TriD::Object::delete_displist { sub PDL::Graphics::TriD::Object::delete_displist {
my($this) = @_; my($this) = @_;
if($this->{List}) { return if !$this->{List};
glDeleteLists($this->{List},1); glDeleteLists($this->{List},1);
undef $this->{List}; delete @$this{qw(List ValidList)};
}
} }
sub PDL::Graphics::TriD::Object::togl { sub PDL::Graphics::TriD::Object::togl { $_->togl for @{$_[0]->{Objects}} }
my($this) = @_;
for(@{$this->{Objects}}) { $_->togl() }
}
my @bb1 = ([0,4,2],[0,1,2],[0,1,5],[0,4,5],[0,4,2],[3,4,2],
[3,1,2],[3,1,5],[3,4,5],[3,4,2]);
my @bb2 = ([0,1,2],[3,1,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]);
sub PDL::Graphics::TriD::BoundingBox::togl { sub PDL::Graphics::TriD::BoundingBox::togl {
my($this) = @_; my($this) = @_;
$this = $this->{Box}; $this = $this->{Box};
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glColor3d(1,1,1); glColor3d(1,1,1);
glBegin(GL_LINES); glBegin(GL_LINES);
for([0,4,2],[0,1,2],[0,1,5],[0,4,5],[0,4,2],[3,4,2], glVertex3d(@{$this}[@$_]) for @bb1;
[3,1,2],[3,1,5],[3,4,5],[3,4,2]) {
glVertex3d(@{$this}[@$_]);
}
glEnd(); glEnd();
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for([0,1,2],[3,1,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]) { glVertex3d(@{$this}[@$_]) for @bb2;
glVertex3d(@{$this}[@$_]);
}
glEnd(); glEnd();
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} }
sub PDL::Graphics::TriD::Graph::togl { sub PDL::Graphics::TriD::Graph::togl {
my($this) = @_; my($this) = @_;
$this->{Axis}{$_}->togl_axis($this) for grep $_ ne "Default", keys %{$thi s->{Axis}}; $this->{Axis}{$_}->togl_axis($this) for grep $_ ne "Default", keys %{$thi s->{Axis}};
$this->{Data}{$_}->togl_graph($this,$this->get_points($_)) for keys %{$th is->{Data}}; $this->{Data}{$_}->togl_graph($this,$this->get_points($_)) for keys %{$th is->{Data}};
} }
skipping to change at line 180 skipping to change at line 164
glLineWidth(1); # ought to be user defined glLineWidth(1); # ought to be user defined
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
my $ndiv = 4; my $ndiv = 4;
my $line_coord = zeroes(3,3)->append(my $id3 = identity(3)); my $line_coord = zeroes(3,3)->append(my $id3 = identity(3));
my $starts = zeroes($ndiv+1)->xlinvals(0,1)->transpose->append(zeroes(2,$ ndiv+1)); my $starts = zeroes($ndiv+1)->xlinvals(0,1)->transpose->append(zeroes(2,$ ndiv+1));
my $ends = $starts + append(0, ones 2) * -0.1; my $ends = $starts + append(0, ones 2) * -0.1;
my $dupseq = sequence(3)->dummy(0,$ndiv+1)->flat; my $dupseq = sequence(3)->dummy(0,$ndiv+1)->flat;
$_ = $_->dup(1,3)->rotate($dupseq) for $starts, $ends; $_ = $_->dup(1,3)->rotate($dupseq) for $starts, $ends;
$line_coord = $line_coord->glue(1, $starts->append($ends)); $line_coord = $line_coord->glue(1, $starts->append($ends));
my $axisvals = zeroes(3,$ndiv+1)->ylinvals($this->{Scale}->dog)->transpos e->flat->transpose; my $axisvals = zeroes(3,$ndiv+1)->ylinvals($this->{Scale}->dog)->transpos e->flat->transpose;
my @label = map [@$_[0..2], sprintf "%.3f", $_->[3]], @{ $ends->append($a my @label = map sprintf("%.3f", $_), @{ $axisvals->flat->unpdl };
xisvals)->unpdl }; push @label, @{$this->{Names}};
my $dim = 0; push @label, map [@$_, $this->{Names}[$dim++]], @{ ($id3*1.1
)->unpdl };
glColor3d(1,1,1); glColor3d(1,1,1);
for (@label) { PDL::Graphics::OpenGLQ::gl_texts($ends->glue(1, $id3), done_glutInit(),
glRasterPos3f(@$_[0..2]); $fontbase, \@label);
if ( done_glutInit() ) {
glutBitmapString($fontbase, $_->[3]);
} else {
OpenGL::glpPrintString($fontbase, $_->[3]);
}
}
PDL::gl_lines_nc($line_coord->splitdim(0,3)->clump(1,2)); PDL::gl_lines_nc($line_coord->splitdim(0,3)->clump(1,2));
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} }
use POSIX qw//; use POSIX qw//;
sub PDL::Graphics::TriD::Quaternion::togl { sub PDL::Graphics::TriD::Quaternion::togl {
my($this) = @_; my($this) = @_;
if(abs($this->[0]) == 1) { return ; } if(abs($this->[0]) == 1) { return ; }
if(abs($this->[0]) >= 1) { if(abs($this->[0]) >= 1) {
$this->normalize_this(); $this->normalize_this();
skipping to change at line 219 skipping to change at line 197
$_[0]->gdraw($_[0]->{Points}); $_[0]->gdraw($_[0]->{Points});
} }
# (this,graphs,points) # (this,graphs,points)
sub PDL::Graphics::TriD::GObject::togl_graph { sub PDL::Graphics::TriD::GObject::togl_graph {
$_[0]->gdraw($_[2]); $_[0]->gdraw($_[2]);
} }
sub PDL::Graphics::TriD::Points::gdraw { sub PDL::Graphics::TriD::Points::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
PDL::gl_points_col($points,$this->{Colors}); eval {
glEnable(GL_LIGHTING); PDL::gl_points_col($points,$this->{Colors});
} };
{ local $@; glPopAttrib(); }
sub PDL::gl_spheres { die if $@;
my ($coords,$colors) = @_;
for (my $np=0; $np<$coords->dim(1); $np++) {
glPushMatrix();
my ($x,$y,$z) = ($coords->slice(":,($np)"))->float->list;
glTranslatef($x,$y,$z);
glutSolidSphere(0.025,15,15);
glPopMatrix();
}
} }
sub PDL::Graphics::TriD::Spheres::gdraw { sub PDL::Graphics::TriD::Spheres::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glEnable(GL_LIGHTING);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
PDL::gl_spheres($points,$this->{Colors}); eval {
PDL::gl_spheres($points, 0.025, 15, 15);
};
{ local $@; glPopAttrib(); }
die if $@;
} }
sub PDL::Graphics::TriD::Lattice::gdraw { sub PDL::Graphics::TriD::Lattice::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); barf "Need 3D points AND colours"
if grep $_->ndims < 3, $points, $this->{Colors};
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
PDL::gl_line_strip_col($points,$this->{Colors}); eval {
PDL::gl_line_strip_col($points->xchg(1,2),$this->{Colors}->xchg(1,2)); PDL::gl_line_strip_col($points,$this->{Colors});
glEnable(GL_LIGHTING); PDL::gl_line_strip_col($points->xchg(1,2),$this->{Colors}->xchg(1,2));
};
{ local $@; glPopAttrib(); }
die if $@;
} }
sub PDL::Graphics::TriD::LineStrip::gdraw { sub PDL::Graphics::TriD::LineStrip::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
PDL::gl_line_strip_col($points,$this->{Colors}); eval {
glEnable(GL_LIGHTING); PDL::gl_line_strip_col($points,$this->{Colors});
};
{ local $@; glPopAttrib(); }
die if $@;
} }
sub PDL::Graphics::TriD::Lines::gdraw { sub PDL::Graphics::TriD::Lines::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
PDL::gl_lines_col($points,$this->{Colors}); eval {
glEnable(GL_LIGHTING); PDL::gl_lines_col($points,$this->{Colors});
};
{ local $@; glPopAttrib(); }
die if $@;
} }
sub PDL::Graphics::TriD::GObject::glOptions { sub PDL::Graphics::TriD::GObject::glOptions {
my ($this) = @_; my ($this) = @_;
glLineWidth($this->{Options}{LineWidth} || 1); glLineWidth($this->{Options}{LineWidth} || 1);
glPointSize($this->{Options}{PointSize} || 1); glPointSize($this->{Options}{PointSize} || 1);
} }
sub PDL::Graphics::TriD::GObject::_lattice_lines {
my ($this, $points) = @_;
glDisable(GL_LIGHTING);
glColor3f(0,0,0);
PDL::gl_line_strip_nc($points);
PDL::gl_line_strip_nc($points->xchg(1,2));
}
sub PDL::Graphics::TriD::Contours::gdraw { sub PDL::Graphics::TriD::Contours::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
my $pcnt=0; eval {
my $i=0; my $pcnt=0;
foreach (grep defined, @{$this->{ContourSegCnt}}){ my $i=0;
my $colors = $this->{Colors}; foreach (grep defined, @{$this->{ContourSegCnt}}){
$colors = $colors->slice(":,($i)") if $colors->getndims==2; my $colors = $this->{Colors};
PDL::gl_lines_col($points->slice(":,$pcnt:$_"),$colors); $colors = $colors->slice(":,($i)") if $colors->getndims==2;
$i++; PDL::gl_lines_col($points->slice(":,$pcnt:$_"),$colors);
$pcnt=$_+1; $i++;
$pcnt=$_+1;
}
if(defined $this->{Labels}){
glColor3d(1,1,1);
my $seg = sprintf(":,%d:%d",$this->{Labels}[0],$this->{Labels}[1]);
PDL::Graphics::OpenGLQ::gl_texts($points->slice($seg),
done_glutInit(), $this->{Options}{Font},
$this->{LabelStrings});
}
};
{ local $@; glPopAttrib(); }
die if $@;
}
my @sls1 = (
":,0:-2,0:-2",
":,1:-1,0:-2",
":,0:-2,1:-1");
my @sls2 = (
":,1:-1,1:-1",
":,0:-2,1:-1",
":,1:-1,0:-2");
sub _lattice_slice {
my ($f, @pdls) = @_;
for my $s (\@sls1, \@sls2) {
my @args;
for my $p (@pdls) {
push @args, map $p->slice($_), @$s;
}
&$f(@args);
} }
if(defined $this->{Labels}){
glColor3d(1,1,1);
my $seg = sprintf(":,%d:%d",$this->{Labels}[0],$this->{Labels}[1]);
PDL::Graphics::OpenGLQ::gl_texts($points->slice($seg),
$this->{Options}{Font}
,$this->{LabelStrings});
}
glEnable(GL_LIGHTING);
} }
sub PDL::Graphics::TriD::SLattice::gdraw { sub PDL::Graphics::TriD::SLattice::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); barf "Need 3D points"
if grep $_->ndims < 3, $points;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel (GL_SMOOTH); glShadeModel(GL_SMOOTH);
my @sls1 = (":,0:-2,0:-2", eval {
":,1:-1,0:-2", _lattice_slice(\&PDL::gl_triangles, $points, $this->{Colors});
":,0:-2,1:-1"); $this->_lattice_lines($points) if $this->{Options}{Lines};
my @sls2 = (":,1:-1,1:-1", };
":,0:-2,1:-1", { local $@; glPopAttrib(); }
":,1:-1,0:-2" die if $@;
);
PDL::gl_triangles(
(map {$points->slice($_)} @sls1),
(map {$this->{Colors}->slice($_)} @sls1)
);
PDL::gl_triangles(
(map {$points->slice($_)} @sls2),
(map {$this->{Colors}->slice($_)} @sls2)
);
if ($this->{Options}{Lines}) {
glColor3f(0,0,0);
PDL::gl_line_strip_nc($points);
PDL::gl_line_strip_nc($points->xchg(1,2));
}
glPopAttrib();
} }
sub PDL::Graphics::TriD::SCLattice::gdraw { sub PDL::Graphics::TriD::SCLattice::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); barf "Need 3D points"
if grep $_->ndims < 3, $points;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);
my @sls1 = (":,0:-2,0:-2", eval {
":,1:-1,0:-2", _lattice_slice(\&PDL::gl_triangles, $points, $this->{Colors});
":,0:-2,1:-1"); $this->_lattice_lines($points) if $this->{Options}{Lines};
my @sls2 = (":,1:-1,1:-1", };
":,0:-2,1:-1", { local $@; glPopAttrib(); }
":,1:-1,0:-2" die if $@;
);
PDL::gl_triangles(
(map {$points->slice($_)} @sls1),
(map {$this->{Colors}} @sls1)
);
PDL::gl_triangles(
(map {$points->slice($_)} @sls2),
(map {$this->{Colors}} @sls2)
);
if ($this->{Options}{Lines}) {
glColor3f(0,0,0);
PDL::gl_line_strip_nc($points);
PDL::gl_line_strip_nc($points->xchg(1,2));
}
glPopAttrib();
} }
sub PDL::Graphics::TriD::SLattice_S::gdraw { sub PDL::Graphics::TriD::SLattice_S::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
$this->glOptions(); barf "Need 3D points"
if grep $_->ndims < 3, $points;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
$this->glOptions;
# For some reason, we need to set this here as well. # For some reason, we need to set this here as well.
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel (GL_SMOOTH); glShadeModel(GL_SMOOTH);
my @sls1 = (":,0:-2,0:-2", eval {
":,1:-1,0:-2", my $f = 'PDL::gl_triangles_';
":,0:-2,1:-1"); $f .= 'w' if $this->{Options}{Smooth};
my @sls2 = (":,1:-1,1:-1", $f .= 'n_mat';
":,0:-2,1:-1", { no strict 'refs'; $f = \&$f; }
":,1:-1,0:-2" my @pdls = $points;
); push @pdls, $this->{Normals} if $this->{Options}{Smooth};
if ($this->{Options}{Smooth}) { push @pdls, $this->{Colors};
$this->{Normals} = $this->smoothn($points) _lattice_slice($f, @pdls);
unless defined($this->{Normals}); $this->_lattice_lines($points) if $this->{Options}{Lines};
my $n = $this->{Normals}; };
my $f = (!$this->{Options}{Material} ? { local $@; glPopAttrib(); }
\&PDL::gl_triangles_wn : \&PDL::gl_triangles_wn_mat); die if $@;
&$f(
(map {$points->slice($_)} @sls1),
(map {$n->slice($_)} @sls1),
(map {$this->{Colors}->slice($_)} @sls1)
);
&$f(
(map {$points->slice($_)} @sls2),
(map {$n->slice($_)} @sls2),
(map {$this->{Colors}->slice($_)} @sls2)
);
} else {
my $f = (!$this->{Options}{Material} ?
\&PDL::gl_triangles_n : \&PDL::gl_triangles_n_mat);
&$f(
(map {$points->slice($_)} @sls1),
(map {$this->{Colors}->slice($_)} @sls1)
);
&$f(
(map {$points->slice($_)} @sls2),
(map {$this->{Colors}->slice($_)} @sls2)
);
}
glDisable(GL_LIGHTING);
if ($this->{Options}{Lines}) {
glColor3f(0,0,0);
PDL::gl_line_strip_nc($points);
PDL::gl_line_strip_nc($points->xchg(1,2));
}
glPopAttrib();
} }
sub PDL::Graphics::TriD::STrigrid_S::gdraw { sub PDL::Graphics::TriD::STrigrid_S::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
# For some reason, we need to set this here as well. $this->glOptions;
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); eval {
# By-vertex doesn't make sense otherwise. # For some reason, we need to set this here as well.
glShadeModel(GL_SMOOTH); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
my @sls = (":,(0)",":,(1)",":,(2)"); # By-vertex doesn't make sense otherwise.
my $idx = [0,1,2,0]; # for lines, below glShadeModel(GL_SMOOTH);
if ($this->{Options}{Smooth}) { my @sls = (":,(0)",":,(1)",":,(2)");
$this->{Normals} //= $this->smoothn($this->{Points}); my $idx = [0,1,2,0]; # for lines, below
my $f=(!$this->{Options}{Material}?\&PDL::gl_triangles_wn if ($this->{Options}{Smooth}) {
:\&PDL::gl_triangles_wn_mat); my $f=\&PDL::gl_triangles_wn_mat;
my $tmpn=$this->{Normals}->dice_axis(1,$this->{Faceidx}->clump(-1)) my $tmpn=$this->{Normals}->dice_axis(1,$this->{Faceidx}->clump(-1))
->splitdim(1,($this->{Faceidx}->dims)[0]); ->splitdim(1,$this->{Faceidx}->dim(0));
my @args=((map {$this->{Faces}->slice($_)} @sls), # faces is a slice of po my @args=((map {$this->{Faces}->slice($_)} @sls), # faces is a slice of
ints points
(map {$tmpn->slice($_)} @sls), (map {$tmpn->slice($_)} @sls),
(map {$this->{Colors}->slice($_)} @sls) );&$f(@args); (map {$this->{Colors}->slice($_)} @sls) );&$f(@args);
} else { } else {
my $f=(!$this->{Options}{Material}?\&PDL::gl_triangles_n my $f=\&PDL::gl_triangles_n_mat;
:\&PDL::gl_triangles_n_mat); &$f( (map {$this->{Faces}->slice($_)} @sls), # faces is a slice of point
&$f( (map {$this->{Faces}->slice($_)} @sls), # faces is a slice of points s
(map {$this->{Colors}->slice($_)} @sls) ); (map {$this->{Colors}->slice($_)} @sls) );
} }
glDisable(GL_LIGHTING); if ($this->{Options}{Lines}) {
if ($this->{Options}{Lines}) { glDisable(GL_LIGHTING);
glColor3f(0,0,0); glColor3f(0,0,0);
PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx)); PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx));
} }
glPopAttrib(); };
{ local $@; glPopAttrib(); }
die if $@;
} }
sub PDL::Graphics::TriD::STrigrid::gdraw { sub PDL::Graphics::TriD::STrigrid::gdraw {
my($this,$points) = @_; my($this,$points) = @_;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT); glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
glDisable(GL_LIGHTING); $this->glOptions;
eval {
glDisable(GL_LIGHTING);
# By-vertex doesn't make sense otherwise. # By-vertex doesn't make sense otherwise.
glShadeModel (GL_SMOOTH); glShadeModel (GL_SMOOTH);
my @sls = (":,(0)",":,(1)",":,(2)"); my @sls = (":,(0)",":,(1)",":,(2)");
my $idx = [0,1,2,0]; my $idx = [0,1,2,0];
PDL::gl_triangles( PDL::gl_triangles(
(map {$this->{Faces}->slice($_)} @sls), # faces is a slice of points (map {$this->{Faces}->slice($_)} @sls), # faces is a slice of points
(map {$this->{Colors}->slice($_)} @sls)); (map {$this->{Colors}->slice($_)} @sls));
if ($this->{Options}{Lines}) { if ($this->{Options}{Lines}) {
glColor3f(0,0,0); glColor3f(0,0,0);
PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx)); PDL::gl_lines_nc($this->{Faces}->dice_axis(1,$idx));
} }
glPopAttrib(); };
{ local $@; glPopAttrib(); }
die if $@;
} }
################################## ##################################
# PDL::Graphics::TriD::Image # PDL::Graphics::TriD::Image
sub PDL::Graphics::TriD::Image::togl { sub PDL::Graphics::TriD::Image::togl {
# A special construct which always faces the display and takes the entire window # A special construct which always faces the display and takes the entire window
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
skipping to change at line 480 skipping to change at line 454
} }
sub PDL::Graphics::TriD::Image::togl_graph { sub PDL::Graphics::TriD::Image::togl_graph {
$_[0]->gdraw(); $_[0]->gdraw();
} }
# The quick method is to use texturing for the good effect. # The quick method is to use texturing for the good effect.
sub PDL::Graphics::TriD::Image::gdraw { sub PDL::Graphics::TriD::Image::gdraw {
my($this,$vert) = @_; my($this,$vert) = @_;
my ($p,$xd,$yd,$txd,$tyd) = $this->flatten(1); # do binary alignment my ($p,$xd,$yd,$txd,$tyd) = $this->flatten(1); # do binary alignment
if(!defined $vert) {$vert = $this->{Points}}
barf "Need 3,4 vert"
if grep $_->dim(1) < 4 || $_->dim(0) != 3, $vert;
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
glColor3d(1,1,1); glColor3d(1,1,1);
glTexImage2D_s(GL_TEXTURE_2D, 0, GL_RGB, $txd, $tyd, 0, GL_RGB, GL_FLOA T, $p->get_dataref()); glTexImage2D_s(GL_TEXTURE_2D, 0, GL_RGB, $txd, $tyd, 0, GL_RGB, GL_FLOA T, $p->get_dataref());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glNormal3d(0,0,1); glNormal3d(0,0,1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
my @texvert = ( eval {
[0,0], my @texvert = (
[$xd/$txd, 0], [0,0],
[$xd/$txd, $yd/$tyd], [$xd/$txd, 0],
[0, $yd/$tyd] [$xd/$txd, $yd/$tyd],
); [0, $yd/$tyd]
if(!defined $vert) {$vert = $this->{Points}} );
for(0..3) { for(0..3) {
glTexCoord2f(@{$texvert[$_]}); glTexCoord2f(@{$texvert[$_]});
glVertex3f($vert->slice(":,($_)")->list); glVertex3f($vert->slice(":,($_)")->list);
} }
glEnd(); };
glEnable(GL_LIGHTING); { local $@; glEnd(); glPopAttrib(); }
glDisable(GL_TEXTURE_2D); die if $@;
} }
sub PDL::Graphics::TriD::SimpleController::togl { sub PDL::Graphics::TriD::SimpleController::togl {
my($this) = @_; my($this) = @_;
$this->{CRotation}->togl(); $this->{CRotation}->togl();
glTranslatef(0,0,-$this->{CDistance}); glTranslatef(0,0,-$this->{CDistance});
$this->{WRotation}->togl(); $this->{WRotation}->togl();
glTranslatef(map {-$_} @{$this->{WOrigin}}); glTranslatef(map {-$_} @{$this->{WOrigin}});
} }
skipping to change at line 526 skipping to change at line 504
package PDL::Graphics::TriD::Window; package PDL::Graphics::TriD::Window;
use OpenGL qw/ :glfunctions :glconstants :glxconstants /; use OpenGL qw/ :glfunctions :glconstants :glxconstants /;
use OpenGL::GLUT qw( :all ); use OpenGL::GLUT qw( :all );
use PDL::Graphics::OpenGL::Perl::OpenGL; use PDL::Graphics::OpenGL::Perl::OpenGL;
use base qw/PDL::Graphics::TriD::Object/; use base qw/PDL::Graphics::TriD::Object/;
use fields qw/Ev Width Height Interactive _GLObject use fields qw/Ev Width Height Interactive _GLObject
_ViewPorts _CurrentViewPort /; _ViewPorts _CurrentViewPort /;
sub i_keep_list {return 1} # For Object, so I will be notified of changes.
use strict;
sub gdriver { sub gdriver {
my($this, $options) = @_; my($this, $options) = @_;
print "GL gdriver...\n" if($PDL::Graphics::TriD::verbose); print "GL gdriver...\n" if($PDL::Graphics::TriD::verbose);
if(defined $this->{_GLObject}){ if(defined $this->{_GLObject}){
print "WARNING: Graphics Driver already defined for this window \n"; print "WARNING: Graphics Driver already defined for this window \n";
return; return;
} }
my @db = OpenGL::GLX_DOUBLEBUFFER; my @db = OpenGL::GLX_DOUBLEBUFFER;
if($PDL::Graphics::TriD::offline) {$options->{x} = -1; @db=()} if($PDL::Graphics::TriD::offline) {$options->{x} = -1; @db=()}
$options->{attributes} = [GLX_RGBA, @db, $options->{attributes} = [GLX_RGBA, @db,
skipping to change at line 558 skipping to change at line 533
PointerMotionMask) unless defined $options->{mask}; PointerMotionMask) unless defined $options->{mask};
print "STARTING OPENGL $options->{width} $options->{height}\n" if($PDL::Graphi cs::TriD::verbose); print "STARTING OPENGL $options->{width} $options->{height}\n" if($PDL::Graphi cs::TriD::verbose);
print "gdriver: Calling OpengGL::OO($options)...\n" if ($PDL::Graphics::TriD:: verbose); print "gdriver: Calling OpengGL::OO($options)...\n" if ($PDL::Graphics::TriD:: verbose);
$this->{_GLObject}= new PDL::Graphics::OpenGL::OO($options); $this->{_GLObject}= new PDL::Graphics::OpenGL::OO($options);
if (exists $this->{_GLObject}->{glutwindow}) { if (exists $this->{_GLObject}->{glutwindow}) {
if ($PDL::Graphics::TriD::verbose) { if ($PDL::Graphics::TriD::verbose) {
print "gdriver: Got OpenGL::OO object(GLUT window ID# " . $this->{_GLObj ect}->{glutwindow} . ")\n"; print "gdriver: Got OpenGL::OO object(GLUT window ID# " . $this->{_GLObj ect}->{glutwindow} . ")\n";
} }
$this->{_GLObject}->{winobjects}->[$this->{_GLObject}->{glutwindow}] = $thi s; # circular ref $this->{_GLObject}->{winobjects}->[$this->{_GLObject}->{glutwindow}] = $thi s; # circular ref
} }
print "gdriver: Calling glClearColor...\n" if ($PDL::Graphics::TriD::verbose); print "gdriver: Calling glClearColor...\n" if $PDL::Graphics::TriD::verbose;
glClearColor(0,0,0,1); glClearColor(0,0,0,1);
print "gdriver: Calling glpRasterFont...\n" if ($PDL::Graphics::TriD::verbose) print "gdriver: Calling glpRasterFont...\n" if $PDL::Graphics::TriD::verbose;
; $PDL::Graphics::TriD::GL::fontbase = $this->{_GLObject}->glpRasterFont($ENV{PD
if ( $this->{_GLObject}->{window_type} eq 'glut' ) { L_3D_FONT} || "5x8", 0, 256);
print STDERR "gdriver: window_type => 'glut' so not actually setting the ra
sterfont\n" if ($PDL::Graphics::TriD::verbose);
eval '$PDL::Graphics::TriD::GL::fontbase = GLUT_BITMAP_8_BY_13';
} else {
# NOTE: glpRasterFont() will die() if the requested font cannot be found
# The new POGL+GLUT TriD implementation uses the builtin GLUT defined
# fonts and does not have this failure mode.
my $lb = eval { $this->{_GLObject}->glpRasterFont( ($ENV{PDL_3D_FONT} or "
5x8"), 0, 256 ) };
if ( $@ ) {
die "glpRasterFont: unable to load font '%s', please set PDL_3D_FONT to
an existing X11 font.";
}
$PDL::Graphics::TriD::GL::fontbase = $lb
}
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
my $light = pack "f*",1.0,1.0,1.0,0.0; my $light = pack "f*",1.0,1.0,1.0,0.0;
glLightfv_s(GL_LIGHT0,GL_POSITION,$light); glLightfv_s(GL_LIGHT0,GL_POSITION,$light);
glColor3f(1,1,1); glColor3f(1,1,1);
print "STARTED OPENGL!\n" if($PDL::Graphics::TriD::verbose); print "STARTED OPENGL!\n" if $PDL::Graphics::TriD::verbose;
if($PDL::Graphics::TriD::offline) { if($PDL::Graphics::TriD::offline) {
$this->doconfig($options->{width}, $options->{height}); $this->doconfig($options->{width}, $options->{height});
} }
return 1; # Interactive Window return 1; # Interactive Window
} }
sub ev_defaults{ sub ev_defaults{
return { ConfigureNotify => \&doconfig, return { ConfigureNotify => \&doconfig,
MotionNotify => \&domotion, MotionNotify => \&domotion,
} }
skipping to change at line 611 skipping to change at line 574
for my $vp (@{$this->{_ViewPorts}}){ for my $vp (@{$this->{_ViewPorts}}){
my $nw = $vp->{W} + ($x-$pw) * $vp->{W}/$pw; my $nw = $vp->{W} + ($x-$pw) * $vp->{W}/$pw;
my $nx0 = $vp->{X0} + ($x-$pw) * $vp->{X0}/$pw; my $nx0 = $vp->{X0} + ($x-$pw) * $vp->{X0}/$pw;
my $nh = $vp->{H} + ($y-$ph) * $vp->{H}/$ph; my $nh = $vp->{H} + ($y-$ph) * $vp->{H}/$ph;
my $ny0 = $vp->{Y0} + ($y-$ph) * $vp->{Y0}/$ph; my $ny0 = $vp->{Y0} + ($y-$ph) * $vp->{Y0}/$ph;
print "reshape: resizing viewport to $nx0,$ny0,$nw,$nh\n" if($PDL::Grap hics::TriD::verbose); print "reshape: resizing viewport to $nx0,$ny0,$nw,$nh\n" if($PDL::Grap hics::TriD::verbose);
$vp->resize($nx0,$ny0,$nw,$nh); $vp->resize($nx0,$ny0,$nw,$nh);
} }
} }
sub get_size { sub get_size { @{$_[0]}{qw(Width Height)} }
my $this=shift;
return ($this->{Width},$this->{Height});
}
sub twiddle { sub twiddle {
my($this,$getout,$dontshow) = @_; my($this,$getout,$dontshow) = @_;
my (@e); my (@e);
my $quit; my $quit;
if($PDL::Graphics::TriD::offline) { if($PDL::Graphics::TriD::offline) {
$PDL::Graphics::TriD::offlineindex ++; $PDL::Graphics::TriD::offlineindex ++;
$this->display(); $this->display();
require PDL::IO::Pic; require PDL::IO::Pic;
wpic($this->read_picture(),"PDL_$PDL::Graphics::TriD::offlineindex.jpg") ; wpic($this->read_picture(),"PDL_$PDL::Graphics::TriD::offlineindex.jpg") ;
return; return;
} }
return if $getout and $dontshow and !$this->{_GLObject}->XPending; return if $getout and $dontshow and !$this->{_GLObject}->XPending;
$getout //= !($PDL::Graphics::TriD::keeptwiddling && $PDL::Graphics::TriD::kee ptwiddling); $getout //= !($PDL::Graphics::TriD::keeptwiddling && $PDL::Graphics::TriD::kee ptwiddling);
$this->display(); $this->display();
TWIDLOOP: while(1) { TWIDLOOP: while(1) {
print "EVENT!\n" if($PDL::Graphics::TriD::verbose); print "EVENT!\n" if($PDL::Graphics::TriD::verbose);
my $hap = 0; my $hap = 0;
my $gotev = 0; my $gotev = 0;
# Run a MainLoop event if GLUT windows
# this pumps the system allowing callbacks to populate
# the fake XEvent queue.
#
glutMainLoopEvent() if $this->{_GLObject}->{window_type} eq 'glut' and
not $this->{_GLObject}->XPending();
if ($this->{_GLObject}->XPending() or !$getout) { if ($this->{_GLObject}->XPending() or !$getout) {
@e = $this->{_GLObject}->glpXNextEvent(); @e = $this->{_GLObject}->glpXNextEvent();
$gotev=1; $gotev=1;
} }
print "e= ".join(",",@e)."\n" if($PDL::Graphics::TriD::verbose); print "e= ".join(",",@e)."\n" if($PDL::Graphics::TriD::verbose);
if(@e){ if(@e){
if ($e[0] == VisibilityNotify || $e[0] == Expose) { if ($e[0] == VisibilityNotify || $e[0] == Expose) {
$hap = 1; $hap = 1;
} elsif ($e[0] == ConfigureNotify) { } elsif ($e[0] == ConfigureNotify) {
print "CONFIGNOTIFE\n" if($PDL::Graphics::TriD::verbose); print "CONFIGNOTIFE\n" if($PDL::Graphics::TriD::verbose);
skipping to change at line 717 skipping to change at line 672
} }
sub domotion { sub domotion {
my($this) = @_; my($this) = @_;
print "MOTIONENOTIFY\n" if($PDL::Graphics::TriD::verbose); print "MOTIONENOTIFY\n" if($PDL::Graphics::TriD::verbose);
} }
sub display { sub display {
my($this) = @_; my($this) = @_;
return unless defined($this); return unless defined($this);
# set GLUT context to current window (for multiwindow support) $this->{_GLObject}->set_window; # for multiwindow support
if ( $this->{_GLObject}->{window_type} eq 'glut' ) {
glutSetWindow($this->{_GLObject}->{glutwindow});
}
print "display: calling glClear()\n" if ($PDL::Graphics::TriD::verbose); print "display: calling glClear()\n" if ($PDL::Graphics::TriD::verbose);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
for my $vp (@{$this->{_ViewPorts}}) { for my $vp (@{$this->{_ViewPorts}}) {
glPushMatrix(); glPushMatrix();
$vp->do_perspective(); $vp->do_perspective();
if($vp->{Transformer}) { if($vp->{Transformer}) {
print "display: transforming viewport!\n" if ($PDL::Graphics::Tri D::verbose); print "display: transforming viewport!\n" if ($PDL::Graphics::Tri D::verbose);
$vp->{Transformer}->togl(); $vp->{Transformer}->togl();
} }
$vp->gl_call_list(); $vp->gl_call_list();
glPopMatrix(); glPopMatrix();
} }
print "display: SwapBuffers() call on return\n" if ($PDL::Graphics::TriD::verb $this->{_GLObject}->swap_buffers;
ose); print "display: after SwapBuffers\n" if $PDL::Graphics::TriD::verbose;
if ( $this->{_GLObject}->{window_type} eq 'glut' ) { # need to make method ca
ll
glutSwapBuffers();
} elsif ( $this->{_GLObject}->{window_type} eq 'x11' ) { # need to make metho
d call
$this->{_GLObject}->glXSwapBuffers();
} else {
print "display: got object with inconsistent _GLObject info\n";
}
} }
# should this really be in viewport? # should this really be in viewport?
sub read_picture { sub read_picture {
my($this) = @_; my($this) = @_;
my($w,$h) = @{$this}{qw/Width Height/}; my($w,$h) = @{$this}{qw/Width Height/};
my $res = PDL->zeroes(PDL::byte,3,$w,$h); my $res = PDL->zeroes(PDL::byte,3,$w,$h);
glPixelStorei(GL_UNPACK_ALIGNMENT,1); glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glPixelStorei(GL_PACK_ALIGNMENT,1); glPixelStorei(GL_PACK_ALIGNMENT,1);
glReadPixels_s(0,0,$w,$h,GL_RGB,GL_UNSIGNED_BYTE,$res->get_dataref); glReadPixels_s(0,0,$w,$h,GL_RGB,GL_UNSIGNED_BYTE,$res->get_dataref);
skipping to change at line 763 skipping to change at line 709
} }
###################################################################### ######################################################################
###################################################################### ######################################################################
# EVENT HANDLER MINIPACKAGE FOLLOWS! # EVENT HANDLER MINIPACKAGE FOLLOWS!
package PDL::Graphics::TriD::EventHandler; package PDL::Graphics::TriD::EventHandler;
use OpenGL qw( use OpenGL qw(
ConfigureNotify MotionNotify DestroyNotify ConfigureNotify MotionNotify DestroyNotify
ButtonPress ButtonRelease Button1Mask Button2Mask Button3Mask ButtonPress ButtonRelease Button1Mask Button2Mask Button3Mask Button4Mask
); );
use PDL::Graphics::OpenGL::Perl::OpenGL; use PDL::Graphics::OpenGL::Perl::OpenGL;
use fields qw/X Y Buttons VP/; use fields qw/X Y Buttons VP/;
use strict;
sub new { sub new {
my $class = shift; my $class = shift;
my $vp = shift; my $vp = shift;
no strict 'refs';
my $self = fields::new($class); my $self = fields::new($class);
$self->{X} = -1; $self->{X} = -1;
$self->{Y} = -1; $self->{Y} = -1;
$self->{Buttons} = []; $self->{Buttons} = [];
$self->{VP} = $vp; $self->{VP} = $vp;
$self; $self;
} }
sub event { sub event {
my($this,$type,@args) = @_; my($this,$type,@args) = @_;
print "EH: ",ref($this)," $type (",join(",",@args),")\n" if($PDL::Graphics::Tr iD::verbose); print "EH: ",ref($this)," $type (",join(",",@args),")\n" if($PDL::Graphics::Tr iD::verbose);
my $retval; my $retval;
if($type == MotionNotify) { if($type == MotionNotify) {
my $but = -1; my $but = -1;
SWITCH: { SWITCH: {
$but = 0, last SWITCH if ($args[0] & (Button1Mask)); $but = 0, last SWITCH if ($args[0] & (Button1Mask));
$but = 1, last SWITCH if ($args[0] & (Button2Mask)); $but = 1, last SWITCH if ($args[0] & (Button2Mask));
$but = 2, last SWITCH if ($args[0] & (Button3Mask)); $but = 2, last SWITCH if ($args[0] & (Button3Mask));
$but = 3, last SWITCH if ($args[0] & (Button4Mask));
print "No button pressed...\n" if($PDL::Graphics::TriD::verbose); print "No button pressed...\n" if($PDL::Graphics::TriD::verbose);
goto NOBUT; goto NOBUT;
} }
print "MOTION $but $args[0]\n" if($PDL::Graphics::TriD::verbose); print "MOTION $but $args[0]\n" if($PDL::Graphics::TriD::verbose);
if($this->{Buttons}[$but]) { if($this->{Buttons}[$but]) {
if($this->{VP}->{Active}){ if($this->{VP}->{Active}){
print "calling ".($this->{Buttons}[$but])."->mouse_moved ($this ->{X},$this->{Y},$args[1],$args[2])...\n" if($PDL::Graphics::TriD::verbose); print "calling ".($this->{Buttons}[$but])."->mouse_moved ($this ->{X},$this->{Y},$args[1],$args[2])...\n" if($PDL::Graphics::TriD::verbose);
$retval = $this->{Buttons}[$but]->mouse_moved( $retval = $this->{Buttons}[$but]->mouse_moved(
$this->{X},$this- >{Y}, $this->{X},$this- >{Y},
$args[1],$args[2] ); $args[1],$args[2] );
skipping to change at line 866 skipping to change at line 810
gluOrtho2D(0,$vp->{W},0,$vp->{H}); gluOrtho2D(0,$vp->{W},0,$vp->{H});
glLineWidth(4); glLineWidth(4);
glColor3f(1,1,1); glColor3f(1,1,1);
gl_line_strip_nc($pts); gl_line_strip_nc($pts);
glLineWidth(1); glLineWidth(1);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} }
sub do_perspective { sub do_perspective {
my($this) = @_; my($this) = @_;
print "do_perspective ",$this->{W}," ",$this->{H} ,"\n" if($PDL::Graphics ::TriD::verbose); print "do_perspective ",$this->{W}," ",$this->{H} ,"\n" if $PDL::Graphics ::TriD::verbose;
print Carp::longmess() if $PDL::Graphics::TriD::verbose>1; print Carp::longmess() if $PDL::Graphics::TriD::verbose>1;
unless($this->{W}>0 and $this->{H}>0) {return;} unless($this->{W}>0 and $this->{H}>0) {return;}
$this->{AspectRatio} = (1.0*$this->{W})/$this->{H}; $this->{AspectRatio} = (1.0*$this->{W})/$this->{H};
glViewport($this->{X0},$this->{Y0},$this->{W},$this->{H}); glViewport($this->{X0},$this->{Y0},$this->{W},$this->{H});
$this->highlight() if($this->{Active}); $this->highlight if $this->{Active};
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(40.0, $this->{AspectRatio} , 0.1, 200000.0); gluPerspective(40.0, $this->{AspectRatio} , 0.1, 200000.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity (); glLoadIdentity ();
} }
############### ###############
# #
# Because of the way GL does texturing, this must be the very last thing # Because of the way GL does texturing, this must be the very last thing
 End of changes. 55 change blocks. 
297 lines changed or deleted 235 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)