ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.30 by root, Thu Apr 13 23:07:56 2006 UTC vs.
Revision 1.36 by elmex, Fri Apr 14 11:32:21 2006 UTC

37 37
38static void 38static void
39substitute_func (FcPattern *pattern, gpointer data) 39substitute_func (FcPattern *pattern, gpointer data)
40{ 40{
41 FcPatternAddBool (pattern, FC_HINTING , 1); 41 FcPatternAddBool (pattern, FC_HINTING , 1);
42 FcPatternAddBool (pattern, FC_AUTOHINT, 1); 42 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
43} 43}
44 44
45static void 45static void
46layout_update (CFClient__Layout self) 46layout_update (CFClient__Layout self)
47{ 47{
150 if (x >= row->c0) 150 if (x >= row->c0)
151 { 151 {
152 if (x >= row->c1) 152 if (x >= row->c1)
153 break; 153 break;
154 154
155 mapcell *cell = row->col + (x - row->c0); 155 row->col[x - row->c0].darkness = -1;
156 cell->darkness = -1;
157 cell->face [2] = 0;
158 } 156 }
159 } 157 }
160} 158}
161 159
162MODULE = CFClient PACKAGE = CFClient 160MODULE = CFClient PACKAGE = CFClient
287 CODE: 285 CODE:
288 g_object_unref (self->pl); 286 g_object_unref (self->pl);
289 Safefree (self); 287 Safefree (self);
290 288
291void 289void
290set_text (CFClient::Layout self, SV *text_)
291 CODE:
292{
293 STRLEN textlen;
294 char *text = SvPVutf8 (text_, textlen);
295
296 pango_layout_set_text (self->pl, text, textlen);
297}
298
299void
292set_markup (CFClient::Layout self, SV *text_) 300set_markup (CFClient::Layout self, SV *text_)
293 CODE: 301 CODE:
294{ 302{
295 STRLEN textlen; 303 STRLEN textlen;
296 char *text = SvPVutf8 (text_, textlen); 304 char *text = SvPVutf8 (text_, textlen);
391{ 399{
392 HV *hv = (HV *)SvRV (self); 400 HV *hv = (HV *)SvRV (self);
393 double s = SvNV (*hv_fetch (hv, "s", 1, 1)); 401 double s = SvNV (*hv_fetch (hv, "s", 1, 1));
394 double t = SvNV (*hv_fetch (hv, "t", 1, 1)); 402 double t = SvNV (*hv_fetch (hv, "t", 1, 1));
395 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 403 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
404 int wrap_mode = SvIV (*hv_fetch (hv, "wrap_mode", 9, 1));
396 405
397 if (items < 5) 406 if (items < 5)
398 { 407 {
399 w = SvNV (*hv_fetch (hv, "w", 1, 1)); 408 w = SvNV (*hv_fetch (hv, "w", 1, 1));
400 h = SvNV (*hv_fetch (hv, "h", 1, 1)); 409 h = SvNV (*hv_fetch (hv, "h", 1, 1));
401 } 410 }
402 411
403 glBindTexture (GL_TEXTURE_2D, name); 412 glBindTexture (GL_TEXTURE_2D, name);
413 if (wrap_mode) {
414 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
415 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
416 }
404 glBegin (GL_QUADS); 417 glBegin (GL_QUADS);
405 glTexCoord2d (0, 0); glVertex2d (x , y ); 418 glTexCoord2d (0, 0); glVertex2d (x , y );
406 glTexCoord2d (0, t); glVertex2d (x , y + h); 419 glTexCoord2d (0, t); glVertex2d (x , y + h);
407 glTexCoord2d (s, t); glVertex2d (x + w, y + h); 420 glTexCoord2d (s, t); glVertex2d (x + w, y + h);
408 glTexCoord2d (s, 0); glVertex2d (x + w, y ); 421 glTexCoord2d (s, 0); glVertex2d (x + w, y );
560 { 573 {
561 cell->face [2] = (data [0] << 8) + data [1]; data += 2; 574 cell->face [2] = (data [0] << 8) + data [1]; data += 2;
562 } 575 }
563 } 576 }
564 else 577 else
565 {
566 cell->darkness = -1; 578 cell->darkness = -1;
567 cell->face [2] = 0;
568 }
569 } 579 }
570} 580}
571 581
572void 582void
573draw (CFClient::Map self, int x0, int y0, int sw, int sh) 583draw (CFClient::Map self, int x0, int y0, int sw, int sh)
574 CODE: 584 PPCODE:
575{ 585{
586 int sw4 = (sw + 3) & ~3;
587 SV *darkness_sv = sv_2mortal (newSV (sw4 * sh));
588 uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv);
589
590 SvPOK_only (darkness_sv);
591 SvCUR_set (darkness_sv, sw4 * sh);
592
576 int vx = self->vx = self->w >= sw 593 int vx = self->vx = self->w >= sw
577 ? self->x + (self->w - sw) / 2 594 ? self->x + (self->w - sw) / 2
578 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); 595 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx));
579 596
580 int vy = self->vy = self->h >= sh 597 int vy = self->vy = self->h >= sh
602 619
603 for (x = 0; x < sw; x++) 620 for (x = 0; x < sw; x++)
604 if (row->c0 <= x + vx && x + vx < row->c1) 621 if (row->c0 <= x + vx && x + vx < row->c1)
605 { 622 {
606 mapcell *cell = row->col + (x + vx - row->c0); 623 mapcell *cell = row->col + (x + vx - row->c0);
624
625 darkness[y * sw4 + x] = cell->darkness < 0
626 ? 255 - FOW_DARKNESS
627 : 255 - cell->darkness;
628
607 uint16_t face = cell->face [z]; 629 uint16_t face = cell->face [z];
608 630
609 if (face) 631 if (face)
610 { 632 {
611 mapface tex = self->face [face]; 633 mapface tex = self->face [face];
628 } 650 }
629 } 651 }
630 } 652 }
631 653
632 glEnd (); 654 glEnd ();
633}
634 655
656 glDisable (GL_TEXTURE_2D);
657 glDisable (GL_BLEND);
658
659 EXTEND (SP, 3);
660 PUSHs (sv_2mortal (newSViv (sw4)));
661 PUSHs (sv_2mortal (newSViv (sh)));
662 PUSHs (darkness_sv);
663}
664

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines