Skip to content

Commit ef53c9f

Browse files
committed
GL actually implement materials, set default to GL defaults
1 parent eafde32 commit ef53c9f

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ $PDL::Graphics::TriD::verbose //= 0;
1212
PDL::Graphics::TriD::Material;
1313
use OpenGL::Modern qw(
1414
glMaterialfv_p
15-
GL_FRONT_AND_BACK GL_SHININESS GL_SPECULAR GL_AMBIENT GL_DIFFUSE
15+
GL_FRONT_AND_BACK GL_SHININESS GL_SPECULAR GL_AMBIENT GL_DIFFUSE GL_EMISSION
1616
);
1717
sub togl {
1818
my $this = shift;
1919
glMaterialfv_p(GL_FRONT_AND_BACK,GL_SHININESS,$this->{Shine});
2020
glMaterialfv_p(GL_FRONT_AND_BACK,GL_SPECULAR,@{$this->{Specular}});
2121
glMaterialfv_p(GL_FRONT_AND_BACK,GL_AMBIENT,@{$this->{Ambient}});
2222
glMaterialfv_p(GL_FRONT_AND_BACK,GL_DIFFUSE,@{$this->{Diffuse}});
23+
glMaterialfv_p(GL_FRONT_AND_BACK,GL_EMISSION,@{$this->{Emission}});
2324
}
2425
}
2526

@@ -880,6 +881,7 @@ sub display {
880881
print "VALID1 $vp\n" if $PDL::Graphics::TriD::verbose;
881882
$vp->{IsValid} = 1;
882883
}
884+
$vp->{DefMaterial}->togl;
883885
$vp->togl;
884886
glMatrixMode(GL_MODELVIEW);
885887
glPopMatrix();

lib/PDL/Graphics/TriD/Logo.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,12 @@ sub new {
465465
bless {
466466
Points => $POINTS->copy,
467467
Index => $FACES->copy,
468-
Material => PDL::Graphics::TriD::Material->new(
468+
Material => PDL::Graphics::TriD::Material->new({
469469
Shine => 0.212766,
470-
Specular =>[0.753217,0.934416,1],
471-
Ambient =>[0,0,0],
472-
Diffuse =>[0.09855,0.153113,0.191489],
473-
Emissive =>[0, 0, 0]),
470+
Specular =>[0.753217,0.934416,1,1],
471+
Ambient =>[0,0,0,1],
472+
Diffuse =>[0.09855,0.153113,0.191489,1],
473+
Emission =>[0, 0, 0, 1]}),
474474
Pos => $pos // [0,1.2,0],
475475
Size => $size // 0.1,
476476
}, $type;

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,13 @@ sub new {
360360
package # hide from PAUSE
361361
PDL::Graphics::TriD::Material;
362362
use base qw/PDL::Graphics::TriD::Object/;
363-
use fields qw(Shine Specular Ambient Diffuse Emissive);
363+
use fields qw(Shine Specular Ambient Diffuse Emission);
364364
sub get_valid_options { +{
365-
Shine => 40,
366-
Specular => [1,1,0.3,0],
367-
Ambient => [0.3,1,1,0],
368-
Diffuse => [1,0.3,1,0],
369-
Emissive => [0,0,0],
365+
Shine => 0,
366+
Specular => [0,0,0,1],
367+
Ambient => [0.2,0.2,0.2,1],
368+
Diffuse => [0.8,0.8,0.8,1],
369+
Emission => [0,0,0,1],
370370
}}
371371
sub new {
372372
my $options = ref($_[-1]) eq 'HASH' ? pop : $_[0]->get_valid_options;

0 commit comments

Comments
 (0)