aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/hls__color__texture_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/hls__color__texture_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/hls__color__texture_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/hls__color__texture_8cpp-source.html952
1 files changed, 952 insertions, 0 deletions
diff --git a/docs/doxygen/nel/hls__color__texture_8cpp-source.html b/docs/doxygen/nel/hls__color__texture_8cpp-source.html
new file mode 100644
index 00000000..d0bd9f3f
--- /dev/null
+++ b/docs/doxygen/nel/hls__color__texture_8cpp-source.html
@@ -0,0 +1,952 @@
+<!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>hls_color_texture.cpp</h1><a href="hls__color__texture_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 <font class="preprocessor">#include "<a class="code" href="hls__color__texture_8h.html">3d/hls_color_texture.h</a>"</font>
+00028 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
+00029 <font class="preprocessor">#include "<a class="code" href="fasthls__modifier_8h.html">3d/fasthls_modifier.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="bitmap_8h.html">nel/misc/bitmap.h</a>"</font>
+00032 <font class="preprocessor">#include "<a class="code" href="system__info_8h.html">nel/misc/system_info.h</a>"</font>
+00033 <font class="preprocessor">#include "<a class="code" href="algo_8h.html">nel/misc/algo.h</a>"</font>
+00034
+00035
+00036 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00037 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00038
+00039 <font class="keyword">namespace </font>NL3D
+00040 {
+00041
+00042
+<a name="l00043"></a><a class="code" href="hls__color__texture_8cpp.html#a0">00043</a> <font class="preprocessor">#define BLOCK_NUM_PIXEL 16</font>
+<a name="l00044"></a><a class="code" href="hls__color__texture_8cpp.html#a1">00044</a> <font class="preprocessor"></font><font class="preprocessor">#define BLOCK_DXTC_SIZE 16</font>
+<a name="l00045"></a><a class="code" href="hls__color__texture_8cpp.html#a2">00045</a> <font class="preprocessor"></font><font class="preprocessor">#define BLOCK_ALPHA_SIZE 16</font>
+00046 <font class="preprocessor"></font>
+00047
+00048 <font class="comment">// ***************************************************************************</font>
+<a name="l00049"></a><a class="code" href="classNL3D_1_1CHLSColorDelta.html#a0">00049</a> <font class="keywordtype">void</font> CHLSColorDelta::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
+00050 {
+00051 f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(0);
+00052 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CHLSColorDelta.html#m0">DHue</a>, <a class="code" href="classNL3D_1_1CHLSColorDelta.html#m1">DLum</a>, <a class="code" href="classNL3D_1_1CHLSColorDelta.html#m2">DSat</a>);
+00053 }
+00054
+00055
+00056 <font class="comment">// ***************************************************************************</font>
+<a name="l00057"></a><a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#a1">00057</a> <font class="keywordtype">void</font> CHLSColorTexture::CMask::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
+00058 {
+00059 f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(0);
+00060
+00061 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#m0">FullBlockIndex</a>);
+00062 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#m1">MixtBlockIndex</a>);
+00063 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#m2">Data</a>);
+00064 }
+00065
+00066
+00067 <font class="comment">// ***************************************************************************</font>
+<a name="l00068"></a><a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#a0">00068</a> <font class="keywordtype">void</font> CHLSColorTexture::CMask::setBit(uint bitId)
+00069 {
+00070 uint8 &amp;b= <a class="code" href="structNL3D_1_1CHLSColorTexture_1_1CMask.html#m2">Data</a>[bitId/8];
+00071 b|= 1&lt;&lt;(bitId&amp;7);
+00072 }
+00073
+00074
+00075 <font class="comment">// ***************************************************************************</font>
+<a name="l00076"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a0">00076</a> CHLSColorTexture::CHLSColorTexture()
+00077 {
+00078 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#a1">reset</a>();
+00079 }
+00080
+00081 <font class="comment">// ***************************************************************************</font>
+<a name="l00082"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a1">00082</a> <font class="keywordtype">void</font> CHLSColorTexture::reset()
+00083 {
+00084 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>= 0;
+00085 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>= 0;
+00086 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>= 0;
+00087 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>);
+00088 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o5">_Masks</a>);
+00089 }
+00090
+00091 <font class="comment">// ***************************************************************************</font>
+<a name="l00092"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a2">00092</a> <font class="keywordtype">void</font> CHLSColorTexture::setBitmap(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CBitmap.html">NLMISC::CBitmap</a> &amp;bmp)
+00093 {
+00094 <a class="code" href="debug_8h.html#a6">nlassert</a>(bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a5">getPixelFormat</a>()==CBitmap::DXTC5);
+00095 uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>();
+00096 uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>();
+00097 uint mmCount= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a9">getMipMapCount</a>();
+00098 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;=1 &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;=1);
+00099 <a class="code" href="debug_8h.html#a6">nlassert</a>(mmCount&gt;1 || <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);
+00100
+00101 <font class="comment">// restart</font>
+00102 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#a1">reset</a>();
+00103
+00104 <font class="comment">// resize.</font>
+00105 uint m;
+00106 uint pixelSize= 0;
+00107 uint numTotalBlock= 0;
+00108 <font class="keywordflow">for</font>(m=0;m&lt;mmCount;m++)
+00109 {
+00110 pixelSize+= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(m).size();
+00111 uint mmWidth= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(m);
+00112 uint mmHeight= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(m);
+00113 uint wBlock= (mmWidth+3)/4;
+00114 uint hBlock= (mmHeight+3)/4;
+00115 numTotalBlock+= wBlock*hBlock;
+00116 }
+00117 <font class="comment">// add the info for the "Block to compress"</font>
+00118 uint blockToCompressSize= 4*((numTotalBlock+31)/32);
+00119 <font class="comment">// allocate good size, and reset to 0 =&gt; no block to re-compress.</font>
+00120 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>.resize(pixelSize+blockToCompressSize, 0);
+00121
+00122 <font class="comment">// fill texture</font>
+00123 uint8 *ptr= &amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[0];
+00124 <font class="keywordflow">for</font>(m=0;m&lt;mmCount;m++)
+00125 {
+00126 uint mSize= bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(m).size();
+00127 memcpy(ptr, &amp;bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(m)[0], mSize);
+00128 ptr+= mSize;
+00129 }
+00130
+00131 <font class="comment">// header</font>
+00132 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>= pixelSize;
+00133 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
+00134 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
+00135 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>= mmCount;
+00136 }
+00137
+00138
+00139 <font class="comment">// ***************************************************************************</font>
+<a name="l00140"></a><a class="code" href="hls__color__texture_8cpp.html#a3">00140</a> <font class="preprocessor">#define MASK_BLOCK_EMPTY 0</font>
+<a name="l00141"></a><a class="code" href="hls__color__texture_8cpp.html#a4">00141</a> <font class="preprocessor"></font><font class="preprocessor">#define MASK_BLOCK_FULL 1</font>
+<a name="l00142"></a><a class="code" href="hls__color__texture_8cpp.html#a5">00142</a> <font class="preprocessor"></font><font class="preprocessor">#define MASK_BLOCK_MIXT 2</font>
+<a name="l00143"></a><a class="code" href="structNL3D_1_1CMaskInfo.html">00143</a> <font class="preprocessor"></font><font class="keyword">struct </font>CMaskInfo
+00144 {
+00145 <font class="comment">// list of block</font>
+<a name="l00146"></a><a class="code" href="structNL3D_1_1CMaskInfo.html#m0">00146</a> uint <a class="code" href="structNL3D_1_1CMaskInfo.html#m0">WBlock</a>, <a class="code" href="structNL3D_1_1CMaskInfo.html#m1">HBlock</a>;
+<a name="l00147"></a><a class="code" href="structNL3D_1_1CMaskInfo.html#m2">00147</a> uint <a class="code" href="structNL3D_1_1CMaskInfo.html#m2">NumBlock</a>;
+<a name="l00148"></a><a class="code" href="structNL3D_1_1CMaskInfo.html#m3">00148</a> vector&lt;uint8&gt; <a class="code" href="structNL3D_1_1CMaskInfo.html#m3">Blocks</a>; <font class="comment">// 0 empty, 1. Full. 2. Mixt.</font>
+00149 };
+00150
+00151 <font class="comment">// ***************************************************************************</font>
+<a name="l00152"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a3">00152</a> <font class="keywordtype">void</font> CHLSColorTexture::addMask(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CBitmap.html">NLMISC::CBitmap</a> &amp;bmpIn, uint threshold)
+00153 {
+00154 <font class="comment">// copy the bitmap and set RGBA/mipmaps.</font>
+00155 CBitmap bmp= bmpIn;
+00156 bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a4">convertToType</a>(CBitmap::RGBA);
+00157 bmp.buildMipMaps();
+00158
+00159 <font class="comment">// verify widht...</font>
+00160 <a class="code" href="debug_8h.html#a6">nlassert</a>(bmp.getWidth()== <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>);
+00161 <a class="code" href="debug_8h.html#a6">nlassert</a>(bmp.getHeight()== <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>);
+00162 <a class="code" href="debug_8h.html#a6">nlassert</a>(bmp.getMipMapCount()== <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>);
+00163
+00164 <font class="comment">// ***** build the information for all mipmaps</font>
+00165 vector&lt;CMaskInfo&gt; masks;
+00166 masks.resize(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>);
+00167 uint m;
+00168 uint numMixtBlock= 0;
+00169 uint numTotalBlock= 0;
+00170 <font class="keywordflow">for</font>(m=0;m&lt;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>;m++)
+00171 {
+00172 CMaskInfo &amp;mask= masks[m];
+00173 uint mmWidth= bmp.getWidth(m);
+00174 uint mmHeight= bmp.getHeight(m);
+00175 mask.WBlock= (mmWidth+3)/4;
+00176 mask.HBlock= (mmHeight+3)/4;
+00177 mask.NumBlock= mask.WBlock*mask.HBlock;
+00178 mask.Blocks.resize(mask.NumBlock);
+00179
+00180 numTotalBlock+= mask.NumBlock;
+00181
+00182 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)(&amp;bmp.getPixels(m)[0]);
+00183
+00184 <font class="keywordflow">for</font>(uint yB=0;yB&lt;mask.HBlock;yB++)
+00185 {
+00186 <font class="keywordflow">for</font>(uint xB=0;xB&lt;mask.WBlock;xB++)
+00187 {
+00188 uint accum= 0;
+00189 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= <a class="code" href="bit__set_8cpp.html#a0">min</a>(mmWidth, 4U);
+00190 uint h= <a class="code" href="bit__set_8cpp.html#a0">min</a>(mmHeight, 4U);
+00191 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= 0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt; h;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00192 {
+00193 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= 0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt; <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00194 {
+00195 uint yPix= yB*4+<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+00196 uint xPix= xB*4+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+00197 <font class="comment">// read the color</font>
+00198 uint8 alphaMask = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[yPix*mmWidth+xPix].R;
+00199 <font class="comment">// remove some dummy precision.</font>
+00200 <font class="keywordflow">if</font>(alphaMask&lt;threshold)
+00201 alphaMask= 0;
+00202 <font class="keywordflow">if</font>(alphaMask&gt;255-threshold)
+00203 alphaMask= 255;
+00204 <font class="comment">// Add to the accum</font>
+00205 accum+= alphaMask;
+00206 }
+00207 }
+00208
+00209 <font class="comment">// full black?</font>
+00210 <font class="keywordflow">if</font>(accum==0)
+00211 mask.Blocks[yB*mask.WBlock+xB]= <a class="code" href="hls__color__texture_8cpp.html#a3">MASK_BLOCK_EMPTY</a>;
+00212 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(accum==<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*255)
+00213 mask.Blocks[yB*mask.WBlock+xB]= <a class="code" href="hls__color__texture_8cpp.html#a4">MASK_BLOCK_FULL</a>;
+00214 <font class="comment">// if not full white or full black, mixt block</font>
+00215 <font class="keywordflow">else</font>
+00216 {
+00217 mask.Blocks[yB*mask.WBlock+xB]= <a class="code" href="hls__color__texture_8cpp.html#a5">MASK_BLOCK_MIXT</a>;
+00218 numMixtBlock++;
+00219 }
+00220 }
+00221 }
+00222 }
+00223
+00224 <font class="comment">// ***** compress into CMask</font>
+00225 CMask newMask;
+00226 uint newMaskDataSize= 0;
+00227
+00228 <font class="comment">// add the mixt block data size (16*uint8 per block)</font>
+00229 newMaskDataSize+= numMixtBlock*<a class="code" href="hls__color__texture_8cpp.html#a2">BLOCK_ALPHA_SIZE</a>;
+00230 <font class="comment">// compute the bit size. NB: use uint32 to blocks bits. =&gt; data is aligned.</font>
+00231 uint bitDataSize= 4*((numTotalBlock+31)/32);
+00232 <font class="comment">// add fullBlock bits</font>
+00233 newMask.FullBlockIndex= newMaskDataSize;
+00234 newMaskDataSize+= bitDataSize;
+00235 <font class="comment">// add mixtBlock bits</font>
+00236 newMask.MixtBlockIndex= newMaskDataSize;
+00237 newMaskDataSize+= bitDataSize;
+00238
+00239 <font class="comment">// allocate. Fill with 0 to initialize bits per default EMPTY value</font>
+00240 newMask.Data.resize(newMaskDataSize, 0);
+00241
+00242 <font class="comment">// compress each mipMaps from bigger to smaller</font>
+00243 uint bitId= 0;
+00244 uint mixtBlockId= 0;
+00245 <font class="keywordflow">for</font>(m=0;m&lt;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>;m++)
+00246 {
+00247 CMaskInfo &amp;mask= masks[m];
+00248
+00249 <font class="comment">// ---- build the mixtBlock alpha Mask</font>
+00250 <font class="keywordflow">for</font>(uint yB=0;yB&lt;mask.HBlock;yB++)
+00251 {
+00252 <font class="keywordflow">for</font>(uint xB=0;xB&lt;mask.WBlock;xB++)
+00253 {
+00254 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= yB*mask.WBlock+xB;
+00255 <font class="comment">// if mixt block</font>
+00256 <font class="keywordflow">if</font>(mask.Blocks[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>]==<a class="code" href="hls__color__texture_8cpp.html#a5">MASK_BLOCK_MIXT</a>)
+00257 {
+00258 <a class="code" href="debug_8h.html#a6">nlassert</a>(mixtBlockId&lt;numMixtBlock);
+00259 <font class="comment">// Fill Alpha data.</font>
+00260 uint8 *dst= &amp;newMask.Data[mixtBlockId*<a class="code" href="hls__color__texture_8cpp.html#a2">BLOCK_ALPHA_SIZE</a>];
+00261 uint mmWidth= bmp.getWidth(m);
+00262 uint mmHeight= bmp.getHeight(m);
+00263 <font class="comment">// point to the src alpha color</font>
+00264 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)(&amp;bmp.getPixels(m)[0]);
+00265 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> + yB*4*mmWidth + xB*4;
+00266
+00267 <font class="comment">// for the 4*4 pixels</font>
+00268 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= <a class="code" href="bit__set_8cpp.html#a0">min</a>(mmWidth, 4U);
+00269 uint h= <a class="code" href="bit__set_8cpp.html#a0">min</a>(mmHeight, 4U);
+00270 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;h;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00271 {
+00272 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00273 {
+00274 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*4+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*mmWidth+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>].R;
+00275 }
+00276 }
+00277
+00278 <font class="comment">// inc</font>
+00279 mixtBlockId++;
+00280 }
+00281 }
+00282 }
+00283
+00284 <font class="comment">// ---- build the fullBlock and mixtBlocks bits.</font>
+00285 <font class="keywordflow">for</font>(uint i=0; i&lt;mask.NumBlock; i++)
+00286 {
+00287 <a class="code" href="debug_8h.html#a6">nlassert</a>(bitId&lt;numTotalBlock);
+00288
+00289 <font class="comment">// fill bits</font>
+00290 <font class="keywordflow">if</font>(mask.Blocks[i]==<a class="code" href="hls__color__texture_8cpp.html#a4">MASK_BLOCK_FULL</a>)
+00291 newMask.setBit(newMask.FullBlockIndex*8 + bitId);
+00292 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(mask.Blocks[i]==<a class="code" href="hls__color__texture_8cpp.html#a5">MASK_BLOCK_MIXT</a>)
+00293 newMask.setBit(newMask.MixtBlockIndex*8 + bitId);
+00294
+00295 <font class="comment">// inc</font>
+00296 bitId++;
+00297 }
+00298 }
+00299
+00300 <font class="comment">// ***** Add the CMask</font>
+00301 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o5">_Masks</a>.push_back(newMask);
+00302
+00303 <font class="comment">// Or the BlockToCompress info with the MixtBlocks bits.</font>
+00304 <a class="code" href="debug_8h.html#a6">nlassert</a>(bitDataSize==<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>.size()-<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>);
+00305 <font class="keywordflow">for</font>(uint i=0;i&lt;bitDataSize;i++)
+00306 {
+00307 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>+i]|= newMask.Data[newMask.MixtBlockIndex+i];
+00308 }
+00309 }
+00310
+00311
+00312 <font class="comment">// ***************************************************************************</font>
+<a name="l00313"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a6">00313</a> <font class="keywordtype">void</font> CHLSColorTexture::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
+00314 {
+00315 f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(0);
+00316
+00317 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>, <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>, <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>, <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>);
+00318 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>);
+00319 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o5">_Masks</a>);
+00320 }
+00321
+00322
+00323 <font class="comment">// ***************************************************************************</font>
+00324 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(uint32 *bitPtr, uint32 &amp;bitMask)
+00325 {
+00326 <font class="preprocessor">#ifdef NL_LITTLE_ENDIAN</font>
+00327 <font class="preprocessor"></font> bitMask= *bitPtr;
+00328 <font class="preprocessor">#else</font>
+00329 <font class="preprocessor"></font> bitMask = ((uint8*)bitPtr)[0];
+00330 bitMask+= ((uint8*)bitPtr)[1]&lt;&lt;8;
+00331 bitMask+= ((uint8*)bitPtr)[2]&lt;&lt;16;
+00332 bitMask+= ((uint8*)bitPtr)[3]&lt;&lt;24;
+00333 <font class="preprocessor">#endif</font>
+00334 <font class="preprocessor"></font>}
+00335
+00336 <font class="comment">// ***************************************************************************</font>
+<a name="l00337"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#a5">00337</a> <font class="keywordtype">void</font> CHLSColorTexture::buildColorVersion(<font class="keyword">const</font> CHLSColorDelta *colDeltaList, <a class="code" href="classNLMISC_1_1CBitmap.html">NLMISC::CBitmap</a> &amp;out)
+00338 {
+00339 <font class="comment">// static to avoid realloc</font>
+00340 <font class="keyword">static</font> vector&lt;uint8&gt; dstTexture;
+00341 <font class="keyword">static</font> vector&lt;CRGBA&gt; dstUnCompTexture;
+00342 uint32 *bitPtr;
+00343 uint8 *srcPtr;
+00344 uint8 *dstPtr;
+00345 CRGBA *dstUnCompPtr;
+00346 uint32 bitMask;
+00347
+00348 <font class="comment">// **** prepare Data</font>
+00349
+00350 <font class="comment">// count number of DXTC5 block in _Texture.</font>
+00351 uint numBlocks= <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>/<a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00352
+00353 <font class="comment">// create a tmp compressed block array, copy of Texture.</font>
+00354 dstTexture.resize(numBlocks*<a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>);
+00355 <font class="comment">// copy from texture (to have non colored version already copied, and also ALPHA ok)</font>
+00356 memcpy(&amp;dstTexture[0], &amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[0], dstTexture.size());
+00357
+00358 <font class="comment">// create a tmp uncompressed block array, which will receive coloring of mixt blocks</font>
+00359 dstUnCompTexture.resize(numBlocks*<a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>);
+00360
+00361 <font class="comment">// For all blockToCompress, uncompress them in dstUnCompTexture, because they will blend with future mask coloring</font>
+00362 uint n= numBlocks;
+00363 bitPtr= (uint32*)(&amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>]);
+00364 dstUnCompPtr= &amp;dstUnCompTexture[0];
+00365 srcPtr= &amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[0];
+00366 <font class="keywordflow">while</font>(n&gt;0)
+00367 {
+00368 uint nBits= <a class="code" href="bit__set_8cpp.html#a0">min</a>(n, 32U);
+00369 <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(bitPtr, bitMask);
+00370 n-= nBits;
+00371 bitPtr++;
+00372 <font class="keywordflow">for</font>(;nBits&gt;0;nBits--)
+00373 {
+00374 <font class="comment">// need to compress/uncompress ??</font>
+00375 <font class="keywordflow">if</font>(bitMask&amp;1)
+00376 {
+00377 <font class="comment">// uncompress this block. ignore alpha</font>
+00378 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f0">uncompressBlockRGB</a>(srcPtr, dstUnCompPtr);
+00379 }
+00380 bitMask&gt;&gt;=1;
+00381 dstUnCompPtr+= <a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>;
+00382 srcPtr+= <a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00383 }
+00384 }
+00385
+00386 <font class="comment">// **** build the color version for all masks.</font>
+00387
+00388 <font class="keywordflow">for</font>(uint maskId= 0; maskId&lt;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o5">_Masks</a>.size();maskId++)
+00389 {
+00390 CMask &amp;mask= <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o5">_Masks</a>[maskId];
+00391 <font class="comment">// unpack colDelta, and prepare for use with CFastHLSModifier.</font>
+00392 uint8 dHue= colDeltaList[maskId].DHue;
+00393 uint dLum= 0xFFFFFF00 + colDeltaList[maskId].DLum*2;
+00394 uint dSat= 0xFFFFFF00 + colDeltaList[maskId].DSat*2;
+00395
+00396 <font class="comment">// get a ptr on alpha of mixt block.</font>
+00397 uint8 *alphaMixtBlock= &amp;mask.Data[0];
+00398
+00399
+00400 <font class="comment">// ---- for all Fullblock ot this mask, color and store in dstTexture</font>
+00401 <font class="comment">// start at full Block bits desc</font>
+00402 bitPtr= (uint32*)(&amp;mask.Data[mask.FullBlockIndex]);
+00403 uint32 *bitCompPtr= (uint32*)(&amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>]);
+00404 srcPtr= &amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[0];
+00405 dstPtr= &amp;dstTexture[0];
+00406 dstUnCompPtr= &amp;dstUnCompTexture[0];
+00407 n= numBlocks;
+00408 <font class="comment">// run all blocks.</font>
+00409 <font class="keywordflow">while</font>(n&gt;0)
+00410 {
+00411 uint nBits= <a class="code" href="bit__set_8cpp.html#a0">min</a>(n, 32U);
+00412 <font class="comment">// get Full block mask.</font>
+00413 <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(bitPtr, bitMask);
+00414 n-= nBits;
+00415 bitPtr++;
+00416 <font class="comment">// get Compress mask.</font>
+00417 uint32 bitCompMask;
+00418 <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(bitCompPtr, bitCompMask);
+00419 bitCompPtr++;
+00420 <font class="comment">// for all bits</font>
+00421 <font class="keywordflow">for</font>(;nBits&gt;0;nBits--)
+00422 {
+00423 <font class="comment">// need to colorize??</font>
+00424 <font class="keywordflow">if</font>(bitMask&amp;1)
+00425 {
+00426 <font class="comment">// colorize this block. ignore alpha</font>
+00427 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f3">colorizeDXTCBlockRGB</a>(srcPtr, dstPtr, dHue, dLum, dSat);
+00428 <font class="comment">// If this block is "a block to recompress", then must uncompress it in dstUnCompPtr</font>
+00429 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f0">uncompressBlockRGB</a>(dstPtr, dstUnCompPtr);
+00430 }
+00431 bitMask&gt;&gt;=1;
+00432 bitCompMask&gt;&gt;=1;
+00433 srcPtr+= <a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00434 dstPtr+= <a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00435 dstUnCompPtr+= <a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>;
+00436 }
+00437 }
+00438
+00439 <font class="comment">// ---- for all mixtblock ot this mask, color, uncompress and blend in store in dstUnCompTexture</font>
+00440 <font class="keyword">static</font> uint8 tmpColoredBlockDXTC[<a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>];
+00441 <font class="keyword">static</font> CRGBA tmpColoredBlockRGBA[<a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>];
+00442 <font class="comment">// start at mixt Block bits desc</font>
+00443 bitPtr= (uint32*)(&amp;mask.Data[mask.MixtBlockIndex]);
+00444 srcPtr= &amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[0];
+00445 dstUnCompPtr= &amp;dstUnCompTexture[0];
+00446 n= numBlocks;
+00447 <font class="comment">// run all blocks.</font>
+00448 <font class="keywordflow">while</font>(n&gt;0)
+00449 {
+00450 uint nBits= <a class="code" href="bit__set_8cpp.html#a0">min</a>(n, 32U);
+00451 <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(bitPtr, bitMask);
+00452 n-= nBits;
+00453 bitPtr++;
+00454 <font class="keywordflow">for</font>(;nBits&gt;0;nBits--)
+00455 {
+00456 <font class="comment">// need to colorize??</font>
+00457 <font class="keywordflow">if</font>(bitMask&amp;1)
+00458 {
+00459 <font class="comment">// colorize this block. store 2 colors in tmp</font>
+00460 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f3">colorizeDXTCBlockRGB</a>(srcPtr, tmpColoredBlockDXTC, dHue, dLum, dSat);
+00461 <font class="comment">// copy RGB bits from src to tmp</font>
+00462 ((uint32*)tmpColoredBlockDXTC)[3]= ((uint32*)srcPtr)[3];
+00463
+00464 <font class="comment">// uncompress the block.</font>
+00465 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f0">uncompressBlockRGB</a>(tmpColoredBlockDXTC, tmpColoredBlockRGBA);
+00466
+00467 <font class="comment">// blend tmpColoredBlockRGBA into dstUnCompPtr, according to alphaMixtBlock.</font>
+00468 <font class="keywordflow">for</font>(uint i=0;i&lt;16;i++)
+00469 {
+00470 dstUnCompPtr[i].blendFromuiRGBOnly(dstUnCompPtr[i], tmpColoredBlockRGBA[i], *alphaMixtBlock);
+00471 <font class="comment">// next pixel</font>
+00472 alphaMixtBlock++;
+00473 }
+00474 }
+00475 bitMask&gt;&gt;=1;
+00476 srcPtr+= <a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00477 dstUnCompPtr+= <a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>;
+00478 }
+00479 }
+00480
+00481 }
+00482
+00483
+00484 <font class="comment">// Since colorizeDXTCBlockRGB() use MMX, must end with emms.</font>
+00485 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00486 <font class="preprocessor"></font> <font class="keywordflow">if</font>(CSystemInfo::hasMMX())
+00487 _asm emms;
+00488 <font class="preprocessor">#endif</font>
+00489 <font class="preprocessor"></font>
+00490
+00491 <font class="comment">// **** compress needed blocks</font>
+00492 n= numBlocks;
+00493 bitPtr= (uint32*)(&amp;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o4">_Texture</a>[<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o3">_BlockToCompressIndex</a>]);
+00494 dstUnCompPtr= &amp;dstUnCompTexture[0];
+00495 dstPtr= &amp;dstTexture[0];
+00496 <font class="keywordflow">while</font>(n&gt;0)
+00497 {
+00498 uint nBits= <a class="code" href="bit__set_8cpp.html#a0">min</a>(n, 32U);
+00499 <a class="code" href="namespaceNL3D.html#a367">getBitPack</a>(bitPtr, bitMask);
+00500 n-= nBits;
+00501 bitPtr++;
+00502 <font class="keywordflow">for</font>(;nBits&gt;0;nBits--)
+00503 {
+00504 <font class="comment">// need to compress ??</font>
+00505 <font class="keywordflow">if</font>(bitMask&amp;1)
+00506 {
+00507 <font class="comment">// uncompress this block. ignore alpha</font>
+00508 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f1">compressBlockRGB</a>(dstUnCompPtr, dstPtr);
+00509 }
+00510 bitMask&gt;&gt;=1;
+00511 dstUnCompPtr+= <a class="code" href="hls__color__texture_8cpp.html#a0">BLOCK_NUM_PIXEL</a>;
+00512 dstPtr+= <a class="code" href="hls__color__texture_8cpp.html#a1">BLOCK_DXTC_SIZE</a>;
+00513 }
+00514 }
+00515
+00516 <font class="comment">// **** format bitmap out with dstTexture.</font>
+00517 out.<a class="code" href="classNLMISC_1_1CBitmap.html#a13">reset</a>(CBitmap::DXTC5);
+00518 out.<a class="code" href="classNLMISC_1_1CBitmap.html#a15">resize</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>, <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>, CBitmap::DXTC5);
+00519
+00520 <font class="comment">// create and fill all the mipMaps</font>
+00521 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= <a class="code" href="classNL3D_1_1CHLSColorTexture.html#o0">_Width</a>, h=<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o1">_Height</a>;
+00522 dstPtr= &amp;dstTexture[0];
+00523 <font class="keywordflow">for</font>(uint m=0;m&lt;<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>;m++)
+00524 {
+00525 <font class="comment">// allocate.</font>
+00526 out.<a class="code" href="classNLMISC_1_1CBitmap.html#a16">resizeMipMap</a>(m, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h);
+00527 <font class="comment">// get the size of this DXTC5 level.</font>
+00528 uint size= out.<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(m).size();
+00529 <font class="comment">// fill</font>
+00530 memcpy(&amp;out.<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(m)[0], dstPtr, size);
+00531 <font class="comment">// next mipmap</font>
+00532 dstPtr+= size;
+00533 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1)/2;
+00534 h= (h+1)/2;
+00535 }
+00536 <font class="comment">// verify all filled</font>
+00537 <a class="code" href="debug_8h.html#a6">nlassert</a>( dstPtr== (&amp;dstTexture[0] + dstTexture.size()) );
+00538
+00539 <font class="comment">// set the correct num of mipmap</font>
+00540 out.<a class="code" href="classNLMISC_1_1CBitmap.html#a17">setMipMapCount</a>(<a class="code" href="classNL3D_1_1CHLSColorTexture.html#o2">_NumMipMap</a>);
+00541 }
+00542
+00543
+00544 <font class="comment">// ***************************************************************************</font>
+<a name="l00545"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#f3">00545</a> <font class="keywordtype">void</font> CHLSColorTexture::colorizeDXTCBlockRGB(<font class="keyword">const</font> uint8 *srcPtr, uint8 *dstPtr, uint8 dHue, uint dLum, uint dSat)
+00546 {
+00547 <font class="comment">// get modifier.</font>
+00548 CFastHLSModifier &amp;fastHLS= CFastHLSModifier::getInstance();
+00549
+00550 <font class="comment">// apply the color on the 2 DXTC colors</font>
+00551 *(uint16*)(dstPtr+8 )= fastHLS.applyHLSMod(*(uint16*)(srcPtr+8 ) , dHue, dLum, dSat);
+00552 *(uint16*)(dstPtr+10)= fastHLS.applyHLSMod(*(uint16*)(srcPtr+10) , dHue, dLum, dSat);
+00553 }
+00554
+00555
+00556 <font class="comment">// ***************************************************************************</font>
+<a name="l00557"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#f0">00557</a> <font class="keywordtype">void</font> CHLSColorTexture::uncompressBlockRGB(<font class="keyword">const</font> uint8* srcDXTC, CRGBA *dstRGBA)
+00558 {
+00559 CRGBA c[4];
+00560
+00561 uint16 color0;
+00562 uint16 color1;
+00563 uint32 bits;
+00564 color0= *(uint16*)(srcDXTC+8);
+00565 color1= *(uint16*)(srcDXTC+10);
+00566 bits= *(uint32*)(srcDXTC+12);
+00567
+00568 c[0].set565(color0);
+00569 c[1].set565(color1);
+00570
+00571 <font class="comment">// ignore color0&gt;color1 for DXT3 and DXT5.</font>
+00572 c[2].blendFromui(c[0],c[1],85);
+00573 c[3].blendFromui(c[0],c[1],171);
+00574
+00575 <font class="comment">// bits to color (ignore alpha result)</font>
+00576 <font class="keywordflow">for</font>(uint n= 16;n&gt;0;n--)
+00577 {
+00578 *dstRGBA= c[bits&amp;3];
+00579 bits&gt;&gt;=2;
+00580 dstRGBA++;
+00581 }
+00582 }
+00583
+00584
+00585 <font class="comment">// ***************************************************************************</font>
+<a name="l00586"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#f2">00586</a> <font class="keywordtype">void</font> CHLSColorTexture::computeMinMax(sint *diffBlock, CVectorInt &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, sint mean[3], sint rgb0[3], sint rgb1[3])
+00587 {
+00588 <font class="comment">// compute the min and max distance along the axis v.</font>
+00589 sint mind= INT_MAX;
+00590 sint maxd= INT_MIN;
+00591 sint *srcDiff= diffBlock;
+00592 <font class="comment">// for the 16 pixels</font>
+00593 <font class="keywordflow">for</font>(uint n=16;n&gt;0;n--,srcDiff+=3)
+00594 {
+00595 sint R= srcDiff[0];
+00596 sint G= srcDiff[1];
+00597 sint B= srcDiff[2];
+00598 sint d= R*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x + G*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y + B*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z;
+00599 <font class="keywordflow">if</font>(d&lt;mind)
+00600 mind= d;
+00601 <font class="keywordflow">if</font>(d&gt;maxd)
+00602 maxd= d;
+00603 }
+00604
+00605 <font class="comment">// avoid overflow. here, Higher possible bit is 16+8+2 (add of 3 values=&gt; *4) == 26</font>
+00606 <font class="comment">// 26-12= 14. 14+16=30 =&gt; ok.</font>
+00607 mind&gt;&gt;= 12;
+00608 maxd&gt;&gt;= 12;
+00609
+00610 <font class="comment">// compute the 2 colors: rgb0 on the min, and rgb1 on the max</font>
+00611 rgb0[0]= mean[0]+ (mind*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x&gt;&gt;20);
+00612 rgb0[1]= mean[1]+ (mind*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y&gt;&gt;20);
+00613 rgb0[2]= mean[2]+ (mind*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z&gt;&gt;20);
+00614 rgb1[0]= mean[0]+ (maxd*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x&gt;&gt;20);
+00615 rgb1[1]= mean[1]+ (maxd*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y&gt;&gt;20);
+00616 rgb1[2]= mean[2]+ (maxd*<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z&gt;&gt;20);
+00617 <font class="comment">// clamp to 0..255</font>
+00618 fastClamp8(rgb0[0]);
+00619 fastClamp8(rgb0[1]);
+00620 fastClamp8(rgb0[2]);
+00621 fastClamp8(rgb1[0]);
+00622 fastClamp8(rgb1[1]);
+00623 fastClamp8(rgb1[2]);
+00624 }
+00625
+00626
+00627 <font class="comment">// ***************************************************************************</font>
+<a name="l00628"></a><a class="code" href="classNL3D_1_1CHLSColorTexture.html#f1">00628</a> <font class="keywordtype">void</font> CHLSColorTexture::compressBlockRGB(CRGBA *srcRGBA, uint8* dstDXTC)
+00629 {
+00630 <font class="comment">// skip alpha part.</font>
+00631 uint8 *dstBlock= dstDXTC+8;
+00632
+00633
+00634 <font class="comment">// **** compute RGB0 and RGB1.</font>
+00635 uint i,j,n;
+00636
+00637 <font class="comment">// compute the mean color of 16 pixels</font>
+00638 sint mean[3];
+00639 mean[0]= 0;
+00640 mean[1]= 0;
+00641 mean[2]= 0;
+00642 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= srcRGBA;
+00643 <font class="keywordflow">for</font>(n=16;n&gt;0;n--,<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>++)
+00644 {
+00645 mean[0]+= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;R;
+00646 mean[1]+= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;G;
+00647 mean[2]+= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;B;
+00648 <font class="comment">// at same time, setup alpha to 0. Important for "compute bits" part (see MMX)!!</font>
+00649 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;A= 0;
+00650 }
+00651 mean[0]&gt;&gt;= 4;
+00652 mean[1]&gt;&gt;= 4;
+00653 mean[2]&gt;&gt;= 4;
+00654
+00655 <font class="comment">// compute col-mean</font>
+00656 sint diffBlock[16*3];
+00657 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= srcRGBA;
+00658 sint *srcDiff= diffBlock;
+00659 <font class="keywordflow">for</font>(n=16;n&gt;0;n--,<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>++,srcDiff+=3)
+00660 {
+00661 srcDiff[0]= (sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;R - mean[0];
+00662 srcDiff[1]= (sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;G - mean[1];
+00663 srcDiff[2]= (sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;B - mean[2];
+00664 }
+00665
+00666
+00667 <font class="comment">// compute the covariant matrix.</font>
+00668 sint coMat[3][3];
+00669 <font class="comment">// Apply std RGB factor (0.3, 0.56, 0.14) to choose the best Axis. This give far much best results.</font>
+00670 sint rgbFact[3]= {77, 143, 36};
+00671 <font class="keywordflow">for</font>(i=0;i&lt;3;i++)
+00672 {
+00673 <font class="comment">// OPTIMIZE SINCE SYMETRIX MATRIX</font>
+00674 <font class="keywordflow">for</font>(j=i;j&lt;3;j++)
+00675 {
+00676 sint32 factor= 0;
+00677 <font class="comment">// divide / 16 to avoid overflow sint32</font>
+00678 uint colFactor= (rgbFact[i]*rgbFact[j]) &gt;&gt; 4;
+00679 <font class="comment">// run all 16 pixels.</font>
+00680 sint *srcDiff= diffBlock;
+00681 <font class="keywordflow">for</font>(n=16;n&gt;0;n--,srcDiff+=3)
+00682 {
+00683 factor+= srcDiff[i] * srcDiff[j] * colFactor;
+00684 }
+00685 coMat[i][j]= factor;
+00686 }
+00687 }
+00688 <font class="comment">// Fill symetrix matrix</font>
+00689 coMat[1][0]= coMat[0][1];
+00690 coMat[2][0]= coMat[0][2];
+00691 coMat[2][1]= coMat[1][2];
+00692
+00693
+00694 <font class="comment">// take the bigger vector</font>
+00695 sint maxSize= 0;
+00696 uint axis= 0;
+00697 <font class="keywordflow">for</font>(i=0;i&lt;3;i++)
+00698 {
+00699 <font class="comment">// Use abs since sqr fails because all sint32 range may be used.</font>
+00700 sint size= abs(coMat[i][0]) + abs(coMat[i][1]) + abs(coMat[i][2]);
+00701 <font class="keywordflow">if</font>(size&gt;maxSize)
+00702 {
+00703 maxSize= size;
+00704 axis= i;
+00705 }
+00706 }
+00707
+00708 <font class="comment">// normalize this vector</font>
+00709 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00710 <font class="comment">// remove some rgb factor...</font>
+00711 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x= (float)coMat[axis][0]/rgbFact[0];
+00712 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y= (float)coMat[axis][1]/rgbFact[1];
+00713 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z= (float)coMat[axis][2]/rgbFact[2];
+00714 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.normalize();
+00715 <font class="comment">// set a Fixed 16:16.</font>
+00716 CVectorInt vInt;
+00717 <font class="comment">// don't bother if OptFastFloorBegin() has been called. 16:16 precision is sufficient.</font>
+00718 vInt.x= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x*65536);
+00719 vInt.y= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y*65536);
+00720 vInt.z= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z*65536);
+00721
+00722
+00723 <font class="comment">// For all pixels, choose the 2 colors along the axis</font>
+00724 sint rgb0[3];
+00725 sint rgb1[3];
+00726 <a class="code" href="classNL3D_1_1CHLSColorTexture.html#f2">computeMinMax</a>(diffBlock, vInt, mean, rgb0, rgb1);
+00727
+00728 <font class="comment">// Average to 16 bits. NB: correclty encode 0..255 to 0.31 or 0..63.</font>
+00729 uint R,G,B;
+00730 R= ((rgb0[0]*7967+32768)&gt;&gt;16);
+00731 G= ((rgb0[1]*16191+32768)&gt;&gt;16);
+00732 B= ((rgb0[2]*7967+32768)&gt;&gt;16);
+00733 uint16 rgb016= (R&lt;&lt;11) + (G&lt;&lt;5) + (B);
+00734 R= ((rgb1[0]*7967+32768)&gt;&gt;16);
+00735 G= ((rgb1[1]*16191+32768)&gt;&gt;16);
+00736 B= ((rgb1[2]*7967+32768)&gt;&gt;16);
+00737 uint16 rgb116= (R&lt;&lt;11) + (G&lt;&lt;5) + (B);
+00738 <font class="comment">// copy to block</font>
+00739 ((uint16*)dstBlock)[0]= rgb016;
+00740 ((uint16*)dstBlock)[1]= rgb116;
+00741
+00742
+00743 <font class="comment">// **** compute bits</font>
+00744 CRGBA c[4];
+00745 c[0].set565(rgb016);
+00746 c[1].set565(rgb116);
+00747 c[2].blendFromui(c[0],c[1],85);
+00748 c[3].blendFromui(c[0],c[1],171);
+00749 <font class="comment">// it is important that c[] and src Alpha are set to 0, because of "pmaddwd" use in MMX code...</font>
+00750 c[0].A= 0;
+00751 c[1].A= 0;
+00752 c[2].A= 0;
+00753 c[3].A= 0;
+00754 CRGBA *cPtr= c;
+00755
+00756 <font class="comment">// result.</font>
+00757 uint32 bits= 0;
+00758
+00759 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00760 <font class="preprocessor"></font> <font class="keywordflow">if</font>(CSystemInfo::hasMMX())
+00761 {
+00762 <font class="comment">// preapre mmx</font>
+00763 uint64 blank= 0;
+00764 __asm
+00765 {
+00766 movq mm7, blank
+00767 }
+00768
+00769 <font class="comment">// for 16 pixels</font>
+00770 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= srcRGBA;
+00771 <font class="keywordflow">for</font>(n=16;n&gt;0;n--,<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>++)
+00772 {
+00773 <font class="comment">/* // C Version (+ little asm).</font>
+00774 <font class="comment"> uint minDist= 0xFFFFFFFF;</font>
+00775 <font class="comment"> uint id= 0;</font>
+00776 <font class="comment"> for(i=0;i&lt;4;i++)</font>
+00777 <font class="comment"> {</font>
+00778 <font class="comment"> // applying factors such *23, *80, *6 gives better results, but slower (in MMX).</font>
+00779 <font class="comment"> uint dist= sqr((sint)src-&gt;R-(sint)c[i].R);</font>
+00780 <font class="comment"> dist+= sqr((sint)src-&gt;G-(sint)c[i].G);</font>
+00781 <font class="comment"> dist+= sqr((sint)src-&gt;B-(sint)c[i].B);</font>
+00782 <font class="comment"> if(dist&lt;minDist)</font>
+00783 <font class="comment"> {</font>
+00784 <font class="comment"> minDist= dist;</font>
+00785 <font class="comment"> id= i;</font>
+00786 <font class="comment"> }</font>
+00787 <font class="comment"> }</font>
+00788 <font class="comment"> bits|=id;</font>
+00789 <font class="comment"> __asm</font>
+00790 <font class="comment"> {</font>
+00791 <font class="comment"> mov eax, bits</font>
+00792 <font class="comment"> ror eax, 2</font>
+00793 <font class="comment"> mov bits, eax</font>
+00794 <font class="comment"> }*/</font>
+00795 __asm
+00796 {
+00797 mov esi, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>
+00798 mov edi, cPtr
+00799
+00800 mov ecx, 4
+00801 mov edx, 0xFFFFFFFF <font class="comment">// edx= minDist</font>
+00802
+00803 movd mm0, [esi]
+00804 punpcklbw mm0, mm7
+00805
+00806 mov esi, 4 <font class="comment">// esi= id MinDist (inverted)</font>
+00807
+00808 <font class="comment">// compare 4 cases.</font>
+00809 myLoop:
+00810 movd mm1, [edi]
+00811 punpcklbw mm1, mm7
+00812 psubsw mm1, mm0
+00813 pmaddwd mm1, mm1
+00814 movd eax, mm1
+00815 psrlq mm1, 32
+00816 movd ebx, mm1
+00817 add eax, ebx
+00818
+00819 <font class="comment">// take smaller of A and B. here: eax= A, edx= B</font>
+00820 sub eax, edx <font class="comment">// eax= A-B</font>
+00821 sbb ebx, ebx <font class="comment">// ebx= FF if A&lt;B.</font>
+00822 and eax, ebx <font class="comment">// eax= A-B if A&lt;B</font>
+00823 add edx, eax <font class="comment">// if A&lt;B, edx= B+A-B= A, else, edx= B. =&gt; minimum</font>
+00824 <font class="comment">// setup the "smaller" id. here esi= iB, ecx= iA</font>
+00825 not ebx <font class="comment">// ebx= 0 if A&lt;B, FF else</font>
+00826 sub esi, ecx <font class="comment">// esi= iB-iA</font>
+00827 and esi, ebx <font class="comment">// esi= 0 if A&lt;B, iB-iA else</font>
+00828 add esi, ecx <font class="comment">// esi= 0+iA= iA if A&lt;B, else esi= iB-iA+iA= iB</font>
+00829
+00830 add edi, 4
+00831 dec ecx
+00832 jnz myLoop
+00833
+00834 <font class="comment">// reverse id</font>
+00835 mov edx, 4
+00836 mov eax, bits
+00837 sub edx, esi
+00838 <font class="comment">// and store into bits</font>
+00839 or eax, edx
+00840 ror eax, 2
+00841 mov bits, eax
+00842 }
+00843 }
+00844
+00845
+00846 <font class="comment">// end MMX block.</font>
+00847 __asm emms;
+00848 }
+00849 <font class="keywordflow">else</font>
+00850 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00851 <font class="preprocessor"></font> {
+00852 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= srcRGBA;
+00853 <font class="keywordflow">for</font>(n=16;n&gt;0;n--,<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>++)
+00854 {
+00855 <font class="comment">// C Version (+ little asm).</font>
+00856 uint minDist= 0xFFFFFFFF;
+00857 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= 0;
+00858 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00859 {
+00860 <font class="comment">// applying factors such *23, *80, *6 gives better results, but slower (in MMX).</font>
+00861 uint dist= <a class="code" href="namespaceNLMISC.html#a214">sqr</a>((sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;R-(sint)c[i].R);
+00862 dist+= <a class="code" href="namespaceNLMISC.html#a214">sqr</a>((sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;G-(sint)c[i].G);
+00863 dist+= <a class="code" href="namespaceNLMISC.html#a214">sqr</a>((sint)<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;B-(sint)c[i].B);
+00864 <font class="keywordflow">if</font>(dist&lt;minDist)
+00865 {
+00866 minDist= dist;
+00867 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= i;
+00868 }
+00869 }
+00870 <font class="comment">// a ror is faster, but full C version</font>
+00871 bits|= <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>&lt;&lt;30;
+00872 <font class="comment">// don't do it for the last.</font>
+00873 <font class="keywordflow">if</font>(n&gt;1)
+00874 bits&gt;&gt;=2;
+00875 }
+00876 }
+00877
+00878 <font class="comment">// copy</font>
+00879 ((uint32*)dstBlock)[1]= bits;
+00880 }
+00881
+00882
+00883 } <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>