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.91 by root, Wed Apr 12 23:15:39 2006 UTC vs.
Revision 1.95 by root, Thu Apr 13 23:31:43 2006 UTC

1454} 1454}
1455 1455
1456sub draw { 1456sub draw {
1457 my ($self) = @_; 1457 my ($self) = @_;
1458 1458
1459 $self->{need_update}++;#d#
1459 if (delete $self->{need_update}) { 1460 if (delete $self->{need_update}) {
1460 glNewList $self->{list}, GL_COMPILE; 1461 glNewList $self->{list}, GL_COMPILE;
1461 1462
1462 my $mx = $::CONN->{mapx};
1463 my $my = $::CONN->{mapy};
1464
1465 my $map = $::CONN->{map};
1466
1467 my ($xofs, $yofs);
1468
1469 my $sw = 1 + int $::WIDTH / 32; 1463 my $sw = int $::WIDTH / 32;
1470 my $sh = 1 + int $::HEIGHT / 32; 1464 my $sh = int $::HEIGHT / 32;
1471 1465
1472 if ($::CONN->{mapw} > $sw) { 1466 if ($::MAP) {
1473 $xofs = $mx + ($::CONN->{mapw} - $sw) * 0.5; 1467 my ($w, $h, $data) = $::MAP->draw (0, 0, $sw, $sh);
1474 } else {
1475 $xofs = $self->{xofs} = min $mx, max $mx + $::CONN->{mapw} - $sw + 1, $self->{xofs};
1476 }
1477 1468
1478 if ($::CONN->{maph} > $sh) { 1469 if ($::CFG->{fow_enable}) {
1479 $yofs = $my + ($::CONN->{maph} - $sh) * 0.5; 1470 if ($::CFG->{fow_smooth}) { # smooth fog of war
1480 } else { 1471 glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER;
1481 $yofs = $self->{yofs} = min $my, max $my + $::CONN->{maph} - $sh + 1, $self->{yofs}; 1472 glConvolutionFilter2D
1482 } 1473 GL_CONVOLUTION_2D,
1483 1474 GL_ALPHA,
1484 glEnable GL_TEXTURE_2D; 1475 3, 3,
1485 glEnable GL_BLEND; 1476 GL_ALPHA, GL_FLOAT,
1486 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1477 pack "f*",
1487 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1478 0.1, 0.1, 0.1,
1488 glColor 1, 1, 1, 1; 1479 0.1, 0.2, 0.1,
1489 1480 0.1, 0.1, 0.1,
1490 my $sw4 = ($sw + 3) & ~3;
1491 my $darkness = "\x00" x ($sw4 * $sh);
1492
1493 for my $x (0 .. $sw - 1) {
1494 my $row = $map->[$x + $xofs];
1495 for my $y (0 .. $sh - 1) {
1496
1497 my $cell = $row->[$y + $yofs]
1498 or next; 1481 ;
1499 1482 glEnable GL_CONVOLUTION_2D;
1500 my $dark = $cell->[0];
1501 if ($dark < 0) {
1502 substr $darkness, $y * $sw4 + $x, 1, chr 224;
1503 } else {
1504 substr $darkness, $y * $sw4 + $x, 1, chr 255 - $dark;
1505 } 1483 }
1506 1484
1507 for my $num (grep $_, @$cell[1,2,3]) { 1485 my $tex = new CFClient::Texture
1508 my $tex = $::CONN->{face}[$num]{texture} || next; 1486 w => $w,
1509 1487 h => $h,
1510 my ($w, $h) = @$tex{qw(w h)}; 1488 data => $data,
1489 internalformat => GL_ALPHA,
1490 format => GL_ALPHA;
1511 1491
1512 $tex->draw_quad (($x + 1) * 32 - $w, ($y + 1) * 32 - $h, $w, $h); 1492 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
1513 } 1493
1494 glEnable GL_BLEND;
1495 glEnable GL_TEXTURE_2D;
1496 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1497
1498 glColor +($::CFG->{fow_intensity}) x 3, 1;
1499 $tex->draw_quad (0, 0, $w * 32, $h * 32);
1500
1501 glDisable GL_TEXTURE_2D;
1502 glDisable GL_BLEND;
1514 } 1503 }
1515 } 1504 }
1516
1517# if (1) { # higher quality darkness
1518# $lighting =~ s/(.)/$1$1$1/gs;
1519# my $pb = new_from_data Gtk2::Gdk::Pixbuf $lighting, "rgb", 0, 8, $sw4, $sh, $sw4 * 3;
1520#
1521# $pb = $pb->scale_simple ($sw4 * 0.5, $sh * 0.5, "bilinear");
1522#
1523# $lighting = $pb->get_pixels;
1524# $lighting =~ s/(.)../$1/gs;
1525# }
1526
1527 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1528
1529 if ($::CFG->{fow_smooth}) { # smooth fog of war
1530 my @conv = (
1531 0.05, 0.05, 0.05,
1532 0.05, 0.60, 0.05,
1533 0.05, 0.05, 0.05,
1534 );
1535 CFClient::glConvolutionParameteri GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_REPLICATE_BORDER;
1536 CFClient::glConvolutionFilter2D GL_CONVOLUTION_2D,
1537 GL_ALPHA, 3, 3, GL_ALPHA, GL_FLOAT,
1538 pack "f*", @conv;
1539 glEnable GL_CONVOLUTION_2D;
1540 }
1541
1542 $darkness = new CFClient::Texture
1543 w => $sw4,
1544 h => $sh,
1545 data => $darkness,
1546 internalformat => GL_ALPHA,
1547 format => GL_ALPHA;
1548
1549 glColor +($::CFG->{fow_intensity}) x 3, 1;
1550 $darkness->draw_quad (0, 0, $sw4 * 32, $sh * 32);
1551
1552 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
1553
1554 glDisable GL_TEXTURE_2D;
1555 glDisable GL_BLEND;
1556 1505
1557 glEndList; 1506 glEndList;
1558 } 1507 }
1559 1508
1560 glCallList $self->{list}; 1509 glCallList $self->{list};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines