… | |
… | |
96 | |
96 | |
97 | my $self = bless { |
97 | my $self = bless { |
98 | x => 0, |
98 | x => 0, |
99 | y => 0, |
99 | y => 0, |
100 | z => 0, |
100 | z => 0, |
101 | w => -1, |
|
|
102 | h => -1, |
|
|
103 | @_ |
101 | @_ |
104 | }, $class; |
102 | }, $class; |
105 | |
103 | |
106 | for (keys %$self) { |
104 | for (keys %$self) { |
107 | if (/^connect_(.*)$/) { |
105 | if (/^connect_(.*)$/) { |
… | |
… | |
110 | } |
108 | } |
111 | |
109 | |
112 | $self |
110 | $self |
113 | } |
111 | } |
114 | |
112 | |
|
|
113 | sub show { |
|
|
114 | my ($self) = @_; |
|
|
115 | |
|
|
116 | return if $self->{parent}; |
|
|
117 | |
|
|
118 | $CFClient::UI::ROOT->add ($self); |
|
|
119 | } |
|
|
120 | |
|
|
121 | sub hide { |
|
|
122 | my ($self) = @_; |
|
|
123 | |
|
|
124 | return unless $self->{parent}; |
|
|
125 | |
|
|
126 | $self->{parent}->remove ($self); |
|
|
127 | } |
|
|
128 | |
115 | sub move { |
129 | sub move { |
116 | my ($self, $x, $y, $z) = @_; |
130 | my ($self, $x, $y, $z) = @_; |
117 | |
131 | |
118 | $self->{x} = int $x; |
132 | $self->{x} = int $x; |
119 | $self->{y} = int $y; |
133 | $self->{y} = int $y; |
… | |
… | |
141 | |
155 | |
142 | $self->{w} = $w; |
156 | $self->{w} = $w; |
143 | $self->{h} = $h; |
157 | $self->{h} = $h; |
144 | |
158 | |
145 | $self->size_allocate ($w, $h); |
159 | $self->size_allocate ($w, $h); |
|
|
160 | $self->update; |
146 | } |
161 | } |
147 | |
162 | |
148 | sub size_allocate { |
163 | sub size_allocate { |
149 | # nothing to be done |
164 | # nothing to be done |
150 | } |
165 | } |
… | |
… | |
272 | $self->{req_w} = $w; |
287 | $self->{req_w} = $w; |
273 | $self->{req_h} = $h; |
288 | $self->{req_h} = $h; |
274 | |
289 | |
275 | $self->{parent}->check_size |
290 | $self->{parent}->check_size |
276 | if $self->{parent}; |
291 | if $self->{parent}; |
277 | |
|
|
278 | $self->size_allocate ($w, $h); |
|
|
279 | $self->update; |
|
|
280 | } |
292 | } |
281 | } |
293 | } |
282 | |
294 | |
283 | sub update { |
295 | sub update { |
284 | my ($self) = @_; |
296 | my ($self) = @_; |
… | |
… | |
288 | } |
300 | } |
289 | |
301 | |
290 | sub connect { |
302 | sub connect { |
291 | my ($self, $signal, $cb) = @_; |
303 | my ($self, $signal, $cb) = @_; |
292 | |
304 | |
293 | push @{ $self->{cb}{$signal} }, $cb; |
305 | push @{ $self->{signal_cb}{$signal} }, $cb; |
294 | } |
306 | } |
295 | |
307 | |
296 | sub emit { |
308 | sub emit { |
297 | my ($self, $signal, @args) = @_; |
309 | my ($self, $signal, @args) = @_; |
298 | |
310 | |
|
|
311 | for my $cb (@{$self->{signal_cb}{$signal} || []}) { |
299 | $_->($self, @args) |
312 | $cb->($self, @args); |
300 | for @{$self->{cb}{$signal} || []}; |
313 | } |
301 | } |
314 | } |
302 | |
315 | |
303 | sub DESTROY { |
316 | sub DESTROY { |
304 | my ($self) = @_; |
317 | my ($self) = @_; |
305 | |
318 | |
… | |
… | |
385 | $self->{children} = [ |
398 | $self->{children} = [ |
386 | sort { $a->{z} <=> $b->{z} } |
399 | sort { $a->{z} <=> $b->{z} } |
387 | @{$self->{children}}, $child |
400 | @{$self->{children}}, $child |
388 | ]; |
401 | ]; |
389 | |
402 | |
390 | $self->{w} = $self->{h} = -1; |
|
|
391 | |
|
|
392 | $child->check_size; |
403 | $child->check_size; |
393 | } |
404 | } |
394 | |
405 | |
395 | sub remove { |
406 | sub remove { |
396 | my ($self, $widget) = @_; |
407 | my ($self, $child) = @_; |
397 | |
408 | |
|
|
409 | delete $child->{parent}; |
|
|
410 | |
398 | $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; |
411 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
399 | |
412 | |
400 | $self->check_size; |
413 | $self->check_size; |
401 | } |
414 | } |
402 | |
415 | |
403 | sub find_widget { |
416 | sub find_widget { |
… | |
… | |
435 | |
448 | |
436 | $class->SUPER::new (children => [$child], %arg) |
449 | $class->SUPER::new (children => [$child], %arg) |
437 | } |
450 | } |
438 | |
451 | |
439 | sub add { |
452 | sub add { |
440 | my ($self, $widget) = @_; |
453 | my ($self, $child) = @_; |
441 | |
454 | |
442 | $self->{children} = []; |
455 | $self->{children} = []; |
443 | |
456 | |
444 | $self->SUPER::add ($widget); |
457 | $self->SUPER::add ($child); |
445 | } |
458 | } |
446 | |
459 | |
447 | sub remove { |
460 | sub remove { |
448 | my ($self, $widget) = @_; |
461 | my ($self, $widget) = @_; |
449 | |
462 | |
… | |
… | |
608 | # TODO: user_x, user_y, overwrite moveto? |
621 | # TODO: user_x, user_y, overwrite moveto? |
609 | |
622 | |
610 | $class->SUPER::new ( |
623 | $class->SUPER::new ( |
611 | bg => [1, 1, 1, 1], |
624 | bg => [1, 1, 1, 1], |
612 | border_bg => [1, 1, 1, 1], |
625 | border_bg => [1, 1, 1, 1], |
613 | border => int $::FONTSIZE * 0.8, |
626 | border => 0.8, |
614 | @_ |
627 | @_ |
615 | ) |
628 | ) |
616 | } |
629 | } |
617 | |
630 | |
|
|
631 | sub border { |
|
|
632 | int $_[0]{border} * $::FONTSIZE |
|
|
633 | } |
|
|
634 | |
618 | sub size_request { |
635 | sub size_request { |
619 | my ($self) = @_; |
636 | my ($self) = @_; |
620 | |
637 | |
621 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
638 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
622 | |
639 | |
623 | my ($w, $h) = $self->SUPER::size_request; |
640 | my ($w, $h) = $self->SUPER::size_request; |
624 | |
641 | |
625 | ( |
642 | ( |
626 | $w + $self->{border} * 2, |
643 | $w + $self->border * 2, |
627 | $h + $self->{border} * 2, |
644 | $h + $self->border * 2, |
628 | ) |
645 | ) |
629 | } |
646 | } |
630 | |
647 | |
631 | sub size_allocate { |
648 | sub size_allocate { |
632 | my ($self, $w, $h) = @_; |
649 | my ($self, $w, $h) = @_; |
633 | |
650 | |
634 | $h -= List::Util::max 0, $self->{border} * 2; |
651 | $h -= List::Util::max 0, $self->border * 2; |
635 | $w -= List::Util::max 0, $self->{border} * 2; |
652 | $w -= List::Util::max 0, $self->border * 2; |
636 | |
653 | |
637 | $self->child->configure ($self->{border}, $self->{border}, $w, $h); |
654 | $self->child->configure ($self->border, $self->border, $w, $h); |
638 | } |
655 | } |
639 | |
656 | |
640 | sub button_down { |
657 | sub button_down { |
641 | my ($self, $ev, $x, $y) = @_; |
658 | my ($self, $ev, $x, $y) = @_; |
642 | |
659 | |
|
|
660 | my $border = $self->border; |
|
|
661 | |
643 | if ($x < $self->{w} && $x >= $self->{w} - $self->{border} |
662 | if ($x < $self->{w} && $x >= $self->{w} - $border |
644 | && $y < $self->{h} && $y >= $self->{h} - $self->{border}) { |
663 | && $y < $self->{h} && $y >= $self->{h} - $border) { |
645 | |
664 | |
646 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
665 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
647 | my ($bw, $bh) = ($self->{w}, $self->{h}); |
666 | my ($bw, $bh) = ($self->{w}, $self->{h}); |
648 | |
667 | |
649 | $self->{motion} = sub { |
668 | $self->{motion} = sub { |
… | |
… | |
655 | $self->{user_h} = $bh + $y - $oy; |
674 | $self->{user_h} = $bh + $y - $oy; |
656 | $self->check_size; |
675 | $self->check_size; |
657 | }; |
676 | }; |
658 | |
677 | |
659 | } elsif ($x >= 0 && $x < $self->{w} |
678 | } elsif ($x >= 0 && $x < $self->{w} |
660 | && $y >= 0 && $y < $self->{border}) { |
679 | && $y >= 0 && $y < $border) { |
661 | |
680 | |
662 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
681 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
663 | my ($bx, $by) = ($self->{x}, $self->{y}); |
682 | my ($bx, $by) = ($self->{x}, $self->{y}); |
664 | |
683 | |
665 | $self->{motion} = sub { |
684 | $self->{motion} = sub { |
… | |
… | |
694 | glEnable GL_BLEND; |
713 | glEnable GL_BLEND; |
695 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
714 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
696 | glEnable GL_TEXTURE_2D; |
715 | glEnable GL_TEXTURE_2D; |
697 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
716 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
698 | |
717 | |
|
|
718 | my $border = $self->border; |
|
|
719 | |
699 | glColor @{ $self->{border_bg} }; |
720 | glColor @{ $self->{border_bg} }; |
700 | $tex[1]->draw_quad (0, 0, $w, $self->{border}); |
721 | $tex[1]->draw_quad (0, 0, $w, $border); |
701 | $tex[3]->draw_quad (0, $self->{border}, $self->{border}, $ch); |
722 | $tex[3]->draw_quad (0, $border, $border, $ch); |
702 | $tex[2]->draw_quad ($w - $self->{border}, $self->{border}, $self->{border}, $ch); |
723 | $tex[2]->draw_quad ($w - $border, $border, $border, $ch); |
703 | $tex[4]->draw_quad (0, $h - $self->{border}, $w, $self->{border}); |
724 | $tex[4]->draw_quad (0, $h - $border, $w, $border); |
704 | |
725 | |
705 | my $bg = $tex[0]; |
726 | my $bg = $tex[0]; |
706 | |
727 | |
707 | # TODO: repeat texture not scale |
728 | # TODO: repeat texture not scale |
708 | my $rep_x = $cw / $bg->{w}; |
729 | my $rep_x = $cw / $bg->{w}; |
… | |
… | |
711 | glColor @{ $self->{bg} }; |
732 | glColor @{ $self->{bg} }; |
712 | |
733 | |
713 | $bg->{s} = $rep_x; |
734 | $bg->{s} = $rep_x; |
714 | $bg->{t} = $rep_y; |
735 | $bg->{t} = $rep_y; |
715 | $bg->{wrap_mode} = 1; |
736 | $bg->{wrap_mode} = 1; |
716 | $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); |
737 | $bg->draw_quad ($border, $border, $cw, $ch); |
717 | |
738 | |
718 | glDisable GL_TEXTURE_2D; |
739 | glDisable GL_TEXTURE_2D; |
719 | glDisable GL_BLEND; |
740 | glDisable GL_BLEND; |
720 | |
741 | |
721 | $self->child->draw; |
742 | $self->child->draw; |
… | |
… | |
743 | sub add { |
764 | sub add { |
744 | my ($self, $x, $y, $child) = @_; |
765 | my ($self, $x, $y, $child) = @_; |
745 | |
766 | |
746 | $child->set_parent ($self); |
767 | $child->set_parent ($self); |
747 | $self->{children}[$y][$x] = $child; |
768 | $self->{children}[$y][$x] = $child; |
748 | |
|
|
749 | $self->{w} = $self->{h} = -1; |
|
|
750 | |
769 | |
751 | $child->check_size; |
770 | $child->check_size; |
752 | } |
771 | } |
753 | |
772 | |
754 | # TODO: move to container class maybe? send childs a signal on removal? |
773 | # TODO: move to container class maybe? send childs a signal on removal? |
… | |
… | |
987 | sub new { |
1006 | sub new { |
988 | my ($class, %arg) = @_; |
1007 | my ($class, %arg) = @_; |
989 | |
1008 | |
990 | my $self = $class->SUPER::new ( |
1009 | my $self = $class->SUPER::new ( |
991 | fg => [1, 1, 1], |
1010 | fg => [1, 1, 1], |
992 | fontsize => $::FONTSIZE, |
1011 | fontsize => 1, |
993 | text => "", |
1012 | text => "", |
994 | align => -1, |
1013 | align => -1, |
995 | valign => -1, |
1014 | valign => -1, |
996 | padding => 2, |
1015 | padding => 2, |
997 | layout => new CFClient::Layout, |
1016 | layout => new CFClient::Layout, |
… | |
… | |
1036 | |
1055 | |
1037 | sub size_request { |
1056 | sub size_request { |
1038 | my ($self) = @_; |
1057 | my ($self) = @_; |
1039 | |
1058 | |
1040 | $self->{layout}->set_width; |
1059 | $self->{layout}->set_width; |
1041 | $self->{layout}->set_height ($self->{fontsize}); |
1060 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1042 | |
1061 | |
1043 | my ($w, $h) = $self->{layout}->size; |
1062 | my ($w, $h) = $self->{layout}->size; |
1044 | |
1063 | |
1045 | ( |
1064 | ( |
1046 | $w + $self->{padding} * 2, |
1065 | $w + $self->{padding} * 2, |
… | |
… | |
1052 | my ($self, $w, $h) = @_; |
1071 | my ($self, $w, $h) = @_; |
1053 | |
1072 | |
1054 | delete $self->{texture}; |
1073 | delete $self->{texture}; |
1055 | } |
1074 | } |
1056 | |
1075 | |
1057 | sub update { |
|
|
1058 | my ($self) = @_; |
|
|
1059 | |
|
|
1060 | delete $self->{texture}; |
|
|
1061 | $self->SUPER::update; |
|
|
1062 | } |
|
|
1063 | |
|
|
1064 | sub _draw { |
1076 | sub _draw { |
1065 | my ($self) = @_; |
1077 | my ($self) = @_; |
1066 | |
1078 | |
1067 | my $tex = $self->{texture} ||= do { |
1079 | my $tex = $self->{texture} ||= do { |
1068 | $self->{layout}->set_width ($self->{w}); |
1080 | $self->{layout}->set_width ($self->{w}); |
1069 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize}); |
1081 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); |
1070 | new_from_layout CFClient::Texture $self->{layout} |
1082 | new_from_layout CFClient::Texture $self->{layout} |
1071 | }; |
1083 | }; |
1072 | |
1084 | |
1073 | glEnable GL_BLEND; |
1085 | glEnable GL_BLEND; |
1074 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1086 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
… | |
… | |
1123 | my ($self, $text) = @_; |
1135 | my ($self, $text) = @_; |
1124 | |
1136 | |
1125 | delete $self->{cur_h}; |
1137 | delete $self->{cur_h}; |
1126 | |
1138 | |
1127 | return if $self->{text} eq $text; |
1139 | return if $self->{text} eq $text; |
|
|
1140 | |
|
|
1141 | delete $self->{texture}; |
1128 | |
1142 | |
1129 | $self->{last_activity} = $::NOW; |
1143 | $self->{last_activity} = $::NOW; |
1130 | $self->{text} = $text; |
1144 | $self->{text} = $text; |
1131 | |
1145 | |
1132 | $text =~ s/./*/g if $self->{hidden}; |
1146 | $text =~ s/./*/g if $self->{hidden}; |
… | |
… | |
1494 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1508 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1495 | my $h2 = $ycut * $self->{h}; |
1509 | my $h2 = $ycut * $self->{h}; |
1496 | |
1510 | |
1497 | my $yp = 0; |
1511 | my $yp = 0; |
1498 | |
1512 | |
1499 | glBindTexture (GL_TEXTURE_2D, $t1->{name}); |
1513 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1500 | glBegin (GL_QUADS); |
1514 | glBegin GL_QUADS; |
1501 | glTexCoord (0, 0); glVertex (0 , $yp); |
1515 | glTexCoord 0 , 0; glVertex 0 , $yp; |
1502 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp + $h1); |
1516 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $yp + $h1; |
1503 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp + $h1); |
1517 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex 0 + $w, $yp + $h1; |
1504 | glTexCoord (1, 0); glVertex (0 + $w, $yp); |
1518 | glTexCoord $t1->{s}, 0; glVertex 0 + $w, $yp; |
1505 | glEnd (); |
1519 | glEnd; |
1506 | |
1520 | |
1507 | $yp += $h1; |
1521 | $yp += $h1; |
1508 | |
1522 | |
1509 | glBindTexture (GL_TEXTURE_2D, $t2->{name}); |
1523 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1510 | glBegin (GL_QUADS); |
1524 | glBegin GL_QUADS; |
1511 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp); |
1525 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $yp; |
1512 | glTexCoord (0, 1); glVertex (0 , $yp + $h2); |
1526 | glTexCoord 0 , $t2->{t}; glVertex 0 , $yp + $h2; |
1513 | glTexCoord (1, 1); glVertex (0 + $w, $yp + $h2); |
1527 | glTexCoord $t2->{s}, $t2->{t}; glVertex 0 + $w, $yp + $h2; |
1514 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp); |
1528 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex 0 + $w, $yp; |
1515 | glEnd (); |
1529 | glEnd; |
1516 | |
1530 | |
1517 | glDisable GL_BLEND; |
1531 | glDisable GL_BLEND; |
1518 | glDisable GL_TEXTURE_2D; |
1532 | glDisable GL_TEXTURE_2D; |
1519 | } |
1533 | } |
1520 | |
1534 | |
… | |
… | |
1542 | # TODO: calculations are off |
1556 | # TODO: calculations are off |
1543 | my $self = $class->SUPER::new ( |
1557 | my $self = $class->SUPER::new ( |
1544 | fg => [1, 1, 1], |
1558 | fg => [1, 1, 1], |
1545 | active_fg => [0, 0, 0], |
1559 | active_fg => [0, 0, 0], |
1546 | range => [0, 0, 100, 10], |
1560 | range => [0, 0, 100, 10], |
1547 | req_w => 40, |
1561 | req_w => 20, |
1548 | req_h => 13, |
1562 | req_h => 20, |
1549 | vertical => 0, |
1563 | vertical => 0, |
1550 | can_hover => 1, |
1564 | can_hover => 1, |
1551 | inner_pad => 5, |
1565 | inner_pad => 5, |
1552 | @_ |
1566 | @_ |
1553 | ); |
1567 | ); |
… | |
… | |
1663 | |
1677 | |
1664 | sub new { |
1678 | sub new { |
1665 | my $class = shift; |
1679 | my $class = shift; |
1666 | |
1680 | |
1667 | my $self = $class->SUPER::new ( |
1681 | my $self = $class->SUPER::new ( |
1668 | req_w => $::WIDTH / 6, |
|
|
1669 | req_h => $::HEIGHT / 6, |
|
|
1670 | fontsize => $::FONTSIZE, |
1682 | fontsize => 1, |
1671 | @_, |
1683 | @_, |
1672 | |
1684 | |
1673 | layout => (new CFClient::Layout), |
1685 | layout => (new CFClient::Layout), |
1674 | par => [], |
1686 | par => [], |
1675 | height => 0, |
1687 | height => 0, |
… | |
… | |
1696 | sub text_height { |
1708 | sub text_height { |
1697 | my ($self, $text) = @_; |
1709 | my ($self, $text) = @_; |
1698 | |
1710 | |
1699 | my $layout = $self->{layout}; |
1711 | my $layout = $self->{layout}; |
1700 | |
1712 | |
1701 | $layout->set_height ($self->{fontsize}); |
1713 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
1702 | $layout->set_width ($self->{w}); |
1714 | $layout->set_width ($self->{w}); |
1703 | $layout->set_text ($text); |
1715 | $layout->set_text ($text); |
1704 | |
1716 | |
1705 | ($layout->size)[1] |
1717 | ($layout->size)[1] |
1706 | } |
1718 | } |
… | |
… | |
1710 | |
1722 | |
1711 | $self->{need_reflow}++; |
1723 | $self->{need_reflow}++; |
1712 | $self->update; |
1724 | $self->update; |
1713 | } |
1725 | } |
1714 | |
1726 | |
1715 | sub size_request { |
|
|
1716 | my ($self) = @_; |
|
|
1717 | |
|
|
1718 | ($self->{req_w}, $self->{req_h}) |
|
|
1719 | } |
|
|
1720 | |
|
|
1721 | sub size_allocate { |
1727 | sub size_allocate { |
1722 | my ($self, $w, $h) = @_; |
1728 | my ($self, $w, $h) = @_; |
1723 | |
1729 | |
|
|
1730 | $self->SUPER::size_allocate ($w, $h); |
|
|
1731 | |
1724 | $self->{layout}->set_height ($self->{fontsize}); |
1732 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1725 | $self->{layout}->set_width ($self->{w}); |
1733 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1726 | |
1734 | |
1727 | $self->reflow; |
1735 | $self->reflow; |
1728 | $self->update; |
|
|
1729 | } |
1736 | } |
1730 | |
1737 | |
1731 | sub add_paragraph { |
1738 | sub add_paragraph { |
1732 | my ($self, $color, $text) = @_; |
1739 | my ($self, $color, $text) = @_; |
1733 | |
1740 | |
… | |
… | |
1913 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
1920 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
1914 | |
1921 | |
1915 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
1922 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
1916 | |
1923 | |
1917 | if ($::CFG->{fow_enable}) { |
1924 | if ($::CFG->{fow_enable}) { |
1918 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1925 | if ($::CFG->{fow_smooth} && $CFClient::GL_VERSION >= 1.2) { # smooth fog of war |
1919 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1926 | glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); |
1920 | glConvolutionFilter2D |
1927 | glConvolutionFilter2D ( |
1921 | GL_CONVOLUTION_2D, |
1928 | GL_CONVOLUTION_2D, |
1922 | GL_ALPHA, |
1929 | GL_ALPHA, |
1923 | 3, 3, |
1930 | 3, 3, |
1924 | GL_ALPHA, GL_FLOAT, |
1931 | GL_ALPHA, GL_FLOAT, |
1925 | pack "f*", |
1932 | pack "f*", |
1926 | 0.1, 0.1, 0.1, |
1933 | 0.1, 0.1, 0.1, |
1927 | 0.1, 0.2, 0.1, |
1934 | 0.1, 0.2, 0.1, |
1928 | 0.1, 0.1, 0.1, |
1935 | 0.1, 0.1, 0.1, |
1929 | ; |
1936 | ); |
1930 | glEnable GL_CONVOLUTION_2D; |
1937 | glEnable GL_CONVOLUTION_2D; |
1931 | } |
1938 | } |
1932 | |
1939 | |
1933 | $self->{fow_texture} = new CFClient::Texture |
1940 | $self->{fow_texture} = new CFClient::Texture |
1934 | w => $w, |
1941 | w => $w, |
… | |
… | |
1964 | $self->{mapmap_texture} = |
1971 | $self->{mapmap_texture} = |
1965 | new CFClient::Texture |
1972 | new CFClient::Texture |
1966 | w => $w, |
1973 | w => $w, |
1967 | h => $h, |
1974 | h => $h, |
1968 | data => $::MAP->mapmap ($w, $h), |
1975 | data => $::MAP->mapmap ($w, $h), |
1969 | type => GL_UNSIGNED_INT_8_8_8_8_REV; |
1976 | type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; |
1970 | |
1977 | |
1971 | $self->{mapmap_texture}->draw_quad (100, 100); |
1978 | $self->{mapmap_texture}->draw_quad (100, 100); |
1972 | |
1979 | |
1973 | glDisable GL_TEXTURE_2D; |
1980 | glDisable GL_TEXTURE_2D; |
1974 | glDisable GL_BLEND; |
1981 | glDisable GL_BLEND; |