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.31 by root, Thu Apr 13 23:11:11 2006 UTC vs.
Revision 1.38 by root, Fri Apr 14 23:32:28 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{
285 CODE: 285 CODE:
286 g_object_unref (self->pl); 286 g_object_unref (self->pl);
287 Safefree (self); 287 Safefree (self);
288 288
289void 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
290set_markup (CFClient::Layout self, SV *text_) 300set_markup (CFClient::Layout self, SV *text_)
291 CODE: 301 CODE:
292{ 302{
293 STRLEN textlen; 303 STRLEN textlen;
294 char *text = SvPVutf8 (text_, textlen); 304 char *text = SvPVutf8 (text_, textlen);
381} 391}
382 392
383MODULE = CFClient PACKAGE = CFClient::Texture 393MODULE = CFClient PACKAGE = CFClient::Texture
384 394
385void 395void
386draw_quad (SV *self, double x, double y, double w = 0, double h = 0) 396draw_quad (SV *self, float x, float y, float w = 0, float h = 0)
387 PROTOTYPE: $$$;$$ 397 PROTOTYPE: $$$;$$
388 CODE: 398 CODE:
389{ 399{
390 HV *hv = (HV *)SvRV (self); 400 HV *hv = (HV *)SvRV (self);
391 double s = SvNV (*hv_fetch (hv, "s", 1, 1)); 401 float s = SvNV (*hv_fetch (hv, "s", 1, 1));
392 double t = SvNV (*hv_fetch (hv, "t", 1, 1)); 402 float t = SvNV (*hv_fetch (hv, "t", 1, 1));
393 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));
394 405
395 if (items < 5) 406 if (items < 5)
396 { 407 {
397 w = SvNV (*hv_fetch (hv, "w", 1, 1)); 408 w = SvNV (*hv_fetch (hv, "w", 1, 1));
398 h = SvNV (*hv_fetch (hv, "h", 1, 1)); 409 h = SvNV (*hv_fetch (hv, "h", 1, 1));
399 } 410 }
400 411
401 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 }
402 glBegin (GL_QUADS); 417 glBegin (GL_QUADS);
403 glTexCoord2d (0, 0); glVertex2d (x , y ); 418 glTexCoord2f (0, 0); glVertex2f (x , y );
404 glTexCoord2d (0, t); glVertex2d (x , y + h); 419 glTexCoord2f (0, t); glVertex2f (x , y + h);
405 glTexCoord2d (s, t); glVertex2d (x + w, y + h); 420 glTexCoord2f (s, t); glVertex2f (x + w, y + h);
406 glTexCoord2d (s, 0); glVertex2d (x + w, y ); 421 glTexCoord2f (s, 0); glVertex2f (x + w, y );
407 glEnd (); 422 glEnd ();
408} 423}
409 424
410MODULE = CFClient PACKAGE = CFClient::Map 425MODULE = CFClient PACKAGE = CFClient::Map
411 426
563 cell->darkness = -1; 578 cell->darkness = -1;
564 } 579 }
565} 580}
566 581
567void 582void
568draw (CFClient::Map self, int x0, int y0, int sw, int sh) 583draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
569 CODE: 584 PPCODE:
570{ 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
593 int vx = self->x + (self->w - sw) / 2 - shift_x;
594 int vy = self->y + (self->h - sh) / 2 - shift_y;
595
596 if (0)
597 {
571 int vx = self->vx = self->w >= sw 598 int vx = self->vx = self->w >= sw
572 ? self->x + (self->w - sw) / 2 599 ? self->x + (self->w - sw) / 2
573 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); 600 : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx));
574 601
575 int vy = self->vy = self->h >= sh 602 int vy = self->vy = self->h >= sh
576 ? self->y + (self->h - sh) / 2 603 ? self->y + (self->h - sh) / 2
577 : MIN (self->y, MAX (self->y + self->h - sh + 1, self->vy)); 604 : MIN (self->y, MAX (self->y + self->h - sh + 1, self->vy));
605 }
578 606
579 glColor4ub (255, 255, 255, 255); 607 glColor4ub (255, 255, 255, 255);
580 608
581 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 609 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
582 glEnable (GL_BLEND); 610 glEnable (GL_BLEND);
597 625
598 for (x = 0; x < sw; x++) 626 for (x = 0; x < sw; x++)
599 if (row->c0 <= x + vx && x + vx < row->c1) 627 if (row->c0 <= x + vx && x + vx < row->c1)
600 { 628 {
601 mapcell *cell = row->col + (x + vx - row->c0); 629 mapcell *cell = row->col + (x + vx - row->c0);
630
631 darkness[y * sw4 + x] = cell->darkness < 0
632 ? 255 - FOW_DARKNESS
633 : 255 - cell->darkness;
634
602 uint16_t face = cell->face [z]; 635 uint16_t face = cell->face [z];
603 636
604 if (face) 637 if (face)
605 { 638 {
606 mapface tex = self->face [face]; 639 mapface tex = self->face [face];
623 } 656 }
624 } 657 }
625 } 658 }
626 659
627 glEnd (); 660 glEnd ();
628}
629 661
662 glDisable (GL_TEXTURE_2D);
663 glDisable (GL_BLEND);
664
665 EXTEND (SP, 3);
666 PUSHs (sv_2mortal (newSViv (sw4)));
667 PUSHs (sv_2mortal (newSViv (sh)));
668 PUSHs (darkness_sv);
669}
670

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines