diff options
Diffstat (limited to 'docs/doxygen/nel/texture__far_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/texture__far_8cpp-source.html | 1989 |
1 files changed, 1989 insertions, 0 deletions
diff --git a/docs/doxygen/nel/texture__far_8cpp-source.html b/docs/doxygen/nel/texture__far_8cpp-source.html new file mode 100644 index 00000000..bd8e9fbd --- /dev/null +++ b/docs/doxygen/nel/texture__far_8cpp-source.html @@ -0,0 +1,1989 @@ +<!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> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </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> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </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> + + +<!-- 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> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <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> </center> +<hr><h1>texture_far.cpp</h1><a href="texture__far_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="texture__far_8h.html">3d/texture_far.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="tile__far__bank_8h.html">3d/tile_far_bank.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="patch_8h.html">3d/patch.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="tile__color_8h.html">3d/tile_color.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="src_23d_2zone_8h.html">3d/zone.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="landscape_8h.html">3d/landscape.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="system__info_8h.html">nel/misc/system_info.h</a>"</font> +00035 +00036 +00037 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00038 <font class="keyword">using</font> <font class="keyword">namespace </font>NL3D; +00039 +00040 <font class="keyword">namespace </font>NL3D { +00041 +<a name="l00042"></a><a class="code" href="classNL3D_1_1CTextureFar.html#r0">00042</a> CRGBA CTextureFar::_LightmapExpanded[<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>*<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>*<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>]; +<a name="l00043"></a><a class="code" href="classNL3D_1_1CTextureFar.html#r1">00043</a> uint8 CTextureFar::_LumelExpanded[(<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>+1)*(<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a>+1)]; +<a name="l00044"></a><a class="code" href="classNL3D_1_1CTextureFar.html#r2">00044</a> CRGBA CTextureFar::_TileTLIColors[(<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*(<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)]; +00045 +<a name="l00046"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a0">00046</a> CTextureFar::CTextureFar() +00047 { +00048 <font class="comment">// This texture is releasable. It doesn't stays in standard memory after been uploaded into video memory.</font> +00049 <a class="code" href="classNL3D_1_1ITexture.html#a3">setReleasable</a> (<font class="keyword">true</font>); +00050 +00051 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>= <font class="keyword">this</font>; +00052 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>= <font class="keyword">this</font>; +00053 } +00054 +<a name="l00055"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a1">00055</a> CTextureFar::~CTextureFar() +00056 { +00057 <font class="comment">// verify the textureFar is correctly unlinked from any ciruclar list.</font> +00058 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>==<font class="keyword">this</font> && <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>==<font class="keyword">this</font>); +00059 } +00060 +00061 +<a name="l00062"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a7">00062</a> <font class="keywordtype">void</font> CTextureFar::linkBeforeUL(CTextureFar *textNext) +00063 { +00064 <a class="code" href="debug_8h.html#a6">nlassert</a>(textNext); +00065 +00066 <font class="comment">// first, unlink others from me. NB: works even if _ULPrec==_ULNext==this.</font> +00067 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>->_ULPrec= <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>; +00068 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>->_ULNext= <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>; +00069 <font class="comment">// link to igNext.</font> +00070 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>= textNext; +00071 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>= textNext->_ULPrec; +00072 <font class="comment">// link others to me.</font> +00073 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>->_ULPrec= <font class="keyword">this</font>; +00074 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>->_ULNext= <font class="keyword">this</font>; +00075 } +00076 +<a name="l00077"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a8">00077</a> <font class="keywordtype">void</font> CTextureFar::unlinkUL() +00078 { +00079 <font class="comment">// first, unlink others from me. NB: works even if _ULPrec==_ULNext==this.</font> +00080 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>->_ULPrec= <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>; +00081 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>->_ULNext= <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>; +00082 <font class="comment">// reset</font> +00083 <a class="code" href="classNL3D_1_1CTextureFar.html#o2">_ULPrec</a>= <font class="keyword">this</font>; +00084 <a class="code" href="classNL3D_1_1CTextureFar.html#o3">_ULNext</a>= <font class="keyword">this</font>; +00085 } +00086 +00087 +<a name="l00088"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a2">00088</a> <font class="keywordtype">void</font> CTextureFar::setSizeOfFarPatch (sint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>) +00089 { +00090 <font class="comment">// Resizing the bitmap</font> +00091 <a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>=<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>; +00092 <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>=<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>*<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>; +00093 +00094 <font class="comment">// Resize patch array</font> +00095 <a class="code" href="namespaceNLMISC.html#a222">contReset</a> (<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>); +00096 <a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>.resize (<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00097 +00098 <font class="comment">// Init count of patch</font> +00099 <a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a>=0; +00100 +00101 <font class="comment">// Init upload format 16 bits</font> +00102 <a class="code" href="classNL3D_1_1ITexture.html#z826_4">setUploadFormat</a>(<a class="code" href="classNL3D_1_1ITexture.html#s29s8">RGB565</a>); +00103 +00104 <font class="comment">// Set filter mode. No mipmap!</font> +00105 <a class="code" href="classNL3D_1_1ITexture.html#z826_6">setFilterMode</a> (<a class="code" href="classNL3D_1_1ITexture.html#s30s19">Linear</a>, <a class="code" href="classNL3D_1_1ITexture.html#s31s24">LinearMipMapOff</a>); +00106 +00107 <font class="comment">// Wrap</font> +00108 <a class="code" href="classNL3D_1_1ITexture.html#z826_0">setWrapS</a> (<a class="code" href="classNL3D_1_1ITexture.html#s28s1">Clamp</a>); +00109 <a class="code" href="classNL3D_1_1ITexture.html#z826_1">setWrapT</a> (<a class="code" href="classNL3D_1_1ITexture.html#s28s1">Clamp</a>); +00110 +00111 <font class="comment">// Init patch array</font> +00112 <font class="keywordflow">for</font> (sint p=0; p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>; p++) +00113 { +00114 <font class="comment">// Set patch pointer to NULL</font> +00115 <a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch=NULL; +00116 } +00117 } +00118 +00119 <font class="comment">// Add a patch in the CTexture Patch. Must not be full! Return true if the texture is full after adding this patch else false.</font> +<a name="l00120"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a3">00120</a> <font class="keywordtype">bool</font> CTextureFar::addPatch (CPatch *pPatch, <font class="keywordtype">float</font>& farUScale, <font class="keywordtype">float</font>& farVScale, <font class="keywordtype">float</font>& farUBias, <font class="keywordtype">float</font>& farVBias, <font class="keywordtype">bool</font>& bRot) +00121 { +00122 <font class="comment">// Check that at least a cell is free</font> +00123 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a><<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00124 +00125 <font class="comment">// Look for a free cell</font> +00126 sint p; +00127 <font class="keywordflow">for</font> (p=0; p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>; p++) +00128 { +00129 <font class="comment">// Cell is NULL ?</font> +00130 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch==NULL) +00131 { +00132 <font class="comment">// Put the patch here and go out.</font> +00133 <a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch=pPatch; +00134 <font class="keywordflow">break</font>; +00135 } +00136 } +00137 <font class="comment">// Check that at least a cell is free</font> +00138 <a class="code" href="debug_8h.html#a6">nlassert</a> (p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00139 +00140 <font class="comment">// Position of the invalide rectangle</font> +00141 <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = ((p & <a class="code" href="texture__far_8h.html#a2">NL_NUM_FAR_PATCHES_BY_EDGE_MASK</a>) * <a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>) >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>; +00142 <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = ((p >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>) * <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>) >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>; +00143 +00144 <font class="comment">// Invalidate the rectangle</font> +00145 CRect rect (<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="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>, <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>); +00146 ITexture::touchRect (rect); +00147 +00148 <font class="comment">// ** Return some values</font> +00149 +00150 <font class="comment">// Rotation flag</font> +00151 bRot = ( pPatch->getOrderS() < pPatch->getOrderT() ); +00152 +00153 <font class="comment">// Scale is the same for all</font> +00154 farUScale=(float)((<a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)-1)/(float)<a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>; +00155 farVScale=(float)((<a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)-1)/(float)<a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>; +00156 +00157 <font class="comment">// UBias is the same for all</font> +00158 farUBias=((float)<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+0.5f)/(float)<a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>; +00159 +00160 <font class="comment">// UBias is the same for all</font> +00161 farVBias=((float)<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+0.5f)/(float)<a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>; +00162 +00163 <font class="comment">// One more patch</font> +00164 <a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a>++; +00165 +00166 <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a> == <a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00167 } +00168 +00169 <font class="comment">// Remove a patch in the CTexture Patch</font> +<a name="l00170"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a4">00170</a> <font class="keywordtype">bool</font> CTextureFar::removePatch (CPatch *pPatch) +00171 { +00172 <font class="comment">// Check that at least a cell is used</font> +00173 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a>>0); +00174 +00175 <font class="comment">// Look for the patch free cell</font> +00176 sint p; +00177 <font class="keywordflow">for</font> (p=0; p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>; p++) +00178 { +00179 <font class="comment">// Is the good cell ?</font> +00180 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch==pPatch) +00181 { +00182 <font class="comment">// ok, remove it</font> +00183 <a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch=NULL; +00184 <font class="keywordflow">break</font>; +00185 } +00186 } +00187 +00188 <font class="comment">// Check it has been found</font> +00189 <a class="code" href="debug_8h.html#a6">nlassert</a> (p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00190 +00191 <font class="comment">// One patch less</font> +00192 <a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a>--; +00193 +00194 <font class="comment">// Return true if it is empty, else return false</font> +00195 <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m1">_PatchCount</a> == 0); +00196 } +00197 +<a name="l00198"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a6">00198</a> uint CTextureFar::touchPatch(uint p) +00199 { +00200 <font class="comment">// Check param</font> +00201 <a class="code" href="debug_8h.html#a6">nlassert</a> (p<<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>); +00202 +00203 <font class="comment">// if there is still a patch here</font> +00204 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[p].Patch!=NULL ) +00205 { +00206 <font class="comment">// Position of the invalide rectangle</font> +00207 <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = ((p & <a class="code" href="texture__far_8h.html#a2">NL_NUM_FAR_PATCHES_BY_EDGE_MASK</a>) * <a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>) >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>; +00208 <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = ((p >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>) * <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>) >> <a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>; +00209 +00210 <font class="comment">// Invalidate the associated rectangle</font> +00211 CRect rect (<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="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>, <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>); +00212 ITexture::touchRect (rect); +00213 +00214 <font class="comment">// return number of pixels touched</font> +00215 <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>) * (<a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>); +00216 } +00217 <font class="keywordflow">else</font> +00218 { +00219 <font class="comment">// no touch</font> +00220 <font class="keywordflow">return</font> 0; +00221 } +00222 } +00223 +00224 <font class="comment">// Generate the texture. See ITexture::doGenerate().</font> +<a name="l00225"></a><a class="code" href="classNL3D_1_1CTextureFar.html#a5">00225</a> <font class="keywordtype">void</font> CTextureFar::doGenerate () +00226 { +00227 <font class="comment">// Resize</font> +00228 CBitmap::resize (<a class="code" href="classNL3D_1_1CTextureFar.html#o0">_OriginalWidth</a>, <a class="code" href="classNL3D_1_1CTextureFar.html#o1">_OriginalHeight</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>); +00229 +00230 <font class="comment">// Rectangle invalidate ?</font> +00231 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1ITexture.html#m1">_ListInvalidRect</a>.begin()!=<a class="code" href="classNL3D_1_1ITexture.html#m1">_ListInvalidRect</a>.end()) +00232 { +00233 <font class="comment">// Yes, rebuild only those rectangles.</font> +00234 +00235 <font class="comment">// For each rectangle to compute</font> +00236 <a class="code" href="classstd_1_1list.html">std::list<NLMISC::CRect></a>::iterator ite=<a class="code" href="classNL3D_1_1ITexture.html#m1">_ListInvalidRect</a>.begin(); +00237 <font class="keywordflow">while</font> (ite!=<a class="code" href="classNL3D_1_1ITexture.html#m1">_ListInvalidRect</a>.end()) +00238 { +00239 <font class="comment">// Compute rectangle coordinates</font> +00240 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=(ite->left()<<<a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)/<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00241 sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=(ite->top()<<<a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)/<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>; +00242 +00243 <font class="comment">// X and Y coord should be >0 and not be greater or equal to the number of patch stored on a texture edge.</font> +00244 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>>=0); +00245 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>); +00246 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>>=0); +00247 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>); +00248 +00249 <font class="comment">// ReBuild the rectangle. verify first patch still exist.</font> +00250 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[<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="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)].Patch) +00251 <a class="code" href="classNL3D_1_1CTextureFar.html#c0">rebuildRectangle</a> (<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>); +00252 +00253 <font class="comment">// Next rectangle</font> +00254 ite++; +00255 } +00256 } +00257 <font class="keywordflow">else</font> +00258 { +00259 <font class="comment">// no, rebuild all the rectangle</font> +00260 <font class="keywordflow">for</font> (sint <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><<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +00261 <font class="keywordflow">for</font> (sint <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><<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +00262 { +00263 <font class="comment">// Rebuild this rectangle</font> +00264 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[<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="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)].Patch) +00265 <a class="code" href="classNL3D_1_1CTextureFar.html#c0">rebuildRectangle</a> (<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>); +00266 } +00267 } +00268 } +00269 +00270 +00271 <font class="comment">// Rebuild the rectangle passed with coordinate passed in parameter</font> +<a name="l00272"></a><a class="code" href="classNL3D_1_1CTextureFar.html#c0">00272</a> <font class="keywordtype">void</font> CTextureFar::rebuildRectangle (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>) +00273 { +00274 <font class="comment">// Patch pointer</font> +00275 CPatch* patch=<a class="code" href="classNL3D_1_1CTextureFar.html#m0">_Patches</a>[<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="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)].Patch; +00276 +00277 <font class="comment">// Check it exists</font> +00278 <a class="code" href="debug_8h.html#a6">nlassert</a> (patch); +00279 +00280 <font class="comment">// get the order</font> +00281 uint nS=patch->getOrderS(); +00282 uint nT=patch->getOrderT(); +00283 +00284 <font class="comment">// Check it is a 16 bits texture</font> +00285 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CBitmap.html#a5">getPixelFormat</a>()==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>); +00286 +00287 <font class="comment">// Check pixels exist</font> +00288 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>().<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()!=0); +00289 +00290 <font class="comment">// Base offset of the first pixel of the patch's texture</font> +00291 uint nBaseOffset; +00292 +00293 <font class="comment">// Delta to add to the destination offset when walk for a pixel to the right in the source tile</font> +00294 sint dstDeltaX; +00295 +00296 <font class="comment">// Delta to add to the destination offset when walk for a pixel to the bottom in the source tile</font> +00297 sint dstDeltaY; +00298 +00299 <font class="comment">// larger size</font> +00300 uint larger; +00301 +00302 <font class="comment">// larger than higher (regular)</font> +00303 <font class="keywordflow">if</font> (nS>=nT) +00304 { +00305 <font class="comment">// Regular offset, top left</font> +00306 nBaseOffset=((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>)>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)+((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>)>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)*<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00307 +00308 <font class="comment">// Regular deltaX, to the right</font> +00309 dstDeltaX=1; +00310 +00311 <font class="comment">// Regular deltaY, to the bottom</font> +00312 dstDeltaY=<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00313 +00314 <font class="comment">// Larger size</font> +00315 larger=nS; +00316 } +00317 <font class="comment">// higher than larger (goofy), the patch is stored with a rotation of 1 (to the left of course)</font> +00318 <font class="keywordflow">else</font> +00319 { +00320 <font class="comment">// Goofy offset, bottom left</font> +00321 nBaseOffset=((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>)>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)+((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>)>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)*<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00322 nBaseOffset+=((<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>>><a class="code" href="texture__far_8h.html#a0">NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT</a>)-1)*<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00323 +00324 <font class="comment">// Goofy deltaX, to the top</font> +00325 dstDeltaX=-(sint)<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; +00326 +00327 <font class="comment">// Goofy deltaY, to the right</font> +00328 dstDeltaY=1; +00329 +00330 <font class="comment">// Larger size</font> +00331 larger=nT; +00332 } +00333 +00334 <font class="comment">// Compute the order of the patch</font> +00335 CTileFarBank::TFarOrder orderX=CTileFarBank::order0; +00336 uint tileSize=0; +00337 <font class="keywordflow">switch</font> ((larger*<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)/<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>) +00338 { +00339 <font class="keywordflow">case</font> 4: +00340 <font class="comment">// Ratio 1:4</font> +00341 orderX=CTileFarBank::order2; +00342 tileSize=<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>>>2; +00343 <font class="keywordflow">break</font>; +00344 <font class="keywordflow">case</font> 2: +00345 <font class="comment">// Ratio 1:2</font> +00346 orderX=CTileFarBank::order1; +00347 tileSize=<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>>>1; +00348 <font class="keywordflow">break</font>; +00349 <font class="keywordflow">case</font> 1: +00350 <font class="comment">// Ratio 1:1</font> +00351 orderX=CTileFarBank::order0; +00352 tileSize=<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>; +00353 <font class="keywordflow">break</font>; +00354 <font class="keywordflow">default</font>: +00355 <font class="comment">// no!: must be one of the previous values</font> +00356 <a class="code" href="debug_8h.html#a6">nlassert</a> (0); +00357 } +00358 +00359 <font class="preprocessor">#ifdef NL_DEBUG</font> +00360 <font class="preprocessor"></font> <font class="comment">// Compute the Y order</font> +00361 CTileFarBank::TFarOrder orderY; +00362 <font class="keywordflow">switch</font> ((<a class="code" href="bit__set_8cpp.html#a0">std::min</a>(nS, nT)*<a class="code" href="texture__far_8h.html#a1">NL_NUM_FAR_PATCHES_BY_EDGE</a>*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)/<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>) +00363 { +00364 <font class="keywordflow">case</font> 4: +00365 <font class="comment">// Ratio 1:4</font> +00366 orderY=CTileFarBank::order2; +00367 <font class="keywordflow">break</font>; +00368 <font class="keywordflow">case</font> 2: +00369 <font class="comment">// Ratio 1:2</font> +00370 orderY=CTileFarBank::order1; +00371 <font class="keywordflow">break</font>; +00372 <font class="keywordflow">case</font> 1: +00373 <font class="comment">// Ratio 1:1</font> +00374 orderY=CTileFarBank::order0; +00375 <font class="keywordflow">break</font>; +00376 <font class="keywordflow">default</font>: +00377 <font class="comment">// no!: must be one of the previous values</font> +00378 <a class="code" href="debug_8h.html#a6">nlassert</a> (0); +00379 } +00380 +00381 <font class="comment">// Check the ratio on Y is the same than on X</font> +00382 <a class="code" href="debug_8h.html#a6">nlassert</a> (orderX == orderY); +00383 <font class="preprocessor">#endif // NL_DEBUG</font> +00384 <font class="preprocessor"></font> <font class="comment">// Must have a far tile bank pointer set in the CFarTexture</font> +00385 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CTextureFar.html#m2">_Bank</a>); +00386 +00387 <font class="comment">// For all the tiles in the textures</font> +00388 sint nTileInPatch=0; +00389 +00390 <font class="comment">// ** Fill the struct for the tile fill method for each layers</font> +00391 <a class="code" href="structNL3D__CComputeTileFar.html">NL3D_CComputeTileFar</a> TileFar; +00392 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>= <font class="keyword">false</font>; +00393 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +00394 <font class="preprocessor"></font> TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>= <a class="code" href="classNLMISC_1_1CSystemInfo.html#d4">NLMISC::CSystemInfo::hasMMX</a>(); +00395 <font class="preprocessor">#endif</font> +00396 <font class="preprocessor"></font> +00397 <font class="comment">// Destination pointer</font> +00398 +00399 <font class="comment">// Destination delta</font> +00400 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>=dstDeltaX; +00401 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m8">DstDeltaY</a>=dstDeltaY; +00402 +00403 <font class="comment">// ** Build expand lightmap..</font> +00404 <a class="code" href="structNL3D__CExpandLightmap.html">NL3D_CExpandLightmap</a> lightMap; +00405 +00406 <font class="comment">// Fill the structure</font> +00407 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m5">MulFactor</a>=tileSize; +00408 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m0">ColorTile</a>=&patch->TileColors[0]; +00409 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>=nS+1; +00410 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>=nT+1; +00411 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>=patch->getZone()->getLandscape()->getStaticLight(); +00412 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m7">DstPixels</a>=<a class="code" href="classNL3D_1_1CTextureFar.html#r0">_LightmapExpanded</a>; +00413 <font class="comment">// Compute current TLI colors.</font> +00414 patch->computeCurrentTLILightmap(<a class="code" href="classNL3D_1_1CTextureFar.html#r2">_TileTLIColors</a>); +00415 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m1">TLIColor</a>= <a class="code" href="classNL3D_1_1CTextureFar.html#r2">_TileTLIColors</a>; +00416 +00417 <font class="comment">// Expand the shadowmap</font> +00418 patch->unpackShadowMap (<a class="code" href="classNL3D_1_1CTextureFar.html#r1">_LumelExpanded</a>); +00419 lightMap.<a class="code" href="structNL3D__CExpandLightmap.html#m2">LumelTile</a>=<a class="code" href="classNL3D_1_1CTextureFar.html#r1">_LumelExpanded</a>; +00420 +00421 <font class="comment">// Expand the patch lightmap now</font> +00422 <a class="code" href="texture__far_8cpp.html#a7">NL3D_expandLightmap</a> (&lightMap); +00423 +00424 <font class="comment">// DeltaY for lightmap</font> +00425 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m5">SrcLightingDeltaY</a>=nS*tileSize; +00426 +00427 <font class="comment">// Base Dst pointer on the tile line</font> +00428 uint nBaseDstTileLine=nBaseOffset; +00429 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a><nT; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>++) +00430 { +00431 <font class="comment">// Base Dst pointer on the tile</font> +00432 uint nBaseDstTilePixels=nBaseDstTileLine; +00433 +00434 <font class="comment">// For each tile of the line</font> +00435 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a><nS; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++) +00436 { +00437 <font class="comment">// Base pointer of the destination texture</font> +00438 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m6">DstPixels</a>=(CRGBA*)&(<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>()[0])+nBaseDstTilePixels; +00439 +00440 <font class="comment">// Lightmap pointer</font> +00441 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m4">SrcLightingPixels</a>=<a class="code" href="classNL3D_1_1CTextureFar.html#r0">_LightmapExpanded</a>+(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>*tileSize)+(<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*nS*tileSize*tileSize); +00442 +00443 <font class="comment">// For each layer of the tile</font> +00444 <font class="keywordflow">for</font> (sint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>=0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a><3; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>++) +00445 { +00446 <font class="comment">// Use of additive in this layer ?</font> +00447 <font class="keywordtype">bool</font> bAdditive=<font class="keyword">false</font>; +00448 +00449 <font class="comment">// Size of the edge far tile</font> +00450 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>=tileSize; +00451 +00452 <font class="comment">// Get a tile element reference for this tile.</font> +00453 <font class="keyword">const</font> CTileElement &tileElm=patch->Tiles[nTileInPatch]; +00454 +00455 <font class="comment">// Check for 256 tiles...</font> +00456 <font class="keywordtype">bool</font> is256x256; +00457 uint8 uvOff; +00458 tileElm.getTile256Info(is256x256, uvOff); +00459 +00460 <font class="comment">// Get the tile number</font> +00461 sint tile=tileElm.Tile[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>]; +00462 +00463 <font class="comment">// Is the last layer ?</font> +00464 <font class="keywordtype">bool</font> lastLayer = ( (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> == 2) || (tileElm.Tile[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>+1] == <a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>) ); +00465 +00466 <font class="comment">// Is an non-empty layer ?</font> +00467 <font class="keywordflow">if</font> (tile!=<a class="code" href="tile__element_8h.html#a12">NL_TILE_ELM_LAYER_EMPTY</a>) +00468 { +00469 <font class="comment">// Get the read only pointer on the far tile</font> +00470 <font class="keyword">const</font> CTileFarBank::CTileFar* pTile=<a class="code" href="classNL3D_1_1CTextureFar.html#m2">_Bank</a>->getTile (tile); +00471 +00472 <font class="comment">// This pointer must not be null, else the farBank is not valid!</font> +00473 <font class="keywordflow">if</font> (pTile==NULL) +00474 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"FarBank is not valid!"</font>); +00475 +00476 <font class="comment">// If the tile exist</font> +00477 <font class="keywordflow">if</font> (pTile) +00478 { +00479 <font class="comment">// Tile exist ?</font> +00480 <font class="keywordflow">if</font> (pTile->isFill (CTileFarBank::diffuse)) +00481 { +00482 <font class="comment">// Get rotation of the tile in this layer</font> +00483 sint nRot=tileElm.getTileOrient(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>); +00484 +00485 <font class="comment">// Source pointer</font> +00486 <font class="keyword">const</font> CRGBA* pSrcDiffusePixels=pTile->getPixels (CTileFarBank::diffuse, orderX); +00487 <font class="keyword">const</font> CRGBA* pSrcAdditivePixels=NULL; +00488 +00489 <font class="comment">// Additive ?</font> +00490 <font class="keywordflow">if</font> (pTile->isFill (CTileFarBank::additive)) +00491 { +00492 <font class="comment">// Use it</font> +00493 bAdditive=<font class="keyword">true</font>; +00494 +00495 <font class="comment">// Get additive pointer</font> +00496 pSrcAdditivePixels=pTile->getPixels (CTileFarBank::additive, orderX); +00497 } +00498 +00499 <font class="comment">// Source size</font> +00500 sint sourceSize; +00501 +00502 <font class="comment">// Source offset (for 256)</font> +00503 uint sourceOffset=0; +00504 +00505 <font class="comment">// 256 ?</font> +00506 <font class="keywordflow">if</font> (is256x256) +00507 { +00508 <font class="comment">// On the left ?</font> +00509 <font class="keywordflow">if</font> (uvOff&0x02) +00510 sourceOffset+=tileSize; +00511 +00512 <font class="comment">// On the bottom ?</font> +00513 <font class="keywordflow">if</font> ((uvOff==1)||(uvOff==2)) +00514 sourceOffset+=2*tileSize*tileSize; +00515 +00516 <font class="comment">// Yes, 256</font> +00517 sourceSize=tileSize<<1; +00518 } +00519 <font class="keywordflow">else</font> +00520 { +00521 <font class="comment">// No, 128</font> +00522 sourceSize=tileSize; +00523 } +00524 +00525 <font class="comment">// Compute offset and deltas</font> +00526 <font class="keywordflow">switch</font> (nRot) +00527 { +00528 <font class="keywordflow">case</font> 0: +00529 <font class="comment">// Source pointers</font> +00530 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>=pSrcDiffusePixels+sourceOffset; +00531 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>=pSrcAdditivePixels+sourceOffset; +00532 +00533 <font class="comment">// Source delta</font> +00534 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>=1; +00535 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>=sourceSize; +00536 <font class="keywordflow">break</font>; +00537 <font class="keywordflow">case</font> 1: +00538 { +00539 <font class="comment">// Source pointers</font> +00540 uint newOffset=sourceOffset+(tileSize-1); +00541 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>=pSrcDiffusePixels+newOffset; +00542 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>=pSrcAdditivePixels+newOffset; +00543 +00544 <font class="comment">// Source delta</font> +00545 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>=sourceSize; +00546 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>=-1; +00547 } +00548 <font class="keywordflow">break</font>; +00549 <font class="keywordflow">case</font> 2: +00550 { +00551 <font class="comment">// Destination pointer</font> +00552 uint newOffset=sourceOffset+(tileSize-1)*sourceSize+tileSize-1; +00553 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>=pSrcDiffusePixels+newOffset; +00554 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>=pSrcAdditivePixels+newOffset; +00555 +00556 <font class="comment">// Source delta</font> +00557 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>=-1; +00558 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>=-sourceSize; +00559 } +00560 <font class="keywordflow">break</font>; +00561 <font class="keywordflow">case</font> 3: +00562 { +00563 <font class="comment">// Destination pointer</font> +00564 uint newOffset=sourceOffset+(tileSize-1)*sourceSize; +00565 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>=pSrcDiffusePixels+newOffset; +00566 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>=pSrcAdditivePixels+newOffset; +00567 +00568 <font class="comment">// Source delta</font> +00569 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>=-sourceSize; +00570 TileFar.<a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>=1; +00571 } +00572 <font class="keywordflow">break</font>; +00573 } +00574 +00575 <font class="comment">// *** Draw the layer</font> +00576 +00577 <font class="comment">// Alpha layer ?</font> +00578 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>>0) +00579 { +00580 <font class="comment">// Additive layer ?</font> +00581 <font class="keywordflow">if</font> (bAdditive && lastLayer) +00582 <a class="code" href="texture__far_8cpp.html#a13">NL3D_drawFarTileInFarTextureAdditiveAlpha</a> (&TileFar); +00583 <font class="keywordflow">else</font> <font class="comment">// No additive layer</font> +00584 <a class="code" href="texture__far_8cpp.html#a11">NL3D_drawFarTileInFarTextureAlpha</a> (&TileFar); +00585 } +00586 <font class="keywordflow">else</font> <font class="comment">// no alpha</font> +00587 { +00588 <font class="comment">// Additive layer ?</font> +00589 <font class="keywordflow">if</font> (bAdditive && lastLayer) +00590 <a class="code" href="texture__far_8cpp.html#a12">NL3D_drawFarTileInFarTextureAdditive</a> (&TileFar); +00591 <font class="keywordflow">else</font> <font class="comment">// No additive layer</font> +00592 <a class="code" href="texture__far_8cpp.html#a10">NL3D_drawFarTileInFarTexture</a> (&TileFar); +00593 } +00594 } +00595 } +00596 } +00597 <font class="keywordflow">else</font> +00598 <font class="comment">// Stop, no more layer</font> +00599 <font class="keywordflow">break</font>; +00600 } +00601 +00602 <font class="comment">// Next tile</font> +00603 nTileInPatch++; +00604 +00605 <font class="comment">// Next tile on the line</font> +00606 nBaseDstTilePixels+=dstDeltaX*tileSize; +00607 } +00608 +00609 <font class="comment">// Next line of tiles</font> +00610 nBaseDstTileLine+=dstDeltaY*tileSize; +00611 } +00612 +00613 } +00614 +00615 } <font class="comment">// NL3D</font> +00616 +00617 +00618 <font class="comment">// ***************************************************************************</font> +00619 <font class="comment">// ***************************************************************************</font> +00620 <font class="comment">// NL3D_ExpandLightmap. C and Asm Part</font> +00621 <font class="comment">// ***************************************************************************</font> +00622 <font class="comment">// ***************************************************************************</font> +00623 +00624 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +00625 <font class="preprocessor"></font> +00626 +00627 <font class="comment">// EMMS called not in __asm block.</font> +00628 <font class="preprocessor"># pragma warning (disable : 4799)</font> +00629 <font class="preprocessor"></font> +00630 +00631 <font class="comment">// ***************************************************************************</font> +00632 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>() +00633 { +00634 __asm +00635 { +00636 <font class="comment">// close MMX computation</font> +00637 emms +00638 } +00639 } +00640 +00641 +00642 <font class="comment">// ***************************************************************************</font> +00646 <font class="comment"></font><font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a1">NL3D_asmExpandLineColor565</a>(<font class="keyword">const</font> uint16 *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, CRGBA *dst, uint du, uint len) +00647 { +00648 <font class="keyword">static</font> uint64 blank = 0; +00649 <font class="keyword">static</font> uint64 cF800 = 0x0000F8000000F800; +00650 <font class="keyword">static</font> uint64 cE000 = 0x0000E0000000E000; +00651 <font class="keyword">static</font> uint64 c07E0 = 0x000007E0000007E0; +00652 <font class="keyword">static</font> uint64 c0600 = 0x0000060000000600; +00653 <font class="keyword">static</font> uint64 c001F = 0x0000001F0000001F; +00654 <font class="keyword">static</font> uint64 c001C = 0x0000001C0000001C; +00655 <font class="keywordflow">if</font>(len==0) +00656 <font class="keywordflow">return</font>; +00657 +00658 +00659 <font class="comment">// Loop for pix.</font> +00660 __asm +00661 { +00662 movq mm7, blank +00663 +00664 <font class="comment">// start at pixel 1 => increment dst, and start u= du</font> +00665 mov esi, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> +00666 mov edi, dst +00667 add edi, 4 +00668 mov ecx, len +00669 mov edx, du +00670 +00671 <font class="comment">// Loop</font> +00672 myLoop: +00673 +00674 +00675 <font class="comment">// Read 565 colors</font> +00676 <font class="comment">//----------</font> +00677 <font class="comment">// index u.</font> +00678 mov ebx, edx +00679 shr ebx, 8 +00680 +00681 <font class="comment">// pack the 2 colors in eax: // Hedx= color0, Ledx= color1</font> +00682 xor eax, eax <font class="comment">// avoid partial stall.</font> +00683 mov ax, [esi + ebx*2] +00684 shl eax, 16 +00685 mov ax, [esi + ebx*2 +2] +00686 +00687 <font class="comment">// store and unpack in mm2: Hmm2= color0, Lmm2= color1</font> +00688 movd mm2, eax +00689 punpcklwd mm2, mm7 +00690 +00691 <font class="comment">// reset accumulator mm3 to black</font> +00692 movq mm3, mm7 +00693 +00694 <font class="comment">// Expand 565 to 888: color0 and color1 in parrallel</font> +00695 <font class="comment">// R</font> +00696 movq mm0, mm2 +00697 movq mm1, mm2 +00698 pand mm0, cF800 +00699 pand mm1, cE000 +00700 psrld mm0, 8 +00701 psrld mm1, 13 +00702 por mm3, mm0 +00703 por mm3, mm1 +00704 <font class="comment">// G</font> +00705 movq mm0, mm2 +00706 movq mm1, mm2 +00707 pand mm0, c07E0 +00708 pand mm1, c0600 +00709 pslld mm0, 5 +00710 psrld mm1, 1 +00711 por mm3, mm0 +00712 por mm3, mm1 +00713 <font class="comment">// B</font> +00714 movq mm0, mm2 +00715 movq mm1, mm2 +00716 pand mm0, c001F +00717 pand mm1, c001C +00718 pslld mm0, 19 +00719 pslld mm1, 14 +00720 por mm3, mm0 +00721 por mm3, mm1 +00722 +00723 <font class="comment">// unpack mm3 quad to mm0=color0 and mm1=color1.</font> +00724 movq mm0, mm3 +00725 movq mm1, mm3 +00726 psrlq mm0, 32 +00727 +00728 +00729 <font class="comment">// Blend.</font> +00730 <font class="comment">//----------</font> +00731 <font class="comment">// blend factors</font> +00732 mov ebx, edx +00733 mov eax, 256 +00734 +00735 and ebx, 0xFF +00736 sub eax, ebx +00737 +00738 movd mm2, ebx <font class="comment">// mm2= factor</font> +00739 movd mm3, eax <font class="comment">// mm3= 1-factor</font> +00740 <font class="comment">// replicate to the 4 words.</font> +00741 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font> +00742 punpckldq mm3, mm3 <font class="comment">// mm3= 0000 00AA 0000 00AA</font> +00743 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font> +00744 packssdw mm3, mm3 <font class="comment">// mm3= 00AA 00AA 00AA 00AA</font> +00745 +00746 <font class="comment">// mul</font> +00747 punpcklbw mm0, mm7 +00748 punpcklbw mm1, mm7 +00749 pmullw mm0, mm3 <font class="comment">// color0*(1-factor)</font> +00750 pmullw mm1, mm2 <font class="comment">// color1*factor</font> +00751 <font class="comment">// add, and unpack</font> +00752 paddusw mm0, mm1 +00753 psrlw mm0, 8 +00754 packuswb mm0, mm0 +00755 +00756 <font class="comment">// store</font> +00757 movd [edi], mm0 +00758 +00759 +00760 <font class="comment">// next pix</font> +00761 add edx, du +00762 add edi, 4 +00763 dec ecx +00764 jnz myLoop +00765 } +00766 } +00767 +00768 +00769 <font class="comment">// ***************************************************************************</font> +00773 <font class="comment"></font><font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a2">NL3D_asmExpandLineColor8888</a>(<font class="keyword">const</font> CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, CRGBA *dst, uint du, uint len) +00774 { +00775 <font class="keyword">static</font> uint64 blank = 0; +00776 <font class="keywordflow">if</font>(len==0) +00777 <font class="keywordflow">return</font>; +00778 +00779 +00780 <font class="comment">// Loop for pix.</font> +00781 __asm +00782 { +00783 movq mm7, blank +00784 +00785 <font class="comment">// start at pixel 1 => increment dst, and start u= du</font> +00786 mov esi, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> +00787 mov edi, dst +00788 add edi, 4 +00789 mov ecx, len +00790 mov edx, du +00791 +00792 <font class="comment">// Loop</font> +00793 myLoop: +00794 +00795 +00796 <font class="comment">// Read 8888 colors</font> +00797 <font class="comment">//----------</font> +00798 <font class="comment">// index u.</font> +00799 mov ebx, edx +00800 shr ebx, 8 +00801 +00802 <font class="comment">// read the 2 colors: mm0= color0, mm1= color1</font> +00803 movd mm0 , [esi + ebx*4] +00804 movd mm1 , [esi + ebx*4 + 4] +00805 +00806 +00807 <font class="comment">// Blend.</font> +00808 <font class="comment">//----------</font> +00809 <font class="comment">// blend factors</font> +00810 mov ebx, edx +00811 mov eax, 256 +00812 +00813 and ebx, 0xFF +00814 sub eax, ebx +00815 +00816 movd mm2, ebx <font class="comment">// mm2= factor</font> +00817 movd mm3, eax <font class="comment">// mm3= 1-factor</font> +00818 <font class="comment">// replicate to the 4 words.</font> +00819 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font> +00820 punpckldq mm3, mm3 <font class="comment">// mm3= 0000 00AA 0000 00AA</font> +00821 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font> +00822 packssdw mm3, mm3 <font class="comment">// mm3= 00AA 00AA 00AA 00AA</font> +00823 +00824 <font class="comment">// mul</font> +00825 punpcklbw mm0, mm7 +00826 punpcklbw mm1, mm7 +00827 pmullw mm0, mm3 <font class="comment">// color0*(1-factor)</font> +00828 pmullw mm1, mm2 <font class="comment">// color1*factor</font> +00829 <font class="comment">// add, and unpack</font> +00830 paddusw mm0, mm1 +00831 psrlw mm0, 8 +00832 packuswb mm0, mm0 +00833 +00834 <font class="comment">// store</font> +00835 movd [edi], mm0 +00836 +00837 +00838 <font class="comment">// next pix</font> +00839 add edx, du +00840 add edi, 4 +00841 dec ecx +00842 jnz myLoop +00843 } +00844 } +00845 +00846 +00847 <font class="comment">// ***************************************************************************</font> +00851 <font class="comment"></font><font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a3">NL3D_asmBlendLines</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, uint len) +00852 { +00853 <font class="keyword">static</font> uint64 blank = 0; +00854 <font class="keywordflow">if</font>(len==0) +00855 <font class="keywordflow">return</font>; +00856 +00857 +00858 <font class="comment">// Loop for pix.</font> +00859 __asm +00860 { +00861 movq mm7, blank +00862 +00863 <font class="comment">// read the factor and expand it to 4 words.</font> +00864 mov ebx, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> +00865 mov eax, 256 +00866 and ebx, 0xFF +00867 sub eax, ebx +00868 movd mm2, ebx <font class="comment">// mm2= factor</font> +00869 movd mm3, eax <font class="comment">// mm3= 1-factor</font> +00870 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font> +00871 punpckldq mm3, mm3 <font class="comment">// mm3= 0000 00AA 0000 00AA</font> +00872 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font> +00873 packssdw mm3, mm3 <font class="comment">// mm3= 00AA 00AA 00AA 00AA</font> +00874 +00875 <font class="comment">// setup ptrs</font> +00876 mov esi, src0 +00877 mov edx, src1 +00878 sub edx, esi <font class="comment">// difference between 2 src</font> +00879 mov edi, dst +00880 mov ecx, len +00881 +00882 <font class="comment">// Loop</font> +00883 myLoop: +00884 +00885 <font class="comment">// Read</font> +00886 movd mm0, [esi] +00887 movd mm1, [esi+edx] +00888 +00889 <font class="comment">// mul</font> +00890 punpcklbw mm0, mm7 +00891 punpcklbw mm1, mm7 +00892 pmullw mm0, mm3 <font class="comment">// color0*(1-factor)</font> +00893 pmullw mm1, mm2 <font class="comment">// color1*factor</font> +00894 <font class="comment">// add, and unpack</font> +00895 paddusw mm0, mm1 +00896 psrlw mm0, 8 +00897 packuswb mm0, mm0 +00898 +00899 <font class="comment">// store</font> +00900 movd [edi], mm0 +00901 +00902 +00903 <font class="comment">// next pix</font> +00904 add esi, 4 +00905 add edi, 4 +00906 dec ecx +00907 jnz myLoop +00908 } +00909 } +00910 +00911 +00912 <font class="comment">// ***************************************************************************</font> +00916 <font class="comment"></font><font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a4">NL3D_asmAssembleShading1x1</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +00917 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint lineWidth, uint nbTexel) +00918 { +00919 <font class="keyword">static</font> uint64 blank = 0; +00920 <font class="keywordflow">if</font>(nbTexel==0) +00921 <font class="keywordflow">return</font>; +00922 +00923 <font class="comment">// local var</font> +00924 uint offsetTLIs= ((uint)srcTLIs-(uint)dst); +00925 uint offsetUSCs= ((uint)srcUSCs-(uint)dst); +00926 +00927 <font class="comment">// Loop for pix.</font> +00928 __asm +00929 { +00930 movq mm7, blank +00931 +00932 <font class="comment">// setup ptrs</font> +00933 mov esi, lumels +00934 mov edi, dst +00935 mov ecx, nbTexel +00936 +00937 <font class="comment">// Loop</font> +00938 myLoop: +00939 +00940 <font class="comment">// Average shade part</font> +00941 <font class="comment">//------------</font> +00942 mov ebx, colorMap +00943 mov edx, lineWidth +00944 +00945 <font class="comment">// read and accumulate shade </font> +00946 xor eax,eax <font class="comment">// avoid partial stall</font> +00947 <font class="comment">// add with line 0</font> +00948 mov al, [esi + 0] +00949 add al, [esi + 1] +00950 adc ah, 0 +00951 add al, [esi + 2] +00952 adc ah, 0 +00953 add al, [esi + 3] +00954 adc ah, 0 +00955 <font class="comment">// add with line 1</font> +00956 add al, [esi + edx + 0] +00957 adc ah, 0 +00958 add al, [esi + edx + 1] +00959 adc ah, 0 +00960 add al, [esi + edx + 2] +00961 adc ah, 0 +00962 add al, [esi + edx + 3] +00963 adc ah, 0 +00964 <font class="comment">// add with line 2</font> +00965 add al, [esi + edx*2 + 0] +00966 adc ah, 0 +00967 add al, [esi + edx*2 + 1] +00968 adc ah, 0 +00969 add al, [esi + edx*2 + 2] +00970 adc ah, 0 +00971 add al, [esi + edx*2 + 3] +00972 adc ah, 0 +00973 <font class="comment">// add with line 3</font> +00974 lea edx, [edx + edx*2] +00975 add al, [esi + edx + 0] +00976 adc ah, 0 +00977 add al, [esi + edx + 1] +00978 adc ah, 0 +00979 add al, [esi + edx + 2] +00980 adc ah, 0 +00981 add al, [esi + edx + 3] +00982 adc ah, 0 +00983 <font class="comment">// average</font> +00984 shr eax, 4 +00985 +00986 <font class="comment">// convert to RGBA from the color Map</font> +00987 movd mm0, [ebx + eax*4] +00988 +00989 <font class="comment">// Assemble part</font> +00990 <font class="comment">//------------</font> +00991 mov edx, offsetTLIs +00992 mov ebx, offsetUSCs +00993 +00994 <font class="comment">// Add with TLI, and clamp.</font> +00995 paddusb mm0, [edi + edx] +00996 +00997 <font class="comment">// mul with USC</font> +00998 movd mm1, [edi + ebx] +00999 punpcklbw mm0, mm7 +01000 punpcklbw mm1, mm7 +01001 pmullw mm0, mm1 +01002 <font class="comment">// unpack</font> +01003 psrlw mm0, 8 +01004 packuswb mm0, mm0 +01005 +01006 <font class="comment">// store</font> +01007 movd [edi], mm0 +01008 +01009 +01010 <font class="comment">// next pix</font> +01011 add esi, 4 <font class="comment">// skip 4 lumels</font> +01012 add edi, 4 <font class="comment">// next texel</font> +01013 dec ecx +01014 jnz myLoop +01015 } +01016 } +01017 +01018 +01019 <font class="comment">// ***************************************************************************</font> +01023 <font class="comment"></font><font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a5">NL3D_asmAssembleShading2x2</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +01024 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint lineWidth, uint nbTexel) +01025 { +01026 <font class="keyword">static</font> uint64 blank = 0; +01027 <font class="keywordflow">if</font>(nbTexel==0) +01028 <font class="keywordflow">return</font>; +01029 +01030 <font class="comment">// local var</font> +01031 uint offsetTLIs= ((uint)srcTLIs-(uint)dst); +01032 uint offsetUSCs= ((uint)srcUSCs-(uint)dst); +01033 +01034 <font class="comment">// Loop for pix.</font> +01035 __asm +01036 { +01037 movq mm7, blank +01038 +01039 <font class="comment">// setup ptrs</font> +01040 mov esi, lumels +01041 mov edi, dst +01042 mov ecx, nbTexel +01043 +01044 <font class="comment">// Loop</font> +01045 myLoop: +01046 +01047 <font class="comment">// Average shade part</font> +01048 <font class="comment">//------------</font> +01049 mov ebx, colorMap +01050 mov edx, lineWidth +01051 +01052 <font class="comment">// read and accumulate shade </font> +01053 xor eax,eax <font class="comment">// avoid partial stall</font> +01054 mov al, [esi] <font class="comment">// read lumel</font> +01055 <font class="comment">// add with nbors</font> +01056 add al, [esi + 1] +01057 adc ah, 0 +01058 add al, [esi + edx] +01059 adc ah, 0 +01060 add al, [esi + edx + 1] +01061 adc ah, 0 +01062 <font class="comment">// average</font> +01063 shr eax, 2 +01064 +01065 <font class="comment">// convert to RGBA from the color Map</font> +01066 movd mm0, [ebx + eax*4] +01067 +01068 <font class="comment">// Assemble part</font> +01069 <font class="comment">//------------</font> +01070 mov edx, offsetTLIs +01071 mov ebx, offsetUSCs +01072 +01073 <font class="comment">// Add with TLI, and clamp.</font> +01074 paddusb mm0, [edi + edx] +01075 +01076 <font class="comment">// mul with USC</font> +01077 movd mm1, [edi + ebx] +01078 punpcklbw mm0, mm7 +01079 punpcklbw mm1, mm7 +01080 pmullw mm0, mm1 +01081 <font class="comment">// unpack</font> +01082 psrlw mm0, 8 +01083 packuswb mm0, mm0 +01084 +01085 <font class="comment">// store</font> +01086 movd [edi], mm0 +01087 +01088 +01089 <font class="comment">// next pix</font> +01090 add esi, 2 <font class="comment">// skip 2 lumels</font> +01091 add edi, 4 <font class="comment">// next texel</font> +01092 dec ecx +01093 jnz myLoop +01094 } +01095 } +01096 +01097 +01098 <font class="comment">// ***************************************************************************</font> +01099 <font class="preprocessor"># pragma warning (disable : 4731) // frame pointer register 'ebp' modified by inline assembly code</font> +01100 <font class="preprocessor"></font> +01103 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a6">NL3D_asmAssembleShading4x4</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +01104 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint nbTexel) +01105 { +01106 <font class="keyword">static</font> uint64 blank = 0; +01107 <font class="keywordflow">if</font>(nbTexel==0) +01108 <font class="keywordflow">return</font>; +01109 +01110 <font class="comment">// Loop for pix.</font> +01111 __asm +01112 { +01113 <font class="comment">// Use ebp as a register for faster access...</font> +01114 push ebp +01115 +01116 movq mm7, blank +01117 +01118 <font class="comment">// setup ptrs</font> +01119 mov esi, lumels +01120 mov edi, dst +01121 mov edx, srcTLIs +01122 sub edx, edi <font class="comment">// difference src and dest</font> +01123 mov ebx, srcUSCs +01124 sub ebx, edi <font class="comment">// difference src and dest</font> +01125 mov ecx, nbTexel +01126 +01127 <font class="comment">// set ebp after reading locals...</font> +01128 mov ebp, colorMap +01129 +01130 <font class="comment">// Loop</font> +01131 myLoop: +01132 +01133 <font class="comment">// read shade RGBA into the color Map</font> +01134 xor eax,eax <font class="comment">// avoid partial stall</font> +01135 mov al,[esi] <font class="comment">// read lumel</font> +01136 movd mm0, [ebp + eax*4] +01137 +01138 <font class="comment">// Add with TLI, and clamp.</font> +01139 paddusb mm0, [edi + edx] +01140 +01141 <font class="comment">// mul with USC</font> +01142 movd mm1, [edi + ebx] +01143 punpcklbw mm0, mm7 +01144 punpcklbw mm1, mm7 +01145 pmullw mm0, mm1 +01146 <font class="comment">// unpack</font> +01147 psrlw mm0, 8 +01148 packuswb mm0, mm0 +01149 +01150 <font class="comment">// store</font> +01151 movd [edi], mm0 +01152 +01153 +01154 <font class="comment">// next pix</font> +01155 add esi, 1 <font class="comment">// next lumel</font> +01156 add edi, 4 <font class="comment">// next texel</font> +01157 dec ecx +01158 jnz myLoop +01159 +01160 <font class="comment">// restore</font> +01161 pop ebp +01162 } +01163 +01164 } +01165 +01166 <font class="preprocessor"># pragma warning (default : 4731) // frame pointer register 'ebp' modified by inline assembly code</font> +01167 <font class="preprocessor"></font> +01168 +01169 <font class="preprocessor">#else // NL_OS_WINDOWS</font> +01170 <font class="preprocessor"></font> +01171 <font class="comment">// Dummy for non-windows platforms</font> +<a name="l01172"></a><a class="code" href="texture__far_8cpp.html#a0">01172</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>() {} +<a name="l01173"></a><a class="code" href="texture__far_8cpp.html#a1">01173</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a1">NL3D_asmExpandLineColor565</a>(<font class="keyword">const</font> uint16 *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, CRGBA *dst, uint du, uint len) {} +<a name="l01174"></a><a class="code" href="texture__far_8cpp.html#a2">01174</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a2">NL3D_asmExpandLineColor8888</a>(<font class="keyword">const</font> CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, CRGBA *dst, uint du, uint len) {} +<a name="l01175"></a><a class="code" href="texture__far_8cpp.html#a3">01175</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a3">NL3D_asmBlendLines</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, uint len) {} +<a name="l01176"></a><a class="code" href="texture__far_8cpp.html#a4">01176</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a4">NL3D_asmAssembleShading1x1</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +01177 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint lineWidth, uint nbTexel) +01178 { +01179 } +<a name="l01180"></a><a class="code" href="texture__far_8cpp.html#a5">01180</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a5">NL3D_asmAssembleShading2x2</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +01181 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint lineWidth, uint nbTexel) +01182 { +01183 } +<a name="l01184"></a><a class="code" href="texture__far_8cpp.html#a6">01184</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a6">NL3D_asmAssembleShading4x4</a>(<font class="keyword">const</font> uint8 *lumels, <font class="keyword">const</font> CRGBA *colorMap, +01185 <font class="keyword">const</font> CRGBA *srcTLIs, <font class="keyword">const</font> CRGBA *srcUSCs, CRGBA *dst, uint nbTexel) +01186 { +01187 } +01188 +01189 <font class="preprocessor">#endif // NL_OS_WINDOWS</font> +01190 <font class="preprocessor"></font> +01191 +01192 <font class="comment">// ***************************************************************************</font> +<a name="l01193"></a><a class="code" href="texture__far_8cpp.html#a7">01193</a> <font class="keyword">extern</font> <font class="stringliteral">"C"</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a7">NL3D_expandLightmap</a> (<font class="keyword">const</font> <a class="code" href="structNL3D__CExpandLightmap.html">NL3D_CExpandLightmap</a>* pLightmap) +01194 { +01195 <font class="keywordtype">bool</font> asmMMX= <font class="keyword">false</font>; +01196 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +01197 <font class="preprocessor"></font> asmMMX= CSystemInfo::hasMMX(); +01198 <font class="comment">// A CTileColor must be a 565 only.</font> +01199 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(CTileColor)==2); +01200 <font class="preprocessor">#endif</font> +01201 <font class="preprocessor"></font> +01202 <font class="comment">// Expanded width</font> +01203 uint dstWidth=(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>-1)*pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m5">MulFactor</a>; +01204 uint dstHeight=(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>-1)*pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m5">MulFactor</a>; +01205 +01206 <font class="comment">// *** First expand user color and TLI colors</font> +01207 <font class="comment">// First pass, expand on U</font> +01208 <font class="keyword">static</font> CRGBA expandedUserColorLine[ (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)* +01209 (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> ]; +01210 <font class="keyword">static</font> CRGBA expandedTLIColorLine[ (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)* +01211 (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> ]; +01212 <font class="comment">// Second pass, expand on V.</font> +01213 <font class="keyword">static</font> CRGBA expandedUserColor[ (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> * +01214 (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> ]; +01215 <font class="keyword">static</font> CRGBA expandedTLIColor[ (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> * +01216 (<a class="code" href="patch_8h.html#a1">NL_MAX_TILES_BY_PATCH_EDGE</a>+1)*<a class="code" href="patch_8h.html#a7">NL_LUMEL_BY_TILE</a> ]; +01217 +01218 +01219 <font class="comment">// ** Expand on U</font> +01220 <font class="comment">//=========</font> +01221 uint u, <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +01222 +01223 <font class="comment">// Expansion factor</font> +01224 uint expandFactor=((pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>-1)<<8)/(dstWidth-1); +01225 +01226 <font class="comment">// Destination pointer</font> +01227 CRGBA *expandedUserColorLinePtr= expandedUserColorLine; +01228 CRGBA *expandedTLIColorLinePtr= expandedTLIColorLine; +01229 +01230 <font class="comment">// Source pointer</font> +01231 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CTileColor.html">NL3D::CTileColor</a> *colorTilePtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m0">ColorTile</a>; +01232 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *colorTLIPtr= pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m1">TLIColor</a>; +01233 +01234 <font class="comment">// Go for U</font> +01235 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a><pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++) +01236 { +01237 <font class="comment">// First pixel</font> +01238 expandedUserColorLinePtr[0].<a class="code" href="classNLMISC_1_1CRGBA.html#a12">set565</a> (colorTilePtr[0].Color565); +01239 expandedTLIColorLinePtr[0]= colorTLIPtr[0]; +01240 +01241 <font class="comment">// MMX implementation.</font> +01242 <font class="comment">//-------------</font> +01243 <font class="keywordflow">if</font>(asmMMX) +01244 { +01245 <a class="code" href="texture__far_8cpp.html#a1">NL3D_asmExpandLineColor565</a>(&colorTilePtr-><a class="code" href="classNL3D_1_1CTileColor.html#m0">Color565</a>, expandedUserColorLinePtr, expandFactor, dstWidth-2); +01246 <a class="code" href="texture__far_8cpp.html#a2">NL3D_asmExpandLineColor8888</a>(colorTLIPtr, expandedTLIColorLinePtr, expandFactor, dstWidth-2); +01247 } +01248 <font class="comment">// C implementation</font> +01249 <font class="comment">//-------------</font> +01250 <font class="keywordflow">else</font> +01251 { +01252 <font class="comment">// Index next pixel</font> +01253 uint srcIndexPixel=expandFactor; +01254 +01255 <font class="keywordflow">for</font> (u=1; u<dstWidth-1; u++) +01256 { +01257 <font class="comment">// Check</font> +01258 <a class="code" href="debug_8h.html#a6">nlassert</a> ( (u+<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>*dstWidth) < (<font class="keyword">sizeof</font>(expandedUserColorLine)/<font class="keyword">sizeof</font>(CRGBA)) ); +01259 +01260 <font class="comment">// Color index</font> +01261 uint srcIndex=srcIndexPixel>>8; +01262 <a class="code" href="debug_8h.html#a6">nlassert</a> (srcIndex>=0); +01263 <a class="code" href="debug_8h.html#a6">nlassert</a> (srcIndex<pLightmap->Width-1); +01264 +01265 <font class="comment">// Compute current color</font> +01266 CRGBA color0; +01267 CRGBA color1; +01268 color0.set565 (colorTilePtr[srcIndex].Color565); +01269 color1.set565 (colorTilePtr[srcIndex+1].Color565); +01270 expandedUserColorLinePtr[u].blendFromui (color0, color1, srcIndexPixel&0xff); +01271 <font class="comment">// Compute current TLI color</font> +01272 color0= colorTLIPtr[srcIndex]; +01273 color1= colorTLIPtr[srcIndex+1]; +01274 expandedTLIColorLinePtr[u].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a> (color0, color1, srcIndexPixel&0xff); +01275 +01276 <font class="comment">// Next index</font> +01277 srcIndexPixel+=expandFactor; +01278 } +01279 } +01280 +01281 <font class="comment">// Last pixel</font> +01282 expandedUserColorLinePtr[dstWidth-1].set565 (colorTilePtr[pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>-1].Color565); +01283 expandedTLIColorLinePtr[dstWidth-1]= colorTLIPtr[pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>-1]; +01284 +01285 <font class="comment">// Next line</font> +01286 expandedUserColorLinePtr+= dstWidth; +01287 expandedTLIColorLinePtr+= dstWidth; +01288 colorTilePtr+=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>; +01289 colorTLIPtr+=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m3">Width</a>; +01290 } +01291 +01292 <font class="comment">// stop MMX if used</font> +01293 <font class="keywordflow">if</font>(asmMMX) +01294 <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>(); +01295 +01296 <font class="comment">// ** Expand on V</font> +01297 <font class="comment">//=========</font> +01298 +01299 <font class="comment">// Expansion factor</font> +01300 expandFactor=((pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>-1)<<8)/(dstHeight-1); +01301 +01302 <font class="comment">// Destination pointer</font> +01303 CRGBA *expandedUserColorPtr= expandedUserColor; +01304 CRGBA *expandedTLIColorPtr= expandedTLIColor; +01305 +01306 <font class="comment">// Src pointer</font> +01307 expandedUserColorLinePtr= expandedUserColorLine; +01308 expandedTLIColorLinePtr= expandedTLIColorLine; +01309 +01310 <font class="comment">// Copy first row</font> +01311 memcpy(expandedUserColorPtr, expandedUserColorLinePtr, dstWidth*<font class="keyword">sizeof</font>(CRGBA)); +01312 memcpy(expandedTLIColorPtr, expandedTLIColorLinePtr, dstWidth*<font class="keyword">sizeof</font>(CRGBA)); +01313 +01314 <font class="comment">// Next line</font> +01315 expandedUserColorPtr+=dstWidth; +01316 expandedTLIColorPtr+=dstWidth; +01317 +01318 <font class="comment">// Index next pixel</font> +01319 uint indexPixel=expandFactor; +01320 +01321 <font class="comment">// Go for V</font> +01322 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=1; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a><dstHeight-1; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++) +01323 { +01324 <font class="comment">// Color index</font> +01325 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>=indexPixel>>8; +01326 +01327 <font class="comment">// Source pointer</font> +01328 CRGBA *colorTilePtr0= expandedUserColorLine + <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>*dstWidth; +01329 CRGBA *colorTilePtr1= expandedUserColorLine + (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>+1)*dstWidth; +01330 CRGBA *colorTLIPtr0= expandedTLIColorLine + <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>*dstWidth; +01331 CRGBA *colorTLIPtr1= expandedTLIColorLine + (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>+1)*dstWidth; +01332 +01333 <font class="comment">// MMX implementation.</font> +01334 <font class="comment">//-------------</font> +01335 <font class="keywordflow">if</font>(asmMMX) +01336 { +01337 <a class="code" href="texture__far_8cpp.html#a3">NL3D_asmBlendLines</a>(expandedUserColorPtr, colorTilePtr0, colorTilePtr1, indexPixel, dstWidth); +01338 <a class="code" href="texture__far_8cpp.html#a3">NL3D_asmBlendLines</a>(expandedTLIColorPtr, colorTLIPtr0, colorTLIPtr1, indexPixel, dstWidth); +01339 } +01340 <font class="comment">// C implementation</font> +01341 <font class="comment">//-------------</font> +01342 <font class="keywordflow">else</font> +01343 { +01344 <font class="comment">// Copy the row</font> +01345 <font class="keywordflow">for</font> (u=0; u<dstWidth; u++) +01346 { +01347 expandedUserColorPtr[u].blendFromui (colorTilePtr0[u], colorTilePtr1[u], indexPixel&0xff); +01348 expandedTLIColorPtr[u].blendFromui (colorTLIPtr0[u], colorTLIPtr1[u], indexPixel&0xff); +01349 } +01350 } +01351 +01352 <font class="comment">// Next index</font> +01353 indexPixel+=expandFactor; +01354 +01355 <font class="comment">// Next line</font> +01356 expandedUserColorPtr+=dstWidth; +01357 expandedTLIColorPtr+=dstWidth; +01358 } +01359 +01360 <font class="comment">// stop MMX if used</font> +01361 <font class="keywordflow">if</font>(asmMMX) +01362 <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>(); +01363 +01364 <font class="comment">// Last row</font> +01365 <font class="comment">// Destination pointer</font> +01366 expandedUserColorPtr= expandedUserColor + dstWidth*(dstHeight-1); +01367 expandedTLIColorPtr= expandedTLIColor + dstWidth*(dstHeight-1); +01368 <font class="comment">// Src pointer</font> +01369 expandedUserColorLinePtr= expandedUserColorLine + dstWidth*(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>-1); +01370 expandedTLIColorLinePtr= expandedTLIColorLine + dstWidth*(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m4">Height</a>-1); +01371 +01372 <font class="comment">// Copy last row</font> +01373 memcpy(expandedUserColorPtr, expandedUserColorLinePtr, dstWidth*<font class="keyword">sizeof</font>(CRGBA)); +01374 memcpy(expandedTLIColorPtr, expandedTLIColorLinePtr, dstWidth*<font class="keyword">sizeof</font>(CRGBA)); +01375 +01376 <font class="comment">// *** Now combine with shading</font> +01377 <font class="comment">//=========</font> +01378 +01379 <font class="comment">// Switch to the optimal method for each expansion value</font> +01380 <font class="keywordflow">switch</font> (pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m5">MulFactor</a>) +01381 { +01382 <font class="keywordflow">case</font> 1: +01383 { +01384 <font class="comment">// Make 4x4 -> 1x1 blend</font> +01385 CRGBA *lineUSCPtr= expandedUserColor; +01386 CRGBA *lineTLIPtr= expandedTLIColor; +01387 CRGBA *lineDestPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m7">DstPixels</a>; +01388 <font class="keyword">const</font> uint8 *lineLumelPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m2">LumelTile</a>; +01389 uint lineWidth=dstWidth<<2; +01390 uint lineWidthx2=lineWidth<<1; +01391 uint lineWidthx3=lineWidthx2+lineWidth; +01392 uint lineWidthx4=lineWidth<<2; +01393 +01394 <font class="comment">// For each line</font> +01395 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a><dstHeight; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++) +01396 { +01397 <font class="comment">// MMX implementation.</font> +01398 <font class="comment">//-------------</font> +01399 <font class="keywordflow">if</font>(asmMMX) +01400 { +01401 <a class="code" href="texture__far_8cpp.html#a4">NL3D_asmAssembleShading1x1</a>(lineLumelPtr, pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>, lineTLIPtr, lineUSCPtr, lineDestPtr, +01402 lineWidth, dstWidth); +01403 } +01404 <font class="comment">// C implementation</font> +01405 <font class="comment">//-------------</font> +01406 <font class="keywordflow">else</font> +01407 { +01408 <font class="comment">// For each lumel block</font> +01409 <font class="keywordflow">for</font> (u=0; u<dstWidth; u++) +01410 { +01411 <font class="comment">// index</font> +01412 uint lumelIndex=u<<2; +01413 +01414 <font class="comment">// Shading is filtred</font> +01415 uint shading= +01416 ((uint)lineLumelPtr[lumelIndex]+(uint)lineLumelPtr[lumelIndex+1]+(uint)lineLumelPtr[lumelIndex+2]+(uint)lineLumelPtr[lumelIndex+3] +01417 +(uint)lineLumelPtr[lumelIndex+lineWidth]+(uint)lineLumelPtr[lumelIndex+1+lineWidth]+(uint)lineLumelPtr[lumelIndex+2+lineWidth]+(uint)lineLumelPtr[lumelIndex+3+lineWidth] +01418 +(uint)lineLumelPtr[lumelIndex+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+1+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+2+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+3+lineWidthx2] +01419 +(uint)lineLumelPtr[lumelIndex+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+1+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+2+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+3+lineWidthx3] +01420 )>>4; +01421 +01422 <font class="comment">// Add shading with TLI color.</font> +01423 CRGBA col; +01424 col.addRGBOnly(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>[shading], lineTLIPtr[u]); +01425 +01426 <font class="comment">// Mul by the userColor</font> +01427 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); +01428 } +01429 } +01430 +01431 <font class="comment">// Next line</font> +01432 lineUSCPtr+=dstWidth; +01433 lineTLIPtr+=dstWidth; +01434 lineDestPtr+=dstWidth; +01435 lineLumelPtr+=lineWidthx4; +01436 } +01437 <font class="keywordflow">break</font>; +01438 } +01439 <font class="keywordflow">case</font> 2: +01440 { +01441 <font class="comment">// Make 2x2 -> 1x1 blend</font> +01442 CRGBA *lineUSCPtr= expandedUserColor; +01443 CRGBA *lineTLIPtr= expandedTLIColor; +01444 CRGBA *lineDestPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m7">DstPixels</a>; +01445 <font class="keyword">const</font> uint8 *lineLumelPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m2">LumelTile</a>; +01446 uint lineWidth=dstWidth*2; +01447 uint lineWidthx2=lineWidth<<1; +01448 +01449 <font class="comment">// For each line</font> +01450 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a><dstHeight; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>++) +01451 { +01452 <font class="comment">// MMX implementation.</font> +01453 <font class="comment">//-------------</font> +01454 <font class="keywordflow">if</font>(asmMMX) +01455 { +01456 <a class="code" href="texture__far_8cpp.html#a5">NL3D_asmAssembleShading2x2</a>(lineLumelPtr, pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>, lineTLIPtr, lineUSCPtr, lineDestPtr, +01457 lineWidth, dstWidth); +01458 } +01459 <font class="comment">// C implementation</font> +01460 <font class="comment">//-------------</font> +01461 <font class="keywordflow">else</font> +01462 { +01463 <font class="comment">// For each lumel block</font> +01464 <font class="keywordflow">for</font> (u=0; u<dstWidth; u++) +01465 { +01466 <font class="comment">// index</font> +01467 uint lumelIndex=u<<1; +01468 +01469 <font class="comment">// Shading is filtred</font> +01470 uint shading= +01471 ((uint)lineLumelPtr[lumelIndex]+(uint)lineLumelPtr[lumelIndex+1]+(uint)lineLumelPtr[lumelIndex+lineWidth]+(uint)lineLumelPtr[lumelIndex+1+lineWidth])>>2; +01472 +01473 <font class="comment">// Add shading with TLI color.</font> +01474 CRGBA col; +01475 col.addRGBOnly(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>[shading], lineTLIPtr[u]); +01476 +01477 <font class="comment">// Mul by the userColor</font> +01478 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); +01479 } +01480 } +01481 +01482 <font class="comment">// Next line</font> +01483 lineUSCPtr+=dstWidth; +01484 lineTLIPtr+=dstWidth; +01485 lineDestPtr+=dstWidth; +01486 lineLumelPtr+=lineWidthx2; +01487 } +01488 <font class="keywordflow">break</font>; +01489 } +01490 +01491 <font class="keywordflow">case</font> 4: +01492 <font class="comment">// Make copy</font> +01493 CRGBA *lineUSCPtr= expandedUserColor; +01494 CRGBA *lineTLIPtr= expandedTLIColor; +01495 CRGBA *lineDestPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m7">DstPixels</a>; +01496 <font class="keyword">const</font> uint8 *lineLumelPtr=pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m2">LumelTile</a>; +01497 uint nbTexel=dstWidth*dstHeight; +01498 +01499 <font class="comment">// MMX implementation.</font> +01500 <font class="comment">//-------------</font> +01501 <font class="keywordflow">if</font>(asmMMX) +01502 { +01503 <a class="code" href="texture__far_8cpp.html#a6">NL3D_asmAssembleShading4x4</a>(lineLumelPtr, pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>, lineTLIPtr, lineUSCPtr, lineDestPtr, +01504 nbTexel); +01505 } +01506 <font class="comment">// C implementation</font> +01507 <font class="comment">//-------------</font> +01508 <font class="keywordflow">else</font> +01509 { +01510 <font class="comment">// For each pixel</font> +01511 <font class="keywordflow">for</font> (u=0; u<nbTexel; u++) +01512 { +01513 <font class="comment">// Shading is filtred</font> +01514 uint shading=lineLumelPtr[u]; +01515 +01516 <font class="comment">// Add shading with TLI color.</font> +01517 CRGBA col; +01518 col.addRGBOnly(pLightmap-><a class="code" href="structNL3D__CExpandLightmap.html#m6">StaticLightColor</a>[shading], lineTLIPtr[u]); +01519 +01520 <font class="comment">// Mul by the userColor</font> +01521 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); +01522 } +01523 } +01524 <font class="keywordflow">break</font>; +01525 } +01526 +01527 <font class="comment">// stop MMX if used</font> +01528 <font class="keywordflow">if</font>(asmMMX) +01529 <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>(); +01530 +01531 } +01532 +01533 +01534 <font class="comment">// ***************************************************************************</font> +01535 <font class="comment">// ***************************************************************************</font> +01536 <font class="comment">// NL3D_drawFarTileInFar*. C and Asm Part</font> +01537 <font class="comment">// ***************************************************************************</font> +01538 <font class="comment">// ***************************************************************************</font> +01539 +01540 +01541 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +01542 <font class="preprocessor"></font> +01543 +01544 <font class="comment">// ***************************************************************************</font> +01545 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a8">NL3D_asmModulateLineColors</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, +01546 uint len, uint src0DeltaX, uint dstDeltaX) +01547 { +01548 <font class="keyword">static</font> uint64 blank= 0; +01549 <font class="keywordflow">if</font>(len==0) +01550 <font class="keywordflow">return</font>; +01551 +01552 __asm +01553 { +01554 movq mm7, blank +01555 +01556 mov esi, src0 <font class="comment">// esi point to src Pixels</font> +01557 mov edx, src1 <font class="comment">// edx point to src lighting pixels</font> +01558 mov edi, dst +01559 mov ecx, len +01560 <font class="comment">// compute increments for esi and edi</font> +01561 mov eax, src0DeltaX +01562 mov ebx, dstDeltaX +01563 sal eax, 2 +01564 sal ebx, 2 +01565 +01566 myLoop: +01567 <font class="comment">// read colors</font> +01568 movd mm0, [esi] +01569 movd mm1, [edx] +01570 +01571 <font class="comment">// mul mm0 and mm1</font> +01572 punpcklbw mm0, mm7 +01573 punpcklbw mm1, mm7 +01574 pmullw mm0, mm1 +01575 psrlw mm0, 8 +01576 <font class="comment">// pack</font> +01577 packuswb mm0, mm0 +01578 +01579 <font class="comment">// out</font> +01580 movd [edi], mm0 +01581 +01582 <font class="comment">// increment</font> +01583 add esi, eax +01584 add edi, ebx +01585 add edx, 4 +01586 dec ecx +01587 jnz myLoop +01588 } +01589 } +01590 +01591 +01592 <font class="comment">// ***************************************************************************</font> +01593 <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a9">NL3D_asmModulateAndBlendLineColors</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, +01594 uint len, uint src0DeltaX, uint dstDeltaX) +01595 { +01596 <font class="keyword">static</font> uint64 blank= 0; +01597 <font class="keyword">static</font> uint64 one= 0x0100010001000100; +01598 <font class="keywordflow">if</font>(len==0) +01599 <font class="keywordflow">return</font>; +01600 +01601 __asm +01602 { +01603 movq mm7, blank +01604 movq mm6, one +01605 +01606 mov esi, src0 <font class="comment">// esi point to src Pixels</font> +01607 mov edx, src1 <font class="comment">// edx point to src lighting pixels</font> +01608 mov edi, dst +01609 mov ecx, len +01610 <font class="comment">// compute increments for esi and edi</font> +01611 mov eax, src0DeltaX +01612 mov ebx, dstDeltaX +01613 sal eax, 2 +01614 sal ebx, 2 +01615 +01616 myLoop: +01617 <font class="comment">// read colors</font> +01618 movd mm0, [esi] +01619 movd mm1, [edx] +01620 +01621 <font class="comment">// save and unpack Alpha. NB: ABGR</font> +01622 movq mm2, mm0 +01623 psrld mm2, 24 <font class="comment">// mm2= 0000 0000 0000 00AA</font> +01624 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font> +01625 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font> +01626 <font class="comment">// negate with 256.</font> +01627 movq mm3, mm6 +01628 psubusw mm3, mm2 +01629 +01630 <font class="comment">// mul mm0 and mm1</font> +01631 punpcklbw mm0, mm7 +01632 punpcklbw mm1, mm7 +01633 pmullw mm0, mm1 +01634 psrlw mm0, 8 +01635 +01636 <font class="comment">// Alpha Blend with mm3 and mm2</font> +01637 movd mm1, [edi] <font class="comment">// read dest</font> +01638 punpcklbw mm1, mm7 +01639 pmullw mm0, mm2 <font class="comment">// mm0= srcColor*A</font> +01640 pmullw mm1, mm3 <font class="comment">// mm1= dstColor*(1-A)</font> +01641 +01642 <font class="comment">// add and pack</font> +01643 paddusw mm0, mm1 +01644 psrlw mm0, 8 +01645 packuswb mm0, mm0 +01646 +01647 <font class="comment">// out</font> +01648 movd [edi], mm0 +01649 +01650 <font class="comment">// increment</font> +01651 add esi, eax +01652 add edi, ebx +01653 add edx, 4 +01654 dec ecx +01655 jnz myLoop +01656 } +01657 } +01658 +01659 +01660 <font class="preprocessor">#else // NL_OS_WINDOWS</font> +01661 <font class="preprocessor"></font> +01662 <font class="comment">// Dummy for non-windows platforms</font> +<a name="l01663"></a><a class="code" href="texture__far_8cpp.html#a8">01663</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a8">NL3D_asmModulateLineColors</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, +01664 uint len, uint src0DeltaX, uint dstDeltaX) +01665 { +01666 } +<a name="l01667"></a><a class="code" href="texture__far_8cpp.html#a9">01667</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a9">NL3D_asmModulateAndBlendLineColors</a>(CRGBA *dst, <font class="keyword">const</font> CRGBA *src0, <font class="keyword">const</font> CRGBA *src1, +01668 uint len, uint src0DeltaX, uint dstDeltaX) +01669 { +01670 } +01671 +01672 <font class="preprocessor">#endif</font> +01673 <font class="preprocessor"></font> +01674 <font class="comment">// ***************************************************************************</font> +<a name="l01675"></a><a class="code" href="texture__far_8cpp.html#a10">01675</a> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a10">NL3D_drawFarTileInFarTexture</a> (<font class="keyword">const</font> <a class="code" href="structNL3D__CComputeTileFar.html">NL3D_CComputeTileFar</a>* pTileFar) +01676 { +01677 <font class="comment">// Pointer of the Src diffuse pixels</font> +01678 <font class="keyword">const</font> CRGBA* pSrcPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>; +01679 +01680 <font class="comment">// Pointer of the Dst pixels</font> +01681 <font class="keyword">const</font> CRGBA* pSrcLightPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m4">SrcLightingPixels</a>; +01682 +01683 <font class="comment">// Pointer of the Dst pixels</font> +01684 CRGBA* pDstPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m6">DstPixels</a>; +01685 +01686 <font class="comment">// For each pixels</font> +01687 <font class="keywordtype">int</font> <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>; +01688 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +01689 { +01690 <font class="comment">// MMX implementation</font> +01691 <font class="comment">//---------</font> +01692 <font class="keywordflow">if</font>(pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>) +01693 { +01694 <a class="code" href="texture__far_8cpp.html#a8">NL3D_asmModulateLineColors</a>(pDstPixels, pSrcPixels, pSrcLightPixels, +01695 pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>, pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>, pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>); +01696 } +01697 <font class="comment">// C Implementation.</font> +01698 <font class="comment">//---------</font> +01699 <font class="keywordflow">else</font> +01700 { +01701 <font class="comment">// Pointer of the source line</font> +01702 <font class="keyword">const</font> CRGBA* pSrcLine=pSrcPixels; +01703 +01704 <font class="comment">// Pointer of the source lighting line</font> +01705 <font class="keyword">const</font> CRGBA* pSrcLightingLine=pSrcLightPixels; +01706 +01707 <font class="comment">// Pointer of the destination line</font> +01708 CRGBA* pDstLine=pDstPixels; +01709 +01710 <font class="comment">// For each pixels on the line</font> +01711 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +01712 { +01713 <font class="comment">// Read and write a pixel</font> +01714 pDstLine->R=(uint8)(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8); +01715 pDstLine->G=(uint8)(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8); +01716 pDstLine->B=(uint8)(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8); +01717 +01718 <font class="comment">// Next pixel</font> +01719 pSrcLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01720 pSrcLightingLine++; +01721 pDstLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>; +01722 } +01723 } +01724 +01725 <font class="comment">// Next line</font> +01726 pSrcPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01727 pSrcLightPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m5">SrcLightingDeltaY</a>; +01728 pDstPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m8">DstDeltaY</a>; +01729 } +01730 +01731 <font class="comment">// stop MMX if used</font> +01732 <font class="keywordflow">if</font>(pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>) +01733 <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>(); +01734 } +01735 +01736 +01737 <font class="comment">// ***************************************************************************</font> +<a name="l01738"></a><a class="code" href="texture__far_8cpp.html#a11">01738</a> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a11">NL3D_drawFarTileInFarTextureAlpha</a> (<font class="keyword">const</font> <a class="code" href="structNL3D__CComputeTileFar.html">NL3D_CComputeTileFar</a>* pTileFar) +01739 { +01740 <font class="comment">// Pointer of the Src pixels</font> +01741 <font class="keyword">const</font> CRGBA* pSrcPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>; +01742 +01743 <font class="comment">// Pointer of the Dst pixels</font> +01744 <font class="keyword">const</font> CRGBA* pSrcLightPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m4">SrcLightingPixels</a>; +01745 +01746 <font class="comment">// Pointer of the Dst pixels</font> +01747 CRGBA* pDstPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m6">DstPixels</a>; +01748 +01749 <font class="comment">// Fill the buffer with layer 0</font> +01750 <font class="keywordtype">int</font> <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>; +01751 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +01752 { +01753 <font class="comment">// MMX implementation</font> +01754 <font class="comment">//---------</font> +01755 <font class="keywordflow">if</font>(pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>) +01756 { +01757 <a class="code" href="texture__far_8cpp.html#a9">NL3D_asmModulateAndBlendLineColors</a>(pDstPixels, pSrcPixels, pSrcLightPixels, +01758 pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>, pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>, pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>); +01759 } +01760 <font class="comment">// C Implementation.</font> +01761 <font class="comment">//---------</font> +01762 <font class="keywordflow">else</font> +01763 { +01764 <font class="comment">// Pointer of the source line</font> +01765 <font class="keyword">const</font> CRGBA* pSrcLine=pSrcPixels; +01766 +01767 <font class="comment">// Pointer of the source lighting line</font> +01768 <font class="keyword">const</font> CRGBA* pSrcLightingLine=pSrcLightPixels; +01769 +01770 <font class="comment">// Pointer of the Dst pixels</font> +01771 CRGBA* pDstLine=pDstPixels; +01772 +01773 <font class="comment">// For each pixels on the line</font> +01774 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +01775 { +01776 <font class="comment">// Read and write a pixel</font> +01777 <font class="keyword">register</font> uint <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>=pSrcLine->A; +01778 <font class="keyword">register</font> uint oneLessAlpha=255-pSrcLine->A; +01779 pDstLine->R=(uint8)(((((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+(uint)pDstLine->R*oneLessAlpha)>>8); +01780 pDstLine->G=(uint8)(((((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+(uint)pDstLine->G*oneLessAlpha)>>8); +01781 pDstLine->B=(uint8)(((((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+(uint)pDstLine->B*oneLessAlpha)>>8); +01782 +01783 <font class="comment">// Next pixel</font> +01784 pSrcLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01785 pSrcLightingLine++; +01786 pDstLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>; +01787 } +01788 } +01789 +01790 <font class="comment">// Next line</font> +01791 pSrcPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01792 pSrcLightPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m5">SrcLightingDeltaY</a>; +01793 pDstPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m8">DstDeltaY</a>; +01794 } +01795 +01796 <font class="comment">// stop MMX if used</font> +01797 <font class="keywordflow">if</font>(pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m10">AsmMMX</a>) +01798 <a class="code" href="texture__far_8cpp.html#a0">NL3D_asmEndMMX</a>(); +01799 } +01800 +01801 +01802 <font class="comment">// ***************************************************************************</font> +01803 <font class="comment">// TODO: asm implementation of this function \\//</font> +01804 <font class="comment">//#ifdef NL_NO_ASM</font> +<a name="l01805"></a><a class="code" href="texture__far_8cpp.html#a12">01805</a> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a12">NL3D_drawFarTileInFarTextureAdditive</a> (<font class="keyword">const</font> <a class="code" href="structNL3D__CComputeTileFar.html">NL3D_CComputeTileFar</a>* pTileFar) +01806 { +01807 <font class="comment">// Pointer of the Src diffuse pixels</font> +01808 <font class="keyword">const</font> CRGBA* pSrcPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>; +01809 +01810 <font class="comment">// Pointer of the Src additive pixels</font> +01811 <font class="keyword">const</font> CRGBA* pSrcAddPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>; +01812 +01813 <font class="comment">// Pointer of the Dst pixels</font> +01814 <font class="keyword">const</font> CRGBA* pSrcLightPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m4">SrcLightingPixels</a>; +01815 +01816 <font class="comment">// Pointer of the Dst pixels</font> +01817 CRGBA* pDstPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m6">DstPixels</a>; +01818 +01819 <font class="comment">// For each pixels</font> +01820 <font class="keywordtype">int</font> <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>; +01821 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +01822 { +01823 <font class="comment">// Pointer of the source line</font> +01824 <font class="keyword">const</font> CRGBA* pSrcLine=pSrcPixels; +01825 +01826 <font class="comment">// Pointer of the source line</font> +01827 <font class="keyword">const</font> CRGBA* pSrcAddLine=pSrcAddPixels; +01828 +01829 <font class="comment">// Pointer of the source lighting line</font> +01830 <font class="keyword">const</font> CRGBA* pSrcLightingLine=pSrcLightPixels; +01831 +01832 <font class="comment">// Pointer of the destination line</font> +01833 CRGBA* pDstLine=pDstPixels; +01834 +01835 <font class="comment">// For each pixels on the line</font> +01836 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +01837 { +01838 <font class="comment">// Read and write a pixel</font> +01839 uint nTmp=(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)+(uint)pSrcAddLine->R; +01840 <font class="keywordflow">if</font> (nTmp>255) +01841 nTmp=255; +01842 pDstLine->R=(uint8)nTmp; +01843 nTmp=(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)+(uint)pSrcAddLine->G; +01844 <font class="keywordflow">if</font> (nTmp>255) +01845 nTmp=255; +01846 pDstLine->G=(uint8)nTmp; +01847 nTmp=(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)+(uint)pSrcAddLine->B; +01848 <font class="keywordflow">if</font> (nTmp>255) +01849 nTmp=255; +01850 pDstLine->B=(uint8)nTmp; +01851 +01852 <font class="comment">// Next pixel</font> +01853 pSrcLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01854 pSrcAddLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01855 pSrcLightingLine++; +01856 pDstLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>; +01857 } +01858 +01859 <font class="comment">// Next line</font> +01860 pSrcPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01861 pSrcAddPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01862 pSrcLightPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m5">SrcLightingDeltaY</a>; +01863 pDstPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m8">DstDeltaY</a>; +01864 } +01865 } +01866 <font class="comment">//#endif // NL_NO_ASM</font> +01867 +01868 +01869 <font class="comment">// ***************************************************************************</font> +01870 <font class="comment">// TODO: asm implementation of this function \\//</font> +01871 <font class="comment">//#ifdef NL_NO_ASM</font> +<a name="l01872"></a><a class="code" href="texture__far_8cpp.html#a13">01872</a> <font class="keywordtype">void</font> <a class="code" href="texture__far_8cpp.html#a13">NL3D_drawFarTileInFarTextureAdditiveAlpha</a> (<font class="keyword">const</font> <a class="code" href="structNL3D__CComputeTileFar.html">NL3D_CComputeTileFar</a>* pTileFar) +01873 { +01874 <font class="comment">// Pointer of the Src pixels</font> +01875 <font class="keyword">const</font> CRGBA* pSrcPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m0">SrcDiffusePixels</a>; +01876 +01877 <font class="comment">// Pointer of the Src pixels</font> +01878 <font class="keyword">const</font> CRGBA* pSrcAddPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m1">SrcAdditivePixels</a>; +01879 +01880 <font class="comment">// Pointer of the Dst pixels</font> +01881 <font class="keyword">const</font> CRGBA* pSrcLightPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m4">SrcLightingPixels</a>; +01882 +01883 <font class="comment">// Pointer of the Dst pixels</font> +01884 CRGBA* pDstPixels=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m6">DstPixels</a>; +01885 +01886 <font class="comment">// Fill the buffer with layer 0</font> +01887 <font class="keywordtype">int</font> <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>; +01888 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +01889 { +01890 <font class="comment">// Pointer of the source line</font> +01891 <font class="keyword">const</font> CRGBA* pSrcLine=pSrcPixels; +01892 +01893 <font class="comment">// Pointer of the source line</font> +01894 <font class="keyword">const</font> CRGBA* pSrcAddLine=pSrcAddPixels; +01895 +01896 <font class="comment">// Pointer of the source lighting line</font> +01897 <font class="keyword">const</font> CRGBA* pSrcLightingLine=pSrcLightPixels; +01898 +01899 <font class="comment">// Pointer of the Dst pixels</font> +01900 CRGBA* pDstLine=pDstPixels; +01901 +01902 <font class="comment">// For each pixels on the line</font> +01903 <font class="keywordflow">for</font> (<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><pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m9">Size</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +01904 { +01905 <font class="comment">// Read and write a pixel</font> +01906 <font class="keyword">register</font> uint <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>=pSrcLine->A; +01907 <font class="keyword">register</font> uint oneLessAlpha=255-pSrcLine->A; +01908 +01909 <font class="comment">// Read and write a pixel</font> +01910 uint nTmp=(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)+(uint)pSrcAddLine->R; +01911 <font class="keywordflow">if</font> (nTmp>255) +01912 nTmp=255; +01913 pDstLine->R=(uint8)((nTmp*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+pDstLine->R*oneLessAlpha)>>8); +01914 nTmp=(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)+(uint)pSrcAddLine->G; +01915 <font class="keywordflow">if</font> (nTmp>255) +01916 nTmp=255; +01917 pDstLine->G=(uint8)((nTmp*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+pDstLine->G*oneLessAlpha)>>8); +01918 nTmp=(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)+(uint)pSrcAddLine->B; +01919 <font class="keywordflow">if</font> (nTmp>255) +01920 nTmp=255; +01921 pDstLine->B=(uint8)((nTmp*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>+pDstLine->B*oneLessAlpha)>>8); +01922 +01923 <font class="comment">// Next pixel</font> +01924 pSrcLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01925 pSrcAddLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m2">SrcDeltaX</a>; +01926 pSrcLightingLine++; +01927 pDstLine+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m7">DstDeltaX</a>; +01928 } +01929 +01930 <font class="comment">// Next line</font> +01931 pSrcPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01932 pSrcAddPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m3">SrcDeltaY</a>; +01933 pSrcLightPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m5">SrcLightingDeltaY</a>; +01934 pDstPixels+=pTileFar-><a class="code" href="structNL3D__CComputeTileFar.html#m8">DstDeltaY</a>; +01935 } +01936 } +01937 <font class="comment">//#endif // NL_NO_ASM</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </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> |