1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AllegroGL: aglf.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="alleggl.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">AllegroGL <span id="projectnumber">0.4.4</span></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('aglf_8c.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<h1>aglf.c</h1> </div>
</div>
<div class="contents">
<a href="aglf_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* This code is (C) AllegroGL contributors, and double licensed under</span>
<a name="l00002"></a>00002 <span class="comment"> * the GPL and zlib licenses. See gpl.txt or zlib.txt for details.</span>
<a name="l00003"></a>00003 <span class="comment"> */</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include <math.h></span>
<a name="l00009"></a>00009 <span class="preprocessor">#include <string.h></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include <stdio.h></span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#include "allegro.h"</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="preprocessor">#include "alleggl.h"</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include "allglint.h"</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#include <OpenGL/glu.h></span>
<a name="l00019"></a>00019 <span class="preprocessor">#else</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#include <GL/glu.h></span>
<a name="l00021"></a>00021 <span class="preprocessor">#endif</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#if defined ALLEGRO_WITH_XWINDOWS && !defined ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include <xalleg.h></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include <GL/glx.h></span>
<a name="l00026"></a>00026 <span class="preprocessor">#endif</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a>00028 <span class="preprocessor">#define PREFIX_E "agl-font ERROR: "</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keyword">static</span> <span class="keywordtype">int</span> aglf_font_generation_mode = <a class="code" href="group__Text.html#ga4b45ef558e7934ceaaff146f450ab23f" title="Font generation mode.">AGL_FONT_POLYGONS</a>;
<a name="l00033"></a>00033
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="comment">/* find_range:</span>
<a name="l00036"></a>00036 <span class="comment"> * Searches a font for a specific character.</span>
<a name="l00037"></a>00037 <span class="comment"> */</span>
<a name="l00038"></a>00038 <span class="keyword">static</span> AL_CONST FONT_AGL_DATA *find_range(AL_CONST FONT_AGL_DATA *f, <span class="keywordtype">int</span> c) {
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="keywordflow">while</span> (f) {
<a name="l00041"></a>00041 <span class="keywordflow">if</span> ((c >= f->start) && (c < f->end))
<a name="l00042"></a>00042 <span class="keywordflow">return</span> f;
<a name="l00043"></a>00043
<a name="l00044"></a>00044 f = f->next;
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="keywordflow">return</span> NULL;
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049
<a name="l00050"></a>00050
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="comment">/* allegro_gl_printf(FONT *f, float x, float y, float z, int color,</span>
<a name="l00053"></a>00053 <span class="comment"> char *format, ...) */</span>
<a name="l00067"></a><a class="code" href="group__Text.html#ga84ecf6d5f5b363d7715e15eca8ebafeb">00067</a> <span class="keywordtype">int</span> <a class="code" href="group__Text.html#ga84ecf6d5f5b363d7715e15eca8ebafeb" title="Equivalent to:">allegro_gl_printf</a>(AL_CONST FONT *f, <span class="keywordtype">float</span> x, <span class="keywordtype">float</span> y, <span class="keywordtype">float</span> z, <span class="keywordtype">int</span> color,
<a name="l00068"></a>00068 AL_CONST <span class="keywordtype">char</span> *format, ...) {
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="preprocessor">#define BUF_SIZE 1024</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span> <span class="keywordtype">char</span> buf[BUF_SIZE];
<a name="l00072"></a>00072 va_list ap;
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keywordflow">if</span> (!__allegro_gl_valid_context)
<a name="l00075"></a>00075 <span class="keywordflow">return</span> 0;
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="comment">/* Get the string */</span>
<a name="l00078"></a>00078 va_start(ap, format);
<a name="l00079"></a>00079 uvszprintf(buf, BUF_SIZE, format, ap);
<a name="l00080"></a>00080 va_end(ap);
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="preprocessor">#undef BUF_SIZE</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>
<a name="l00084"></a>00084 <span class="comment">/* Set color */</span>
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 GLubyte c[4];
<a name="l00087"></a>00087 c[0] = (GLubyte)getr(color);
<a name="l00088"></a>00088 c[1] = (GLubyte)getg(color);
<a name="l00089"></a>00089 c[2] = (GLubyte)getb(color);
<a name="l00090"></a>00090 c[3] = (__allegro_gl_use_alpha && bitmap_color_depth(screen) == 32)
<a name="l00091"></a>00091 ? (GLubyte)geta(color) : 255;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 glColor4ubv(c);
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095
<a name="l00096"></a>00096 <span class="keywordflow">return</span> <a class="code" href="group__Text.html#gab93317445f8a566f8b5632e04fbf8e5b" title="Prints a formatted string (printf style) on the screen.">allegro_gl_printf_ex</a>(f, x, y, z, buf);
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098
<a name="l00099"></a>00099
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="comment">/* allegro_gl_printf_ex(FONT *f, float x, float y, float z,</span>
<a name="l00102"></a>00102 <span class="comment"> * char *format, ...)</span>
<a name="l00103"></a>00103 <span class="comment"> */</span>
<a name="l00169"></a><a class="code" href="group__Text.html#gab93317445f8a566f8b5632e04fbf8e5b">00169</a> <span class="keywordtype">int</span> <a class="code" href="group__Text.html#gab93317445f8a566f8b5632e04fbf8e5b" title="Prints a formatted string (printf style) on the screen.">allegro_gl_printf_ex</a>(AL_CONST FONT *f, <span class="keywordtype">float</span> x, <span class="keywordtype">float</span> y, <span class="keywordtype">float</span> z,
<a name="l00170"></a>00170 AL_CONST <span class="keywordtype">char</span> *format, ...) {
<a name="l00171"></a>00171 <span class="preprocessor"> #define BUF_SIZE 1024</span>
<a name="l00172"></a>00172 <span class="preprocessor"></span> <span class="keywordtype">char</span> buf[BUF_SIZE];
<a name="l00173"></a>00173 va_list ap;
<a name="l00174"></a>00174
<a name="l00175"></a>00175 AL_CONST FONT_AGL_DATA *range = NULL;
<a name="l00176"></a>00176 <span class="keywordtype">int</span> c, pos = 0;
<a name="l00177"></a>00177 <span class="keywordtype">int</span> count = 0;
<a name="l00178"></a>00178 AL_CONST FONT_AGL_DATA *d;
<a name="l00179"></a>00179 GLint vert_order, cull_mode;
<a name="l00180"></a>00180 GLint matrix_mode;
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="keywordtype">int</span> restore_rasterpos = 0;
<a name="l00183"></a>00183 GLuint old_texture_bind = 0;
<a name="l00184"></a>00184 GLfloat old_raster_pos[4];
<a name="l00185"></a>00185
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="keywordflow">if</span> (!__allegro_gl_valid_context)
<a name="l00188"></a>00188 <span class="keywordflow">return</span> 0;
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="comment">/* Check arguments */</span>
<a name="l00191"></a>00191 <span class="keywordflow">if</span> (!format || !f) {
<a name="l00192"></a>00192 TRACE(PREFIX_E <span class="stringliteral">"agl_printf: Null parameter\n"</span>);
<a name="l00193"></a>00193 <span class="keywordflow">return</span> 0;
<a name="l00194"></a>00194 }
<a name="l00195"></a>00195
<a name="l00196"></a>00196 <span class="keywordflow">if</span> (f->vtable != font_vtable_agl) {
<a name="l00197"></a>00197 TRACE(PREFIX_E <span class="stringliteral">"agl_printf: Font parameter isn't of the AGL "</span>
<a name="l00198"></a>00198 <span class="stringliteral">"type.\n"</span>);
<a name="l00199"></a>00199 <span class="keywordflow">return</span> 0;
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201
<a name="l00202"></a>00202 d = (AL_CONST FONT_AGL_DATA*)f->data;
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="comment">/* Get the string */</span>
<a name="l00205"></a>00205 va_start(ap, format);
<a name="l00206"></a>00206 uvszprintf(buf, BUF_SIZE, format, ap);
<a name="l00207"></a>00207 va_end(ap);
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="preprocessor">#undef BUF_SIZE</span>
<a name="l00210"></a>00210 <span class="preprocessor"></span>
<a name="l00211"></a>00211 glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
<a name="l00212"></a>00212 glGetIntegerv(GL_FRONT_FACE, &vert_order);
<a name="l00213"></a>00213 glGetIntegerv(GL_CULL_FACE_MODE, &cull_mode);
<a name="l00214"></a>00214
<a name="l00215"></a>00215 glMatrixMode(GL_MODELVIEW);
<a name="l00216"></a>00216 glPushMatrix();
<a name="l00217"></a>00217
<a name="l00218"></a>00218 glFrontFace(GL_CW);
<a name="l00219"></a>00219 glCullFace(GL_BACK);
<a name="l00220"></a>00220
<a name="l00221"></a>00221 { GLint temp;
<a name="l00222"></a>00222 glGetIntegerv(GL_TEXTURE_BINDING_2D, &temp);
<a name="l00223"></a>00223 old_texture_bind = (GLuint)temp;
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225
<a name="l00226"></a>00226 <span class="keywordflow">if</span> (d->type == <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>) {
<a name="l00227"></a>00227 glTranslatef(0, 0, -1);
<a name="l00228"></a>00228 glBindTexture(GL_TEXTURE_2D, 0);
<a name="l00229"></a>00229
<a name="l00230"></a>00230 glGetFloatv(GL_CURRENT_RASTER_POSITION, old_raster_pos);
<a name="l00231"></a>00231 glRasterPos2f(x, y);
<a name="l00232"></a>00232 restore_rasterpos = 1;
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (d->type == <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>) {
<a name="l00235"></a>00235 glTranslatef(x, y, z);
<a name="l00236"></a>00236 glBindTexture(GL_TEXTURE_2D, 0);
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (d->type == <a class="code" href="group__Text.html#ga92bf039bc7b06568273ee17f15cf6671" title="Indicates that you want fonts to be converted to a texture format.">AGL_FONT_TYPE_TEXTURED</a>) {
<a name="l00239"></a>00239 glTranslatef(x, y, z);
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241
<a name="l00242"></a>00242
<a name="l00243"></a>00243 <span class="keywordflow">while</span> ((c = ugetc(buf + pos)) != 0) {
<a name="l00244"></a>00244
<a name="l00245"></a>00245 pos += ucwidth(c);
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <span class="keywordflow">if</span> ((!range) || (c < range->start) || (c >= range->end)) {
<a name="l00248"></a>00248 <span class="comment">/* search for a suitable character range */</span>
<a name="l00249"></a>00249 range = find_range(d, c);
<a name="l00250"></a>00250
<a name="l00251"></a>00251 <span class="keywordflow">if</span> (!range) {
<a name="l00252"></a>00252 range = find_range(d, (c = <span class="charliteral">'^'</span>));
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="keywordflow">if</span> (!range)
<a name="l00255"></a>00255 <span class="keywordflow">continue</span>;
<a name="l00256"></a>00256 }
<a name="l00257"></a>00257 }
<a name="l00258"></a>00258
<a name="l00259"></a>00259 <span class="comment">/* Set up texture */</span>
<a name="l00260"></a>00260 <span class="keywordflow">if</span> (d->type == <a class="code" href="group__Text.html#ga92bf039bc7b06568273ee17f15cf6671" title="Indicates that you want fonts to be converted to a texture format.">AGL_FONT_TYPE_TEXTURED</a>) {
<a name="l00261"></a>00261 glBindTexture(GL_TEXTURE_2D, range->texture);
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263
<a name="l00264"></a>00264 <span class="comment">/* draw the character */</span>
<a name="l00265"></a>00265 c -= range->start;
<a name="l00266"></a>00266 c += range->list_base;
<a name="l00267"></a>00267
<a name="l00268"></a>00268 glCallList(c);
<a name="l00269"></a>00269
<a name="l00270"></a>00270 count++;
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272
<a name="l00273"></a>00273 glPopMatrix();
<a name="l00274"></a>00274
<a name="l00275"></a>00275 glMatrixMode(matrix_mode);
<a name="l00276"></a>00276 glFrontFace(vert_order);
<a name="l00277"></a>00277 glCullFace(cull_mode);
<a name="l00278"></a>00278
<a name="l00279"></a>00279 glBindTexture(GL_TEXTURE_2D, old_texture_bind);
<a name="l00280"></a>00280
<a name="l00281"></a>00281 <span class="keywordflow">if</span> (restore_rasterpos) {
<a name="l00282"></a>00282 glRasterPos4fv(old_raster_pos);
<a name="l00283"></a>00283 }
<a name="l00284"></a>00284
<a name="l00285"></a>00285 <span class="keywordflow">return</span> count;
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287
<a name="l00288"></a>00288
<a name="l00289"></a>00289
<a name="l00290"></a>00290 <span class="preprocessor">#ifndef ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00291"></a>00291 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>
<a name="l00293"></a>00293 <span class="keyword">static</span> FONT *win_load_system_font(<span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> style, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <span class="keywordtype">float</span> depth, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> end) {
<a name="l00294"></a>00294
<a name="l00295"></a>00295 HFONT hFont;
<a name="l00296"></a>00296
<a name="l00297"></a>00297 FONT_AGL_DATA *data;
<a name="l00298"></a>00298 FONT *ret;
<a name="l00299"></a>00299
<a name="l00300"></a>00300 ret = malloc(<span class="keyword">sizeof</span>(FONT));
<a name="l00301"></a>00301 <span class="keywordflow">if</span> (!ret) {
<a name="l00302"></a>00302 TRACE(PREFIX_E <span class="stringliteral">"win_load_system_font: Ran out of memory "</span>
<a name="l00303"></a>00303 <span class="stringliteral">"while allocating %i bytes\n"</span>, <span class="keyword">sizeof</span>(FONT));
<a name="l00304"></a>00304 <span class="keywordflow">return</span> NULL;
<a name="l00305"></a>00305 }
<a name="l00306"></a>00306 data = malloc(<span class="keyword">sizeof</span>(FONT_AGL_DATA));
<a name="l00307"></a>00307 <span class="keywordflow">if</span> (!data) {
<a name="l00308"></a>00308 free(ret);
<a name="l00309"></a>00309 TRACE(PREFIX_E <span class="stringliteral">"win_load_system_font: Ran out of memory "</span>
<a name="l00310"></a>00310 <span class="stringliteral">"while allocating %i bytes\n"</span>, <span class="keyword">sizeof</span>(FONT_AGL_DATA));
<a name="l00311"></a>00311 <span class="keywordflow">return</span> NULL;
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313 ret->vtable = font_vtable_agl;
<a name="l00314"></a>00314 ret->data = data;
<a name="l00315"></a>00315
<a name="l00316"></a>00316 data->list_base = glGenLists(end - start);
<a name="l00317"></a>00317 data->start = start;
<a name="l00318"></a>00318 data->end = end;
<a name="l00319"></a>00319 data->next = NULL;
<a name="l00320"></a>00320 data->is_free_chunk = 0;
<a name="l00321"></a>00321
<a name="l00322"></a>00322 <span class="keywordflow">if</span> (type == <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a> || type == <a class="code" href="group__Text.html#gad2ebae17d2548a5befb888f8618f2206" title="Indicates that you don&#39;t really care how a font will be converted.">AGL_FONT_TYPE_DONT_CARE</a>) {
<a name="l00323"></a>00323
<a name="l00324"></a>00324 HDC dc;
<a name="l00325"></a>00325
<a name="l00326"></a>00326 hFont = CreateFont( -h, w,
<a name="l00327"></a>00327 0, 0,
<a name="l00328"></a>00328 (style & <a class="code" href="group__Text.html#gab77d7d2c6ec6d1786472943f7cd814ca" title="Creates a font with bold characters.">AGL_FONT_STYLE_BOLD</a>) ? FW_BOLD
<a name="l00329"></a>00329 : ((style & <a class="code" href="group__Text.html#ga27874c1fb7fdc1e00115bd853c973fc3" title="Creates a font with black (strong bold) characters.">AGL_FONT_STYLE_BLACK</a>) ? FW_BLACK : FW_NORMAL),
<a name="l00330"></a>00330 ((style & <a class="code" href="group__Text.html#ga67c48bf08c2b6cd6cc1a08dec2c7c5ef" title="Creates a font with italicized characters.">AGL_FONT_STYLE_ITALIC</a>) ? TRUE : FALSE),
<a name="l00331"></a>00331 ((style & <a class="code" href="group__Text.html#gae9e4682339d264429ee601c632231c9f" title="Creates a font with underlined characters.">AGL_FONT_STYLE_UNDERLINE</a>) ? TRUE : FALSE),
<a name="l00332"></a>00332 ((style & <a class="code" href="group__Text.html#ga6ba31b9c7866d28b5494fad2577569db" title="Creates a font with striked out characters.">AGL_FONT_STYLE_STRIKEOUT</a>) ? TRUE : FALSE),
<a name="l00333"></a>00333 ANSI_CHARSET,
<a name="l00334"></a>00334 OUT_TT_PRECIS,
<a name="l00335"></a>00335 CLIP_DEFAULT_PRECIS,
<a name="l00336"></a>00336 (style & <a class="code" href="group__Text.html#ga91cc859278878dd4bf200bed7eab4359" title="Creates a font with anti-aliased characters.">AGL_FONT_STYLE_ANTI_ALIASED</a>) ? ANTIALIASED_QUALITY
<a name="l00337"></a>00337 : DEFAULT_QUALITY,
<a name="l00338"></a>00338 FF_DONTCARE | DEFAULT_PITCH,
<a name="l00339"></a>00339 name);
<a name="l00340"></a>00340
<a name="l00341"></a>00341 dc = GetDC(win_get_window());
<a name="l00342"></a>00342
<a name="l00343"></a>00343 SelectObject(dc, hFont);
<a name="l00344"></a>00344
<a name="l00345"></a>00345 wglUseFontBitmaps(dc, start, end - start, data->list_base);
<a name="l00346"></a>00346 data->type = <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>;
<a name="l00347"></a>00347 data->data = NULL;
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (type == <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>) {
<a name="l00350"></a>00350 HDC dc;
<a name="l00351"></a>00351
<a name="l00352"></a>00352 GLYPHMETRICSFLOAT *gmf;
<a name="l00353"></a>00353 gmf = malloc(<span class="keyword">sizeof</span>(GLYPHMETRICSFLOAT) * (end - start));
<a name="l00354"></a>00354 memset(gmf, 0, <span class="keyword">sizeof</span>(GLYPHMETRICSFLOAT) * (end - start));
<a name="l00355"></a>00355
<a name="l00356"></a>00356 hFont = CreateFont( -h, w,
<a name="l00357"></a>00357 0, 0,
<a name="l00358"></a>00358 (style & AGL_FONT_STYLE_BOLD) ? FW_BOLD
<a name="l00359"></a>00359 : ((style & AGL_FONT_STYLE_BLACK) ? FW_BLACK : FW_NORMAL),
<a name="l00360"></a>00360 ((style & AGL_FONT_STYLE_ITALIC) ? TRUE : FALSE),
<a name="l00361"></a>00361 ((style & AGL_FONT_STYLE_UNDERLINE) ? TRUE : FALSE),
<a name="l00362"></a>00362 ((style & AGL_FONT_STYLE_STRIKEOUT) ? TRUE : FALSE),
<a name="l00363"></a>00363 ANSI_CHARSET,
<a name="l00364"></a>00364 OUT_TT_PRECIS,
<a name="l00365"></a>00365 CLIP_DEFAULT_PRECIS,
<a name="l00366"></a>00366 (style & <a class="code" href="group__Text.html#ga91cc859278878dd4bf200bed7eab4359" title="Creates a font with anti-aliased characters.">AGL_FONT_STYLE_ANTI_ALIASED</a>) ? ANTIALIASED_QUALITY
<a name="l00367"></a>00367 : DEFAULT_QUALITY,
<a name="l00368"></a>00368 FF_DONTCARE | DEFAULT_PITCH,
<a name="l00369"></a>00369 name);
<a name="l00370"></a>00370
<a name="l00371"></a>00371 dc = GetDC(win_get_window());
<a name="l00372"></a>00372
<a name="l00373"></a>00373 SelectObject(dc, hFont);
<a name="l00374"></a>00374 wglUseFontOutlines(dc, start, end - start, data->list_base,
<a name="l00375"></a>00375 0.0, depth, (aglf_font_generation_mode == <a class="code" href="group__Text.html#ga4b45ef558e7934ceaaff146f450ab23f" title="Font generation mode.">AGL_FONT_POLYGONS</a>)
<a name="l00376"></a>00376 ? WGL_FONT_POLYGONS : WGL_FONT_LINES, gmf);
<a name="l00377"></a>00377
<a name="l00378"></a>00378 data->type = <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>;
<a name="l00379"></a>00379 data->data = gmf;
<a name="l00380"></a>00380 }
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <span class="keywordflow">return</span> ret;
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384 <span class="preprocessor">#endif</span>
<a name="l00385"></a>00385 <span class="preprocessor"></span>
<a name="l00386"></a>00386
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="preprocessor">#ifdef ALLEGRO_WITH_XWINDOWS</span>
<a name="l00389"></a>00389 <span class="preprocessor"></span><span class="keyword">static</span> FONT *x_load_system_font(<span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> style, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h,
<a name="l00390"></a>00390 <span class="keywordtype">float</span> depth, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> end) {
<a name="l00391"></a>00391 FONT_AGL_DATA *data;
<a name="l00392"></a>00392 FONT *ret;
<a name="l00393"></a>00393 XFontStruct *xfont;
<a name="l00394"></a>00394
<a name="l00395"></a>00395 ret = malloc(<span class="keyword">sizeof</span>(FONT));
<a name="l00396"></a>00396 <span class="keywordflow">if</span> (!ret) {
<a name="l00397"></a>00397 TRACE(PREFIX_E <span class="stringliteral">"x_load_system_font: Ran out of memory "</span>
<a name="l00398"></a>00398 <span class="stringliteral">"while allocating %zi bytes\n"</span>, <span class="keyword">sizeof</span>(FONT));
<a name="l00399"></a>00399 <span class="keywordflow">return</span> NULL;
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401 data = malloc(<span class="keyword">sizeof</span>(FONT_AGL_DATA));
<a name="l00402"></a>00402 <span class="keywordflow">if</span> (!data) {
<a name="l00403"></a>00403 free(ret);
<a name="l00404"></a>00404 TRACE(PREFIX_E <span class="stringliteral">"x_load_system_font: Ran out of memory "</span>
<a name="l00405"></a>00405 <span class="stringliteral">"while allocating %zi bytes\n"</span>, <span class="keyword">sizeof</span>(FONT_AGL_DATA));
<a name="l00406"></a>00406 <span class="keywordflow">return</span> NULL;
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408 ret->vtable = font_vtable_agl;
<a name="l00409"></a>00409 ret->data = data;
<a name="l00410"></a>00410
<a name="l00411"></a>00411 data->list_base = glGenLists(end - start);
<a name="l00412"></a>00412 data->start = start;
<a name="l00413"></a>00413 data->end = end;
<a name="l00414"></a>00414 data->next = NULL;
<a name="l00415"></a>00415 data->is_free_chunk = 0;
<a name="l00416"></a>00416
<a name="l00417"></a>00417 <span class="keywordflow">if</span> (type == <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a> || type == <a class="code" href="group__Text.html#gad2ebae17d2548a5befb888f8618f2206" title="Indicates that you don&#39;t really care how a font will be converted.">AGL_FONT_TYPE_DONT_CARE</a>) {
<a name="l00418"></a>00418 <span class="keywordtype">char</span> buf[256], major_type[256], minor_type[2];
<a name="l00419"></a>00419
<a name="l00420"></a>00420 usprintf(major_type, <span class="stringliteral">"medium"</span>);
<a name="l00421"></a>00421 <span class="keywordflow">if</span> (style & AGL_FONT_STYLE_BOLD)
<a name="l00422"></a>00422 usprintf(major_type, <span class="stringliteral">"bold"</span>);
<a name="l00423"></a>00423 minor_type[0] = (style & <a class="code" href="group__Text.html#ga67c48bf08c2b6cd6cc1a08dec2c7c5ef" title="Creates a font with italicized characters.">AGL_FONT_STYLE_ITALIC</a>) ? <span class="charliteral">'i'</span> : <span class="charliteral">'r'</span>;
<a name="l00424"></a>00424 minor_type[1] = <span class="charliteral">'\0'</span>;
<a name="l00425"></a>00425
<a name="l00426"></a>00426 usprintf(buf, <span class="stringliteral">"-*-%s-%s-%s-normal-*-%i-*-*-*-*-*-*-*"</span>, name,
<a name="l00427"></a>00427 major_type, minor_type, h);
<a name="l00428"></a>00428 <span class="comment">/* Load the font */</span>
<a name="l00429"></a>00429 xfont = XLoadQueryFont(_xwin.display, buf);
<a name="l00430"></a>00430 <span class="keywordflow">if</span> (!xfont) {
<a name="l00431"></a>00431 free(ret);
<a name="l00432"></a>00432 free(data);
<a name="l00433"></a>00433 TRACE(PREFIX_E <span class="stringliteral">"x_load_system_font: Failed to load "</span>
<a name="l00434"></a>00434 <span class="stringliteral">"%s\n"</span>, buf);
<a name="l00435"></a>00435 <span class="keywordflow">return</span> NULL;
<a name="l00436"></a>00436 }
<a name="l00437"></a>00437 glXUseXFont(xfont->fid, start, end - start, data->list_base);
<a name="l00438"></a>00438 data->type = <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>;
<a name="l00439"></a>00439 data->data = NULL;
<a name="l00440"></a>00440 XFreeFont(_xwin.display, xfont);
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 <span class="keywordflow">else</span> {
<a name="l00443"></a>00443 <span class="comment">/* Not Yet Implemented */</span>
<a name="l00444"></a>00444 <span class="keywordflow">return</span> NULL;
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446
<a name="l00447"></a>00447 <span class="keywordflow">return</span> ret;
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449 <span class="preprocessor">#endif</span>
<a name="l00450"></a>00450 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* ALLEGROGL_GENERIC_DRIVER */</span>
<a name="l00451"></a>00451
<a name="l00452"></a>00452
<a name="l00453"></a>00453
<a name="l00454"></a>00454 <span class="comment">/* void allegro_gl_set_font_generation_mode(int mode) */</span>
<a name="l00469"></a><a class="code" href="group__Text.html#ga62e79ccec5062f1cdadbc225319e9b44">00469</a> <span class="keywordtype">void</span> <a class="code" href="group__Text.html#ga62e79ccec5062f1cdadbc225319e9b44" title="Set the font generation mode for system fonts.">allegro_gl_set_font_generation_mode</a>(<span class="keywordtype">int</span> mode) {
<a name="l00470"></a>00470 aglf_font_generation_mode = mode;
<a name="l00471"></a>00471 <span class="keywordflow">return</span>;
<a name="l00472"></a>00472 }
<a name="l00473"></a>00473
<a name="l00474"></a>00474
<a name="l00475"></a>00475
<a name="l00476"></a>00476 <span class="comment">/* FONT *allegro_gl_load_system_font(char *name, int style, int w, int h) */</span>
<a name="l00485"></a><a class="code" href="group__Text.html#ga5bddcc6c1954665140083928117519de">00485</a> FONT *<a class="code" href="group__Text.html#ga5bddcc6c1954665140083928117519de" title="Short hand for aglf_load_system_font_ex(name, AGL_FONT_TYPE_OUTLINE, style, w, h, 0...">allegro_gl_load_system_font</a>(<span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> style, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h) {
<a name="l00486"></a>00486
<a name="l00487"></a>00487 <span class="keywordflow">return</span> <a class="code" href="group__Text.html#ga4ad68c54b0183c60cdbf2c7a02dc3157" title="Loads a system font.">allegro_gl_load_system_font_ex</a>(name, <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>,
<a name="l00488"></a>00488 style, w, h, 0.0f, 32, 256);
<a name="l00489"></a>00489 }
<a name="l00490"></a>00490
<a name="l00491"></a>00491
<a name="l00492"></a>00492
<a name="l00493"></a>00493 <span class="comment">/* FONT *allegro_gl_load_system_font_ex(char *name, int type, int style,</span>
<a name="l00494"></a>00494 <span class="comment"> int w, int h, float depth, int start, int end) */</span>
<a name="l00526"></a><a class="code" href="group__Text.html#ga4ad68c54b0183c60cdbf2c7a02dc3157">00526</a> FONT *<a class="code" href="group__Text.html#ga4ad68c54b0183c60cdbf2c7a02dc3157" title="Loads a system font.">allegro_gl_load_system_font_ex</a>(<span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> style,
<a name="l00527"></a>00527 <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <span class="keywordtype">float</span> depth, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> end) {
<a name="l00528"></a>00528
<a name="l00529"></a>00529 FONT *ret = NULL;
<a name="l00530"></a>00530
<a name="l00531"></a>00531 <span class="keywordflow">if</span> (!__allegro_gl_valid_context)
<a name="l00532"></a>00532 <span class="keywordflow">return</span> NULL;
<a name="l00533"></a>00533
<a name="l00534"></a>00534 <span class="keywordflow">if</span> (!name) {
<a name="l00535"></a>00535 TRACE(PREFIX_E <span class="stringliteral">"load_system_font: Nameless font\n"</span>);
<a name="l00536"></a>00536 <span class="keywordflow">return</span> NULL;
<a name="l00537"></a>00537 }
<a name="l00538"></a>00538
<a name="l00539"></a>00539 <span class="comment">/* Load a system font */</span>
<a name="l00540"></a>00540
<a name="l00541"></a>00541 <span class="preprocessor">#ifndef ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00542"></a>00542 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00543"></a>00543 <span class="preprocessor"></span> ret = win_load_system_font(name, type, style, w, h, depth, start, end);
<a name="l00544"></a>00544 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00545"></a>00545 <span class="preprocessor"></span> XLOCK();
<a name="l00546"></a>00546 ret = x_load_system_font(name, type, style, w, h, depth, start, end);
<a name="l00547"></a>00547 XUNLOCK();
<a name="l00548"></a>00548 <span class="preprocessor">#else</span>
<a name="l00549"></a>00549 <span class="preprocessor"></span> <span class="comment">/* Other platform */</span>
<a name="l00550"></a>00550 <span class="preprocessor">#endif</span>
<a name="l00551"></a>00551 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00552"></a>00552 <span class="preprocessor"></span>
<a name="l00553"></a>00553 <span class="keywordflow">return</span> ret;
<a name="l00554"></a>00554 }
<a name="l00555"></a>00555
<a name="l00556"></a>00556
<a name="l00557"></a>00557
<a name="l00573"></a><a class="code" href="group__Text.html#gabcbdd9810f7254cdb105f987ae1e557f">00573</a> <span class="keywordtype">void</span> <a class="code" href="group__Text.html#gabcbdd9810f7254cdb105f987ae1e557f" title="void allegro_gl_destroy_font(FONT *usefont)">allegro_gl_destroy_font</a>(FONT *f) {
<a name="l00574"></a>00574
<a name="l00575"></a>00575 FONT_AGL_DATA *data;
<a name="l00576"></a>00576
<a name="l00577"></a>00577 <span class="keywordflow">if</span> (!f) {
<a name="l00578"></a>00578 <span class="keywordflow">return</span>;
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 <span class="keywordflow">if</span> (f->vtable != font_vtable_agl) {
<a name="l00581"></a>00581 TRACE(PREFIX_E <span class="stringliteral">"destroy_font: Font is not of AGL type\n"</span>);
<a name="l00582"></a>00582 <span class="keywordflow">return</span>;
<a name="l00583"></a>00583 }
<a name="l00584"></a>00584
<a name="l00585"></a>00585 data = f->data;
<a name="l00586"></a>00586
<a name="l00587"></a>00587 <span class="keywordflow">if</span> (!data) {
<a name="l00588"></a>00588 TRACE(PREFIX_E <span class="stringliteral">"destroy_font: Font is inconsistent\n"</span>);
<a name="l00589"></a>00589 <span class="keywordflow">return</span>;
<a name="l00590"></a>00590 }
<a name="l00591"></a>00591
<a name="l00592"></a>00592 <span class="comment">/* Iterate through every segment of the font */</span>
<a name="l00593"></a>00593 <span class="keywordflow">while</span> (data) {
<a name="l00594"></a>00594 FONT_AGL_DATA *datanext;
<a name="l00595"></a>00595
<a name="l00596"></a>00596 <span class="comment">/* Release all resources taken up by this font */</span>
<a name="l00597"></a>00597 <span class="keywordflow">if</span> (data->type == <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>
<a name="l00598"></a>00598 || data->type == <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>
<a name="l00599"></a>00599 || data->type == <a class="code" href="group__Text.html#ga92bf039bc7b06568273ee17f15cf6671" title="Indicates that you want fonts to be converted to a texture format.">AGL_FONT_TYPE_TEXTURED</a>) {
<a name="l00600"></a>00600
<a name="l00601"></a>00601 <span class="keywordflow">if</span> (__allegro_gl_valid_context) {
<a name="l00602"></a>00602 <span class="keywordflow">if</span> (data->list_base)
<a name="l00603"></a>00603 glDeleteLists(data->list_base, data->end - data->start);
<a name="l00604"></a>00604 <span class="keywordflow">if</span> (data->texture)
<a name="l00605"></a>00605 glDeleteTextures(1, &data->texture);
<a name="l00606"></a>00606 }
<a name="l00607"></a>00607 }
<a name="l00608"></a>00608 <span class="keywordflow">if</span> (data->type == <a class="code" href="group__Text.html#gaba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>) {
<a name="l00609"></a>00609 <span class="keywordflow">if</span> (data->data)
<a name="l00610"></a>00610 free(data->data);
<a name="l00611"></a>00611 }
<a name="l00612"></a>00612 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (data->type == <a class="code" href="group__Text.html#ga92bf039bc7b06568273ee17f15cf6671" title="Indicates that you want fonts to be converted to a texture format.">AGL_FONT_TYPE_TEXTURED</a>) {
<a name="l00613"></a>00613 <span class="keywordflow">if</span> (data->data)
<a name="l00614"></a>00614 destroy_bitmap(data->data);
<a name="l00615"></a>00615 <span class="keywordflow">if</span> (data->glyph_coords)
<a name="l00616"></a>00616 free(data->glyph_coords);
<a name="l00617"></a>00617 }
<a name="l00618"></a>00618 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (data->type == <a class="code" href="group__Text.html#ga7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>) {
<a name="l00619"></a>00619 <span class="keywordflow">if</span> (data->data) {
<a name="l00620"></a>00620 <span class="keywordtype">int</span> i;
<a name="l00621"></a>00621 FONT_GLYPH **gl = data->data;
<a name="l00622"></a>00622 <span class="keywordflow">for</span> (i = 0; i < data->end - data->start; i++) {
<a name="l00623"></a>00623 <span class="keywordflow">if</span> (gl[i])
<a name="l00624"></a>00624 free(gl[i]);
<a name="l00625"></a>00625 }
<a name="l00626"></a>00626 free(gl);
<a name="l00627"></a>00627 }
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629 datanext = data->next;
<a name="l00630"></a>00630
<a name="l00631"></a>00631 <span class="keywordflow">if</span> (data->is_free_chunk)
<a name="l00632"></a>00632 free(data);
<a name="l00633"></a>00633
<a name="l00634"></a>00634 data = datanext;
<a name="l00635"></a>00635 }
<a name="l00636"></a>00636 free(f->data);
<a name="l00637"></a>00637
<a name="l00638"></a>00638 <span class="keywordflow">if</span> (f != font)
<a name="l00639"></a>00639 free(f);
<a name="l00640"></a>00640
<a name="l00641"></a>00641 <span class="keywordflow">return</span>;
<a name="l00642"></a>00642 }
<a name="l00643"></a>00643
<a name="l00644"></a>00644
<a name="l00645"></a>00645
<a name="l00646"></a>00646 <span class="comment">/* size_t allegro_gl_list_font_textures(FONT *f, GLuint *ids, size_t max_num_id) */</span>
<a name="l00689"></a><a class="code" href="group__Text.html#ga70b78c3a523dc9977c222d466edc6a5a">00689</a> <span class="keywordtype">size_t</span> <a class="code" href="group__Text.html#ga70b78c3a523dc9977c222d466edc6a5a" title="List the texture ID of all textures forming the specified font.">allegro_gl_list_font_textures</a>(FONT *f, GLuint *ids, <span class="keywordtype">size_t</span> max_num_id) {
<a name="l00690"></a>00690
<a name="l00691"></a>00691 <span class="keywordtype">size_t</span> num_ids = 0;
<a name="l00692"></a>00692 FONT_AGL_DATA *data;
<a name="l00693"></a>00693
<a name="l00694"></a>00694 <span class="keywordflow">if</span> (!f) {
<a name="l00695"></a>00695 <span class="keywordflow">return</span> 0;
<a name="l00696"></a>00696 }
<a name="l00697"></a>00697 <span class="keywordflow">if</span> (f->vtable != font_vtable_agl) {
<a name="l00698"></a>00698 TRACE(PREFIX_E <span class="stringliteral">"list_font_textures: Font is not of AGL type\n"</span>);
<a name="l00699"></a>00699 <span class="keywordflow">return</span> 0;
<a name="l00700"></a>00700 }
<a name="l00701"></a>00701
<a name="l00702"></a>00702 data = f->data;
<a name="l00703"></a>00703
<a name="l00704"></a>00704 <span class="keywordflow">if</span> (!data) {
<a name="l00705"></a>00705 TRACE(PREFIX_E <span class="stringliteral">"list_font_textures: Font is inconsistent\n"</span>);
<a name="l00706"></a>00706 <span class="keywordflow">return</span> 0;
<a name="l00707"></a>00707 }
<a name="l00708"></a>00708
<a name="l00709"></a>00709 <span class="keywordflow">if</span> (!__allegro_gl_valid_context) {
<a name="l00710"></a>00710 <span class="keywordflow">return</span> 0;
<a name="l00711"></a>00711 }
<a name="l00712"></a>00712
<a name="l00713"></a>00713 <span class="comment">/* Iterate through all font segments */</span>
<a name="l00714"></a>00714 <span class="keywordflow">while</span> (data) {
<a name="l00715"></a>00715 <span class="keywordflow">if</span> (data->texture) {
<a name="l00716"></a>00716 <span class="comment">/* Add the texture ID in the array, if it's not NULL and if there</span>
<a name="l00717"></a>00717 <span class="comment"> * is room.</span>
<a name="l00718"></a>00718 <span class="comment"> */</span>
<a name="l00719"></a>00719 <span class="keywordflow">if</span> (ids && num_ids < max_num_id) {
<a name="l00720"></a>00720 ids[num_ids] = data->texture;
<a name="l00721"></a>00721 }
<a name="l00722"></a>00722 num_ids++;
<a name="l00723"></a>00723 }
<a name="l00724"></a>00724
<a name="l00725"></a>00725 data = data->next;
<a name="l00726"></a>00726 }
<a name="l00727"></a>00727
<a name="l00728"></a>00728 <span class="keywordflow">return</span> num_ids;
<a name="l00729"></a>00729 }
<a name="l00730"></a>00730
</pre></div></div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="aglf_8c.html">aglf.c</a> </li>
<li class="footer">Generated on Thu May 19 2011 23:20:20 for AllegroGL by 
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
</ul>
</div>
</body>
</html>
|