… | |
… | |
564 | } |
564 | } |
565 | } |
565 | } |
566 | |
566 | |
567 | void |
567 | void |
568 | draw (CFClient::Map self, int x0, int y0, int sw, int sh) |
568 | draw (CFClient::Map self, int x0, int y0, int sw, int sh) |
569 | CODE: |
569 | PPCODE: |
570 | { |
570 | { |
|
|
571 | int sw4 = (sw + 3) & ~3; |
|
|
572 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
|
|
573 | uint8_t *darkness = SvPVX (darkness_sv); |
|
|
574 | |
|
|
575 | SvPOK_only (darkness_sv); |
|
|
576 | SvCUR_set (darkness_sv, sw4 * sh); |
|
|
577 | |
571 | int vx = self->vx = self->w >= sw |
578 | int vx = self->vx = self->w >= sw |
572 | ? self->x + (self->w - sw) / 2 |
579 | ? self->x + (self->w - sw) / 2 |
573 | : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); |
580 | : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); |
574 | |
581 | |
575 | int vy = self->vy = self->h >= sh |
582 | int vy = self->vy = self->h >= sh |
… | |
… | |
597 | |
604 | |
598 | for (x = 0; x < sw; x++) |
605 | for (x = 0; x < sw; x++) |
599 | if (row->c0 <= x + vx && x + vx < row->c1) |
606 | if (row->c0 <= x + vx && x + vx < row->c1) |
600 | { |
607 | { |
601 | mapcell *cell = row->col + (x + vx - row->c0); |
608 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
609 | |
|
|
610 | darkness[y * sw4 + x] = cell->darkness < 0 |
|
|
611 | ? 224 |
|
|
612 | : 255 - cell->darkness; |
|
|
613 | |
602 | uint16_t face = cell->face [z]; |
614 | uint16_t face = cell->face [z]; |
603 | |
615 | |
604 | if (face) |
616 | if (face) |
605 | { |
617 | { |
606 | mapface tex = self->face [face]; |
618 | mapface tex = self->face [face]; |
… | |
… | |
623 | } |
635 | } |
624 | } |
636 | } |
625 | } |
637 | } |
626 | |
638 | |
627 | glEnd (); |
639 | glEnd (); |
628 | } |
|
|
629 | |
640 | |
|
|
641 | EXTEND (SP, 3); |
|
|
642 | PUSHs (sv_2mortal (newSViv (sw4))); |
|
|
643 | PUSHs (sv_2mortal (newSViv (sh))); |
|
|
644 | PUSHs (darkness_sv); |
|
|
645 | |
|
|
646 | glDisable (GL_TEXTURE_2D); |
|
|
647 | glDisable (GL_BLEND); |
|
|
648 | } |
|
|
649 | |