aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/driver__opengl__material_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/driver__opengl__material_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/driver__opengl__material_8cpp-source.html1823
1 files changed, 1823 insertions, 0 deletions
diff --git a/docs/doxygen/nel/driver__opengl__material_8cpp-source.html b/docs/doxygen/nel/driver__opengl__material_8cpp-source.html
new file mode 100644
index 00000000..666280d1
--- /dev/null
+++ b/docs/doxygen/nel/driver__opengl__material_8cpp-source.html
@@ -0,0 +1,1823 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>driver_opengl_material.cpp</h1><a href="driver__opengl__material_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="stdopengl_8h.html">stdopengl.h</a>"</font>
+00027 <font class="preprocessor">#include "<a class="code" href="cube__map__builder_8h.html">3d/cube_map_builder.h</a>"</font>
+00028 <font class="preprocessor">#include "<a class="code" href="texture__mem_8h.html">3d/texture_mem.h</a>"</font>
+00029
+00030
+00031 <font class="keyword">namespace </font>NL3D {
+00032
+00033 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a343">convBlend</a>(CMaterial::TBlend <a class="code" href="namespaceNLMISC.html#a286">blend</a>, GLenum&amp; glenum)
+00034 {
+00035 <font class="keywordflow">switch</font>(blend)
+00036 {
+00037 <font class="keywordflow">case</font> CMaterial::one: glenum=GL_ONE; <font class="keywordflow">break</font>;
+00038 <font class="keywordflow">case</font> CMaterial::zero: glenum=GL_ZERO; <font class="keywordflow">break</font>;
+00039 <font class="keywordflow">case</font> CMaterial::srcalpha: glenum=GL_SRC_ALPHA; <font class="keywordflow">break</font>;
+00040 <font class="keywordflow">case</font> CMaterial::invsrcalpha:glenum=GL_ONE_MINUS_SRC_ALPHA; <font class="keywordflow">break</font>;
+00041 <font class="keywordflow">case</font> CMaterial::srccolor: glenum=GL_SRC_COLOR; <font class="keywordflow">break</font>;
+00042 <font class="keywordflow">case</font> CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; <font class="keywordflow">break</font>;
+00043 <font class="comment">// Extended Blend modes.</font>
+00044 <font class="keywordflow">case</font> CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; <font class="keywordflow">break</font>;
+00045 <font class="keywordflow">case</font> CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; <font class="keywordflow">break</font>;
+00046 <font class="keywordflow">case</font> CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; <font class="keywordflow">break</font>;
+00047 <font class="keywordflow">case</font> CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; <font class="keywordflow">break</font>;
+00048 <font class="keywordflow">default</font>: <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00049 }
+00050 }
+00051
+00052 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a344">convZFunction</a>(CMaterial::ZFunc zfunc, GLenum&amp; glenum)
+00053 {
+00054 <font class="keywordflow">switch</font>(zfunc)
+00055 {
+00056 <font class="keywordflow">case</font> CMaterial::lessequal: glenum=GL_LEQUAL; <font class="keywordflow">break</font>;
+00057 <font class="keywordflow">case</font> CMaterial::less: glenum=GL_LESS; <font class="keywordflow">break</font>;
+00058 <font class="keywordflow">case</font> CMaterial::always: glenum=GL_ALWAYS; <font class="keywordflow">break</font>;
+00059 <font class="keywordflow">case</font> CMaterial::never: glenum=GL_NEVER; <font class="keywordflow">break</font>;
+00060 <font class="keywordflow">case</font> CMaterial::equal: glenum=GL_EQUAL; <font class="keywordflow">break</font>;
+00061 <font class="keywordflow">case</font> CMaterial::notequal: glenum=GL_NOTEQUAL; <font class="keywordflow">break</font>;
+00062 <font class="keywordflow">case</font> CMaterial::greater: glenum=GL_GREATER; <font class="keywordflow">break</font>;
+00063 <font class="keywordflow">case</font> CMaterial::greaterequal: glenum=GL_GEQUAL; <font class="keywordflow">break</font>;
+00064 <font class="keywordflow">default</font>: <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00065 }
+00066 }
+00067
+00068 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a345">convColor</a>(CRGBA col, GLfloat glcol[4])
+00069 {
+00070 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> OO255= 1.0f/255;
+00071 glcol[0]= col.R*OO255;
+00072 glcol[1]= col.G*OO255;
+00073 glcol[2]= col.B*OO255;
+00074 glcol[3]= col.A*OO255;
+00075 }
+00076
+00077 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a346">convTexAddr</a>(ITexture *tex, CMaterial::TTexAddressingMode mode, GLenum &amp;glenum)
+00078 {
+00079 <a class="code" href="debug_8h.html#a6">nlassert</a>(mode &lt; CMaterial::TexAddrCount);
+00080 <font class="keyword">static</font> <font class="keyword">const</font> GLenum glTex2dAddrModesNV[] =
+00081 {
+00082 GL_NONE, GL_TEXTURE_2D, <a class="code" href="driver__opengl__extension__def_8h.html#a166">GL_PASS_THROUGH_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a167">GL_CULL_FRAGMENT_NV</a>,
+00083 <a class="code" href="driver__opengl__extension__def_8h.html#a168">GL_OFFSET_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a162">GL_OFFSET_TEXTURE_2D_SCALE_NV</a>,
+00084 <a class="code" href="driver__opengl__extension__def_8h.html#a169">GL_DEPENDENT_AR_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a170">GL_DEPENDENT_GB_TEXTURE_2D_NV</a>,
+00085 <a class="code" href="driver__opengl__extension__def_8h.html#a171">GL_DOT_PRODUCT_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a173">GL_DOT_PRODUCT_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a175">GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV</a>,
+00086 <a class="code" href="driver__opengl__extension__def_8h.html#a177">GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a178">GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV</a>,
+00087 <a class="code" href="driver__opengl__extension__def_8h.html#a176">GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a172">GL_DOT_PRODUCT_DEPTH_REPLACE_NV</a>
+00088 };
+00089
+00090
+00091 <font class="keyword">static</font> <font class="keyword">const</font> GLenum glTexCubedAddrModesNV[] =
+00092 {
+00093 GL_NONE, GL_TEXTURE_CUBE_MAP_ARB, <a class="code" href="driver__opengl__extension__def_8h.html#a166">GL_PASS_THROUGH_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a167">GL_CULL_FRAGMENT_NV</a>,
+00094 <a class="code" href="driver__opengl__extension__def_8h.html#a168">GL_OFFSET_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a162">GL_OFFSET_TEXTURE_2D_SCALE_NV</a>,
+00095 <a class="code" href="driver__opengl__extension__def_8h.html#a169">GL_DEPENDENT_AR_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a170">GL_DEPENDENT_GB_TEXTURE_2D_NV</a>,
+00096 <a class="code" href="driver__opengl__extension__def_8h.html#a171">GL_DOT_PRODUCT_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a173">GL_DOT_PRODUCT_TEXTURE_2D_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a175">GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV</a>,
+00097 <a class="code" href="driver__opengl__extension__def_8h.html#a177">GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a178">GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV</a>,
+00098 <a class="code" href="driver__opengl__extension__def_8h.html#a176">GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a172">GL_DOT_PRODUCT_DEPTH_REPLACE_NV</a>
+00099 };
+00100
+00101
+00102 <font class="keywordflow">if</font> (!tex || !tex-&gt;isTextureCube())
+00103 {
+00104 glenum = glTex2dAddrModesNV[(uint) mode];
+00105 }
+00106 <font class="keywordflow">else</font>
+00107 {
+00108 glenum = glTexCubedAddrModesNV[(uint) mode];
+00109 }
+00110 }
+00111
+00112
+00113 <font class="comment">// --------------------------------------------------</font>
+<a name="l00114"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a24">00114</a> <font class="keywordtype">void</font> CDriverGL::setTextureEnvFunction(uint stage, CMaterial&amp; mat)
+00115 {
+00116 ITexture *text= mat.getTexture(stage);
+00117 <font class="keywordflow">if</font>(text)
+00118 {
+00119 CMaterial::CTexEnv &amp;env= mat._TexEnvs[stage];
+00120
+00121 <font class="comment">// Activate the env for this stage.</font>
+00122 <font class="comment">// NB: Thoses calls use caching.</font>
+00123 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(stage, env);
+00124 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a>(stage, env);
+00125
+00126 <font class="comment">// Activate texture generation mapping</font>
+00127 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
+00128 <font class="keywordflow">if</font> (mat.getTexCoordGen (stage))
+00129 {
+00130 <font class="comment">// Enable it</font>
+00131 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (stage, <font class="keyword">true</font>);
+00132
+00133 <font class="comment">// Cubic or normal ?</font>
+00134 <font class="keywordflow">if</font> (text-&gt;isTextureCube ())
+00135 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTexGenMode (stage, GL_REFLECTION_MAP_ARB);
+00136 <font class="keywordflow">else</font>
+00137 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTexGenMode (stage, GL_SPHERE_MAP);
+00138 }
+00139 <font class="keywordflow">else</font>
+00140 {
+00141 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (stage, <font class="keyword">false</font>);
+00142 }
+00143 }
+00144 }
+00145
+00146
+00147 <font class="comment">//--------------------------------</font>
+<a name="l00148"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a25">00148</a> <font class="keywordtype">void</font> CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial&amp; mat)
+00149 {
+00150 <font class="keywordflow">if</font> (
+00151 (<a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> != 0 &amp;&amp; (mat.getFlags() &amp; <a class="code" href="namespaceNL3D.html#a138">IDRV_MAT_USER_TEX_MAT_ALL</a>) == 0)
+00152 || (mat.getFlags() &amp; <a class="code" href="namespaceNL3D.html#a138">IDRV_MAT_USER_TEX_MAT_ALL</a>) != 0
+00153 )
+00154 {
+00155 glMatrixMode(GL_TEXTURE);
+00156 <font class="comment">// for each stage, setup the texture matrix if needed</font>
+00157 uint newMask = (mat.getFlags() &amp; <a class="code" href="namespaceNL3D.html#a138">IDRV_MAT_USER_TEX_MAT_ALL</a>) &gt;&gt; <a class="code" href="namespaceNL3D.html#a139">IDRV_MAT_USER_TEX_FIRST_BIT</a>;
+00158 uint shiftMask = 1;
+00159 <font class="keywordflow">for</font> (uint k = 0; k &lt; numStages ; ++k)
+00160 {
+00161 <font class="keywordflow">if</font> (newMask &amp; shiftMask) <font class="comment">// user matrix for this stage</font>
+00162 {
+00163 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(k);
+00164 glLoadMatrixf(mat.getUserTexMat(k).get());
+00165 <a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> |= shiftMask;
+00166 }
+00167 <font class="keywordflow">else</font>
+00168 {
+00170 <font class="keywordflow">if</font> (
+00171 (newMask &amp; shiftMask) != (<a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> &amp; shiftMask)
+00172 )
+00173 {
+00174 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(k);
+00175 glLoadIdentity();
+00176 <a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> &amp;= ~shiftMask;
+00177 }
+00178 }
+00179 shiftMask &lt;&lt;= 1;
+00180 }
+00181 glMatrixMode(GL_MODELVIEW);
+00182 }
+00183 }
+00184
+<a name="l00185"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a26">00185</a> <font class="keywordtype">void</font> CDriverGL::disableUserTextureMatrix()
+00186 {
+00187 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> != 0)
+00188 {
+00189 glMatrixMode(GL_TEXTURE);
+00190 uint k = 0;
+00191 <font class="keywordflow">do</font>
+00192 {
+00193 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> &amp; (1 &lt;&lt; k)) <font class="comment">// user matrix for this stage</font>
+00194 {
+00195 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(k);
+00196 glLoadIdentity();
+00197 <a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> &amp;= ~ (1 &lt;&lt; k);
+00198
+00199 }
+00200 ++k;
+00201 }
+00202 <font class="keywordflow">while</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#o30">_UserTexMatEnabled</a> != 0);
+00203 glMatrixMode(GL_MODELVIEW);
+00204 }
+00205 }
+00206
+00207
+00208 <font class="comment">// --------------------------------------------------</font>
+<a name="l00209"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z415_0">00209</a> CMaterial::TShader CDriverGL::getSupportedShader(CMaterial::TShader shader)
+00210 {
+00211 <font class="keywordflow">switch</font> (shader)
+00212 {
+00213 <font class="keywordflow">case</font> CMaterial::PerPixelLighting: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z404_1">_SupportPerPixelShader</a> ? CMaterial::PerPixelLighting : CMaterial::Normal;
+00214 <font class="keywordflow">case</font> CMaterial::PerPixelLightingNoSpec: <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z404_2">_SupportPerPixelShaderNoSpec</a> ? CMaterial::PerPixelLightingNoSpec : CMaterial::Normal;
+00215 <font class="comment">// Lightmap and Specular work only if at least 2 text stages.</font>
+00216 <font class="keywordflow">case</font> CMaterial::LightMap: <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>()&gt;=2) ? CMaterial::LightMap : CMaterial::Normal;
+00217 <font class="keywordflow">case</font> CMaterial::Specular: <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>()&gt;=2) ? CMaterial::Specular : CMaterial::Normal;
+00218 <font class="keywordflow">default</font>: <font class="keywordflow">return</font> shader;
+00219 }
+00220 }
+00221
+00222
+00223 <font class="comment">// --------------------------------------------------</font>
+00224
+<a name="l00225"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a27">00225</a> <font class="keywordtype">bool</font> CDriverGL::setupMaterial(CMaterial&amp; mat)
+00226 {
+00227 CShaderGL* pShader;
+00228 GLenum glenum;
+00229 uint32 touched=mat.getTouched();
+00230 sint stage;
+00231
+00232
+00233 <font class="comment">// profile.</font>
+00234 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_4">_NbSetupMaterialCall</a>++;
+00235
+00236
+00237 <font class="comment">// 0. Retrieve/Create driver shader.</font>
+00238 <font class="comment">//==================================</font>
+00239 <font class="keywordflow">if</font> (!mat.pShader)
+00240 {
+00241 <font class="comment">// insert into driver list. (so it is deleted when driver is deleted).</font>
+00242 <a class="code" href="namespaceNL3D.html#a235">ItShaderPtrList</a> it= <a class="code" href="classNL3D_1_1IDriver.html#n2">_Shaders</a>.insert(<a class="code" href="classNL3D_1_1IDriver.html#n2">_Shaders</a>.end());
+00243 <font class="comment">// create and set iterator, for future deletion.</font>
+00244 *it= mat.pShader= <font class="keyword">new</font> CShaderGL(<font class="keyword">this</font>, it);
+00245
+00246 <font class="comment">// Must create all OpenGL shader states.</font>
+00247 touched= <a class="code" href="namespaceNL3D.html#a109">IDRV_TOUCHED_ALL</a>;
+00248 }
+00249 pShader=static_cast&lt;CShaderGL*&gt;((<a class="code" href="classNL3D_1_1IDriver.html#l3">IShader</a>*)(mat.pShader));
+00250
+00251
+00252 <font class="comment">// 1. Setup modified fields of material.</font>
+00253 <font class="comment">//=====================================</font>
+00254 <font class="keywordflow">if</font>( touched )
+00255 {
+00256 <font class="comment">/* Exception: if only Textures are modified in the material, no need to "Bind OpenGL States", or even to test</font>
+00257 <font class="comment"> for change, because textures are activated alone, see below.</font>
+00258 <font class="comment"> No problem with delete/new problem (see below), because in this case, IDRV_TOUCHED_ALL is set (see above).</font>
+00259 <font class="comment"> */</font>
+00260 <font class="comment">// If any flag is set (but a flag of texture)</font>
+00261 <font class="keywordflow">if</font>( touched &amp; (~_MaterialAllTextureTouchedFlag) )
+00262 {
+00263 <font class="comment">// Convert Material to driver shader.</font>
+00264 <font class="keywordflow">if</font> (touched &amp; <a class="code" href="namespaceNL3D.html#a95">IDRV_TOUCHED_BLENDFUNC</a>)
+00265 {
+00266 <a class="code" href="namespaceNL3D.html#a343">convBlend</a>( mat.getSrcBlend(),glenum );
+00267 pShader-&gt;SrcBlend=glenum;
+00268 <a class="code" href="namespaceNL3D.html#a343">convBlend</a>( mat.getDstBlend(),glenum );
+00269 pShader-&gt;DstBlend=glenum;
+00270 }
+00271 <font class="keywordflow">if</font> (touched &amp; <a class="code" href="namespaceNL3D.html#a98">IDRV_TOUCHED_ZFUNC</a>)
+00272 {
+00273 <a class="code" href="namespaceNL3D.html#a344">convZFunction</a>( mat.getZFunc(),glenum);
+00274 pShader-&gt;ZComp= glenum;
+00275 }
+00276 <font class="keywordflow">if</font> (touched &amp; <a class="code" href="namespaceNL3D.html#a101">IDRV_TOUCHED_LIGHTING</a>)
+00277 {
+00278 <a class="code" href="namespaceNL3D.html#a345">convColor</a>(mat.getEmissive(), pShader-&gt;Emissive);
+00279 <a class="code" href="namespaceNL3D.html#a345">convColor</a>(mat.getAmbient(), pShader-&gt;Ambient);
+00280 <a class="code" href="namespaceNL3D.html#a345">convColor</a>(mat.getDiffuse(), pShader-&gt;Diffuse);
+00281 <a class="code" href="namespaceNL3D.html#a345">convColor</a>(mat.getSpecular(), pShader-&gt;Specular);
+00282 pShader-&gt;PackedEmissive= mat.getEmissive().getPacked();
+00283 pShader-&gt;PackedAmbient= mat.getAmbient().getPacked();
+00284 pShader-&gt;PackedDiffuse= mat.getDiffuse().getPacked();
+00285 pShader-&gt;PackedSpecular= mat.getSpecular().getPacked();
+00286 }
+00287 <font class="keywordflow">if</font> (touched &amp; <a class="code" href="namespaceNL3D.html#a97">IDRV_TOUCHED_SHADER</a>)
+00288 {
+00289 <font class="comment">// Get shader. Fallback to other shader if not supported.</font>
+00290 pShader-&gt;SupportedShader= <a class="code" href="classNL3D_1_1CDriverGL.html#z415_0">getSupportedShader</a>(mat.getShader());
+00291 }
+00292
+00293
+00294 <font class="comment">// Since modified, must rebind all openGL states. And do this also for the delete/new problem.</font>
+00295 <font class="comment">/* If an old material is deleted, _CurrentMaterial is invalid. But this is grave only if a new </font>
+00296 <font class="comment"> material is created, with the same pointer (bad luck). Since an newly allocated material always </font>
+00297 <font class="comment"> pass here before use, we are sure to avoid any problems.</font>
+00298 <font class="comment"> */</font>
+00299 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>= NULL;
+00300 }
+00301
+00302 <font class="comment">// Optimize: reset all flags at the end.</font>
+00303 mat.clearTouched(0xFFFFFFFF);
+00304 }
+00305
+00306
+00307 <font class="comment">// Now we can get the supported shader from the cache.</font>
+00308 CMaterial::TShader matShader = pShader-&gt;SupportedShader;
+00309
+00310 <font class="comment">// setup the global</font>
+00311 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_3">_CurrentMaterialSupportedShader</a>= matShader;
+00312
+00313
+00314 <font class="comment">// 2. Setup / Bind Textures.</font>
+00315 <font class="comment">//==========================</font>
+00316 <font class="comment">// Must setup textures each frame. (need to test if touched).</font>
+00317 <font class="comment">// Must separate texture setup and texture activation in 2 "for"...</font>
+00318 <font class="comment">// because setupTexture() may disable all stage.</font>
+00319 <font class="keywordflow">for</font>(stage=0 ; stage&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>() ; stage++)
+00320 {
+00321 ITexture *text= mat.getTexture(stage);
+00322 <font class="keywordflow">if</font> (text != NULL &amp;&amp; !<a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*text))
+00323 <font class="keywordflow">return</font>(false);
+00324 }
+00325 <font class="comment">// Here, for Lightmap materials, setup the lightmaps.</font>
+00326 <font class="keywordflow">if</font>(matShader == CMaterial::LightMap)
+00327 {
+00328 <font class="keywordflow">for</font>(stage=0 ; stage&lt;(sint)mat._LightMaps.size() ; stage++)
+00329 {
+00330 ITexture *text= mat._LightMaps[stage].Texture;
+00331 <font class="keywordflow">if</font> (text != NULL &amp;&amp; !<a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*text))
+00332 <font class="keywordflow">return</font>(false);
+00333 }
+00334 }
+00335
+00336 <font class="comment">// Here, for caustic shader, setup the lightmaps</font>
+00337 <font class="comment">/*if (matShader == CMaterial::Caustics)</font>
+00338 <font class="comment"> {</font>
+00339 <font class="comment"> if (mat.getTexture(stage))</font>
+00340 <font class="comment"> }*/</font>
+00341
+00342
+00343 <font class="comment">// Activate the textures.</font>
+00344 <font class="comment">// Do not do it for Lightmap and per pixel lighting , because done in multipass in a very special fashion.</font>
+00345 <font class="comment">// This avoid the useless multiple change of texture states per lightmapped object.</font>
+00346 <font class="keywordflow">if</font>(matShader != CMaterial::LightMap
+00347 &amp;&amp; matShader != CMaterial::PerPixelLighting
+00348 <font class="comment">/* &amp;&amp; matShader != CMaterial::Caustics */</font>
+00349 &amp;&amp; matShader != CMaterial::Cloud
+00350 )
+00351 {
+00352 <font class="keywordflow">for</font>(stage=0 ; stage&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>() ; stage++)
+00353 {
+00354 ITexture *text= mat.getTexture(stage);
+00355
+00356 <font class="comment">// activate the texture, or disable texturing if NULL.</font>
+00357 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage,text);
+00358
+00359 <font class="comment">// If texture not NULL, Change texture env fonction.</font>
+00360 <font class="comment">//==================================================</font>
+00361 <a class="code" href="classNL3D_1_1CDriverGL.html#a24">setTextureEnvFunction</a>(stage, mat);
+00362 }
+00363 }
+00364
+00365
+00366 <font class="comment">// 3. Bind OpenGL States.</font>
+00367 <font class="comment">//=======================</font>
+00368 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>!=&amp;mat)
+00369 {
+00370 <font class="comment">// Bind Blend Part.</font>
+00371 <font class="comment">//=================</font>
+00372 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a117">IDRV_MAT_BLEND</a>);
+00373 <font class="keywordflow">if</font>(mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a117">IDRV_MAT_BLEND</a>)
+00374 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.blendFunc(pShader-&gt;SrcBlend, pShader-&gt;DstBlend);
+00375
+00376 <font class="comment">// Double Sided Part.</font>
+00377 <font class="comment">//===================</font>
+00378 <font class="comment">// NB: inverse state: DoubleSided &lt;=&gt; !CullFace.</font>
+00379 uint32 twoSided= mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a118">IDRV_MAT_DOUBLE_SIDED</a>;
+00380 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableCullFace( twoSided==0 );
+00381
+00382
+00383 <font class="comment">// Alpha Test Part.</font>
+00384 <font class="comment">//=================</font>
+00385 uint32 alphaTest= mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a119">IDRV_MAT_ALPHA_TEST</a>;
+00386 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableAlphaTest(alphaTest);
+00387 <font class="keywordflow">if</font>(alphaTest)
+00388 {
+00389 <font class="comment">// setup alphaTest threshold.</font>
+00390 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.alphaFunc(mat.getAlphaTestThreshold());
+00391 }
+00392
+00393
+00394 <font class="comment">// Bind ZBuffer Part.</font>
+00395 <font class="comment">//===================</font>
+00396 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableZWrite(mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a112">IDRV_MAT_ZWRITE</a>);
+00397 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.depthFunc(pShader-&gt;ZComp);
+00398 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setDepthRange (mat.getZBias () * <a class="code" href="classNL3D_1_1CDriverGL.html#o10">_OODeltaZ</a>);
+00399
+00400
+00401 <font class="comment">// Color-Lighting Part.</font>
+00402 <font class="comment">//=====================</font>
+00403
+00404 <font class="comment">// Light Part.</font>
+00405 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableLighting(mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a114">IDRV_MAT_LIGHTING</a>);
+00406 <font class="keywordflow">if</font>(mat.getFlags()&amp;<a class="code" href="namespaceNL3D.html#a114">IDRV_MAT_LIGHTING</a>)
+00407 {
+00408 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setEmissive(pShader-&gt;PackedEmissive, pShader-&gt;Emissive);
+00409 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setAmbient(pShader-&gt;PackedAmbient, pShader-&gt;Ambient);
+00410 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setDiffuse(pShader-&gt;PackedDiffuse, pShader-&gt;Diffuse);
+00411 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setSpecular(pShader-&gt;PackedSpecular, pShader-&gt;Specular);
+00412 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setShininess(mat.getShininess());
+00413 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setVertexColorLighted(mat.isLightedVertexColor ());
+00414 }
+00415 <font class="keywordflow">else</font>
+00416 {
+00417 <font class="comment">// Color unlit part.</font>
+00418 CRGBA col= mat.getColor();
+00419 glColor4ub(col.R, col.G, col.B, col.A);
+00420 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setVertexColorLighted(<font class="keyword">false</font>);
+00421 }
+00422
+00423
+00424 <font class="comment">// Texture shader part.</font>
+00425 <font class="comment">//=====================</font>
+00426
+00427 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureShader)
+00428 {
+00429 <font class="keywordflow">if</font> (matShader == CMaterial::Normal)
+00430 {
+00431 <font class="comment">// Texture addressing modes (support only via NVTextureShader for now)</font>
+00432 <font class="comment">//=================================================================== </font>
+00433 <font class="keywordflow">if</font> ( mat.getFlags() &amp; <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a> )
+00434 {
+00435 <a class="code" href="classNL3D_1_1CDriverGL.html#c9">enableNVTextureShader</a>(<font class="keyword">true</font>);
+00436
+00437 GLenum glAddrMode;
+00438 <font class="keywordflow">for</font> (stage = 0; stage &lt; <a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); ++stage)
+00439 {
+00440 <a class="code" href="namespaceNL3D.html#a346">convTexAddr</a>(mat.getTexture(stage), (CMaterial::TTexAddressingMode) (mat._TexAddrMode[stage]), glAddrMode);
+00441
+00442 <font class="keywordflow">if</font> (glAddrMode != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_8">_CurrentTexAddrMode</a>[stage]) <font class="comment">// addressing mode different from the one in the device?</font>
+00443
+00444 {
+00445 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
+00446 glTexEnvi(<a class="code" href="driver__opengl__extension__def_8h.html#a155">GL_TEXTURE_SHADER_NV</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a156">GL_SHADER_OPERATION_NV</a>, glAddrMode);
+00447 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_8">_CurrentTexAddrMode</a>[stage] = glAddrMode;
+00448 }
+00449 }
+00450 }
+00451 <font class="keywordflow">else</font>
+00452 {
+00453 <a class="code" href="classNL3D_1_1CDriverGL.html#c9">enableNVTextureShader</a>(<font class="keyword">false</font>);
+00454 }
+00455 }
+00456 <font class="keywordflow">else</font>
+00457 {
+00458 <a class="code" href="classNL3D_1_1CDriverGL.html#c9">enableNVTextureShader</a>(<font class="keyword">false</font>);
+00459 }
+00460 }
+00461
+00462 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>=&amp;mat;
+00463 }
+00464
+00465
+00466 <font class="comment">// 4. Misc</font>
+00467 <font class="comment">//=====================================</font>
+00468
+00469 <font class="comment">// If !lightMap and prec material was lihgtmap =&gt; vertex setup is dirty!</font>
+00470 <font class="keywordflow">if</font>( matShader != CMaterial::LightMap &amp;&amp; <a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a> )
+00471 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_4">resetLightMapVertexSetup</a>();
+00472
+00473 <font class="comment">// Textures user matrix</font>
+00474 <font class="keywordflow">if</font> (matShader == CMaterial::Normal)
+00475 {
+00476 <a class="code" href="classNL3D_1_1CDriverGL.html#a25">setupUserTextureMatrix</a>((uint) <a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(), mat);
+00477 }
+00478 <font class="keywordflow">else</font> <font class="comment">// deactivate texture matrix</font>
+00479 {
+00480 <a class="code" href="classNL3D_1_1CDriverGL.html#a26">disableUserTextureMatrix</a>();
+00481 }
+00482
+00483 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00484 }
+00485
+00486
+00487 <font class="comment">// ***************************************************************************</font>
+<a name="l00488"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">00488</a> sint CDriverGL::beginMultiPass()
+00489 {
+00490 <font class="comment">// Depending on material type and hardware, return number of pass required to draw this material.</font>
+00491 <font class="keywordflow">switch</font>(_CurrentMaterialSupportedShader)
+00492 {
+00493 <font class="keywordflow">case</font> CMaterial::LightMap:
+00494 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z407_1">beginLightMapMultiPass</a>();
+00495 <font class="keywordflow">case</font> CMaterial::Specular:
+00496 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z408_0">beginSpecularMultiPass</a>();
+00497 <font class="keywordflow">case</font> CMaterial::PerPixelLighting:
+00498 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z409_2">beginPPLMultiPass</a>();
+00499 <font class="keywordflow">case</font> CMaterial::PerPixelLightingNoSpec:
+00500 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z409_5">beginPPLNoSpecMultiPass</a>();
+00501 <font class="comment">/* case CMaterial::Caustics:</font>
+00502 <font class="comment"> return beginCausticsMultiPass(); */</font>
+00503 <font class="keywordflow">case</font> CMaterial::Cloud:
+00504 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#c15">beginCloudMultiPass</a>();
+00505
+00506 <font class="comment">// All others materials require just 1 pass.</font>
+00507 <font class="keywordflow">default</font>: <font class="keywordflow">return</font> 1;
+00508 }
+00509 }
+00510 <font class="comment">// ***************************************************************************</font>
+<a name="l00511"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">00511</a> <font class="keywordtype">void</font> CDriverGL::setupPass(uint pass)
+00512 {
+00513 <font class="keywordflow">switch</font>(_CurrentMaterialSupportedShader)
+00514 {
+00515 <font class="keywordflow">case</font> CMaterial::LightMap:
+00516 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_2">setupLightMapPass</a> (pass);
+00517 <font class="keywordflow">break</font>;
+00518 <font class="keywordflow">case</font> CMaterial::Specular:
+00519 <a class="code" href="classNL3D_1_1CDriverGL.html#z408_1">setupSpecularPass</a> (pass);
+00520 <font class="keywordflow">break</font>;
+00521 <font class="keywordflow">case</font> CMaterial::PerPixelLighting:
+00522 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_3">setupPPLPass</a> (pass);
+00523 <font class="keywordflow">break</font>;
+00524 <font class="keywordflow">case</font> CMaterial::PerPixelLightingNoSpec:
+00525 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_6">setupPPLNoSpecPass</a> (pass);
+00526 <font class="keywordflow">break</font>;
+00527 <font class="comment">/* case CMaterial::Caustics:</font>
+00528 <font class="comment"> case CMaterial::Caustics:</font>
+00529 <font class="comment"> break; */</font>
+00530 <font class="keywordflow">case</font> CMaterial::Cloud:
+00531 <a class="code" href="classNL3D_1_1CDriverGL.html#c16">setupCloudPass</a> (pass);
+00532 <font class="keywordflow">break</font>;
+00533
+00534 <font class="comment">// All others materials do not require multi pass.</font>
+00535 <font class="keywordflow">default</font>: <font class="keywordflow">return</font>;
+00536 }
+00537 }
+00538
+00539
+00540 <font class="comment">// ***************************************************************************</font>
+<a name="l00541"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">00541</a> <font class="keywordtype">void</font> CDriverGL::endMultiPass()
+00542 {
+00543 <font class="keywordflow">switch</font>(_CurrentMaterialSupportedShader)
+00544 {
+00545 <font class="keywordflow">case</font> CMaterial::LightMap:
+00546 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_3">endLightMapMultiPass</a>();
+00547 <font class="keywordflow">break</font>;
+00548 <font class="keywordflow">case</font> CMaterial::Specular:
+00549 <a class="code" href="classNL3D_1_1CDriverGL.html#z408_2">endSpecularMultiPass</a>();
+00550 <font class="keywordflow">break</font>;
+00551 <font class="keywordflow">case</font> CMaterial::PerPixelLighting:
+00552 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_4">endPPLMultiPass</a>();
+00553 <font class="keywordflow">break</font>;
+00554 <font class="keywordflow">case</font> CMaterial::PerPixelLightingNoSpec:
+00555 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_7">endPPLNoSpecMultiPass</a>();
+00556 <font class="keywordflow">break</font>;
+00557 <font class="comment">/* case CMaterial::Caustics:</font>
+00558 <font class="comment"> endCausticsMultiPass();</font>
+00559 <font class="comment"> break; */</font>
+00560 <font class="keywordflow">case</font> CMaterial::Cloud:
+00561 <a class="code" href="classNL3D_1_1CDriverGL.html#c17">endCloudMultiPass</a>();
+00562 <font class="keywordflow">break</font>;
+00563 <font class="comment">// All others materials do not require multi pass.</font>
+00564 <font class="keywordflow">default</font>: <font class="keywordflow">return</font>;
+00565 }
+00566 }
+00567
+00568
+00569 <font class="comment">// ***************************************************************************</font>
+<a name="l00570"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z407_0">00570</a> <font class="keywordtype">void</font> CDriverGL::computeLightMapInfos (<font class="keyword">const</font> CMaterial &amp;mat)
+00571 {
+00572 <font class="keyword">static</font> <font class="keyword">const</font> uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked();
+00573
+00574 <font class="comment">// For optimisation consideration, suppose there is not too much lightmap.</font>
+00575 <a class="code" href="debug_8h.html#a6">nlassert</a>(mat._LightMaps.size()&lt;=<a class="code" href="driver__opengl_8h.html#a1">NL3D_DRV_MAX_LIGHTMAP</a>);
+00576
+00577 <font class="comment">// Compute number of lightmaps really used (ie factor not NULL), and build the LUT.</font>
+00578 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a> = 0;
+00579 <font class="comment">// For all lightmaps of the material.</font>
+00580 <font class="keywordflow">for</font> (uint i = 0; i &lt; mat._LightMaps.size(); ++i)
+00581 {
+00582 <font class="comment">// If the lightmap's factor is not null.</font>
+00583 <font class="keywordflow">if</font> (mat._LightMaps[i].Factor.getPacked() &amp; RGBMaskPacked)
+00584 {
+00585 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_8">_LightMapLUT</a>[<a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a>] = i;
+00586 ++<a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a>;
+00587 }
+00588 }
+00589
+00590 <font class="comment">// Compute how many pass, according to driver caps.</font>
+00591 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a> = <a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>()-1;
+00592 <font class="comment">// Can do more than 2 texture stages only if NVTextureEnvCombine4 or ATIXTextureEnvCombine3</font>
+00593 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4 || !<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ATIXTextureEnvCombine3)
+00594 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a> = 1;
+00595
+00596 <font class="comment">// Number of pass.</font>
+00597 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_7">_NLightMapPass</a> = (<a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a> + <a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a>-1)/(_NLightMapPerPass);
+00598
+00599 <font class="comment">// NB: _NLightMaps==0 means there is no lightmaps at all.</font>
+00600 }
+00601
+00602
+00603 <font class="comment">// ***************************************************************************</font>
+<a name="l00604"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z407_1">00604</a> sint CDriverGL::beginLightMapMultiPass ()
+00605 {
+00606 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+00607
+00608 <font class="comment">// compute how many lightmap and pass we must process.</font>
+00609 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_0">computeLightMapInfos</a> (mat);
+00610
+00611 <font class="comment">// Too be sure, disable vertex coloring / lightmap.</font>
+00612 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableLighting(<font class="keyword">false</font>);
+00613 <font class="comment">// reset VertexColor array if necessary.</font>
+00614 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.VertexFormat &amp; CVertexBuffer::PrimaryColorFlag)
+00615 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00616
+00617 <font class="comment">// Manage too if no lightmaps.</font>
+00618 <font class="keywordflow">return</font> std::max (<a class="code" href="classNL3D_1_1CDriverGL.html#z407_7">_NLightMapPass</a>, (uint)1);
+00619 }
+00620 <font class="comment">// ***************************************************************************</font>
+<a name="l00621"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z407_2">00621</a> <font class="keywordtype">void</font> CDriverGL::setupLightMapPass(uint pass)
+00622 {
+00623 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+00624
+00625 <font class="comment">// No lightmap or all blacks??, just setup "black texture" for stage 0.</font>
+00626 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a>==0)
+00627 {
+00628 ITexture *text= mat.getTexture(0);
+00629 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(0,text);
+00630
+00631 <font class="comment">// setup std modulate env</font>
+00632 CMaterial::CTexEnv env;
+00633 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(0, env);
+00634 <font class="comment">// Since Lighting is disabled, as well as colorArray, must setup alpha.</font>
+00635 <font class="comment">// setup color to 0 =&gt; blackness</font>
+00636 glColor4ub(0, 0, 0, 255);
+00637
+00638 <font class="comment">// Setup gen tex off</font>
+00639 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+00640 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (0, <font class="keyword">false</font>);
+00641
+00642 <font class="comment">// And disable other stages.</font>
+00643 <font class="keywordflow">for</font>(sint stage=1 ; stage&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>() ; stage++)
+00644 {
+00645 <font class="comment">// disable texturing.</font>
+00646 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage, NULL);
+00647 }
+00648
+00649 <font class="keywordflow">return</font>;
+00650 }
+00651
+00652 <a class="code" href="debug_8h.html#a6">nlassert</a>(pass&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#z407_7">_NLightMapPass</a>);
+00653
+00654
+00655 <font class="comment">// setup Texture Pass.</font>
+00656 <font class="comment">//=========================</font>
+00657 uint lmapId;
+00658 uint nstages;
+00659 lmapId= pass * <a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a>; <font class="comment">// Nb lightmaps already processed</font>
+00660 <font class="comment">// N lightmaps for this pass, plus the texture.</font>
+00661 nstages= <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a>, <a class="code" href="classNL3D_1_1CDriverGL.html#z407_5">_NLightMaps</a>-lmapId) + 1;
+00662 <font class="comment">// setup all stages.</font>
+00663 <font class="keywordflow">for</font>(uint stage= 0; stage&lt;(uint)<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); stage++)
+00664 {
+00665 <font class="comment">// if must setup a lightmap stage.</font>
+00666 <font class="keywordflow">if</font>(stage&lt;nstages-1)
+00667 {
+00668 <font class="comment">// setup lightMap.</font>
+00669 uint whichLightMap= <a class="code" href="classNL3D_1_1CDriverGL.html#z407_8">_LightMapLUT</a>[lmapId];
+00670 <font class="comment">// get text and factor.</font>
+00671 ITexture *text = mat._LightMaps[whichLightMap].Texture;
+00672 CRGBA lmapFactor = mat._LightMaps[whichLightMap].Factor;
+00673 lmapFactor.A= 255;
+00674
+00675 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage,text);
+00676
+00677 <font class="comment">// If texture not NULL, Change texture env fonction.</font>
+00678 <font class="comment">//==================================================</font>
+00679 <font class="keywordflow">if</font>(text)
+00680 {
+00681 <font class="keyword">static</font> CMaterial::CTexEnv stdEnv;
+00682
+00683 <font class="comment">// NB, !_Extensions.NVTextureEnvCombine4, nstages==2, so here always stage==0.</font>
+00684 <font class="keywordflow">if</font> (stage==0)
+00685 {
+00686 <font class="comment">// do not use consant color to blend lightmap, but incoming diffuse color, for stage0 only.</font>
+00687 <font class="comment">// (NB: lighting and vertexcolorArray are disabled here)</font>
+00688 glColor4ub(lmapFactor.R, lmapFactor.G, lmapFactor.B, 255);
+00689
+00690 <font class="comment">// Leave stage as default env (Modulate with previous)</font>
+00691 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(stage, stdEnv);
+00692
+00693 <font class="comment">// Setup gen tex off</font>
+00694 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
+00695 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (stage, <font class="keyword">false</font>);
+00696 }
+00697 <font class="keywordflow">else</font>
+00698 {
+00699 <font class="comment">// Here, we are sure that texEnvCombine4 or texEnvCombine3 is OK.</font>
+00700 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4 || <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ATIXTextureEnvCombine3);
+00701
+00702 <font class="comment">// setup constant color with Lightmap factor.</font>
+00703 stdEnv.ConstantColor=lmapFactor;
+00704 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a>(stage, stdEnv);
+00705
+00706
+00707 <font class="comment">// TexEnv is special.</font>
+00708 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[stage] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u1">TexEnvSpecialLightMap</a>;
+00709
+00710 <font class="comment">// Setup env for texture stage.</font>
+00711 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
+00712
+00713 <font class="comment">// setup TexEnvCombine4 (ignore alpha part).</font>
+00714 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[stage] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u1">TexEnvSpecialLightMap</a>)
+00715 {
+00716 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4)
+00717 {
+00718 <font class="comment">// What we want to setup is Texture*Constant + Previous*1.</font>
+00719 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+00720
+00721 <font class="comment">// Operator.</font>
+00722 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD );
+00723 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD );
+00724 <font class="comment">// Arg0.</font>
+00725 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00726 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+00727 <font class="comment">// Arg1.</font>
+00728 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT );
+00729 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+00730 <font class="comment">// Arg2.</font>
+00731 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+00732 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+00733 <font class="comment">// Arg3.</font>
+00734 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+00735 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+00736 }
+00737 <font class="keywordflow">else</font>
+00738 {
+00739 <font class="comment">// ATI EnvCombine3</font>
+00740 <font class="comment">// What we want to setup is Texture*Constant + Previous.</font>
+00741 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+00742 <font class="comment">// Operator.</font>
+00743 glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+00744 glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+00745 <font class="comment">// Arg0.</font>
+00746 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00747 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+00748 <font class="comment">// Arg1.</font>
+00749 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT );
+00750 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+00751 <font class="comment">// Arg2.</font>
+00752 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+00753 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+00754 }
+00755 }
+00756 }
+00757
+00758 <font class="comment">// setup UV, with UV1. Only if needed (cached)</font>
+00759 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a> || <a class="code" href="classNL3D_1_1CDriverGL.html#z407_11">_LightMapUVMap</a>[stage]!=1 )
+00760 {
+00761 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(stage, <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>, 1);
+00762 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_11">_LightMapUVMap</a>[stage]= 1;
+00763 }
+00764 }
+00765
+00766 <font class="comment">// Next lightmap.</font>
+00767 lmapId++;
+00768 }
+00769 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(stage&lt;nstages)
+00770 {
+00771 <font class="comment">// optim: do this only for first pass, and last pass only if stage!=nLMapPerPass </font>
+00772 <font class="comment">// (meaning not the same stage as preceding passes).</font>
+00773 <font class="keywordflow">if</font>(pass==0 || (pass==<a class="code" href="classNL3D_1_1CDriverGL.html#z407_7">_NLightMapPass</a>-1 &amp;&amp; stage!=<a class="code" href="classNL3D_1_1CDriverGL.html#z407_6">_NLightMapPerPass</a>))
+00774 {
+00775 <font class="comment">// activate the texture at last stage.</font>
+00776 ITexture *text= mat.getTexture(0);
+00777 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage,text);
+00778
+00779 <font class="comment">// setup ModulateRGB/ReplaceAlpha env. (this may disable possible COMBINE4_NV setup).</font>
+00780 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(stage, <a class="code" href="classNL3D_1_1CDriverGL.html#z407_9">_LightMapLastStageEnv</a>);
+00781
+00782 <font class="comment">// Setup gen tex off</font>
+00783 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
+00784 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (stage, <font class="keyword">false</font>);
+00785
+00786 <font class="comment">// setup UV, with UV0. Only if needed (cached)</font>
+00787 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a> || <a class="code" href="classNL3D_1_1CDriverGL.html#z407_11">_LightMapUVMap</a>[stage]!=0 )
+00788 {
+00789 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(stage, <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>, 0);
+00790 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_11">_LightMapUVMap</a>[stage]= 0;
+00791 }
+00792 }
+00793 }
+00794 <font class="keywordflow">else</font>
+00795 {
+00796 <font class="comment">// else all other stages are disabled.</font>
+00797 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage,NULL);
+00798 }
+00799 }
+00800
+00801
+00802 <font class="comment">// setup blend / lighting.</font>
+00803 <font class="comment">//=========================</font>
+00804
+00805 <font class="comment">/* If multi-pass, then must setup a black Fog color for 1+ pass (just do it for the pass 1).</font>
+00806 <font class="comment"> This is because Transparency ONE/ONE is used.</font>
+00807 <font class="comment"> */</font>
+00808 <font class="keywordflow">if</font>(pass==1 &amp;&amp; <a class="code" href="classNL3D_1_1CDriverGL.html#o16">_FogEnabled</a>)
+00809 {
+00810 <font class="keyword">static</font> GLfloat blackFog[4]= {0,0,0,0};
+00811 glFogfv(GL_FOG_COLOR, blackFog);
+00812 }
+00813
+00814 <font class="comment">// Blend is different if the material is blended or not</font>
+00815 <font class="keywordflow">if</font>( !mat.getBlend() )
+00816 {
+00817 <font class="comment">// Not blended, std case.</font>
+00818 <font class="keywordflow">if</font>(pass==0)
+00819 {
+00820 <font class="comment">// no transparency for first pass.</font>
+00821 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">false</font>);
+00822 }
+00823 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(pass==1)
+00824 {
+00825 <font class="comment">// setup an Additive transparency (only for pass 1, will be kept for successives pass).</font>
+00826 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">true</font>);
+00827 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.blendFunc(GL_ONE, GL_ONE);
+00828 }
+00829 }
+00830 <font class="keywordflow">else</font>
+00831 {
+00832 <font class="comment">/* 1st pass, std alphaBlend. 2nd pass, add to background. Demo:</font>
+00833 <font class="comment"> T: texture.</font>
+00834 <font class="comment"> l0: lightmap (or group of lightmap) of pass 0.</font>
+00835 <font class="comment"> l1: lightmap (or group of lightmap) of pass 1. (same thing with 2,3 etc....)</font>
+00836 <font class="comment"> B: Background.</font>
+00837 <font class="comment"> A: Alpha of texture.</font>
+00838 <font class="comment"></font>
+00839 <font class="comment"> finalResult= T*(l0+l1) * A + B * (1-A).</font>
+00840 <font class="comment"></font>
+00841 <font class="comment"> We get it in two pass:</font>
+00842 <font class="comment"> fint= T*l0 * A + B * (1-A).</font>
+00843 <font class="comment"> finalResult= T*l1 * A + fint = T*l1 * A + T*l0 * A + B * (1-A)=</font>
+00844 <font class="comment"> T* (l0+l1) * A + B * (1-A)</font>
+00845 <font class="comment"> */</font>
+00846 <font class="keywordflow">if</font>(pass==0)
+00847 {
+00848 <font class="comment">// no transparency for first pass.</font>
+00849 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">true</font>);
+00850 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+00851 }
+00852 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(pass==1)
+00853 {
+00854 <font class="comment">// setup an Additive transparency (only for pass 1, will be kept for successives pass).</font>
+00855 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">true</font>);
+00856 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.blendFunc(GL_SRC_ALPHA, GL_ONE);
+00857 }
+00858 }
+00859
+00860 }
+00861 <font class="comment">// ***************************************************************************</font>
+<a name="l00862"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z407_3">00862</a> <font class="keywordtype">void</font> CDriverGL::endLightMapMultiPass()
+00863 {
+00864 <font class="comment">// Cache it. reseted in setupGLArrays(), and setupMaterial()</font>
+00865 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a>= <font class="keyword">true</font>;
+00866
+00867 <font class="comment">// If multi-pass, then must reset the fog color</font>
+00868 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z407_7">_NLightMapPass</a>&gt;=2 &amp;&amp; <a class="code" href="classNL3D_1_1CDriverGL.html#o16">_FogEnabled</a>)
+00869 {
+00870 glFogfv(GL_FOG_COLOR, <a class="code" href="classNL3D_1_1CDriverGL.html#o17">_CurrentFogColor</a>);
+00871 }
+00872
+00873 <font class="comment">// nothing to do with blending/lighting, since always setuped in activeMaterial().</font>
+00874 <font class="comment">// If material is the same, then it is still a lightmap material (if changed =&gt; touched =&gt; different!)</font>
+00875 <font class="comment">// So no need to reset lighting/blending here.</font>
+00876 }
+00877
+00878
+00879 <font class="comment">// ***************************************************************************</font>
+<a name="l00880"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z407_4">00880</a> <font class="keywordtype">void</font> CDriverGL::resetLightMapVertexSetup()
+00881 {
+00882 <font class="comment">// special for all stage, std UV behavior.</font>
+00883 <font class="keywordflow">for</font>(sint i=0; i&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
+00884 {
+00885 <font class="comment">// normal behavior: each texture has its own UV.</font>
+00886 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(i, <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>, i);
+00887 <font class="comment">// reset cache</font>
+00888 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_11">_LightMapUVMap</a>[i]= -1;
+00889 }
+00890
+00891 <font class="comment">// pop VertexColor array if necessary.</font>
+00892 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.VertexFormat &amp; CVertexBuffer::PrimaryColorFlag)
+00893 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">true</font>);
+00894
+00895 <font class="comment">// flag</font>
+00896 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a>= <font class="keyword">false</font>;
+00897 }
+00898
+00899
+00900 <font class="comment">// ***************************************************************************</font>
+<a name="l00901"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z408_0">00901</a> sint CDriverGL::beginSpecularMultiPass()
+00902 {
+00903 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+00904
+00905 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+00906 glMatrixMode(GL_TEXTURE);
+00907 glLoadMatrixf( <a class="code" href="classNL3D_1_1CDriverGL.html#o13">_TexMtx</a>.get() );
+00908 glMatrixMode(GL_MODELVIEW);
+00909
+00910 <font class="comment">// Manage the rare case when the SpecularMap is not provided (fault of graphist).</font>
+00911 <font class="keywordflow">if</font>(mat.getTexture(1)==NULL)
+00912 <font class="keywordflow">return</font> 1;
+00913
+00914 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ARBTextureCubeMap)
+00915 <font class="keywordflow">return</font> 1;
+00916
+00917 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4 || <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ATIXTextureEnvCombine3) <font class="comment">// NVidia or ATI optimization</font>
+00918 <font class="keywordflow">return</font> 1;
+00919 <font class="keywordflow">else</font>
+00920 <font class="keywordflow">return</font> 2;
+00921
+00922 }
+00923 <font class="comment">// ***************************************************************************</font>
+<a name="l00924"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z408_1">00924</a> <font class="keywordtype">void</font> CDriverGL::setupSpecularPass(uint pass)
+00925 {
+00926 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+00927
+00928 <font class="comment">// Manage the rare case when the SpecularMap is not provided (error of a graphist).</font>
+00929 <font class="keywordflow">if</font>(mat.getTexture(1)==NULL)
+00930 {
+00931 <font class="comment">// Just display the texture forcing no blend (as in std case).</font>
+00932 <font class="comment">// NB: setupMaterial() code has correclty setuped textures.</font>
+00933 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">false</font>);
+00934 <font class="keywordflow">return</font>;
+00935 }
+00936
+00938 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4 )
+00939 { <font class="comment">// Ok we can do it in a single pass</font>
+00940 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">false</font>);
+00941
+00942 <font class="comment">// Stage 0</font>
+00943 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u2">TexEnvSpecialSpecularStage0</a>)
+00944 {
+00945 <font class="comment">// TexEnv is special.</font>
+00946 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u2">TexEnvSpecialSpecularStage0</a>;
+00947
+00948 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+00949 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+00950 <font class="comment">// Operator.</font>
+00951 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD );
+00952 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD );
+00953 <font class="comment">// Arg0.</font>
+00954 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00955 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+00956 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE );
+00957 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
+00958 <font class="comment">// Arg1.</font>
+00959 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
+00960 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+00961 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO );
+00962 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA );
+00963 <font class="comment">// Arg2.</font>
+00964 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
+00965 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR );
+00966 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO );
+00967 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA );
+00968 <font class="comment">// Arg3.</font>
+00969 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO );
+00970 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR);
+00971 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO );
+00972 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_ALPHA );
+00973 <font class="comment">// Result RGB : Texture*Diffuse, Alpha : Texture</font>
+00974 }
+00975
+00976 <font class="comment">// Set Stage 1</font>
+00977 <font class="comment">// Special: not the same sepcial env if there is or not texture in stage 0.</font>
+00978 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0">CTexEnvSpecial</a> newEnvStage1;
+00979 <font class="keywordflow">if</font>( mat.getTexture(0) == NULL )
+00980 newEnvStage1= <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u4">TexEnvSpecialSpecularStage1NoText</a>;
+00981 <font class="keywordflow">else</font>
+00982 newEnvStage1= <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u3">TexEnvSpecialSpecularStage1</a>;
+00983 <font class="comment">// Test if same env as prec.</font>
+00984 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[1] != newEnvStage1)
+00985 {
+00986 <font class="comment">// TexEnv is special.</font>
+00987 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[1] = newEnvStage1;
+00988
+00989 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+00990 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+00991 <font class="comment">// Operator Add (Arg0*Arg1+Arg2*Arg3)</font>
+00992 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD );
+00993 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD );
+00994 <font class="comment">// Arg0.</font>
+00995 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00996 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+00997 <font class="comment">// Arg1.</font>
+00998 <font class="keywordflow">if</font>( newEnvStage1 == <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u4">TexEnvSpecialSpecularStage1NoText</a> )
+00999 {
+01000 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
+01001 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
+01002 }
+01003 <font class="keywordflow">else</font>
+01004 {
+01005 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
+01006 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_ALPHA );
+01007 }
+01008 <font class="comment">// Arg2.</font>
+01009 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+01010 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR );
+01011 <font class="comment">// Arg3.</font>
+01012 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO );
+01013 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01014 <font class="comment">// Result : Texture*Previous.Alpha+Previous</font>
+01015 }
+01016
+01017 <font class="comment">// Setup TexCoord gen for stage1.</font>
+01018 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01019 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureCubeMap);
+01020 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
+01021 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (1, <font class="keyword">true</font>);
+01022 }
+01023 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ATIXTextureEnvCombine3)
+01024 {
+01025 <font class="comment">// Ok we can do it in a single pass</font>
+01026 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">false</font>);
+01027
+01028 <font class="comment">// Stage 0</font>
+01029 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u2">TexEnvSpecialSpecularStage0</a>)
+01030 {
+01031 <font class="comment">// TexEnv is special.</font>
+01032 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u2">TexEnvSpecialSpecularStage0</a>;
+01033
+01034 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+01035 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01036 <font class="comment">// Operator Mad (Arg0 * Arg2 + Arg1) </font>
+01037 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE );
+01038 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE );
+01039 <font class="comment">// Arg0.</font>
+01040 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+01041 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+01042 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE );
+01043 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
+01044 <font class="comment">// Arg1.</font>
+01045 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
+01046 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01047 <font class="comment">// Result RGB : Texture*Diffuse, Alpha : Texture</font>
+01048 }
+01049
+01050 <font class="comment">// Set Stage 1</font>
+01051 <font class="comment">// Special: not the same sepcial env if there is or not texture in stage 0.</font>
+01052 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0">CTexEnvSpecial</a> newEnvStage1;
+01053 <font class="keywordflow">if</font>( mat.getTexture(0) == NULL )
+01054 newEnvStage1= <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u4">TexEnvSpecialSpecularStage1NoText</a>;
+01055 <font class="keywordflow">else</font>
+01056 newEnvStage1= <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u3">TexEnvSpecialSpecularStage1</a>;
+01057 <font class="comment">// Test if same env as prec.</font>
+01058 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[1] != newEnvStage1)
+01059 {
+01060 <font class="comment">// TexEnv is special.</font>
+01061 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[1] = newEnvStage1;
+01062
+01063 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01064 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01065 <font class="comment">// Operator Add (Arg0*Arg1+Arg2*Arg3)</font>
+01066 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a> );
+01067 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a> );
+01068 <font class="comment">// Arg0.</font>
+01069 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+01070 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+01071 <font class="comment">// Arg2.</font>
+01072 <font class="keywordflow">if</font>( newEnvStage1 == <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u4">TexEnvSpecialSpecularStage1NoText</a> )
+01073 {
+01074 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
+01075 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
+01076 }
+01077 <font class="keywordflow">else</font>
+01078 {
+01079 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+01080 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA );
+01081 }
+01082 <font class="comment">// Arg1.</font>
+01083 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
+01084 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR );
+01085 <font class="comment">// Result : Texture*Previous.Alpha+Previous</font>
+01086 }
+01087
+01088 <font class="comment">// Setup TexCoord gen for stage1.</font>
+01089 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01090 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureCubeMap);
+01091 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
+01092 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (1, <font class="keyword">true</font>);
+01093 }
+01094 <font class="keywordflow">else</font>
+01095 { <font class="comment">// We have to do it in 2 passes</font>
+01096
+01097 <font class="keywordflow">if</font>( pass == 0 )
+01098 { <font class="comment">// Just display the texture</font>
+01099 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">false</font>);
+01100 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01101 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureDisabled);
+01102 }
+01103 <font class="keywordflow">else</font>
+01104 { <font class="comment">// Multiply texture1 by alpha_texture0 and display with add</font>
+01105 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableBlend(<font class="keyword">true</font>);
+01106 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.blendFunc(GL_ONE, GL_ONE);
+01107
+01108 <font class="comment">// Set stage 0</font>
+01109 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+01110 CMaterial::CTexEnv env;
+01111
+01112 env.Env.OpRGB = CMaterial::Replace;
+01113 env.Env.SrcArg0RGB = CMaterial::Texture;
+01114 env.Env.OpArg0RGB = CMaterial::SrcAlpha;
+01115
+01116 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(0, env);
+01117
+01118
+01119 <font class="comment">// Set stage 1</font>
+01120 <font class="keywordflow">if</font>( mat.getTexture(0) == NULL )
+01121 {
+01122 env.Env.OpRGB = CMaterial::Replace;
+01123 env.Env.SrcArg0RGB = CMaterial::Texture;
+01124 env.Env.OpArg0RGB = CMaterial::SrcColor;
+01125 }
+01126 <font class="keywordflow">else</font>
+01127 {
+01128 env.Env.OpRGB = CMaterial::Modulate;
+01129 env.Env.SrcArg0RGB = CMaterial::Texture;
+01130 env.Env.OpArg0RGB = CMaterial::SrcColor;
+01131
+01132 env.Env.SrcArg1RGB = CMaterial::Previous;
+01133 env.Env.OpArg1RGB = CMaterial::SrcColor;
+01134 }
+01135
+01136 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(1, env);
+01137
+01138 <font class="comment">// Set Stage 1</font>
+01139 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01140 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureCubeMap);
+01141 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
+01142 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (1, <font class="keyword">true</font>);
+01143 }
+01144 }
+01145 }
+01146 <font class="comment">// ***************************************************************************</font>
+<a name="l01147"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z408_2">01147</a> <font class="keywordtype">void</font> CDriverGL::endSpecularMultiPass()
+01148 {
+01149 <font class="comment">// Disable Texture coord generation.</font>
+01150 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01151 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexGen (1, <font class="keyword">false</font>);
+01152 <font class="comment">//_DriverGLStates.setTextureMode(1, CDriverGLStates::TextureDisabled);</font>
+01153
+01154 <font class="comment">// Happiness !!! we have already enabled the stage 1</font>
+01155 glMatrixMode(GL_TEXTURE);
+01156 glLoadIdentity();
+01157 glMatrixMode(GL_MODELVIEW);
+01158 }
+01159
+01160
+01161 <font class="comment">// a functor that can is used to generate a cube map used for specular / diffuse lighting</font>
+<a name="l01162"></a><a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html">01162</a> <font class="keyword">struct </font>CSpecCubeMapFunctor : ICubeMapFunctor
+01163 {
+<a name="l01164"></a><a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#a0">01164</a> <a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#a0">CSpecCubeMapFunctor</a>(<font class="keywordtype">float</font> exp) : <a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#m0">Exp</a>(exp) {}
+<a name="l01165"></a><a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#a1">01165</a> <font class="keyword">virtual</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> <a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#a1">operator()</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
+01166 {
+01167
+01168 uint8 intensity = (uint8) (255.f * ::powf(std::max(v.<a class="code" href="classNLMISC_1_1CVector.html#z331_5">normed</a>().z, 0.f), <a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#m0">Exp</a>));
+01169 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>(intensity, intensity, intensity, intensity);
+01170 <font class="comment">//return Exp == 1.f ? CRGBA((uint8)(v.x*127+127), (uint8)(v.y*127+127), (uint8)(v.z*127+127), 0): CRGBA::Black;</font>
+01171 }
+<a name="l01172"></a><a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#m0">01172</a> <font class="keywordtype">float</font> <a class="code" href="structNL3D_1_1CSpecCubeMapFunctor.html#m0">Exp</a>;
+01173 };
+01174
+01175
+01176 <font class="comment">/* </font>
+01177 <font class="comment">const uint MaxSpecularExp = 64;</font>
+01178 <font class="comment">const uint SpecularExpStep = 8;</font>
+01179 <font class="comment">const uint SpecularMapSize = 32; */</font>
+01180
+01181
+01182 <font class="comment">// ***************************************************************************</font>
+<a name="l01183"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_8">01183</a> CTextureCube *CDriverGL::getSpecularCubeMap(uint exp)
+01184 {
+01185 <font class="keyword">const</font> uint SpecularMapSize = 32;
+01186 <font class="keyword">const</font> uint SpecularMapSizeHighExponent = 64;
+01187 <font class="keyword">const</font> <font class="keywordtype">float</font> HighExponent = 128.f;
+01188 <font class="keyword">const</font> uint MaxExponent = 512;
+01189 <font class="comment">// this gives the cube map to use given an exponent (from 0 to 128)</font>
+01190 <font class="keyword">static</font> uint16 expToCubeMap[MaxExponent];
+01191 <font class="comment">// this gives the exponent used by a given cube map (not necessarily ordered)</font>
+01192 <font class="keyword">static</font> <font class="keywordtype">float</font> cubeMapExp[] =
+01193 {
+01194 1.f, 4.f, 8.f, 24.f, 48.f, 128.f, 256.f, 511.f
+01195 };
+01196 <font class="keyword">const</font> uint numCubeMap = <font class="keyword">sizeof</font>(expToCubeMap) / <font class="keyword">sizeof</font>(float);
+01197 <font class="keyword">static</font> <font class="keywordtype">bool</font> tableBuilt = <font class="keyword">false</font>;
+01198
+01199 <font class="keywordflow">if</font> (!tableBuilt)
+01200 {
+01201 <font class="keywordflow">for</font> (uint k = 0; k &lt; MaxExponent; ++k)
+01202 {
+01203 uint nearest = 0;
+01204 <font class="keywordtype">float</font> diff = (float) MaxExponent;
+01205 <font class="comment">// look for the nearest exponent</font>
+01206 <font class="keywordflow">for</font> (uint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> &lt; numCubeMap; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
+01207 {
+01208 <font class="keywordtype">float</font> newDiff = ::fabsf(k - cubeMapExp[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>]);
+01209 <font class="keywordflow">if</font> (newDiff &lt; diff)
+01210 {
+01211 diff = newDiff;
+01212 nearest = <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
+01213 }
+01214 }
+01215 expToCubeMap[k] = nearest;
+01216 }
+01217 tableBuilt = <font class="keyword">true</font>;
+01218 }
+01219
+01220 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z409_10">_SpecularTextureCubes</a>.empty())
+01221 {
+01222 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_10">_SpecularTextureCubes</a>.resize(MaxExponent);
+01223 }
+01224
+01225
+01226 <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(exp, 1u, (MaxExponent - 1));
+01227
+01228
+01229 uint cubeMapIndex = expToCubeMap[(uint) exp];
+01230 <a class="code" href="debug_8h.html#a6">nlassert</a>(cubeMapIndex &lt; numCubeMap);
+01231
+01232
+01233 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z409_10">_SpecularTextureCubes</a>[cubeMapIndex] != NULL) <font class="comment">// has the cube map already been cted ?</font>
+01234 {
+01235 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z409_10">_SpecularTextureCubes</a>[cubeMapIndex];
+01236 }
+01237 <font class="keywordflow">else</font> <font class="comment">// build the cube map</font>
+01238 {
+01239 <font class="keywordtype">float</font> exponent = cubeMapExp[cubeMapIndex];
+01240 CSpecCubeMapFunctor scmf(exponent);
+01241 <font class="keyword">const</font> uint bufSize = 128;
+01242 <font class="keywordtype">char</font> name[bufSize];
+01243 <a class="code" href="namespaceNLMISC.html#a211">NLMISC::smprintf</a>(name, bufSize, <font class="stringliteral">"#SM%d"</font>, cubeMapIndex);
+01244 CTextureCube *tc = <a class="code" href="namespaceNL3D.html#a321">BuildCubeMap</a>(exponent &gt;= HighExponent ? SpecularMapSizeHighExponent
+01245 : SpecularMapSize,
+01246 scmf,
+01247 <font class="keyword">false</font>,
+01248 name);
+01249
+01250 <font class="keyword">static</font> <font class="keyword">const</font> CTextureCube::TFace numToFace[] =
+01251 { CTextureCube::positive_x,
+01252 CTextureCube::negative_x,
+01253 CTextureCube::positive_y,
+01254 CTextureCube::negative_y,
+01255 CTextureCube::positive_z,
+01256 CTextureCube::negative_z
+01257 };
+01258
+01259 <font class="keywordflow">if</font> (exponent != 1.f)
+01260 {
+01261 <font class="comment">// force 16 bit for specular part, 32 bit if exponent is 1 (diffuse part)</font>
+01262 <font class="keywordflow">for</font> (uint k = 0; k &lt; 6; ++k)
+01263 {
+01264 <a class="code" href="debug_8h.html#a6">nlassert</a>(tc-&gt;getTexture(numToFace[k]));
+01265 tc-&gt;getTexture(numToFace[k])-&gt;setUploadFormat(ITexture::RGB565);
+01266 }
+01267 }
+01268
+01269 <a class="code" href="classNL3D_1_1CDriverGL.html#z409_10">_SpecularTextureCubes</a>[cubeMapIndex] = tc;
+01270 <font class="keywordflow">return</font> tc;
+01271 }
+01272 }
+01273
+01274 <font class="comment">// ***************************************************************************</font>
+<a name="l01275"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_2">01275</a> sint CDriverGL::beginPPLMultiPass()
+01276 {
+01277 <font class="preprocessor"> #ifdef NL_DEBUG</font>
+01278 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#a86">supportPerPixelLighting</a>(<font class="keyword">true</font>)); <font class="comment">// make sure the hardware can do that</font>
+01279 <font class="preprocessor"> #endif</font>
+01280 <font class="preprocessor"></font> <font class="keywordflow">return</font> 1;
+01281 }
+01282
+01283 <font class="comment">// ***************************************************************************</font>
+<a name="l01284"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_3">01284</a> <font class="keywordtype">void</font> CDriverGL::setupPPLPass(uint pass)
+01285 {
+01286 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+01287
+01288 <a class="code" href="debug_8h.html#a6">nlassert</a>(pass == 0);
+01289
+01290 <font class="comment">/* ITexture *tex0 = getSpecularCubeMap(1);</font>
+01291 <font class="comment"> if (tex0) setupTexture(*tex0);</font>
+01292 <font class="comment"> activateTexture(0, tex0);</font>
+01293 <font class="comment"> </font>
+01294 <font class="comment"></font>
+01295 <font class="comment"> static CMaterial::CTexEnv env;</font>
+01296 <font class="comment"> env.Env.SrcArg0Alpha = CMaterial::Diffuse; </font>
+01297 <font class="comment"> env.Env.SrcArg1Alpha = CMaterial::Constant; </font>
+01298 <font class="comment"> env.Env.SrcArg0RGB = CMaterial::Diffuse; </font>
+01299 <font class="comment"> env.Env.SrcArg1RGB = CMaterial::Constant;</font>
+01300 <font class="comment"> env.Env.OpRGB = CMaterial::Replace;</font>
+01301 <font class="comment"> env.Env.OpAlpha = CMaterial::Replace;</font>
+01302 <font class="comment"> activateTexEnvMode(0, env);</font>
+01303 <font class="comment"></font>
+01304 <font class="comment"> return;*/</font>
+01305
+01306 ITexture *tex0 = <a class="code" href="classNL3D_1_1CDriverGL.html#z409_8">getSpecularCubeMap</a>(1);
+01307 <font class="keywordflow">if</font> (tex0) <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*tex0);
+01308 ITexture *tex2 = <a class="code" href="classNL3D_1_1CDriverGL.html#z409_8">getSpecularCubeMap</a>((uint) mat.getShininess());
+01309 <font class="keywordflow">if</font> (tex2) <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*tex2);
+01310 <font class="keywordflow">if</font> (mat.getTexture(0)) <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*mat.getTexture(0));
+01311
+01312 <font class="comment">// tex coord 0 = texture coordinates</font>
+01313 <font class="comment">// tex coord 1 = normal in tangent space</font>
+01314 <font class="comment">// tex coord 2 = half angle vector in tangent space</font>
+01315
+01316 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(0, tex0);
+01317 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(1, mat.getTexture(0));
+01318 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(2, tex2);
+01319
+01320 <font class="keywordflow">for</font> (uint k = 3; k &lt; (uint) <a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); ++k)
+01321 {
+01322 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(k, NULL);
+01323 }
+01324
+01325 <font class="comment">// setup the tex envs</font>
+01326
+01327
+01328 <font class="comment">// Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1 (TODO : EnvCombine3)</font>
+01329 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u5">TexEnvSpecialPPLStage0</a>)
+01330 {
+01331 <font class="comment">// TexEnv is special.</font>
+01332 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u5">TexEnvSpecialPPLStage0</a>;
+01333 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+01334
+01335 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4)
+01336 {
+01337 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01338
+01339 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01340 <font class="comment">// Arg0 = Diffuse read in cube map</font>
+01341 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01342 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01343 <font class="comment">// Arg1 = Light color</font>
+01344 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01345 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01346 <font class="comment">// Arg2 = Primary color (other light diffuse and </font>
+01347 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01348 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01349 <font class="comment">// Arg3 = White (= ~ Black)</font>
+01350 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01351 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01352 }
+01353 <font class="keywordflow">else</font> <font class="comment">// use ATI extension</font>
+01354 {
+01355 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01356
+01357 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+01358 <font class="comment">// Arg0 = Diffuse read in cube map</font>
+01359 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01360 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01361 <font class="comment">// Arg1 = Light color</font>
+01362 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01363 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01364 <font class="comment">// Arg2 = Primary color (other light diffuse and </font>
+01365 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01366 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01367 }
+01368 }
+01369 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a>(0, <a class="code" href="classNL3D_1_1CDriverGL.html#z404_4">_PPLightDiffuseColor</a>);
+01370
+01371 <font class="comment">// Stage 1 </font>
+01372 <font class="keyword">static</font> CMaterial::CTexEnv env;
+01373 env.Env.SrcArg1Alpha = CMaterial::Diffuse;
+01374 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(1, env);
+01375
+01376
+01377
+01378 <font class="comment">// Stage 2 is rgb = SpecularCubeMap * SpecularLightColor + Prec * 1</font>
+01379 <font class="comment">// alpha = prec alpha</font>
+01380
+01381 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[2] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u6">TexEnvSpecialPPLStage2</a>)
+01382 {
+01383 <font class="comment">// TexEnv is special.</font>
+01384 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[2] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u6">TexEnvSpecialPPLStage2</a>;
+01385 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(2);
+01386
+01387 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4)
+01388 {
+01389 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01390 <font class="comment">//== colors ==</font>
+01391 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01392 <font class="comment">// Arg0 = Specular read in cube map</font>
+01393 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01394 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01395 <font class="comment">// Arg1 = Light color</font>
+01396 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01397 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01398 <font class="comment">// Arg2 = Primary color ( + other light diffuse )</font>
+01399 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);
+01400 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01401 <font class="comment">// Arg3 = White (= ~ Black)</font>
+01402 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01403 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01404
+01405 <font class="comment">//== alpha ==</font>
+01406 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);
+01407 <font class="comment">// Arg0 = PREVIOUS ALPHA</font>
+01408 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01409 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);
+01410 <font class="comment">// Arg1 = 1</font>
+01411 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO);
+01412 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_ONE_MINUS_SRC_COLOR);
+01413 <font class="comment">// Arg2 = 0</font>
+01414 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01415 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_COLOR);
+01416 <font class="comment">// Arg3 = 0</font>
+01417 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO);
+01418 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_COLOR);
+01419 }
+01420 <font class="keywordflow">else</font> <font class="comment">// ATI EnvCombine3</font>
+01421 {
+01422 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01423 <font class="comment">//== colors ==</font>
+01424 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+01425 <font class="comment">// Arg0 = Specular read in cube map</font>
+01426 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01427 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01428 <font class="comment">// Arg2 = Light color</font>
+01429 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01430 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01431 <font class="comment">// Arg1 = Primary color ( + other light diffuse)</font>
+01432 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);
+01433 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01434
+01435 <font class="comment">//== alpha ==</font>
+01436 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+01437 <font class="comment">// Arg0 = PREVIOUS ALPHA</font>
+01438 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01439 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);
+01440 <font class="comment">// Arg2 = 1</font>
+01441 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01442 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_ONE_MINUS_SRC_COLOR);
+01443 <font class="comment">// Arg1 = 0</font>
+01444 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO);
+01445 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_COLOR);
+01446 }
+01447 }
+01448 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a>(2, <a class="code" href="classNL3D_1_1CDriverGL.html#z404_5">_PPLightSpecularColor</a>);
+01449
+01450 }
+01451
+01452 <font class="comment">// ***************************************************************************</font>
+<a name="l01453"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_4">01453</a> <font class="keywordtype">void</font> CDriverGL::endPPLMultiPass()
+01454 {
+01455 <font class="comment">// nothing to do there ...</font>
+01456 }
+01457
+01458
+01459 <font class="comment">// ******PER PIXEL LIGHTING, NO SPECULAR**************************************</font>
+<a name="l01460"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_5">01460</a> sint CDriverGL::beginPPLNoSpecMultiPass()
+01461 {
+01462 <font class="preprocessor"> #ifdef NL_DEBUG</font>
+01463 <font class="preprocessor"></font> <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#a86">supportPerPixelLighting</a>(<font class="keyword">false</font>)); <font class="comment">// make sure the hardware can do that</font>
+01464 <font class="preprocessor"> #endif</font>
+01465 <font class="preprocessor"></font> <font class="keywordflow">return</font> 1;
+01466 }
+01467
+01468 <font class="comment">// ******PER PIXEL LIGHTING, NO SPECULAR**************************************</font>
+<a name="l01469"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_6">01469</a> <font class="keywordtype">void</font> CDriverGL::setupPPLNoSpecPass(uint pass)
+01470 {
+01471 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+01472
+01473 <a class="code" href="debug_8h.html#a6">nlassert</a>(pass == 0);
+01474
+01475 ITexture *tex0 = <a class="code" href="classNL3D_1_1CDriverGL.html#z409_8">getSpecularCubeMap</a>(1);
+01476 <font class="keywordflow">if</font> (tex0) <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*tex0);
+01477
+01478 <font class="keywordflow">if</font> (mat.getTexture(0)) <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(*mat.getTexture(0));
+01479
+01480 <font class="comment">// tex coord 0 = texture coordinates</font>
+01481 <font class="comment">// tex coord 1 = normal in tangent space </font>
+01482
+01483 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(0, tex0);
+01484 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(1, mat.getTexture(0));
+01485
+01486
+01487 <font class="keywordflow">for</font> (uint k = 2; k &lt; (uint) <a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); ++k)
+01488 {
+01489 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(k, NULL);
+01490 }
+01491
+01492 <font class="comment">// setup the tex envs</font>
+01493
+01494
+01495 <font class="comment">// Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1 (TODO : EnvCombine3)</font>
+01496 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u5">TexEnvSpecialPPLStage0</a>)
+01497 {
+01498 <font class="comment">// TexEnv is special.</font>
+01499 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u5">TexEnvSpecialPPLStage0</a>;
+01500 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+01501
+01502 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4)
+01503 {
+01504 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01505
+01506 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01507 <font class="comment">// Arg0 = Diffuse read in cube map alpha</font>
+01508 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01509 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01510 <font class="comment">// Arg1 = Light color</font>
+01511 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01512 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01513 <font class="comment">// Arg2 = Primary color (other light diffuse and </font>
+01514 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01515 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01516 <font class="comment">// Arg3 = White (= ~ Black)</font>
+01517 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01518 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01519 }
+01520 <font class="keywordflow">else</font>
+01521 {
+01522 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01523
+01524 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a342">GL_MODULATE_ADD_ATIX</a>);
+01525 <font class="comment">// Arg0 = Diffuse read in cube map alpha</font>
+01526 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01527 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01528 <font class="comment">// Arg2 = Light color</font>
+01529 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01530 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01531 <font class="comment">// Arg1 = Primary color (other light diffuse and </font>
+01532 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01533 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01534 }
+01535 }
+01536 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a>(0, <a class="code" href="classNL3D_1_1CDriverGL.html#z404_4">_PPLightDiffuseColor</a>);
+01537
+01538 <font class="comment">// Stage 1 </font>
+01539 <font class="keyword">static</font> CMaterial::CTexEnv env;
+01540 env.Env.SrcArg1Alpha = CMaterial::Diffuse;
+01541 <a class="code" href="classNL3D_1_1CDriverGL.html#c3">activateTexEnvMode</a>(1, env);
+01542
+01543 }
+01544
+01545 <font class="comment">// ******PER PIXEL LIGHTING, NO SPECULAR**************************************</font>
+<a name="l01546"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z409_7">01546</a> <font class="keywordtype">void</font> CDriverGL::endPPLNoSpecMultiPass()
+01547 {
+01548 <font class="comment">// nothing to do there ...</font>
+01549 }
+01550
+01551 <font class="comment">// ***************************************************************************</font>
+01552 <font class="comment">/* sint CDriverGL::beginCausticsMultiPass(const CMaterial &amp;mat)</font>
+01553 <font class="comment">{</font>
+01554 <font class="comment"> nlassert(mat.getShader() == CMaterial::Caustics);</font>
+01555 <font class="comment"> if (!_Extensions.ARBTextureCubeMap) return 1;</font>
+01556 <font class="comment"> switch (inlGetNumTextStages())</font>
+01557 <font class="comment"> {</font>
+01558 <font class="comment"> case 1: return 3;</font>
+01559 <font class="comment"> case 2: return 2;</font>
+01560 <font class="comment"> default:</font>
+01561 <font class="comment"> return 1;</font>
+01562 <font class="comment"> }</font>
+01563 <font class="comment">}*/</font>
+01564
+01565
+01566 <font class="comment">// ***************************************************************************</font>
+01567 <font class="comment">/*inline void CDriverGL::setupCausticsFirstTex(const CMaterial &amp;mat)</font>
+01568 <font class="comment">{</font>
+01570 <font class="comment"> activateTexture(0, mat.getTexture(0));</font>
+01571 <font class="comment"></font>
+01573 <font class="comment"> setTextureEnvFunction(0, mat);</font>
+01574 <font class="comment"></font>
+01576 <font class="comment"> setupUserTextureMatrix(0, mat);</font>
+01577 <font class="comment">}</font>
+01578 <font class="comment"></font>
+01579 <font class="comment">// ***************************************************************************</font>
+01580 <font class="comment">inline void CDriverGL::setupCausticsSecondTex(uint stage)</font>
+01581 <font class="comment">{</font>
+01582 <font class="comment"> activateTexture(stage, mat.getTexture(0));</font>
+01583 <font class="comment"> _CausticCubeMap</font>
+01584 <font class="comment">}</font>
+01585 <font class="comment"></font>
+01586 <font class="comment">// ***************************************************************************</font>
+01587 <font class="comment">void CDriverGL::setupCausticsPass(const CMaterial &amp;mat, uint pass)</font>
+01588 <font class="comment">{</font>
+01589 <font class="comment"> </font>
+01590 <font class="comment"> nlassert(mat.getShader() == CMaterial::Caustics);</font>
+01591 <font class="comment"></font>
+01592 <font class="comment"> if (inlGetNumTextStages() == 1 || !_Extensions.ARBTextureCubeMap)</font>
+01593 <font class="comment"> {</font>
+01594 <font class="comment"> setupCausticsFirstTex(mat);</font>
+01595 <font class="comment"> }</font>
+01596 <font class="comment"> else</font>
+01597 <font class="comment"> if (inlGetNumTextStages() &gt;= 3) </font>
+01598 <font class="comment"> {</font>
+01599 <font class="comment"> nlassert(pass == 0); </font>
+01600 <font class="comment"></font>
+01601 <font class="comment"> setupCausticsFirstTex(mat);</font>
+01602 <font class="comment"> </font>
+01603 <font class="comment"></font>
+01604 <font class="comment"> }</font>
+01605 <font class="comment"> else if (inlGetNumTextStages() == 2) </font>
+01606 <font class="comment"> {</font>
+01607 <font class="comment"> nlassert(pass &lt; 2);</font>
+01608 <font class="comment"> if (pass == 0) </font>
+01609 <font class="comment"> {</font>
+01610 <font class="comment"> setupCausticsFirstTex(mat); </font>
+01611 <font class="comment"> }</font>
+01612 <font class="comment"> else </font>
+01613 <font class="comment"> {</font>
+01615 <font class="comment"> _DriverGLStates.enableBlend(); </font>
+01616 <font class="comment"> _DriverGLStates.blendFunc(pShader-&gt;SrcBlend, pShader-&gt;DstBlend);</font>
+01617 <font class="comment"></font>
+01618 <font class="comment"></font>
+01619 <font class="comment"> }</font>
+01620 <font class="comment"> }</font>
+01621 <font class="comment">}</font>
+01622 <font class="comment"></font>
+01623 <font class="comment">// ***************************************************************************</font>
+01624 <font class="comment">void CDriverGL::endCausticsMultiPass(const CMaterial &amp;mat)</font>
+01625 <font class="comment">{</font>
+01626 <font class="comment"> nlassert(mat.getShader() == CMaterial::Caustics); </font>
+01627 <font class="comment"></font>
+01628 <font class="comment">}</font>
+01629 <font class="comment">*/</font>
+01630
+01632
+01633 <font class="comment">// ***************************************************************************</font>
+<a name="l01634"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c15">01634</a> sint CDriverGL::beginCloudMultiPass ()
+01635 {
+01636 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>-&gt;getShader() == CMaterial::Cloud);
+01637 <font class="keywordflow">return</font> 1;
+01638 }
+01639
+01640 <font class="comment">// ***************************************************************************</font>
+<a name="l01641"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c16">01641</a> <font class="keywordtype">void</font> CDriverGL::setupCloudPass (uint pass)
+01642 {
+01643 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>-&gt;getShader() == CMaterial::Cloud);
+01644
+01645 <font class="keyword">const</font> CMaterial &amp;mat= *<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>;
+01646
+01647 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(0, mat.getTexture(0));
+01648 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(1, mat.getTexture(0));
+01649
+01650 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u7">TexEnvSpecialCloudStage0</a>)
+01651 {
+01652 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[0] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u7">TexEnvSpecialCloudStage0</a>;
+01653 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[1] = <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u8">TexEnvSpecialCloudStage1</a>;
+01654
+01655 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureEnvCombine4)
+01656 {
+01657 <font class="comment">// Setup 1st Stage</font>
+01658 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
+01659 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01660 <font class="comment">//== colors ==</font>
+01661 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01662 <font class="comment">// Arg0 = 0</font>
+01663 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO);
+01664 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01665 <font class="comment">// Arg1 = 0</font>
+01666 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO);
+01667 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01668 <font class="comment">// Arg2 = 0</font>
+01669 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO);
+01670 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01671 <font class="comment">// Arg3 = 0</font>
+01672 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01673 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR);
+01674
+01675 <font class="comment">//== alpha ==</font>
+01676 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);
+01677 <font class="comment">// Arg0 = AT0</font>
+01678 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE0_ARB);
+01679 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01680 <font class="comment">// Arg1 = AWPOS</font>
+01681 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT);
+01682 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01683 <font class="comment">// Arg2 = AT1</font>
+01684 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE1_ARB);
+01685 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01686 <font class="comment">// Arg3 = 1-AWPOS</font>
+01687 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_PRIMARY_COLOR_EXT);
+01688 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_ONE_MINUS_SRC_ALPHA);
+01689
+01690 <font class="comment">// Setup 2nd Stage</font>
+01691 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(1);
+01692 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01693 <font class="comment">//== colors ==</font>
+01694 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01695 <font class="comment">// Arg0 = 0</font>
+01696 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO);
+01697 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01698 <font class="comment">// Arg1 = 0</font>
+01699 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO);
+01700 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01701 <font class="comment">// Arg2 = 0</font>
+01702 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO);
+01703 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01704 <font class="comment">// Arg3 = 0</font>
+01705 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01706 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR);
+01707
+01708 <font class="comment">//== alpha ==</font>
+01709 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);
+01710 <font class="comment">// Arg0 = AT0*AWPOS+AT1*(1-AWPOS)</font>
+01711 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01712 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01713 <font class="comment">// Arg1 = AINT</font>
+01714 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_CONSTANT_EXT);
+01715 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01716 <font class="comment">// Arg2 = 0</font>
+01717 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01718 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01719 <font class="comment">// Arg3 = 0</font>
+01720 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO);
+01721 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_ALPHA);
+01722
+01723 }
+01724 <font class="keywordflow">else</font> <font class="comment">// ATI EnvCombine3</font>
+01725 {
+01726 <font class="comment">/*glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); </font>
+01727 <font class="comment"> //== colors ==</font>
+01728 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX); </font>
+01729 <font class="comment"> // Arg0 = Specular read in cube map</font>
+01730 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);</font>
+01731 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);</font>
+01732 <font class="comment"> // Arg2 = Light color</font>
+01733 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);</font>
+01734 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);</font>
+01735 <font class="comment"> // Arg1 = Primary color ( + other light diffuse)</font>
+01736 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);</font>
+01737 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR); </font>
+01738 <font class="comment"></font>
+01739 <font class="comment"> //== alpha ==</font>
+01740 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATIX); </font>
+01741 <font class="comment"> // Arg0 = PREVIOUS ALPHA</font>
+01742 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);</font>
+01743 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);</font>
+01744 <font class="comment"> // Arg2 = 1</font>
+01745 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);</font>
+01746 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_ONE_MINUS_SRC_COLOR);</font>
+01747 <font class="comment"> // Arg1 = 0</font>
+01748 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO);</font>
+01749 <font class="comment"> glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_COLOR);*/</font>
+01750 }
+01751 }
+01752 <a class="code" href="classNL3D_1_1CDriverGL.html#c4">activateTexEnvColor</a> (1, mat.getColor());
+01753 }
+01754
+01755 <font class="comment">// ***************************************************************************</font>
+<a name="l01756"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c17">01756</a> <font class="keywordtype">void</font> CDriverGL::endCloudMultiPass()
+01757 {
+01758 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_2">_CurrentMaterial</a>-&gt;getShader() == CMaterial::Cloud);
+01759 }
+01760
+01761 } <font class="comment">// NL3D</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>