From: Lars Stoltenow Date: Sat, 17 Oct 2009 18:26:11 +0200 Subject: [PATCH] fix textures to work on GLSL capable systems missed a translation for abs(), and the fact that GLSL doesn't treat boolean values as numbers like Perl does. --- lib/Dizzy/Perl2GLSL.pm | 2 +- lib/Dizzy/Textures/Default.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Dizzy/Perl2GLSL.pm b/lib/Dizzy/Perl2GLSL.pm index 3d0b350..982aeed 100644 --- a/lib/Dizzy/Perl2GLSL.pm +++ b/lib/Dizzy/Perl2GLSL.pm @@ -168,7 +168,7 @@ sub make_code { } elsif ($op[0] eq "negate") { return "-(" . make_code($op[1], $symtab, $in_sub) . ")"; - } elsif ($op[0] =~ /^(sqrt|sin|cos|pow|log)$/) { + } elsif ($op[0] =~ /^(sqrt|sin|cos|pow|log|abs)$/) { # builtin functions return "$op[0](" . join(", ", map { make_code($_, $symtab, $in_sub) } @op[1..$#op]) . ")"; } else { diff --git a/lib/Dizzy/Textures/Default.pm b/lib/Dizzy/Textures/Default.pm index 9a090df..2eb3a06 100644 --- a/lib/Dizzy/Textures/Default.pm +++ b/lib/Dizzy/Textures/Default.pm @@ -144,7 +144,7 @@ my @textures = ( function => sub { my ($x, $y) = @_; my $dist = sqrt($x ** 2 + $y ** 2); - return abs($dist - 0.5) < 0.1; + return abs($dist - 0.5) < 0.1 ? 1.0 : 0.0; }, }, ); -- 1.6.4.msysgit.0