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.16 by root, Tue Apr 11 13:27:48 2006 UTC vs.
Revision 1.18 by root, Tue Apr 11 19:31:17 2006 UTC

21 21
22typedef struct cf_layout { 22typedef struct cf_layout {
23 PangoLayout *pl; 23 PangoLayout *pl;
24 int base_height; 24 int base_height;
25} *CFClient__Layout; 25} *CFClient__Layout;
26
27static void
28layout_update (CFClient__Layout self)
29{
30 PangoFontDescription *font = pango_context_get_font_description (context);
31 pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE);
32}
26 33
27static void 34static void
28layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 35layout_get_pixel_size (CFClient__Layout self, int *w, int *h)
29{ 36{
30 PangoFontDescription *font = pango_context_get_font_description (context); 37 PangoFontDescription *font = pango_context_get_font_description (context);
124size (CFClient::Layout self) 131size (CFClient::Layout self)
125 PPCODE: 132 PPCODE:
126{ 133{
127 int w, h; 134 int w, h;
128 135
136 layout_update (self);
129 layout_get_pixel_size (self, &w, &h); 137 layout_get_pixel_size (self, &w, &h);
130 138
131 EXTEND (SP, 2); 139 EXTEND (SP, 2);
132 PUSHs (sv_2mortal (newSViv (w))); 140 PUSHs (sv_2mortal (newSViv (w)));
133 PUSHs (sv_2mortal (newSViv (h))); 141 PUSHs (sv_2mortal (newSViv (h)));
134} 142}
135 143
144int
145xy_to_index (CFClient::Layout self, int x, int y)
146 CODE:
147{
148 int index, trailing;
149
150 layout_update (self);
151 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
152
153 RETVAL = index;
154}
155 OUTPUT:
156 RETVAL
157
158void
159cursor_pos (CFClient::Layout self, int index)
160 PPCODE:
161{
162 PangoRectangle strong_pos;
163 layout_update (self);
164 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
165 EXTEND (SP, 3);
166 PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE)));
167 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
168 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
169}
170
136void 171void
137render (CFClient::Layout self) 172render (CFClient::Layout self)
138 PPCODE: 173 PPCODE:
139{ 174{
140 SV *retval; 175 SV *retval;
141 int w, h; 176 int w, h;
142 FT_Bitmap bitmap; 177 FT_Bitmap bitmap;
143 178
179 layout_update (self);
144 layout_get_pixel_size (self, &w, &h); 180 layout_get_pixel_size (self, &w, &h);
145 181
146 retval = newSV (w * h); 182 retval = newSV (w * h);
147 SvPOK_only (retval); 183 SvPOK_only (retval);
148 SvCUR_set (retval, w * h); 184 SvCUR_set (retval, w * h);
176 double t = SvNV (*hv_fetch (hv, "t", 1, 1)); 212 double t = SvNV (*hv_fetch (hv, "t", 1, 1));
177 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 213 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
178 214
179 if (items < 5) 215 if (items < 5)
180 { 216 {
181 w = SvNV (*hv_fetch (hv, "width", 5, 1)); 217 w = SvNV (*hv_fetch (hv, "w", 1, 1));
182 h = SvNV (*hv_fetch (hv, "height", 6, 1)); 218 h = SvNV (*hv_fetch (hv, "h", 1, 1));
183 } 219 }
184 220
185 glBindTexture (GL_TEXTURE_2D, name); 221 glBindTexture (GL_TEXTURE_2D, name);
186 glBegin (GL_QUADS); 222 glBegin (GL_QUADS);
187 glTexCoord2d (0, 0); glVertex2d (x , y ); 223 glTexCoord2d (0, 0); glVertex2d (x , y );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines