… | |
… | |
6 | |
6 | |
7 | #include <SDL.h> |
7 | #include <SDL.h> |
8 | #include <SDL_opengl.h> |
8 | #include <SDL_opengl.h> |
9 | |
9 | |
10 | #include <pango/pango.h> |
10 | #include <pango/pango.h> |
|
|
11 | #include <pango/pangofc-fontmap.h> |
11 | #include <pango/pangoft2.h> |
12 | #include <pango/pangoft2.h> |
|
|
13 | |
|
|
14 | #include <sys/types.h> |
|
|
15 | #include <sys/socket.h> |
|
|
16 | #include <netinet/in.h> |
|
|
17 | #include <netinet/tcp.h> |
12 | |
18 | |
13 | static PangoContext *context; |
19 | static PangoContext *context; |
14 | static PangoFontMap *fontmap; |
20 | static PangoFontMap *fontmap; |
15 | |
21 | |
16 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
22 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
17 | |
23 | |
|
|
24 | PROTOTYPES: ENABLE |
|
|
25 | |
18 | BOOT: |
26 | BOOT: |
19 | { |
27 | { |
20 | fontmap = pango_ft2_font_map_new (); |
28 | fontmap = pango_ft2_font_map_new (); |
21 | context = pango_context_new (); |
29 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
22 | pango_context_set_font_map (context, fontmap); |
|
|
23 | } |
30 | } |
|
|
31 | |
|
|
32 | void |
|
|
33 | lowdelay (int fd, int val = 1) |
|
|
34 | CODE: |
|
|
35 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
24 | |
36 | |
25 | char * |
37 | char * |
26 | gl_version () |
38 | gl_version () |
27 | CODE: |
39 | CODE: |
28 | RETVAL = (char *)glGetString (GL_VERSION); |
40 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
35 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
47 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
36 | OUTPUT: |
48 | OUTPUT: |
37 | RETVAL |
49 | RETVAL |
38 | |
50 | |
39 | void |
51 | void |
|
|
52 | set_font (char *file) |
|
|
53 | CODE: |
|
|
54 | { |
|
|
55 | int count; |
|
|
56 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
|
|
57 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
58 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
|
|
59 | FcPatternDestroy (pattern); |
|
|
60 | pango_context_set_font_description (context, font); |
|
|
61 | } |
|
|
62 | |
|
|
63 | void |
40 | font_render (SV *text_, int height) |
64 | font_render (SV *text_, int height = 10) |
41 | PPCODE: |
65 | PPCODE: |
42 | { |
66 | { |
43 | STRLEN textlen; |
67 | STRLEN textlen; |
44 | char *text = SvPVutf8 (text_, textlen); |
68 | char *text = SvPVutf8 (text_, textlen); |
45 | SV *retval; |
69 | SV *retval; |
46 | int w, h; |
70 | int w, h; |
47 | FT_Bitmap bitmap; |
71 | FT_Bitmap bitmap; |
48 | PangoLayout *layout; |
72 | PangoLayout *layout; |
49 | PangoFontDescription *font = pango_context_get_font_description (context); |
73 | PangoFontDescription *font = pango_context_get_font_description (context); |
50 | pango_font_description_set_absolute_size (font, 40 * PANGO_SCALE); |
74 | pango_font_description_set_absolute_size (font, height * PANGO_SCALE); |
51 | |
75 | |
52 | layout = pango_layout_new (context); |
76 | layout = pango_layout_new (context); |
53 | pango_layout_set_markup (layout, text, textlen); |
77 | pango_layout_set_markup (layout, text, textlen); |
54 | pango_layout_get_pixel_size (layout, &w, &h); |
78 | pango_layout_get_pixel_size (layout, &w, &h); |
55 | |
79 | |
56 | w = (w + 3) & ~3; |
80 | w = (w + 3) & ~3; |
|
|
81 | if (!w) w = 1; |
57 | if (h == 0) h = 1; |
82 | if (!h) h = 1; |
58 | |
83 | |
59 | retval = newSV (w * h); |
84 | retval = newSV (w * h); |
60 | SvPOK_only (retval); |
85 | SvPOK_only (retval); |
61 | SvCUR_set (retval, w * h); |
86 | SvCUR_set (retval, w * h); |
62 | |
87 | |
… | |
… | |
75 | EXTEND (SP, 3); |
100 | EXTEND (SP, 3); |
76 | PUSHs (sv_2mortal (newSViv (w))); |
101 | PUSHs (sv_2mortal (newSViv (w))); |
77 | PUSHs (sv_2mortal (newSViv (h))); |
102 | PUSHs (sv_2mortal (newSViv (h))); |
78 | PUSHs (sv_2mortal (retval)); |
103 | PUSHs (sv_2mortal (retval)); |
79 | } |
104 | } |
|
|
105 | |
|
|
106 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture |
|
|
107 | |
|
|
108 | void |
|
|
109 | texture_quad (SV *self, double x0, double y0, double w, double h) |
|
|
110 | CODE: |
|
|
111 | { |
|
|
112 | //glBegin |
|
|
113 | } |