--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/13 23:07:57 1.94 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/13 23:31:43 1.95 @@ -1463,94 +1463,44 @@ my $sw = int $::WIDTH / 32; my $sh = int $::HEIGHT / 32; - $::MAP->draw (0, 0, $sw, $sh) if $::MAP; - - if (0) { + if ($::MAP) { + my ($w, $h, $data) = $::MAP->draw (0, 0, $sw, $sh); - my $mx = $::CONN->{mapx}; - my $my = $::CONN->{mapy}; - - my $map = $::CONN->{map}; - - my ($xofs, $yofs); - - my $sw = 1 + int $::WIDTH / 32; - my $sh = 1 + int $::HEIGHT / 32; - - if ($::CONN->{mapw} > $sw) { - $xofs = $mx + ($::CONN->{mapw} - $sw) * 0.5; - } else { - $xofs = $self->{xofs} = min $mx, max $mx + $::CONN->{mapw} - $sw + 1, $self->{xofs}; - } - - if ($::CONN->{maph} > $sh) { - $yofs = $my + ($::CONN->{maph} - $sh) * 0.5; - } else { - $yofs = $self->{yofs} = min $my, max $my + $::CONN->{maph} - $sh + 1, $self->{yofs}; - } - - glEnable GL_TEXTURE_2D; - glEnable GL_BLEND; - glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; - glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; - glColor 1, 1, 1, 1; - - my $sw4 = ($sw + 3) & ~3; - my $darkness = "\x00" x ($sw4 * $sh); - - for my $x (0 .. $sw - 1) { - my $row = $map->[$x + $xofs]; - for my $y (0 .. $sh - 1) { - - my $cell = $row->[$y + $yofs] - or next; - - my $dark = $cell->[0]; - if ($dark < 0) { - substr $darkness, $y * $sw4 + $x, 1, chr 224; - } else { - substr $darkness, $y * $sw4 + $x, 1, chr 255 - $dark; - } - - for my $num (grep $_, @$cell[1,2,3]) { - my $tex = $::CONN->{face}[$num]{texture} || next; - - my ($w, $h) = @$tex{qw(w h)}; - - $tex->draw_quad (($x + 1) * 32 - $w, ($y + 1) * 32 - $h, $w, $h); + if ($::CFG->{fow_enable}) { + if ($::CFG->{fow_smooth}) { # smooth fog of war + glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; + glConvolutionFilter2D + GL_CONVOLUTION_2D, + GL_ALPHA, + 3, 3, + GL_ALPHA, GL_FLOAT, + pack "f*", + 0.1, 0.1, 0.1, + 0.1, 0.2, 0.1, + 0.1, 0.1, 0.1, + ; + glEnable GL_CONVOLUTION_2D; } - } - } - glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; + my $tex = new CFClient::Texture + w => $w, + h => $h, + data => $data, + internalformat => GL_ALPHA, + format => GL_ALPHA; + + glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; + + glEnable GL_BLEND; + glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; - if ($::CFG->{fow_smooth}) { # smooth fog of war - my @conv = ( - 0.1, 0.1, 0.1, - 0.1, 0.2, 0.1, - 0.1, 0.1, 0.1, - ); - glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; - glConvolutionFilter2D GL_CONVOLUTION_2D, - GL_ALPHA, 3, 3, GL_ALPHA, GL_FLOAT, - pack "f*", @conv; - glEnable GL_CONVOLUTION_2D; - } + glColor +($::CFG->{fow_intensity}) x 3, 1; + $tex->draw_quad (0, 0, $w * 32, $h * 32); - $darkness = new CFClient::Texture - w => $sw4, - h => $sh, - data => $darkness, - internalformat => GL_ALPHA, - format => GL_ALPHA; - - glColor +($::CFG->{fow_intensity}) x 3, 1; - $darkness->draw_quad (0, 0, $sw4 * 32, $sh * 32); - - glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; - - glDisable GL_TEXTURE_2D; - glDisable GL_BLEND; + glDisable GL_TEXTURE_2D; + glDisable GL_BLEND; + } } glEndList;