… | |
… | |
18 | |
18 | |
19 | static PangoContext *context; |
19 | static PangoContext *context; |
20 | static PangoFontMap *fontmap; |
20 | static PangoFontMap *fontmap; |
21 | |
21 | |
22 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
22 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
|
|
23 | |
|
|
24 | PROTOTYPES: ENABLE |
23 | |
25 | |
24 | BOOT: |
26 | BOOT: |
25 | { |
27 | { |
26 | fontmap = pango_ft2_font_map_new (); |
28 | fontmap = pango_ft2_font_map_new (); |
27 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
29 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
… | |
… | |
45 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
47 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
46 | OUTPUT: |
48 | OUTPUT: |
47 | RETVAL |
49 | RETVAL |
48 | |
50 | |
49 | void |
51 | void |
|
|
52 | add_font (char *file) |
|
|
53 | CODE: |
|
|
54 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
55 | |
|
|
56 | void |
50 | set_font (char *file) |
57 | set_font (char *file) |
51 | CODE: |
58 | CODE: |
52 | { |
59 | { |
53 | int count; |
60 | int count; |
54 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
61 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
55 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
56 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
62 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
57 | FcPatternDestroy (pattern); |
63 | FcPatternDestroy (pattern); |
58 | pango_context_set_font_description (context, font); |
64 | pango_context_set_font_description (context, font); |
59 | } |
65 | } |
|
|
66 | |
|
|
67 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
60 | |
68 | |
61 | void |
69 | void |
62 | font_render (SV *text_, int height = 10) |
70 | font_render (SV *text_, int height = 10) |
63 | PPCODE: |
71 | PPCODE: |
64 | { |
72 | { |
… | |
… | |
98 | EXTEND (SP, 3); |
106 | EXTEND (SP, 3); |
99 | PUSHs (sv_2mortal (newSViv (w))); |
107 | PUSHs (sv_2mortal (newSViv (w))); |
100 | PUSHs (sv_2mortal (newSViv (h))); |
108 | PUSHs (sv_2mortal (newSViv (h))); |
101 | PUSHs (sv_2mortal (retval)); |
109 | PUSHs (sv_2mortal (retval)); |
102 | } |
110 | } |
|
|
111 | |
|
|
112 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture |
|
|
113 | |
|
|
114 | void |
|
|
115 | draw_quad (SV *self, double x, double y, double w = 0, double h = 0) |
|
|
116 | PROTOTYPE: $$$;$$ |
|
|
117 | CODE: |
|
|
118 | { |
|
|
119 | HV *hv = (HV *)SvRV (self); |
|
|
120 | double s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
|
|
121 | double t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
|
|
122 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
|
|
123 | |
|
|
124 | if (items < 5) |
|
|
125 | { |
|
|
126 | w = SvNV (*hv_fetch (hv, "width", 5, 1)); |
|
|
127 | h = SvNV (*hv_fetch (hv, "height", 6, 1)); |
|
|
128 | } |
|
|
129 | |
|
|
130 | glBindTexture (GL_TEXTURE_2D, name); |
|
|
131 | glBegin (GL_QUADS); |
|
|
132 | glTexCoord2d (0, 0); glVertex2d (x , y ); |
|
|
133 | glTexCoord2d (0, t); glVertex2d (x , y + h); |
|
|
134 | glTexCoord2d (s, t); glVertex2d (x + w, y + h); |
|
|
135 | glTexCoord2d (s, 0); glVertex2d (x + w, y ); |
|
|
136 | glEnd (); |
|
|
137 | } |