Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 8ffe23af9b6e2265bcac8526648e8186 > files > 21

alleggl-devel-0.4.3-8.fc14.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AllegroGL: aglf.c Source File</title>
<link href="alleggl.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.2 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li class="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul>
</div>
<h1>aglf.c</h1><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 &lt;math.h&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;allegro.h&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include "<a class="code" href="alleggl_8h.html" title="Main header file for AllegroGL.">alleggl.h</a>"</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 &lt;OpenGL/glu.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#else</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#include &lt;GL/glu.h&gt;</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 &amp;&amp; !defined ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include &lt;xalleg.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;GL/glx.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#endif</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span>
<a name="l00028"></a><a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">00028</a> <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><a class="code" href="aglf_8c.html#2a3def9f845a76d84e7e34df3baa7d0a">00032</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="aglf_8c.html#2a3def9f845a76d84e7e34df3baa7d0a">aglf_font_generation_mode</a> = <a class="code" href="group__Text.html#g4b45ef558e7934ceaaff146f450ab23f" 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><a class="code" href="aglf_8c.html#c0a28eb85df0e3b1414f80522b87de21">00038</a> <span class="keyword">static</span> AL_CONST <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *<a class="code" href="aglf_8c.html#c0a28eb85df0e3b1414f80522b87de21">find_range</a>(AL_CONST <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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 &gt;= f-&gt;start) &amp;&amp; (c &lt; f-&gt;end))
<a name="l00042"></a>00042             <span class="keywordflow">return</span> f;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044         f = f-&gt;<a class="code" href="structFONT__AGL__DATA.html#cc7efd9b41620520c8e5b49b70bd8df7">next</a>;
<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#g84ecf6d5f5b363d7715e15eca8ebafeb">00067</a> <span class="keywordtype">int</span> <a class="code" href="group__Text.html#g84ecf6d5f5b363d7715e15eca8ebafeb" 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> (!<a class="code" href="alleggl_8c.html#1cf577416af8a45cce479746114d7acb">__allegro_gl_valid_context</a>)
<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] = (<a class="code" href="texture_8c.html#4a21cbf7c33064409941c606e8ccda0a">__allegro_gl_use_alpha</a> &amp;&amp; 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#gb93317445f8a566f8b5632e04fbf8e5b" 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#gb93317445f8a566f8b5632e04fbf8e5b">00169</a> <span class="keywordtype">int</span> <a class="code" href="group__Text.html#gb93317445f8a566f8b5632e04fbf8e5b" 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 <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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 <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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> (!<a class="code" href="alleggl_8c.html#1cf577416af8a45cce479746114d7acb">__allegro_gl_valid_context</a>)
<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(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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-&gt;vtable != <a class="code" href="fontconv_8c.html#639ff5b4222f196b5b82a388b80139ba">font_vtable_agl</a>) {
<a name="l00197"></a>00197         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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 <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a>*)f-&gt;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, &amp;matrix_mode);
<a name="l00212"></a>00212     glGetIntegerv(GL_FRONT_FACE, &amp;vert_order);
<a name="l00213"></a>00213     glGetIntegerv(GL_CULL_FACE_MODE, &amp;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, &amp;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-&gt;type == <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" 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-&gt;type == <a class="code" href="group__Text.html#gba7b8c941356029687ff4b4340e8b841" 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-&gt;type == <a class="code" href="group__Text.html#g92bf039bc7b06568273ee17f15cf6671" 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 &lt; range-&gt;start) || (c &gt;= range-&gt;end)) {
<a name="l00248"></a>00248             <span class="comment">/* search for a suitable character range */</span>
<a name="l00249"></a>00249             range = <a class="code" href="aglf_8c.html#c0a28eb85df0e3b1414f80522b87de21">find_range</a>(d, c);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251             <span class="keywordflow">if</span> (!range) {
<a name="l00252"></a>00252                 range = <a class="code" href="aglf_8c.html#c0a28eb85df0e3b1414f80522b87de21">find_range</a>(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-&gt;type == <a class="code" href="group__Text.html#g92bf039bc7b06568273ee17f15cf6671" 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-&gt;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-&gt;start;
<a name="l00266"></a>00266         c += range-&gt;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     <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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>(<a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a>));
<a name="l00307"></a>00307     <span class="keywordflow">if</span> (!data) {
<a name="l00308"></a>00308         free(ret);
<a name="l00309"></a>00309         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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>(<a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a>));
<a name="l00311"></a>00311         <span class="keywordflow">return</span> NULL;
<a name="l00312"></a>00312     }
<a name="l00313"></a>00313     ret-&gt;vtable = <a class="code" href="fontconv_8c.html#639ff5b4222f196b5b82a388b80139ba">font_vtable_agl</a>;
<a name="l00314"></a>00314     ret-&gt;data = data;
<a name="l00315"></a>00315         
<a name="l00316"></a>00316     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a> = glGenLists(end - start);
<a name="l00317"></a>00317     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#47e0c298ba2936d3ba256d4eb267be0c">start</a> = start;
<a name="l00318"></a>00318     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cf52aaba640c57ef28bd697920a40107">end</a> = end;
<a name="l00319"></a>00319     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cc7efd9b41620520c8e5b49b70bd8df7">next</a> = NULL;
<a name="l00320"></a>00320     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#048c4564f222713cbd015f125a3595f2">is_free_chunk</a> = 0;
<a name="l00321"></a>00321 
<a name="l00322"></a>00322     <span class="keywordflow">if</span> (type == <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" 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#gd2ebae17d2548a5befb888f8618f2206" title="Indicates that you don'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 &amp; <a class="code" href="group__Text.html#gb77d7d2c6ec6d1786472943f7cd814ca" title="Creates a font with bold characters.">AGL_FONT_STYLE_BOLD</a>) ? FW_BOLD
<a name="l00329"></a>00329                      : ((style &amp; <a class="code" href="group__Text.html#g27874c1fb7fdc1e00115bd853c973fc3" title="Creates a font with black (strong bold) characters.">AGL_FONT_STYLE_BLACK</a>) ? FW_BLACK : FW_NORMAL),
<a name="l00330"></a>00330             ((style &amp; <a class="code" href="group__Text.html#g67c48bf08c2b6cd6cc1a08dec2c7c5ef" title="Creates a font with italicized characters.">AGL_FONT_STYLE_ITALIC</a>) ? TRUE : FALSE),
<a name="l00331"></a>00331             ((style &amp; <a class="code" href="group__Text.html#ge9e4682339d264429ee601c632231c9f" title="Creates a font with underlined characters.">AGL_FONT_STYLE_UNDERLINE</a>) ? TRUE : FALSE),
<a name="l00332"></a>00332             ((style &amp; <a class="code" href="group__Text.html#g6ba31b9c7866d28b5494fad2577569db" 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 &amp; <a class="code" href="group__Text.html#g91cc859278878dd4bf200bed7eab4359" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a>);
<a name="l00346"></a>00346         data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> = <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>;
<a name="l00347"></a>00347         data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a> = 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#gba7b8c941356029687ff4b4340e8b841" 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 &amp; AGL_FONT_STYLE_BOLD) ? FW_BOLD
<a name="l00359"></a>00359                       : ((style &amp; AGL_FONT_STYLE_BLACK) ? FW_BLACK : FW_NORMAL),
<a name="l00360"></a>00360             ((style &amp; AGL_FONT_STYLE_ITALIC) ? TRUE : FALSE),
<a name="l00361"></a>00361             ((style &amp; AGL_FONT_STYLE_UNDERLINE) ? TRUE : FALSE),
<a name="l00362"></a>00362             ((style &amp; 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 &amp; <a class="code" href="group__Text.html#g91cc859278878dd4bf200bed7eab4359" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a>,
<a name="l00375"></a>00375             0.0, depth, (<a class="code" href="aglf_8c.html#2a3def9f845a76d84e7e34df3baa7d0a">aglf_font_generation_mode</a> == <a class="code" href="group__Text.html#g4b45ef558e7934ceaaff146f450ab23f" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> = <a class="code" href="group__Text.html#gba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>;
<a name="l00379"></a>00379         data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a> = 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     <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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>(<a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a>));
<a name="l00402"></a>00402     <span class="keywordflow">if</span> (!data) {
<a name="l00403"></a>00403         free(ret);
<a name="l00404"></a>00404         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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>(<a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a>));
<a name="l00406"></a>00406         <span class="keywordflow">return</span> NULL;
<a name="l00407"></a>00407     }
<a name="l00408"></a>00408     ret-&gt;vtable = <a class="code" href="fontconv_8c.html#639ff5b4222f196b5b82a388b80139ba">font_vtable_agl</a>;
<a name="l00409"></a>00409     ret-&gt;data = data;
<a name="l00410"></a>00410         
<a name="l00411"></a>00411     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a> = glGenLists(end - start);
<a name="l00412"></a>00412     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#47e0c298ba2936d3ba256d4eb267be0c">start</a> = start;
<a name="l00413"></a>00413     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cf52aaba640c57ef28bd697920a40107">end</a> = end;
<a name="l00414"></a>00414     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cc7efd9b41620520c8e5b49b70bd8df7">next</a> = NULL;
<a name="l00415"></a>00415     data-&gt;<a class="code" href="structFONT__AGL__DATA.html#048c4564f222713cbd015f125a3595f2">is_free_chunk</a> = 0;
<a name="l00416"></a>00416 
<a name="l00417"></a>00417     <span class="keywordflow">if</span> (type == <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" 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#gd2ebae17d2548a5befb888f8618f2206" title="Indicates that you don'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 &amp; 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 &amp; AGL_FONT_STYLE_ITALIC) ? <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(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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-&gt;fid, start, end - start, data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a>);
<a name="l00438"></a>00438         data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> = <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>;
<a name="l00439"></a>00439         data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a> = 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#g62e79ccec5062f1cdadbc225319e9b44">00469</a> <span class="keywordtype">void</span> <a class="code" href="group__Text.html#g62e79ccec5062f1cdadbc225319e9b44" 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     <a class="code" href="aglf_8c.html#2a3def9f845a76d84e7e34df3baa7d0a">aglf_font_generation_mode</a> = 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#g5bddcc6c1954665140083928117519de">00485</a> FONT *<a class="code" href="group__Text.html#g5bddcc6c1954665140083928117519de" title="Short hand for aglf_load_system_font_ex(name, AGL_FONT_TYPE_OUTLINE, style, w, h...">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#g4ad68c54b0183c60cdbf2c7a02dc3157" title="Loads a system font.">allegro_gl_load_system_font_ex</a>(name, <a class="code" href="group__Text.html#gba7b8c941356029687ff4b4340e8b841" 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#g4ad68c54b0183c60cdbf2c7a02dc3157">00526</a> FONT *<a class="code" href="group__Text.html#g4ad68c54b0183c60cdbf2c7a02dc3157" 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> (!<a class="code" href="alleggl_8c.html#1cf577416af8a45cce479746114d7acb">__allegro_gl_valid_context</a>)
<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(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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#gbcbdd9810f7254cdb105f987ae1e557f">00573</a> <span class="keywordtype">void</span> <a class="code" href="group__Text.html#gbcbdd9810f7254cdb105f987ae1e557f" title="Destroys the font.">allegro_gl_destroy_font</a>(FONT *f) {
<a name="l00574"></a>00574 
<a name="l00575"></a>00575     <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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-&gt;vtable != <a class="code" href="fontconv_8c.html#639ff5b4222f196b5b82a388b80139ba">font_vtable_agl</a>) {
<a name="l00581"></a>00581         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>;
<a name="l00586"></a>00586     
<a name="l00587"></a>00587     <span class="keywordflow">if</span> (!data) {
<a name="l00588"></a>00588         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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         <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" title="Indicates that you want fonts to be converted to a bitmap format.">AGL_FONT_TYPE_BITMAP</a>
<a name="l00598"></a>00598          || data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#gba7b8c941356029687ff4b4340e8b841" title="Indicates that you want fonts to be converted to an outline format.">AGL_FONT_TYPE_OUTLINE</a>
<a name="l00599"></a>00599          || data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#g92bf039bc7b06568273ee17f15cf6671" 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> (<a class="code" href="alleggl_8c.html#1cf577416af8a45cce479746114d7acb">__allegro_gl_valid_context</a>) {
<a name="l00602"></a>00602                 <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a>)
<a name="l00603"></a>00603                     glDeleteLists(data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d75ac7c37602a33f55fb0e064de1cd55">list_base</a>, data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cf52aaba640c57ef28bd697920a40107">end</a> - data-&gt;<a class="code" href="structFONT__AGL__DATA.html#47e0c298ba2936d3ba256d4eb267be0c">start</a>);
<a name="l00604"></a>00604                 <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#8ccc47e0953f26711bec22ed363a6caf">texture</a>)
<a name="l00605"></a>00605                     glDeleteTextures(1, &amp;data-&gt;<a class="code" href="structFONT__AGL__DATA.html#8ccc47e0953f26711bec22ed363a6caf">texture</a>);
<a name="l00606"></a>00606             }
<a name="l00607"></a>00607         }
<a name="l00608"></a>00608         <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#gba7b8c941356029687ff4b4340e8b841" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>) 
<a name="l00610"></a>00610                 free(data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>);
<a name="l00611"></a>00611         }
<a name="l00612"></a>00612         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#g92bf039bc7b06568273ee17f15cf6671" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>)
<a name="l00614"></a>00614                 destroy_bitmap(data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>);
<a name="l00615"></a>00615             <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d224273e9394e20f2298c31dcea4c151">glyph_coords</a>)
<a name="l00616"></a>00616                 free(data-&gt;<a class="code" href="structFONT__AGL__DATA.html#d224273e9394e20f2298c31dcea4c151">glyph_coords</a>);
<a name="l00617"></a>00617         }
<a name="l00618"></a>00618         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#4225e2a7596dcbf9ccd332dc4b22c445">type</a> == <a class="code" href="group__Text.html#g7ed8fdc1b0065d2fe584b15d69108b1a" 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>) {
<a name="l00620"></a>00620                 <span class="keywordtype">int</span> i;
<a name="l00621"></a>00621                 FONT_GLYPH **gl = data-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>;
<a name="l00622"></a>00622                 <span class="keywordflow">for</span> (i = 0; i &lt; data-&gt;<a class="code" href="structFONT__AGL__DATA.html#cf52aaba640c57ef28bd697920a40107">end</a> - data-&gt;<a class="code" href="structFONT__AGL__DATA.html#47e0c298ba2936d3ba256d4eb267be0c">start</a>; 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-&gt;<a class="code" href="structFONT__AGL__DATA.html#cc7efd9b41620520c8e5b49b70bd8df7">next</a>;
<a name="l00630"></a>00630 
<a name="l00631"></a>00631         <span class="keywordflow">if</span> (data-&gt;<a class="code" href="structFONT__AGL__DATA.html#048c4564f222713cbd015f125a3595f2">is_free_chunk</a>)
<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-&gt;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#g70b78c3a523dc9977c222d466edc6a5a">00689</a> <span class="keywordtype">size_t</span> <a class="code" href="group__Text.html#g70b78c3a523dc9977c222d466edc6a5a" 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     <a class="code" href="structFONT__AGL__DATA.html">FONT_AGL_DATA</a> *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-&gt;vtable != <a class="code" href="fontconv_8c.html#639ff5b4222f196b5b82a388b80139ba">font_vtable_agl</a>) {
<a name="l00698"></a>00698         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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-&gt;<a class="code" href="structFONT__AGL__DATA.html#c2c54d469bbf9e9290bf9755dec984e7">data</a>;
<a name="l00703"></a>00703     
<a name="l00704"></a>00704     <span class="keywordflow">if</span> (!data) {
<a name="l00705"></a>00705         TRACE(<a class="code" href="aglf_8c.html#8c04b6ea901068c5cc4020e9a18c0cbe">PREFIX_E</a> <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> (!<a class="code" href="alleggl_8c.html#1cf577416af8a45cce479746114d7acb">__allegro_gl_valid_context</a>) {
<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-&gt;<a class="code" href="structFONT__AGL__DATA.html#8ccc47e0953f26711bec22ed363a6caf">texture</a>) {
<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 &amp;&amp; num_ids &lt; max_num_id) {
<a name="l00720"></a>00720                 ids[num_ids] = data-&gt;<a class="code" href="structFONT__AGL__DATA.html#8ccc47e0953f26711bec22ed363a6caf">texture</a>;
<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-&gt;<a class="code" href="structFONT__AGL__DATA.html#cc7efd9b41620520c8e5b49b70bd8df7">next</a>;
<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><hr size="1"><address style="text-align: right;"><small>Generated on Mon Nov 12 11:05:31 2007 for AllegroGL by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address>
</body>
</html>