1 | #ifdef _WIN32 |
1 | #ifdef _WIN32 |
|
|
2 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
2 | # include <malloc.h> |
3 | # include <malloc.h> |
|
|
4 | # include <windows.h> |
3 | # pragma warning(disable:4244) |
5 | # pragma warning(disable:4244) |
4 | #endif |
6 | #endif |
5 | |
7 | |
6 | #include "EXTERN.h" |
8 | #include "EXTERN.h" |
7 | #include "perl.h" |
9 | #include "perl.h" |
8 | #include "XSUB.h" |
10 | #include "XSUB.h" |
9 | |
11 | |
|
|
12 | #include <math.h> |
10 | #include <string.h> |
13 | #include <string.h> |
11 | #include <stdio.h> |
14 | #include <stdio.h> |
12 | |
15 | |
13 | #include <SDL.h> |
16 | #include <SDL.h> |
14 | #include <SDL_endian.h> |
17 | #include <SDL_endian.h> |
… | |
… | |
81 | |
84 | |
82 | static void |
85 | static void |
83 | substitute_func (FcPattern *pattern, gpointer data) |
86 | substitute_func (FcPattern *pattern, gpointer data) |
84 | { |
87 | { |
85 | FcPatternAddBool (pattern, FC_HINTING , 1); |
88 | FcPatternAddBool (pattern, FC_HINTING , 1); |
|
|
89 | #ifndef _WIN32 |
86 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
90 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
|
|
91 | #endif |
87 | } |
92 | } |
88 | |
93 | |
89 | static void |
94 | static void |
90 | layout_update_font (CFClient__Layout self) |
95 | layout_update_font (CFClient__Layout self) |
91 | { |
96 | { |
… | |
… | |
404 | # undef const_iv |
409 | # undef const_iv |
405 | }; |
410 | }; |
406 | |
411 | |
407 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
412 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
408 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
413 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
414 | } |
409 | |
415 | |
|
|
416 | void |
|
|
417 | pango_init () |
|
|
418 | CODE: |
|
|
419 | { |
|
|
420 | // delayed, so it can pick up new fonts added by AddFontResourceEx |
410 | ft2_fontmap = pango_ft2_font_map_new (); |
421 | ft2_fontmap = pango_ft2_font_map_new (); |
411 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); |
422 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); |
412 | ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); |
423 | ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); |
413 | |
424 | |
414 | cairo_fontmap = pango_cairo_font_map_get_default (); |
425 | cairo_fontmap = pango_cairo_font_map_get_default (); |
415 | cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); |
426 | cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); |
416 | } |
427 | } |
417 | |
428 | |
418 | int |
429 | int |
419 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
430 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
420 | |
431 | |
… | |
… | |
559 | |
570 | |
560 | void |
571 | void |
561 | add_font (char *file) |
572 | add_font (char *file) |
562 | CODE: |
573 | CODE: |
563 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
574 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
575 | #ifdef _WIN32 |
|
|
576 | // cairo... sigh... requires win2000 |
|
|
577 | AddFontResourceEx (file, FR_PRIVATE, 0); |
|
|
578 | #endif |
564 | |
579 | |
565 | void |
580 | void |
566 | load_image_inline (SV *image_) |
581 | load_image_inline (SV *image_) |
567 | ALIAS: |
582 | ALIAS: |
568 | load_image_file = 1 |
583 | load_image_file = 1 |
… | |
… | |
1577 | void glEnd () |
1592 | void glEnd () |
1578 | |
1593 | |
1579 | void glColor (float r, float g, float b, float a = 1.0) |
1594 | void glColor (float r, float g, float b, float a = 1.0) |
1580 | PROTOTYPE: @ |
1595 | PROTOTYPE: @ |
1581 | CODE: |
1596 | CODE: |
1582 | // 255.999 is close enough to correctness (256 and clamp) |
1597 | glColor4ub (MIN ((int)(r * 255.f), 255), |
1583 | glColor4ub (r * 255.999, g * 255.999, b * 255.999, a * 255.999); |
1598 | MIN ((int)(g * 255.f), 255), |
|
|
1599 | MIN ((int)(b * 255.f), 255), |
|
|
1600 | MIN ((int)(a * 255.f), 255)); |
1584 | |
1601 | |
1585 | void glVertex (float x, float y, float z = 0.) |
1602 | void glVertex (float x, float y, float z = 0.) |
1586 | CODE: |
1603 | CODE: |
1587 | glVertex3f (x, y, z); |
1604 | glVertex3f (x, y, z); |
1588 | |
1605 | |