… | |
… | |
37 | |
37 | |
38 | static void |
38 | static void |
39 | substitute_func (FcPattern *pattern, gpointer data) |
39 | substitute_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 | |
45 | static void |
45 | static void |
46 | layout_update (CFClient__Layout self) |
46 | layout_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 | |
289 | void |
289 | void |
|
|
290 | set_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 | |
|
|
299 | void |
290 | set_markup (CFClient::Layout self, SV *text_) |
300 | set_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 | |
383 | MODULE = CFClient PACKAGE = CFClient::Texture |
393 | MODULE = CFClient PACKAGE = CFClient::Texture |
384 | |
394 | |
385 | void |
395 | void |
386 | draw_quad (SV *self, double x, double y, double w = 0, double h = 0) |
396 | draw_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 | |
410 | MODULE = CFClient PACKAGE = CFClient::Map |
425 | MODULE = CFClient PACKAGE = CFClient::Map |
411 | |
426 | |
… | |
… | |
563 | cell->darkness = -1; |
578 | cell->darkness = -1; |
564 | } |
579 | } |
565 | } |
580 | } |
566 | |
581 | |
567 | void |
582 | void |
568 | draw (CFClient::Map self, int x0, int y0, int sw, int sh) |
583 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
569 | PPCODE: |
584 | PPCODE: |
570 | { |
585 | { |
571 | int sw4 = (sw + 3) & ~3; |
586 | int sw4 = (sw + 3) & ~3; |
572 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
587 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
573 | uint8_t *darkness = SvPVX (darkness_sv); |
588 | uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); |
574 | |
589 | |
575 | SvPOK_only (darkness_sv); |
590 | SvPOK_only (darkness_sv); |
576 | SvCUR_set (darkness_sv, sw4 * sh); |
591 | SvCUR_set (darkness_sv, sw4 * sh); |
577 | |
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 | { |
578 | int vx = self->vx = self->w >= sw |
598 | int vx = self->vx = self->w >= sw |
579 | ? self->x + (self->w - sw) / 2 |
599 | ? self->x + (self->w - sw) / 2 |
580 | : 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)); |
581 | |
601 | |
582 | int vy = self->vy = self->h >= sh |
602 | int vy = self->vy = self->h >= sh |
583 | ? self->y + (self->h - sh) / 2 |
603 | ? self->y + (self->h - sh) / 2 |
584 | : 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 | } |
585 | |
606 | |
586 | glColor4ub (255, 255, 255, 255); |
607 | glColor4ub (255, 255, 255, 255); |
587 | |
608 | |
588 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
609 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
589 | glEnable (GL_BLEND); |
610 | glEnable (GL_BLEND); |