@@ -198,9 +198,11 @@ sub PDL::Graphics::TriD::Lattice::gdraw {
198198 } else {
199199 glShadeModel($shading == 1 ? GL_FLAT : GL_SMOOTH);
200200 my $f = ' PDL::gl_triangles' ;
201- $f .= ' _' . ($this -> {Options }{Smooth } ? ' w' : ' ' ) . ' n_mat ' if $shading > 2;
201+ $f .= ' _' . ($this -> {Options }{Smooth } ? ' w' : ' ' ) . ' n ' if $shading > 2;
202202 { no strict ' refs' ; $f = \&$f ; }
203+ if ($shading > 2) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
203204 _lattice_slice($f , $points , $this -> {Options }{Smooth } ? $this -> {VertexNormals } : (), $this -> {Colors });
205+ if ($shading > 2) { glDisable(GL_COLOR_MATERIAL); }
204206 $this -> _lattice_lines($points ) if $this -> {Options }{Lines };
205207 }
206208 if ($this -> {Options }{ShowNormals }) {
@@ -252,12 +254,14 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
252254 glShadeModel(GL_SMOOTH); # By-vertex doesn't make sense otherwise.
253255 my $f = ' PDL::gl_triangles' ;
254256 my $send_normals = $this -> {Options }{Smooth } && $this -> {Options }{Shading };
255- $f .= ' _' . ($send_normals ? ' w' : ' ' ) . ' n_mat ' if $this -> {Options }{Shading };
257+ $f .= ' _' . ($send_normals ? ' w' : ' ' ) . ' n ' if $this -> {Options }{Shading };
256258 { no strict ' refs' ; $f = \&$f ; }
257259 my $tmpn = $send_normals
258260 ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
259261 -> splitdim(1,$this -> {Faceidx }-> dim(0)) : undef ;
262+ if ($this -> {Options }{Shading }) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
260263 $f -> (map $_ -> mv(1,-1)-> dog, $faces , $send_normals ? $tmpn : (), $colours );
264+ if ($this -> {Options }{Shading }) { glDisable(GL_COLOR_MATERIAL); }
261265 if ($this -> {Options }{ShowNormals }) {
262266 die " No normals to show!" if !grep defined $this -> {$_ }, qw( FaceNormals VertexNormals) ;
263267 if (defined $this -> {VertexNormals }) {
0 commit comments