aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/texture__dlm_8cpp-source.html
blob: b8b68c42d140c7834c80450dcc68317b26a0de0a (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
490
491
492
493
494
495
496
497
<!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="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><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="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG  SRC="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="http://www.nevrax.org/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="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

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

<!-- title -->
<TABLE  background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="http://www.nevrax.org/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="http://www.nevrax.org/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:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>texture_dlm.cpp</h1><a href="texture__dlm_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000-2002 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 "<a class="code" href="texture__dlm_8h.html">3d/texture_dlm.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="fast__mem_8h.html">nel/misc/fast_mem.h</a>"</font>
00031 
00032 
00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00035 
00036 
00037 <font class="keyword">namespace </font>NL3D 
00038 {
00039 
00040 
00041 <font class="comment">// ***************************************************************************</font>
<a name="l00042"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#a0">00042</a> CTextureDLM::CTextureDLM(uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
00043 {
00044         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;=<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>);
00045         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;=<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>);
00046         <a class="code" href="debug_8h.html#a6">nlassert</a>(NLMISC::isPowerOf2(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>));
00047         <a class="code" href="debug_8h.html#a6">nlassert</a>(NLMISC::isPowerOf2(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>));
00048 
00049         <font class="comment">// verify there is sufficient blocks.</font>
00050         <a class="code" href="classNL3D_1_1CTextureDLM.html#o0">_WBlock</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>/<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>;
00051         uint    nBlocks= <a class="code" href="classNL3D_1_1CTextureDLM.html#o0">_WBlock</a> * (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>/<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>);
00052         <a class="code" href="debug_8h.html#a6">nlassert</a>(nBlocks&gt;=<a class="code" href="texture__dlm_8h.html#a1">NL_DLM_LIGHTMAP_TYPE_SIZE</a>);
00053 
00054 
00055         <font class="comment">// The DLM texture always reside in memory...</font>
00056         <font class="comment">// NB: this is simplier like that, and this is not a problem, since actually only 256Ko is allocated :o)</font>
00057         <a class="code" href="classNL3D_1_1ITexture.html#a3">setReleasable</a>(<font class="keyword">false</font>);
00058         <font class="comment">// create the bitmap.</font>
00059         CBitmap::resize(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>, CBitmap::RGBA);
00060         <font class="comment">// Format of texture, 32 bits and no mipmaps.</font>
00061         <font class="comment">// NB: 16 bits is not a good idea, because implies lot of flicking</font>
00062         <a class="code" href="classNL3D_1_1ITexture.html#z826_4">setUploadFormat</a>(ITexture::RGBA8888);
00063         <a class="code" href="classNL3D_1_1ITexture.html#z826_6">setFilterMode</a>(ITexture::Linear, ITexture::LinearMipMapOff);
00064 
00065         <font class="comment">// Fill the array of blocks.</font>
00066         <a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>.resize(nBlocks);
00067         <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.resize(nBlocks);
00068         sint i;
00069         <font class="keywordflow">for</font>(i=0;i&lt;(sint)<a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>.size();i++)
00070         {
00071                 <font class="comment">// compute position of the block in the texture</font>
00072                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>[i].PosX= (i%<a class="code" href="classNL3D_1_1CTextureDLM.html#o0">_WBlock</a>) * <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>;
00073                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>[i].PosY= (i/<a class="code" href="classNL3D_1_1CTextureDLM.html#o0">_WBlock</a>) * <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>;
00074 
00075                 <font class="comment">// This block is free!!</font>
00076                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>[i]=i;
00077         }
00078 
00079         <font class="comment">// init list to NULL.</font>
00080         <font class="keywordflow">for</font>(i=0;i&lt;(sint)<a class="code" href="texture__dlm_8h.html#a1">NL_DLM_LIGHTMAP_TYPE_SIZE</a>;i++)
00081         {
00082                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[i]= NULL;
00083         }
00084 
00085         <font class="comment">// Since NL_DLM_BLOCK_SIZE is 10 or 18 (a factor of prime number 5 or 3 respectively), we are sure there is </font>
00086         <font class="comment">// at least one pixel which is not used by blcks. The last pixel is filled with black (see CTextureDLm doc)</font>
00087         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>==10 || <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>==18);
00088         CRGBA   *ptr= (CRGBA*)(&amp;CBitmap::getPixels(0)[0]);
00089         <font class="comment">// fill last pixel with black.</font>
00090         ptr[<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-1]= CRGBA::Black;
00091         <font class="comment">// Also, to ensure the texture do not wrap around, disable Tiling.</font>
00092         ITexture::setWrapS(ITexture::Clamp);
00093         ITexture::setWrapT(ITexture::Clamp);
00094 }
00095 
00096 
00097 <font class="comment">// ***************************************************************************</font>
<a name="l00098"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#c0">00098</a> uint                            CTextureDLM::getTypeForSize(uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
00099 {
00100 <font class="preprocessor">#ifdef NL_DLM_TILE_RES</font>
00101 <font class="preprocessor"></font>        <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==3 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==5 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==9 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==17);
00102         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==3 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==5 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==9 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==17);
00103 <font class="preprocessor">#else</font>
00104 <font class="preprocessor"></font>        <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==2 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==3 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==5 || <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>==9);
00105         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==2 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==3 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==5 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>==9);
00106 <font class="preprocessor">#endif</font>
00107 <font class="preprocessor"></font>
00108         <font class="comment">// 0 for 2, 1 for 3, 2 for 5, and 3 for 9, and 4 for 17</font>
00109         <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>-1);
00110         <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-1);
00111 <font class="preprocessor">#ifdef NL_DLM_TILE_RES</font>
00112 <font class="preprocessor"></font>        <font class="comment">// 0 for 3, 1 for 5, 2, for 9, and 3 for 17</font>
00113         <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>--; <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>--;
00114 <font class="preprocessor">#endif</font>
00115 <font class="preprocessor"></font>
00116         uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>*4;
00117         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>&lt;<a class="code" href="texture__dlm_8h.html#a1">NL_DLM_LIGHTMAP_TYPE_SIZE</a>);
00118 
00119         <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>;
00120 }
00121 
00122 
00123 <font class="comment">// ***************************************************************************</font>
<a name="l00124"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_0">00124</a> <font class="keywordtype">bool</font>                    CTextureDLM::canCreateLightMap(uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h)
00125 {
00126         <font class="comment">// First test if the list is not empty.</font>
00127         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[<a class="code" href="classNL3D_1_1CTextureDLM.html#c0">getTypeForSize</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>,h)])
00128                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00129 
00130         <font class="comment">// If empty, test if there is an empty block.</font>
00131         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.size()&gt;0;
00132 }
00133 
00134 
00135 <font class="comment">// ***************************************************************************</font>
<a name="l00136"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#c1">00136</a> <font class="keywordtype">void</font>                    CTextureDLM::linkFreeBlock(uint lMapType, CBlock *block)
00137 {
00138         <font class="comment">// link me to others</font>
00139         block-&gt;FreeNext= <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType];
00140         block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>= NULL;
00141         <font class="comment">// link other to me</font>
00142         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType])
00143                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType]-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>= block;
00144         <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType]= block;
00145 }
00146 
00147 <font class="comment">// ***************************************************************************</font>
<a name="l00148"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#c2">00148</a> <font class="keywordtype">void</font>                    CTextureDLM::unlinkFreeBlock(uint lMapType, CBlock *block)
00149 {
00150         <font class="comment">// unlink other from me</font>
00151         <font class="keywordflow">if</font>(block-&gt;FreeNext)
00152                 block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m6">FreeNext</a>-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>= block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>;
00153         <font class="keywordflow">if</font>(block-&gt;FreePrec)
00154                 block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m6">FreeNext</a>= block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m6">FreeNext</a>;
00155         <font class="keywordflow">else</font>
00156                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType]= block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m6">FreeNext</a>;
00157         <font class="comment">// reset me</font>
00158         block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m5">FreePrec</a>= NULL;
00159         block-&gt;<a class="code" href="structNL3D_1_1CTextureDLM_1_1CBlock.html#m6">FreeNext</a>= NULL;
00160 }
00161 
00162 
00163 <font class="comment">// ***************************************************************************</font>
<a name="l00164"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_1">00164</a> <font class="keywordtype">bool</font>                    CTextureDLM::createLightMap(uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, uint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)
00165 {
00166         <font class="comment">// at least cna create it??</font>
00167         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CTextureDLM.html#z829_0">canCreateLightMap</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h))
00168                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00169 
00170         <font class="comment">// the type of lightmap.</font>
00171         uint    lMapType= <a class="code" href="classNL3D_1_1CTextureDLM.html#c0">getTypeForSize</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>,h);
00172 
00173         <font class="comment">// First manage case list is empty.</font>
00174         <font class="comment">//===================</font>
00175         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType]==NULL)
00176         {
00177                 <font class="comment">// list is empty =&gt; allocate a block from _EmptyBlocks.</font>
00178                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.size()&gt;0);
00179 
00180                 <font class="comment">// pop a block from empty list</font>
00181                 CBlock  *block= &amp;<a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>[<a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.back()];
00182                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.pop_back();
00183 
00184                 <font class="comment">// init this block.</font>
00185                 <a class="code" href="debug_8h.html#a6">nlassert</a>(block-&gt;FreeSpace==0);
00186                 <font class="comment">// set size of lightmaps for this blocks.</font>
00187                 block-&gt;Width= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
00188                 block-&gt;Height= h;
00189 
00190                 <font class="comment">// Link this block to the list.</font>
00191                 <a class="code" href="classNL3D_1_1CTextureDLM.html#c1">linkFreeBlock</a>(lMapType, block);
00192         }
00193 
00194         <font class="comment">// Get the block from the list.</font>
00195         CBlock  *block= <a class="code" href="classNL3D_1_1CTextureDLM.html#o3">_FreeBlocks</a>[lMapType];
00196 
00197         <font class="comment">// Allocate block lightmap.</font>
00198         <font class="comment">//===================</font>
00199 
00200         <font class="comment">// compute block info.</font>
00201         uint    nLMapOnX= <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a> / block-&gt;Width;
00202         uint    nLMapOnY= <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a> / block-&gt;Height;
00203         uint    nLMapPerBlock= nLMapOnX * nLMapOnY;
00204         <font class="comment">// bit must fit in a uint64</font>
00205         <a class="code" href="debug_8h.html#a6">nlassert</a>(nLMapPerBlock&lt;=64);
00206 
00207         <font class="comment">// get an id in the FreeSpace bitField.</font>
00208         uint    i;
00209         <font class="keywordflow">for</font>(i= 0;i&lt;nLMapPerBlock; i++)
00210         {
00211                 uint    mask= 1&lt;&lt;i;
00212                 <font class="comment">// If the bit is not set, then this id is free.</font>
00213                 <font class="keywordflow">if</font>( (block-&gt;FreeSpace &amp; mask)==0 )
00214                 {
00215                         <font class="comment">// take this id, hence set this bit</font>
00216                         block-&gt;FreeSpace|= mask;
00217                         <font class="comment">// stop, found.</font>
00218                         <font class="keywordflow">break</font>;
00219                 }
00220         }
00221         <a class="code" href="debug_8h.html#a6">nlassert</a>(i&lt;nLMapPerBlock);
00222 
00223         <font class="comment">// compute x/y texture pos for this id.</font>
00224         <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= block-&gt;PosX + (i%nLMapOnX) * <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
00225         <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= block-&gt;PosY + (i/nLMapOnX) * h;
00226 
00227 
00228         <font class="comment">// if lightmap full</font>
00229         <font class="comment">//===================</font>
00230         <font class="comment">// if bitfield is full</font>
00231         <font class="keywordflow">if</font>( block-&gt;FreeSpace == (uint)(1&lt;&lt;nLMapPerBlock)-1 )
00232         {
00233                 <font class="comment">// Must remove it from free list.</font>
00234                 <a class="code" href="classNL3D_1_1CTextureDLM.html#c2">unlinkFreeBlock</a>(lMapType, block);
00235         }
00236 
00237         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00238 }
00239 
00240 <font class="comment">// ***************************************************************************</font>
<a name="l00241"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_2">00241</a> <font class="keywordtype">void</font>                    CTextureDLM::copyRect(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, CRGBA  *textMap)
00242 {
00243         <font class="comment">// copy image.</font>
00244         CRGBA   *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= textMap;
00245         CRGBA   *dst= (CRGBA*)&amp;(*<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().begin());
00246         dst+= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00247         <font class="keywordflow">for</font>(sint n= h;n&gt;0;n--, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, dst+= <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>())
00248         {
00249                 memcpy(dst, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*<font class="keyword">sizeof</font>(CRGBA));
00250         }
00251 
00252         <font class="comment">// Invalidate the rectangle.</font>
00253         ITexture::touchRect(CRect(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h));
00254 }
00255 
00256 <font class="comment">// ***************************************************************************</font>
<a name="l00257"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_3">00257</a> <font class="keywordtype">void</font>                    CTextureDLM::fillRect(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00258 {
00259         <font class="comment">// copy image.</font>
00260         CRGBA   *dst= (CRGBA*)&amp;(*<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().begin());
00261         dst+= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00262         <font class="keywordflow">for</font>(sint n= h;n&gt;0;n--, dst+= <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>())
00263         {
00264                 memset(dst, <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*<font class="keyword">sizeof</font>(CRGBA));
00265         }
00266 
00267         <font class="comment">// Invalidate the rectangle.</font>
00268         ITexture::touchRect(CRect(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h));
00269 }
00270 
00271 
00272 <font class="comment">// ***************************************************************************</font>
<a name="l00273"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_4">00273</a> <font class="keywordtype">void</font>                    CTextureDLM::modulateAndfillRect565(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, CRGBA  *textMap, uint16 *modColor)
00274 {
00275         <font class="comment">// compute start dst to copy.</font>
00276         CRGBA   *dst= (CRGBA*)&amp;(*<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().begin());
00277         dst+= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00278 
00279         <font class="comment">// precahce Data in memory (best CPU support)</font>
00280         CFastMem::precache(textMap, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*<font class="keyword">sizeof</font>(CRGBA));
00281         CFastMem::precache(modColor, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*<font class="keyword">sizeof</font>(uint16));
00282 
00283         <font class="comment">// For all lines</font>
00284         <font class="keywordflow">for</font>(sint n= h;n&gt;0;n--, dst+= (<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()-<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>) )
00285         {
00286                 <font class="comment">// For all the line.</font>
00287                 <font class="keywordflow">for</font>(sint nc= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;nc&gt;0;nc--, textMap++, modColor++, dst++)
00288                 {
00289                         uint16  tc= *modColor;
00290                         <font class="comment">// modulate R.</font>
00291                         dst-&gt;R= ( (tc&gt;&gt;11) * textMap-&gt;R)&gt;&gt;5;
00292                         <font class="comment">// modulate G.</font>
00293                         dst-&gt;G= (((tc&gt;&gt;5)&amp;63) * textMap-&gt;G)&gt;&gt;6;
00294                         <font class="comment">// modulate B.</font>
00295                         dst-&gt;B= ( (tc&amp;31) * textMap-&gt;B)&gt;&gt;5;
00296                 }
00297         }
00298 
00299         <font class="comment">// Invalidate the rectangle.</font>
00300         ITexture::touchRect(CRect(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h));
00301 }
00302 
00303 
00304 <font class="comment">// ***************************************************************************</font>
<a name="l00305"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_5">00305</a> <font class="keywordtype">void</font>                    CTextureDLM::modulateAndfillRect8888(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, CRGBA  *textMap, CRGBA *modColor)
00306 {
00307         <font class="comment">// compute start dst to copy.</font>
00308         CRGBA   *dst= (CRGBA*)&amp;(*<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().begin());
00309         dst+= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00310 
00311         <font class="comment">// precahce Data in memory (best CPU support)</font>
00312         CFastMem::precache(textMap, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*<font class="keyword">sizeof</font>(CRGBA));
00313         CFastMem::precache(modColor, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*<font class="keyword">sizeof</font>(CRGBA));
00314 
00315         <font class="comment">// For all lines</font>
00316         <font class="keywordflow">for</font>(sint n= h;n&gt;0;n--, dst+= (<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()-<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>) )
00317         {
00318                 <font class="comment">// For all the line.</font>
00319                 <font class="keywordflow">for</font>(sint nc= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;nc&gt;0;nc--, textMap++, modColor++, dst++)
00320                 {
00321                         CRGBA           mc= *modColor;
00322                         <font class="comment">// modulate RGB only</font>
00323                         dst-&gt;R= ( mc.R * textMap-&gt;R)&gt;&gt;8;
00324                         dst-&gt;G= ( mc.G * textMap-&gt;G)&gt;&gt;8;
00325                         dst-&gt;B= ( mc.B * textMap-&gt;B)&gt;&gt;8;
00326                 }
00327         }
00328 
00329         <font class="comment">// Invalidate the rectangle.</font>
00330         ITexture::touchRect(CRect(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h));
00331 }
00332 
00333 
00334 <font class="comment">// ***************************************************************************</font>
<a name="l00335"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_6">00335</a> <font class="keywordtype">void</font>                    CTextureDLM::modulateConstantAndfillRect(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, CRGBA  *textMap, CRGBA mc)
00336 {
00337         <font class="comment">// compute start dst to copy.</font>
00338         CRGBA   *dst= (CRGBA*)&amp;(*<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().begin());
00339         dst+= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00340 
00341         <font class="comment">// precahce Data in memory (best CPU support)</font>
00342         CFastMem::precache(textMap, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*<font class="keyword">sizeof</font>(CRGBA));
00343 
00344         <font class="comment">// For all lines</font>
00345         <font class="keywordflow">for</font>(sint n= h;n&gt;0;n--, dst+= (<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>()-<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>) )
00346         {
00347                 <font class="comment">// For all the line.</font>
00348                 <font class="keywordflow">for</font>(sint nc= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;nc&gt;0;nc--, textMap++, dst++)
00349                 {
00350                         <font class="comment">// modulate RGB only</font>
00351                         dst-&gt;R= ( mc.R * textMap-&gt;R)&gt;&gt;8;
00352                         dst-&gt;G= ( mc.G * textMap-&gt;G)&gt;&gt;8;
00353                         dst-&gt;B= ( mc.B * textMap-&gt;B)&gt;&gt;8;
00354                 }
00355         }
00356 
00357         <font class="comment">// Invalidate the rectangle.</font>
00358         ITexture::touchRect(CRect(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h));
00359 }
00360 
00361 
00362 <font class="comment">// ***************************************************************************</font>
<a name="l00363"></a><a class="code" href="classNL3D_1_1CTextureDLM.html#z829_7">00363</a> <font class="keywordtype">void</font>                    CTextureDLM::releaseLightMap(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)
00364 {
00365         <font class="comment">// Search what block is under this pos.</font>
00366         uint    blockId= (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>/<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>)*<a class="code" href="classNL3D_1_1CTextureDLM.html#o0">_WBlock</a> + (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>/<a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a>);
00367         <a class="code" href="debug_8h.html#a6">nlassert</a>(blockId&lt;<a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>.size());
00368         CBlock  *block= &amp;<a class="code" href="classNL3D_1_1CTextureDLM.html#o1">_Blocks</a>[blockId];
00369 
00370         <font class="comment">// compute block info.</font>
00371         uint    nLMapOnX= <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a> / block-&gt;Width;
00372         uint    nLMapOnY= <a class="code" href="texture__dlm_8h.html#a0">NL_DLM_BLOCK_SIZE</a> / block-&gt;Height;
00373         uint    nLMapPerBlock= nLMapOnX * nLMapOnY;
00374         <font class="comment">// was Full (ie all bits set) before this release</font>
00375         <font class="keywordtype">bool</font>    wasFull= (block-&gt;FreeSpace == (uint)(1&lt;&lt;nLMapPerBlock)-1);
00376         <font class="comment">// the type of lightmap.</font>
00377         uint    lMapType= <a class="code" href="classNL3D_1_1CTextureDLM.html#c0">getTypeForSize</a>(block-&gt;Width, block-&gt;Height);
00378 
00379 
00380         <font class="comment">// get relative pos to the block.</font>
00381         <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-= block-&gt;PosX;
00382         <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-= block-&gt;PosY;
00383 
00384         <font class="comment">// compute bit number.</font>
00385         uint    bitX= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>/block-&gt;Width;
00386         uint    bitY= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>/block-&gt;Height;
00387         <font class="comment">// assert good pos param.</font>
00388         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> == bitX*block-&gt;Width);
00389         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> == bitY*block-&gt;Height);
00390 
00391         <font class="comment">// compute bitId, as done in createLightMap()</font>
00392         uint    bitId= bitY * nLMapOnX + bitX;
00393         uint    mask= 1&lt;&lt;bitId;
00394 
00395         <font class="comment">// Free this bit in the block.</font>
00396         <a class="code" href="debug_8h.html#a6">nlassert</a>(block-&gt;FreeSpace &amp; mask);
00397         block-&gt;FreeSpace&amp;= ~mask;
00398 
00399 
00400         <font class="comment">// Free the block if necessary.</font>
00401         <font class="comment">//=======================</font>
00402         <font class="keywordtype">bool</font>    isEmpty= block-&gt;FreeSpace==0;
00403 
00404         <font class="comment">// If wasFull and now it is empty (nLMapPerBlock==1 case), just append to EmptyBlocks.</font>
00405         <font class="keywordflow">if</font>(wasFull &amp;&amp; isEmpty)
00406         {
00407                 <font class="comment">// add the id to the empty list.</font>
00408                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.push_back(blockId);
00409         }
00410         <font class="comment">// if wasFull, but still have some lightmap now, must insert into FreeList</font>
00411         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(wasFull &amp;&amp; !isEmpty)
00412         {
00413                 <a class="code" href="classNL3D_1_1CTextureDLM.html#c1">linkFreeBlock</a>(lMapType, block);
00414         }
00415         <font class="comment">// if was not full but now it is empty, must remove from free list and insert into EmptyBlocks</font>
00416         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(!wasFull &amp;&amp; isEmpty)
00417         {
00418                 <font class="comment">// remove the block from Free List</font>
00419                 <a class="code" href="classNL3D_1_1CTextureDLM.html#c2">unlinkFreeBlock</a>(lMapType, block);
00420                 <font class="comment">// add the id to the empty list.</font>
00421                 <a class="code" href="classNL3D_1_1CTextureDLM.html#o2">_EmptyBlocks</a>.push_back(blockId);
00422         }
00423         <font class="comment">// else (!wasFull &amp;&amp; !isEmpty) no-op, since must be kept in the FreeList.</font>
00424 
00425 }
00426 
00427 
00428 } <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=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>