ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.56 by root, Mon Apr 10 22:16:34 2006 UTC vs.
Revision 1.57 by root, Mon Apr 10 22:53:49 2006 UTC

797 glEnable GL_TEXTURE_2D; 797 glEnable GL_TEXTURE_2D;
798 glEnable GL_BLEND; 798 glEnable GL_BLEND;
799 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 799 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
800 800
801 my $sw4 = ($sw + 3) & ~3; 801 my $sw4 = ($sw + 3) & ~3;
802 my $lighting = "\x00" x ($sw4 * $sh); 802 my $darkness = "\x00" x ($sw4 * $sh);
803 803
804 for my $x (0 .. $sw - 1) { 804 for my $x (0 .. $sw - 1) {
805 my $row = $map->[$x + $xofs];
805 for my $y (0 .. $sh - 1) { 806 for my $y (0 .. $sh - 1) {
806 807
807 my $cell = $map->[$x + $xofs][$y + $yofs] 808 my $cell = $row->[$y + $yofs]
808 or next; 809 or next;
809 810
810 my $darkness = $cell->[0] * (1 / 255); 811 my $dark = $cell->[0];
811 if ($darkness < 0) { 812 if ($dark < 0) {
812 $darkness = $cell->[1] ? 0.1 : 0; 813 substr $darkness, $y * $sw4 + $x, 1, chr 224;
814 } else {
815 substr $darkness, $y * $sw4 + $x, 1, chr 255 - $dark;
813 } 816 }
814 substr $lighting, $y * $sw4 + $x, 1, chr 255 - $darkness * 255;
815 817
816 for my $num (grep $_, @$cell[1,2,3]) { 818 for my $num (grep $_, @$cell[1,2,3]) {
817 my $tex = $::CONN->{face}[$num]{texture} || next; 819 my $tex = $::CONN->{face}[$num]{texture} || next;
818 820
819 my $w = $tex->{width}; 821 my $w = $tex->{width};
820 my $h = $tex->{height}; 822 my $h = $tex->{height};
821 823
822 my $px = ($x + 1) * 32 - $w; 824 $tex->draw_quad (($x + 1) * 32 - $w, ($y + 1) * 32 - $h, $w, $h);
823 my $py = ($y + 1) * 32 - $h;
824
825 $tex->draw_quad ($px, $py, $w, $h);
826 } 825 }
827 } 826 }
828 } 827 }
829 828
830# if (1) { # higher quality darkness 829# if (1) { # higher quality darkness
835# 834#
836# $lighting = $pb->get_pixels; 835# $lighting = $pb->get_pixels;
837# $lighting =~ s/(.)../$1/gs; 836# $lighting =~ s/(.)../$1/gs;
838# } 837# }
839 838
839 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
840 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
841
840 $lighting = new Crossfire::Client::Texture 842 $darkness = new Crossfire::Client::Texture
841 width => $sw4, 843 width => $sw4,
842 height => $sh, 844 height => $sh,
843 data => $lighting, 845 data => $darkness,
844 internalformat => GL_ALPHA, 846 internalformat => GL_ALPHA,
845 format => GL_ALPHA; 847 format => GL_ALPHA;
846 848
847 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
848 glColor 0.45, 0.45, 0.45, 1; 849 glColor 0.45, 0.45, 0.45, 1;
849 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
850 glBindTexture GL_TEXTURE_2D, $lighting->{name};
851 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR;
852
853 $lighting->draw_quad (0, 0, $sw4 * 32, $sh * 32); 850 $darkness->draw_quad (0, 0, $sw4 * 32, $sh * 32);
854 851
855 glDisable GL_TEXTURE_2D; 852 glDisable GL_TEXTURE_2D;
856 glDisable GL_BLEND; 853 glDisable GL_BLEND;
857} 854}
858 855
926} 923}
927 924
928sub animate { 925sub animate {
929 my ($self, $interval) = @_; 926 my ($self, $interval) = @_;
930 927
931 printf "%5.2f\n", 1 / $interval;#d# 928 printf "%5.2f\n", 1 / $interval if $interval;#d#
932 929
933 $self->{time} -= $interval * $self->{speed}; 930 $self->{time} -= $interval * $self->{speed};
934 if ($self->{time} <= 0) { 931 if ($self->{time} <= 0) {
935 $self->{time} = 0; 932 $self->{time} = 0;
936 ::animation_stop $self; 933 ::animation_stop $self;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines