… | |
… | |
499 | |
499 | |
500 | $self->{fow_texture} = new DC::Texture |
500 | $self->{fow_texture} = new DC::Texture |
501 | w => $w, |
501 | w => $w, |
502 | h => $h, |
502 | h => $h, |
503 | data => $data, |
503 | data => $data, |
504 | internalformat => GL_ALPHA, |
504 | internalformat => GL_INTENSITY, |
505 | format => GL_ALPHA; |
505 | format => GL_LUMINANCE; |
506 | } else { |
506 | } else { |
507 | delete $self->{fow_texture}; |
507 | delete $self->{fow_texture}; |
508 | } |
508 | } |
509 | |
509 | |
510 | glNewList ($self->{list} ||= glGenList); |
510 | glNewList ($self->{list} ||= glGenList); |
… | |
… | |
521 | |
521 | |
522 | #d#glTranslate -$self->{sdx}, -$self->{sdy}; # anchor fow at player |
522 | #d#glTranslate -$self->{sdx}, -$self->{sdy}; # anchor fow at player |
523 | glScale $self->{tilesize}, $self->{tilesize}; |
523 | glScale $self->{tilesize}, $self->{tilesize}; |
524 | |
524 | |
525 | if (my $tex = $self->{fow_texture}) { |
525 | if (my $tex = $self->{fow_texture}) { |
526 | glEnable GL_TEXTURE_2D; |
|
|
527 | glEnable GL_BLEND; |
|
|
528 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
|
|
529 | glBlendEquation GL_FUNC_REVERSE_SUBTRACT; |
|
|
530 | glBlendFunc GL_ONE, GL_ZERO; |
|
|
531 | |
|
|
532 | my $a1 = 0.9; |
|
|
533 | |
|
|
534 | if (0 && $self->{last_fow_texture}) { |
526 | if (0 && $self->{last_fow_texture}) { |
535 | my $d1 = ($self->{sdx} ** 2 + $self->{sdy} ** 2) ** 0.5; |
527 | my $d1 = ($self->{sdx} ** 2 + $self->{sdy} ** 2) ** 0.5; |
536 | my $d2 = ($self->{ldx} ** 2 + $self->{ldy} ** 2) ** 0.5; |
528 | my $d2 = ($self->{ldx} ** 2 + $self->{ldy} ** 2) ** 0.5; |
537 | |
529 | |
538 | if ($d1 * $d2) { |
530 | if ($d1 * $d2) { |
539 | my $a2 = $d1 / $d2; |
531 | my $a2 = $d1 / $d2; |
540 | |
|
|
541 | $a1 = 1 - $a2; |
532 | my $a1 = 1 - $a2; |
542 | |
533 | |
543 | #$a1 *= 0.9; |
534 | #$a1 *= 0.9; |
544 | #$a2 *= 0.9; |
535 | #$a2 *= 0.9; |
545 | |
536 | |
546 | printf "%4g %4g %4g %4g\n", $d1, $d2, $a1, $a2;#d# |
537 | printf "%8g %8g %8g %8g\n", $d1, $d2, $a1, $a2;#d# |
547 | |
538 | |
548 | #$a1 = 1 - (1-$a1) * 0.707; |
539 | #$a1 = 1 - (1-$a1) * 0.707; |
549 | #$a2 = 1 - (1-$a2) * 0.707; |
540 | #$a2 = 1 - (1-$a2) * 0.707; |
550 | |
541 | |
551 | glColor 1,0,0,1; |
542 | glColor 1,0,0,1; |
… | |
… | |
554 | glVertex 11 + $sdx_t, 10; |
545 | glVertex 11 + $sdx_t, 10; |
555 | glVertex 11 + $sdx_t, 11; |
546 | glVertex 11 + $sdx_t, 11; |
556 | glVertex 10 + $sdx_t, 11; |
547 | glVertex 10 + $sdx_t, 11; |
557 | glEnd; |
548 | glEnd; |
558 | |
549 | |
|
|
550 | if(0){ |
|
|
551 | glBlendFunc GL_ZERO, GL_DST_COLOR; |
559 | glColor +($::CFG->{fow_intensity}) x 3, $a2; |
552 | glColor +($::CFG->{fow_intensity}) x 3, $a2; |
560 | glPushMatrix; |
553 | glPushMatrix; |
561 | glTranslate $sdx_t, $sdy_t; # anchor at player |
554 | glTranslate $sdx_t, $sdy_t; # anchor at player |
562 | glTranslate $self->{ldx} / -$tilesize, $self->{ldy} / -$tilesize; |
555 | glTranslate $self->{ldx} / -$tilesize, $self->{ldy} / -$tilesize; |
563 | glScale 1/3, 1/3; |
556 | glScale 1/3, 1/3; |
564 | $self->{last_fow_texture}->draw_quad_alpha (0, 0); |
557 | $self->{last_fow_texture}->draw_quad_alpha (0, 0); |
565 | glPopMatrix; |
558 | glPopMatrix; |
|
|
559 | } |
566 | } else { |
560 | } else { |
567 | delete $self->{last_fow_texture}; |
561 | delete $self->{last_fow_texture}; |
568 | } |
562 | } |
|
|
563 | } else { |
|
|
564 | DC::Texture::draw_fow_texture |
|
|
565 | $::CFG->{fow_intensity}, |
|
|
566 | @{$self->{fow_texture}}{qw(name s t w h)}; |
|
|
567 | #d#glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); # anchor at player |
569 | } |
568 | } |
570 | |
|
|
571 | glColor +($::CFG->{fow_intensity}) x 3, $a1; |
|
|
572 | glPushMatrix; |
|
|
573 | #d#glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); # anchor at player |
|
|
574 | glScale 1/3, 1/3; |
|
|
575 | $self->{fow_texture}->draw_quad_alpha (0, 0); |
|
|
576 | glPopMatrix; |
|
|
577 | |
|
|
578 | glBlendEquation GL_FUNC_ADD; |
|
|
579 | glDisable GL_TEXTURE_2D; |
|
|
580 | glDisable GL_BLEND; |
|
|
581 | } |
569 | } |
582 | |
570 | |
583 | if ($self->{magicmap}) { |
571 | if ($self->{magicmap}) { |
584 | my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; |
572 | my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; |
585 | |
573 | |