ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/pango-render.c
(Generate patch)

Comparing deliantra/Deliantra-Client/pango-render.c (file contents):
Revision 1.2 by root, Tue Jul 4 23:44:23 2006 UTC vs.
Revision 1.5 by root, Wed Jul 5 01:53:24 2006 UTC

146} 146}
147 147
148typedef struct glyph_info { 148typedef struct glyph_info {
149 tc_area tex; 149 tc_area tex;
150 int left, top; 150 int left, top;
151 int generation;
151} glyph_info; 152} glyph_info;
152 153
153static void 154static void
154free_glyph_info (glyph_info *g) 155free_glyph_info (glyph_info *g)
155{ 156{
172 glyph = PANGO_GLYPH_UNKNOWN_FLAG; 173 glyph = PANGO_GLYPH_UNKNOWN_FLAG;
173 } 174 }
174 175
175 g = _pango_opengl_font_get_cache_glyph_data (font, glyph); 176 g = _pango_opengl_font_get_cache_glyph_data (font, glyph);
176 177
177 if (!g) 178 if (!g || g->generation != tc_generation)
178 { 179 {
179 Glyph bm; 180 Glyph bm;
180 font_render_glyph (&bm, font, glyph); 181 font_render_glyph (&bm, font, glyph);
181 182
183 if (g)
184 g->generation = tc_generation;
185 else
186 {
182 g = g_slice_new (glyph_info); 187 g = g_slice_new (glyph_info);
188
189 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info);
190 _pango_opengl_font_set_cache_glyph_data (font, glyph, g);
191 }
192
193 if (renderer->curtex)
194 glEnd ();
183 195
184 tc_get (&g->tex, bm.width, bm.height); 196 tc_get (&g->tex, bm.width, bm.height);
185 197
186 g->left = bm.left; 198 g->left = bm.left;
187 g->top = bm.top; 199 g->top = bm.top;
188
189 if (renderer->curtex)
190 {
191 glEnd ();
192 renderer->curtex = 0;
193 }
194 200
195 glBindTexture (GL_TEXTURE_2D, g->tex.name); 201 glBindTexture (GL_TEXTURE_2D, g->tex.name);
196 glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); 202 glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride);
197 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 203 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
198 glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); 204 glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap);
199 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); 205 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
200 glPixelStorei (GL_UNPACK_ALIGNMENT, 4); 206 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
201 207
202 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); 208 renderer->curtex = g->tex.name;
203 _pango_opengl_font_set_cache_glyph_data (font, glyph, g); 209 glBegin (GL_QUADS);
204 } 210 }
205 211
206 x += g->left; 212 x += g->left;
207 y -= g->top; 213 y -= g->top;
208 214
216 if (renderer->curtex) 222 if (renderer->curtex)
217 glEnd (); 223 glEnd ();
218 224
219 glBindTexture (GL_TEXTURE_2D, g->tex.name); 225 glBindTexture (GL_TEXTURE_2D, g->tex.name);
220 renderer->curtex = g->tex.name; 226 renderer->curtex = g->tex.name;
227
221 glBegin (GL_QUADS); 228 glBegin (GL_QUADS);
222 } 229 }
223 230
224 glTexCoord2f (x1, y1); glVertex2i (x , y ); 231 glTexCoord2f (x1, y1); glVertex2i (x , y );
225 glTexCoord2f (x2, y1); glVertex2i (x + g->tex.w, y ); 232 glTexCoord2f (x2, y1); glVertex2i (x + g->tex.w, y );
247 254
248 glDisable (GL_TEXTURE_2D); 255 glDisable (GL_TEXTURE_2D);
249 256
250 glBegin (GL_QUADS); 257 glBegin (GL_QUADS);
251 glVertex2d (x11, y1); 258 glVertex2d (x11, y1);
252 glVertex2d (x12, y1); 259 glVertex2d (x21, y1);
253 glVertex2d (x22, y2); 260 glVertex2d (x22, y2);
254 glVertex2d (x21, y2); 261 glVertex2d (x12, y2);
255 glEnd (); 262 glEnd ();
256 263
257 glEnable (GL_TEXTURE_2D); 264 glEnable (GL_TEXTURE_2D);
258} 265}
259 266

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines