aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/font__manager_8cpp-source.html
blob: 4b267f4de3df7993df0a519adae270cfab499d37 (plain)
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
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>font_manager.cpp</h1><a href="font__manager_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include &lt;string&gt;</font>
00029 <font class="preprocessor">#include &lt;sstream&gt;</font>
00030 
00031 <font class="preprocessor">#include "<a class="code" href="font__manager_8h.html">3d/font_manager.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="font__generator_8h.html">3d/font_generator.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="texture__font_8h.html">3d/texture_font.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="computed__string_8h.html">3d/computed_string.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="smart__ptr_8h.html">nel/misc/smart_ptr.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00039 
00040 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00041 
00042 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00043 
00044 <font class="keyword">namespace </font>NL3D {
00045 
00046 
00047 
00048 <font class="comment">/*------------------------------------------------------------------*\</font>
00049 <font class="comment">                                                        getFontMaterial()</font>
00050 <font class="comment">\*------------------------------------------------------------------*/</font>
<a name="l00051"></a><a class="code" href="classNL3D_1_1CFontManager.html#a3">00051</a> CMaterial* CFontManager::getFontMaterial()
00052 {
00053         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CFontManager.html#o4">_TexFont</a> == NULL)
00054         {
00055                 <a class="code" href="classNL3D_1_1CFontManager.html#o4">_TexFont</a> = <font class="keyword">new</font> CTextureFont;
00056         }
00057 
00058         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a> == NULL)
00059         {
00060                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>= <font class="keyword">new</font> CMaterial;
00061                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;initUnlit();
00062                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;setSrcBlend(CMaterial::srcalpha);
00063                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;setDstBlend(CMaterial::invsrcalpha);
00064                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;setBlend(<font class="keyword">true</font>);
00065                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;setTexture(0, <a class="code" href="classNL3D_1_1CFontManager.html#o4">_TexFont</a>);
00066                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;texEnvOpRGB(0, CMaterial::Replace);
00067                 <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>-&gt;texEnvArg0RGB(0, CMaterial::Diffuse, CMaterial::SrcColor);
00068         }
00069         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CFontManager.html#o3">_MatFont</a>;
00070 }
00071 
00072 
00073 
00078 <font class="comment">/*</font>
00079 <font class="comment">template  &lt;class T&gt; static void NL3DcomputeString (CFontManager *fm, const std::basic_string&lt;T&gt; &amp;s,</font>
00080 <font class="comment">                                CFontGenerator *fontGen,</font>
00081 <font class="comment">                                const NLMISC::CRGBA &amp;color,</font>
00082 <font class="comment">                                uint32 fontSize,</font>
00083 <font class="comment">                                IDriver *driver,</font>
00084 <font class="comment">                                CComputedString &amp;output,</font>
00085 <font class="comment">                                bool    keep800x600Ratio)</font>
00086 <font class="comment">{</font>
00087 <font class="comment"></font>
00088 <font class="comment">        float FontRatio = 1.0;</font>
00089 <font class="comment">        uint32 width, height;</font>
00090 <font class="comment"></font>
00091 <font class="comment">        output.Color = color;</font>
00092 <font class="comment">        driver-&gt;getWindowSize (width, height);</font>
00093 <font class="comment">        if (height &gt; 0)</font>
00094 <font class="comment">                FontRatio = FontRatio / height;</font>
00095 <font class="comment">        </font>
00096 <font class="comment">        // resize fontSize if window not of 800x600.</font>
00097 <font class="comment">        if (keep800x600Ratio)</font>
00098 <font class="comment">        {</font>
00099 <font class="comment">                // keep the 800*600 ratio</font>
00100 <font class="comment">                fontSize = (uint32)floor(fontSize*height/600.f);</font>
00101 <font class="comment">                fontSize = max(fontSize, (uint32)2);</font>
00102 <font class="comment">        }</font>
00103 <font class="comment">        </font>
00104 <font class="comment">        // Setting vertices format</font>
00105 <font class="comment">        output.Vertices.setNumVertices (4 * s.size());</font>
00106 <font class="comment">        </font>
00107 <font class="comment">        // 1 character &lt;-&gt; 1 primitive block</font>
00108 <font class="comment">        sint32 penx = 0, dx;</font>
00109 <font class="comment">        sint32 penz = 0, dz;</font>
00110 <font class="comment">        float x1, z1, x2, z2;</font>
00111 <font class="comment">        float u1, v1, u2, v2;</font>
00112 <font class="comment">        CMaterial               *pMatFont = fm-&gt;getFontMaterial();</font>
00113 <font class="comment">        CTextureFont    *pTexFont = (CTextureFont*)(pMatFont-&gt;getTexture (0));</font>
00114 <font class="comment">        float hlfW = 0.5f / pTexFont-&gt;getWidth();</font>
00115 <font class="comment">        float hlfH = 0.5f / pTexFont-&gt;getHeight();</font>
00116 <font class="comment">        float hlfPix = 0.5f;</font>
00117 <font class="comment">        if (height &gt; 0)</font>
00118 <font class="comment">                hlfPix = hlfPix / height;</font>
00119 <font class="comment">        CTextureFont::SLetterKey k;</font>
00120 <font class="comment"></font>
00121 <font class="comment">        output.StringHeight = 0;</font>
00122 <font class="comment">        uint j = 0;</font>
00123 <font class="comment">        for (uint i = 0; i &lt; s.size(); i++)</font>
00124 <font class="comment">        {</font>
00125 <font class="comment">                // Creating font</font>
00126 <font class="comment">                k.Char = s[i];</font>
00127 <font class="comment">                k.FontGenerator = fontGen;</font>
00128 <font class="comment">                k.Size = fontSize;</font>
00129 <font class="comment">                CTextureFont::SLetterInfo *pLI = pTexFont-&gt;getLetterInfo (k);</font>
00130 <font class="comment">                if(pLI != NULL)</font>
00131 <font class="comment">                {</font>
00132 <font class="comment">                        if ((pLI-&gt;CharWidth &gt; 0) &amp;&amp; (pLI-&gt;CharHeight &gt; 0))</font>
00133 <font class="comment">                        {</font>
00134 <font class="comment">                                // Creating vertices</font>
00135 <font class="comment">                                dx = pLI-&gt;Left;</font>
00136 <font class="comment">                                dz = -((sint32)pLI-&gt;CharHeight-(sint32)(pLI-&gt;Top));</font>
00137 <font class="comment">                                u1 = pLI-&gt;U - hlfW;</font>
00138 <font class="comment">                                v1 = pLI-&gt;V - hlfH;</font>
00139 <font class="comment">                                u2 = pLI-&gt;U + ((float)pLI-&gt;CharWidth) / pTexFont-&gt;getWidth() + hlfW;</font>
00140 <font class="comment">                                v2 = pLI-&gt;V + ((float)pLI-&gt;CharHeight) / pTexFont-&gt;getHeight() + hlfH;</font>
00141 <font class="comment"></font>
00142 <font class="comment">                                x1 = (penx + dx) * FontRatio - hlfPix;</font>
00143 <font class="comment">                                z1 = (penz + dz) * FontRatio - hlfPix;</font>
00144 <font class="comment">                                x2 = (penx + dx + (sint32)pLI-&gt;CharWidth)  * FontRatio + hlfPix;</font>
00145 <font class="comment">                                z2 = (penz + dz + (sint32)pLI-&gt;CharHeight) * FontRatio + hlfPix;</font>
00146 <font class="comment"></font>
00147 <font class="comment">                                output.Vertices.setVertexCoord  (j, x1, 0, z1);</font>
00148 <font class="comment">                                output.Vertices.setTexCoord             (j, 0, u1, v2);</font>
00149 <font class="comment">                                ++j;</font>
00150 <font class="comment"></font>
00151 <font class="comment">                                output.Vertices.setVertexCoord  (j, x2, 0, z1);</font>
00152 <font class="comment">                                output.Vertices.setTexCoord             (j, 0, u2, v2);</font>
00153 <font class="comment">                                ++j;</font>
00154 <font class="comment"></font>
00155 <font class="comment">                                output.Vertices.setVertexCoord  (j, x2, 0, z2); </font>
00156 <font class="comment">                                output.Vertices.setTexCoord             (j, 0, u2, v1);</font>
00157 <font class="comment">                                ++j;</font>
00158 <font class="comment"></font>
00159 <font class="comment">                                output.Vertices.setVertexCoord  (j, x1, 0, z2); </font>
00160 <font class="comment">                                output.Vertices.setTexCoord             (j, 0, u1, v1);</font>
00161 <font class="comment">                                ++j;</font>
00162 <font class="comment">                                </font>
00163 <font class="comment">                                if (z2 &gt; output.StringHeight) </font>
00164 <font class="comment">                                        output.StringHeight = z2;</font>
00165 <font class="comment">                        }</font>
00166 <font class="comment">                        penx += pLI-&gt;AdvX;</font>
00167 <font class="comment">                }</font>
00168 <font class="comment"></font>
00169 <font class="comment">                // Building Material</font>
00170 <font class="comment">                output.Material = pMatFont;</font>
00171 <font class="comment">        }</font>
00172 <font class="comment">        output.Vertices.setNumVertices (j);</font>
00173 <font class="comment"></font>
00174 <font class="comment">        output.StringWidth = penx * FontRatio;</font>
00175 <font class="comment">}</font>
00176 <font class="comment">  */</font>
00177 
00178 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a354">NL3DcomputeStringChar</a> (CFontManager *fm, <font class="keyword">const</font> std::basic_string&lt;char&gt; &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>,
00179                                 CFontGenerator *fontGen,
00180                                 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;color,
00181                                 <a class="code" href="types__nl_8h.html#a10">uint32</a> fontSize,
00182                                 IDriver *driver,
00183                                 CComputedString &amp;output,
00184                                 <font class="keywordtype">bool</font>    keep800x600Ratio)
00185 {
00186 
00187         <font class="keywordtype">float</font> FontRatio = 1.0;
00188         <a class="code" href="types__nl_8h.html#a10">uint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00189 
00190         output.Color = color;
00191         driver-&gt;getWindowSize (<a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>);
00192         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a> &gt; 0)
00193                 FontRatio = FontRatio / <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00194         
00195         <font class="comment">// resize fontSize if window not of 800x600.</font>
00196         <font class="keywordflow">if</font> (keep800x600Ratio)
00197         {
00198                 <font class="comment">// keep the 800*600 ratio</font>
00199                 fontSize = (uint32)floor(fontSize*<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>/600.f);
00200                 fontSize = max(fontSize, (<a class="code" href="types__nl_8h.html#a10">uint32</a>)2);
00201         }
00202         
00203         <font class="comment">// Setting vertices format</font>
00204         output.Vertices.setNumVertices (4 * <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>.size());
00205         
00206         <font class="comment">// 1 character &lt;-&gt; 1 primitive block</font>
00207         <a class="code" href="types__nl_8h.html#a9">sint32</a> penx = 0, dx;
00208         <a class="code" href="types__nl_8h.html#a9">sint32</a> penz = 0, dz;
00209         <font class="keywordtype">float</font> x1, z1, x2, z2;
00210         <font class="keywordtype">float</font> u1, v1, u2, v2;
00211         CMaterial               *pMatFont = fm-&gt;getFontMaterial();
00212         CTextureFont    *pTexFont = (CTextureFont*)(pMatFont-&gt;getTexture (0));
00213         <font class="keywordtype">float</font> hlfW = 0.5f / pTexFont-&gt;getWidth();
00214         <font class="keywordtype">float</font> hlfH = 0.5f / pTexFont-&gt;getHeight();
00215         <font class="keywordtype">float</font> hlfPix = 0.5f;
00216         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a> &gt; 0)
00217                 hlfPix = hlfPix / <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00218         CTextureFont::SLetterKey k;
00219 
00220         output.StringHeight = 0;
00221         <a class="code" href="types__nl_8h.html#a14">uint</a> j = 0;
00222         <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>.size(); i++)
00223         {
00224                 <font class="comment">// Creating font</font>
00225                 k.Char = <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>[i];
00226                 k.FontGenerator = fontGen;
00227                 k.Size = fontSize;
00228                 CTextureFont::SLetterInfo *pLI = pTexFont-&gt;getLetterInfo (k);
00229                 <font class="keywordflow">if</font>(pLI != NULL)
00230                 {
00231                         <a class="code" href="types__nl_8h.html#a9">sint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a> = pLI-&gt;CharWidth - 1;
00232                         <a class="code" href="types__nl_8h.html#a9">sint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a> = pLI-&gt;CharHeight - 1;
00233                         <font class="keywordflow">if</font> ((pLI-&gt;CharWidth &gt; 0) &amp;&amp; (pLI-&gt;CharHeight &gt; 0))
00234                         {
00235                                 <font class="comment">// Creating vertices</font>
00236                                 dx = pLI-&gt;Left;
00237                                 dz = -(<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>-(sint32)(pLI-&gt;Top));
00238                                 u1 = pLI-&gt;U - hlfW;
00239                                 v1 = pLI-&gt;V - hlfH;
00240                                 u2 = pLI-&gt;U + ((float)<a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>) / pTexFont-&gt;getWidth() + hlfW;
00241                                 v2 = pLI-&gt;V + ((float)<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>) / pTexFont-&gt;getHeight() + hlfH;
00242 
00243                                 x1 = (penx + dx) * FontRatio - hlfPix;
00244                                 z1 = (penz + dz) * FontRatio - hlfPix;
00245                                 x2 = (penx + dx + <a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>)  * FontRatio + hlfPix;
00246                                 z2 = (penz + dz + <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>) * FontRatio + hlfPix;
00247 
00248                                 output.Vertices.setVertexCoord  (j, x1, 0, z1);
00249                                 output.Vertices.setTexCoord             (j, 0, u1, v2);
00250                                 ++j;
00251 
00252                                 output.Vertices.setVertexCoord  (j, x2, 0, z1);
00253                                 output.Vertices.setTexCoord             (j, 0, u2, v2);
00254                                 ++j;
00255 
00256                                 output.Vertices.setVertexCoord  (j, x2, 0, z2); 
00257                                 output.Vertices.setTexCoord             (j, 0, u2, v1);
00258                                 ++j;
00259 
00260                                 output.Vertices.setVertexCoord  (j, x1, 0, z2); 
00261                                 output.Vertices.setTexCoord             (j, 0, u1, v1);
00262                                 ++j;
00263                                 
00264                                 <font class="keywordflow">if</font> (fabsf(z1-z2) &gt; output.StringHeight) 
00265                                         output.StringHeight = fabsf(z1-z2);
00266                         }
00267                         penx += pLI-&gt;AdvX;
00268                 }
00269 
00270                 <font class="comment">// Building Material</font>
00271                 output.Material = pMatFont;
00272         }
00273         output.Vertices.setNumVertices (j);
00274 
00275         output.StringWidth = penx * FontRatio;
00276 }
00277 <font class="comment">// ---------------------------------------------------------------------------------------</font>
00278 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a355">NL3DcomputeStringUC</a> (CFontManager *fm, <font class="keyword">const</font> std::basic_string&lt;ucchar&gt; &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>,
00279                                 CFontGenerator *fontGen,
00280                                 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;color,
00281                                 <a class="code" href="types__nl_8h.html#a10">uint32</a> fontSize,
00282                                 IDriver *driver,
00283                                 CComputedString &amp;output,
00284                                 <font class="keywordtype">bool</font>    keep800x600Ratio)
00285 {
00286 
00287         <font class="keywordtype">float</font> FontRatio = 1.0;
00288         <a class="code" href="types__nl_8h.html#a10">uint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00289 
00290         output.Color = color;
00291         driver-&gt;getWindowSize (<a class="code" href="driver__opengl__extension__def_8h.html#a266">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>);
00292         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a> &gt; 0)
00293                 FontRatio = FontRatio / <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00294         
00295         <font class="comment">// resize fontSize if window not of 800x600.</font>
00296         <font class="keywordflow">if</font> (keep800x600Ratio)
00297         {
00298                 <font class="comment">// keep the 800*600 ratio</font>
00299                 fontSize = (uint32)floor(fontSize*<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>/600.f);
00300                 fontSize = max(fontSize, (<a class="code" href="types__nl_8h.html#a10">uint32</a>)2);
00301         }
00302         
00303         <font class="comment">// Setting vertices format</font>
00304         output.Vertices.setNumVertices (4 * <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>.size());
00305         
00306         <font class="comment">// 1 character &lt;-&gt; 1 primitive block</font>
00307         <a class="code" href="types__nl_8h.html#a9">sint32</a> penx = 0, dx;
00308         <a class="code" href="types__nl_8h.html#a9">sint32</a> penz = 0, dz;
00309         <font class="keywordtype">float</font> x1, z1, x2, z2;
00310         <font class="keywordtype">float</font> u1, v1, u2, v2;
00311         <font class="keywordtype">float</font> maxZ=-1.0f, minZ=1.0f;
00312         CMaterial               *pMatFont = fm-&gt;getFontMaterial();
00313         CTextureFont    *pTexFont = (CTextureFont*)(pMatFont-&gt;getTexture (0));
00314         <font class="keywordtype">float</font> hlfW = 0.5f / pTexFont-&gt;getWidth();
00315         <font class="keywordtype">float</font> hlfH = 0.5f / pTexFont-&gt;getHeight();
00316         <font class="keywordtype">float</font> hlfPix = 0.5f;
00317         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a> &gt; 0)
00318                 hlfPix = hlfPix / <a class="code" href="driver__opengl__extension__def_8h.html#a267">height</a>;
00319         CTextureFont::SLetterKey k;
00320 
00321         output.StringHeight = 0;
00322         <a class="code" href="types__nl_8h.html#a14">uint</a> j = 0;
00323         <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>.size(); i++)
00324         {
00325                 <font class="comment">// Creating font</font>
00326                 k.Char = <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>[i];
00327                 k.FontGenerator = fontGen;
00328                 k.Size = fontSize;
00329                 CTextureFont::SLetterInfo *pLI = pTexFont-&gt;getLetterInfo (k);
00330                 <font class="keywordflow">if</font>(pLI != NULL)
00331                 {
00332                         <font class="keywordflow">if</font> ((pLI-&gt;CharWidth &gt; 0) &amp;&amp; (pLI-&gt;CharHeight &gt; 0))
00333                         {
00334                                 <font class="comment">// Creating vertices</font>
00335                                 dx = pLI-&gt;Left;
00336                                 dz = -((sint32)pLI-&gt;CharHeight-(sint32)(pLI-&gt;Top));
00337                                 u1 = pLI-&gt;U - hlfW;
00338                                 v1 = pLI-&gt;V - hlfH;
00339                                 u2 = pLI-&gt;U + ((float)pLI-&gt;CharWidth) / pTexFont-&gt;getWidth() + hlfW;
00340                                 v2 = pLI-&gt;V + ((float)pLI-&gt;CharHeight) / pTexFont-&gt;getHeight() + hlfH;
00341 
00342                                 x1 = (penx + dx) * FontRatio - hlfPix;
00343                                 z1 = (penz + dz) * FontRatio - hlfPix;
00344                                 x2 = (penx + dx + (sint32)pLI-&gt;CharWidth)  * FontRatio + hlfPix;
00345                                 z2 = (penz + dz + (sint32)pLI-&gt;CharHeight) * FontRatio + hlfPix;
00346 
00347                                 output.Vertices.setVertexCoord  (j, x1, 0, z1);
00348                                 output.Vertices.setTexCoord             (j, 0, u1, v2);
00349                                 ++j;
00350 
00351                                 output.Vertices.setVertexCoord  (j, x2, 0, z1);
00352                                 output.Vertices.setTexCoord             (j, 0, u2, v2);
00353                                 ++j;
00354 
00355                                 output.Vertices.setVertexCoord  (j, x2, 0, z2); 
00356                                 output.Vertices.setTexCoord             (j, 0, u2, v1);
00357                                 ++j;
00358 
00359                                 output.Vertices.setVertexCoord  (j, x1, 0, z2); 
00360                                 output.Vertices.setTexCoord             (j, 0, u1, v1);
00361                                 ++j;
00362                                 
00363                                 <font class="keywordflow">if</font> (z1 &lt; minZ) minZ = z1;
00364                                 <font class="keywordflow">if</font> (z2 &gt; maxZ) maxZ = z2;
00365                         }
00366                         penx += pLI-&gt;AdvX;
00367                 }
00368 
00369                 <font class="comment">// Building Material</font>
00370                 output.Material = pMatFont;
00371         }
00372         output.Vertices.setNumVertices (j);
00373 
00374         output.StringWidth = penx * FontRatio;
00375         output.StringHeight = maxZ - minZ;
00376         output.StringLine = fabsf(minZ);
00377 }
00378 
00379 
00380 
00381 <font class="comment">/*------------------------------------------------------------------*\</font>
00382 <font class="comment">                                                        computeString()</font>
00383 <font class="comment">\*------------------------------------------------------------------*/</font>
<a name="l00384"></a><a class="code" href="classNL3D_1_1CFontManager.html#a4">00384</a> <font class="keywordtype">void</font> CFontManager::computeString (<font class="keyword">const</font> std::string &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>,
00385                                                                   CFontGenerator *fontGen,
00386                                                                   <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;color,
00387                                                                   <a class="code" href="types__nl_8h.html#a10">uint32</a> fontSize,
00388                                                                   IDriver *driver,
00389                                                                   CComputedString &amp;output,
00390                                                                   <font class="keywordtype">bool</font>  keep800x600Ratio)
00391 {
00392         <a class="code" href="namespaceNL3D.html#a354">NL3DcomputeStringChar</a> (<font class="keyword">this</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>, fontGen, color, fontSize, driver, output,keep800x600Ratio);
00393 }
00394 
00395 
00396 <font class="comment">/*------------------------------------------------------------------*\</font>
00397 <font class="comment">                                                        computeString()</font>
00398 <font class="comment">\*------------------------------------------------------------------*/</font>
<a name="l00399"></a><a class="code" href="classNL3D_1_1CFontManager.html#a5">00399</a> <font class="keywordtype">void</font> CFontManager::computeString (<font class="keyword">const</font> <a class="code" href="classucstring.html">ucstring</a> &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a260">s</a>,
00400                                                                   CFontGenerator *fontGen,
00401                                                                   <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;color,
00402                                                                   <a class="code" href="types__nl_8h.html#a10">uint32</a> fontSize,
00403                                                                   IDriver *driver,
00404                                                                   CComputedString &amp;output,
00405                                                                   <font class="keywordtype">bool</font>  keep800x600Ratio)
00406 {
00407         <a class="code" href="namespaceNL3D.html#a355">NL3DcomputeStringUC</a> (<font class="keyword">this</font>, s, fontGen, color, fontSize, driver, output,keep800x600Ratio);
00408 }
00409 
00410 
<a name="l00411"></a><a class="code" href="classNL3D_1_1CFontManager.html#a6">00411</a> string CFontManager::getCacheInformation()<font class="keyword"> const</font>
00412 <font class="keyword"></font>{
00413         stringstream ss;
00414 
00415         ss &lt;&lt; <font class="stringliteral">"MaxMemory: "</font> &lt;&lt; (uint) <a class="code" href="classNL3D_1_1CFontManager.html#o1">_MaxMemory</a> &lt;&lt; <font class="stringliteral">" MemSize: "</font> &lt;&lt; (uint) <a class="code" href="classNL3D_1_1CFontManager.html#o0">_MemSize</a> &lt;&lt; <font class="stringliteral">" NbChar: "</font> &lt;&lt; (uint) <a class="code" href="classNL3D_1_1CFontManager.html#o2">_NbChar</a>;
00416 
00417         <font class="keywordflow">return</font> ss.str();
00418 }
00419 
00420 
00421 
00422 
00423 
00424 } <font class="comment">// NL3D</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>