aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html1234
1 files changed, 1234 insertions, 0 deletions
diff --git a/docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html b/docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html
new file mode 100644
index 00000000..5da0441d
--- /dev/null
+++ b/docs/doxygen/nel/driver__opengl__vertex_8cpp-source.html
@@ -0,0 +1,1234 @@
+<!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_vertex.cpp</h1><a href="driver__opengl__vertex_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00009 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
+00010 <font class="comment"> *</font>
+00011 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00012 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00013 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00014 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00015 <font class="comment"> * any later version.</font>
+00016 <font class="comment"></font>
+00017 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00018 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00019 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00020 <font class="comment"> * General Public License for more details.</font>
+00021 <font class="comment"></font>
+00022 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00023 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00024 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00025 <font class="comment"> * MA 02111-1307, USA.</font>
+00026 <font class="comment"> */</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="stdopengl_8h.html">stdopengl.h</a>"</font>
+00029
+00030 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="driver__opengl__vertex__buffer__hard_8h.html">driver_opengl_vertex_buffer_hard.h</a>"</font>
+00032
+00033
+00034 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00036
+00037
+00038
+00039 <font class="comment">// ***************************************************************************</font>
+00040 <font class="comment">// Flags for software vertex skinning.</font>
+<a name="l00041"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a0">00041</a> <font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VNEEDCOMPUTE 3</font>
+<a name="l00042"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a1">00042</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VMUSTCOMPUTE 1</font>
+<a name="l00043"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a2">00043</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VCOMPUTED 0</font>
+00044 <font class="preprocessor"></font><font class="comment">// 3 means "vertex may need compute".</font>
+00045 <font class="comment">// 1 means "Primitive say vertex must be computed".</font>
+00046 <font class="comment">// 0 means "vertex is computed".</font>
+00047
+00048
+00049 <font class="comment">// 500K min.</font>
+<a name="l00050"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a3">00050</a> <font class="preprocessor">#define NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE (512*1024)</font>
+00051 <font class="preprocessor"></font>
+00052
+00053
+00054 <font class="keyword">namespace </font>NL3D
+00055 {
+00056
+00057
+00058
+00059 <font class="comment">// ***************************************************************************</font>
+<a name="l00060"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c1">00060</a> <font class="keywordtype">bool</font> CDriverGL::setupVertexBuffer(CVertexBuffer&amp; VB)
+00061 {
+00062 <font class="comment">// 1. Retrieve/Create driver shader.</font>
+00063 <font class="comment">//==================================</font>
+00064 <font class="keywordflow">if</font> (!VB.DrvInfos)
+00065 {
+00066 <font class="comment">// insert into driver list. (so it is deleted when driver is deleted).</font>
+00067 <a class="code" href="namespaceNL3D.html#a295">ItVBDrvInfoPtrList</a> it= <a class="code" href="classNL3D_1_1IDriver.html#n3">_VBDrvInfos</a>.insert(<a class="code" href="classNL3D_1_1IDriver.html#n3">_VBDrvInfos</a>.end());
+00068 <font class="comment">// create and set iterator, for future deletion.</font>
+00069 *it= VB.DrvInfos= <font class="keyword">new</font> CVBDrvInfosGL(<font class="keyword">this</font>, it);
+00070 }
+00071
+00072 <font class="comment">// 2. If necessary, do modifications.</font>
+00073 <font class="comment">//==================================</font>
+00074 <font class="keywordflow">if</font>( VB.getTouchFlags()!=0 )
+00075 {
+00076 <font class="comment">// nop</font>
+00077 <font class="comment">// OK!</font>
+00078 VB.resetTouchFlags();
+00079 }
+00080
+00081
+00082 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00083 }
+00084
+00085
+00086 <font class="comment">// ***************************************************************************</font>
+<a name="l00087"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a44">00087</a> <font class="keywordtype">bool</font> CDriverGL::activeVertexBuffer(CVertexBuffer&amp; VB, uint first, uint end)
+00088 {
+00089 <font class="comment">// NB: must duplicate changes in activeVertexBufferHard()</font>
+00090
+00091 uint32 flags;
+00092
+00093 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c1">setupVertexBuffer</a>(VB))
+00094 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00095
+00096 <font class="keywordflow">if</font> (VB.getNumVertices()==0)
+00097 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00098
+00099 <a class="code" href="debug_8h.html#a6">nlassert</a>(end&lt;=VB.getNumVertices());
+00100 <a class="code" href="debug_8h.html#a6">nlassert</a>(first&lt;=end);
+00101
+00102 <font class="comment">// Get VB flags, to setup matrixes and arrays.</font>
+00103 flags=VB.getVertexFormat();
+00104
+00105
+00106 <font class="comment">// 2. Setup Arrays.</font>
+00107 <font class="comment">//===================</font>
+00108
+00109 <font class="comment">// Fence mgt.</font>
+00110 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">fenceOnCurVBHardIfNeeded</a>(NULL);
+00111
+00112 <font class="comment">// For MultiPass Material.</font>
+00113 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.setupVertexBuffer(VB);
+00114
+00115 <font class="comment">// Disable the current vertexBufferHard if setuped.</font>
+00116 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00117 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;disable();
+00118
+00119 <font class="comment">// Setup the OpenGL arrays.</font>
+00120 <a class="code" href="classNL3D_1_1CDriverGL.html#c18">setupGlArrays</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>);
+00121
+00122
+00123 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00124 }
+00125
+00126
+00127 <font class="comment">// ***************************************************************************</font>
+<a name="l00128"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a43">00128</a> <font class="keywordtype">bool</font> CDriverGL::activeVertexBuffer(CVertexBuffer&amp; VB)
+00129 {
+00130 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#a43">activeVertexBuffer</a>(VB, 0, VB.getNumVertices());
+00131 }
+00132
+00133
+00134 <font class="comment">// ***************************************************************************</font>
+<a name="l00135"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a46">00135</a> <font class="keywordtype">bool</font> CDriverGL::render(CPrimitiveBlock&amp; PB, CMaterial&amp; Mat)
+00136 {
+00137 <font class="comment">// update matrix and Light in OpenGL if needed</font>
+00138 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
+00139
+00140 <font class="comment">// setup material</font>
+00141 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
+00142 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00143
+00144
+00145 <font class="comment">// render primitives.</font>
+00146 <font class="comment">//==============================</font>
+00147 <font class="comment">// start multipass.</font>
+00148 uint nPass;
+00149 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
+00150 <font class="comment">// draw all passes.</font>
+00151 <font class="keywordflow">for</font>(uint pass=0;pass&lt;nPass; pass++)
+00152 {
+00153 <font class="comment">// setup the pass.</font>
+00154 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
+00155 <font class="comment">// draw the primitives.</font>
+00156 <font class="keywordflow">if</font>(PB.getNumTri()!=0)
+00157 glDrawElements(GL_TRIANGLES,3*PB.getNumTri(),GL_UNSIGNED_INT,PB.getTriPointer());
+00158 <font class="keywordflow">if</font>(PB.getNumQuad()!=0)
+00159 glDrawElements(GL_QUADS,4*PB.getNumQuad(),GL_UNSIGNED_INT,PB.getQuadPointer());
+00160 <font class="keywordflow">if</font>(PB.getNumLine()!=0)
+00161 glDrawElements(GL_LINES,2*PB.getNumLine(),GL_UNSIGNED_INT,PB.getLinePointer());
+00162 }
+00163 <font class="comment">// end multipass.</font>
+00164 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
+00165
+00166
+00167 <font class="comment">// Profiling.</font>
+00168 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NLines+= PB.getNumLine();
+00169 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= PB.getNumTri();
+00170 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NQuads+= PB.getNumQuad();
+00171 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NLines+= PB.getNumLine() * nPass;
+00172 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= PB.getNumTri() * nPass;
+00173 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NQuads+= PB.getNumQuad() * nPass;
+00174
+00175 <font class="comment">// We have render some prims. inform the VBHard.</font>
+00176 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00177 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;GPURenderingAfterFence= <font class="keyword">true</font>;
+00178
+00179 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00180
+00181
+00182 }
+00183
+00184
+00185 <font class="comment">// ***************************************************************************</font>
+<a name="l00186"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a47">00186</a> <font class="keywordtype">void</font> CDriverGL::renderTriangles(CMaterial&amp; Mat, uint32 *tri, uint32 ntris)
+00187 {
+00188 <font class="comment">// update matrix and Light in OpenGL if needed</font>
+00189 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
+00190
+00191 <font class="comment">// setup material</font>
+00192 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
+00193 <font class="keywordflow">return</font>;
+00194
+00195
+00196 <font class="comment">// render primitives.</font>
+00197 <font class="comment">//==============================</font>
+00198 <font class="comment">// start multipass.</font>
+00199 uint nPass;
+00200 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
+00201 <font class="comment">// draw all passes.</font>
+00202 <font class="keywordflow">for</font>(uint pass=0;pass&lt;nPass; pass++)
+00203 {
+00204 <font class="comment">// setup the pass.</font>
+00205 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
+00206 <font class="comment">// draw the primitives.</font>
+00207 <font class="keywordflow">if</font>(ntris!=0)
+00208 glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
+00209 }
+00210 <font class="comment">// end multipass.</font>
+00211 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
+00212
+00213
+00214 <font class="comment">// Profiling.</font>
+00215 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= ntris;
+00216 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= ntris * nPass;
+00217
+00218 <font class="comment">// We have render some prims. inform the VBHard.</font>
+00219 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00220 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;GPURenderingAfterFence= <font class="keyword">true</font>;
+00221 }
+00222
+00223
+00224 <font class="comment">// ***************************************************************************</font>
+<a name="l00225"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a48">00225</a> <font class="keywordtype">void</font> CDriverGL::renderSimpleTriangles(uint32 *tri, uint32 ntris)
+00226 {
+00227 <a class="code" href="debug_8h.html#a6">nlassert</a>(ntris&gt;0);
+00228
+00229 <font class="comment">// update matrix and Light in OpenGL if needed</font>
+00230 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
+00231
+00232
+00233 <font class="comment">// Don't setup any material here.</font>
+00234
+00235 <font class="comment">// render primitives.</font>
+00236 <font class="comment">//==============================</font>
+00237 <font class="comment">// NO MULTIPASS HERE!!</font>
+00238 <font class="comment">// draw the primitives. (nb: ntrsi&gt;0).</font>
+00239 glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
+00240
+00241 <font class="comment">// Profiling.</font>
+00242 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= ntris;
+00243 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= ntris;
+00244
+00245 <font class="comment">// We have render some prims. inform the VBHard.</font>
+00246 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00247 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;GPURenderingAfterFence= <font class="keyword">true</font>;
+00248 }
+00249
+00250
+00251 <font class="comment">// ***************************************************************************</font>
+<a name="l00252"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a49">00252</a> <font class="keywordtype">void</font> CDriverGL::renderPoints(CMaterial&amp; Mat, uint32 numPoints)
+00253 {
+00254 <font class="comment">// update matrix and Light in OpenGL if needed</font>
+00255 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
+00256
+00257 <font class="comment">// setup material</font>
+00258 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
+00259 <font class="keywordflow">return</font>;
+00260
+00261
+00262 <font class="comment">// render primitives.</font>
+00263 <font class="comment">//==============================</font>
+00264 <font class="comment">// start multipass.</font>
+00265 uint nPass;
+00266 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
+00267 <font class="comment">// draw all passes.</font>
+00268 <font class="keywordflow">for</font>(uint pass=0;pass&lt;nPass; pass++)
+00269 {
+00270 <font class="comment">// setup the pass.</font>
+00271 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
+00272 <font class="comment">// draw the primitives.</font>
+00273 <font class="keywordflow">if</font>(numPoints)
+00274 glDrawArrays(GL_POINTS,0, numPoints);
+00275 }
+00276 <font class="comment">// end multipass.</font>
+00277 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
+00278
+00279
+00280 <font class="comment">// Profiling.</font>
+00281 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NPoints+= numPoints;
+00282 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NPoints+= numPoints * nPass;
+00283
+00284 <font class="comment">// We have render some prims. inform the VBHard.</font>
+00285 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00286 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;GPURenderingAfterFence= <font class="keyword">true</font>;
+00287 }
+00288
+00289
+00290
+00291
+00292 <font class="comment">// ***************************************************************************</font>
+<a name="l00293"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a50">00293</a> <font class="keywordtype">void</font> CDriverGL::renderQuads(CMaterial&amp; Mat, uint32 startIndex, uint32 numQuads)
+00294 {
+00295 <font class="comment">// update matrix and Light in OpenGL if needed</font>
+00296 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
+00297
+00298 <font class="comment">// setup material</font>
+00299 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
+00300 <font class="keywordflow">return</font>;
+00301
+00302
+00303 <font class="comment">// render primitives.</font>
+00304 <font class="comment">//==============================</font>
+00305 <font class="comment">// start multipass.</font>
+00306 uint nPass;
+00307 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
+00308 <font class="comment">// draw all passes.</font>
+00309 <font class="keywordflow">for</font>(uint pass=0;pass&lt;nPass; pass++)
+00310 {
+00311 <font class="comment">// setup the pass.</font>
+00312 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
+00313 <font class="comment">// draw the primitives.</font>
+00314 <font class="keywordflow">if</font>(numQuads)
+00315 glDrawArrays(GL_QUADS, startIndex &lt;&lt; 2, numQuads &lt;&lt; 2) ;
+00316 }
+00317 <font class="comment">// end multipass.</font>
+00318 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
+00319
+00320
+00321 <font class="comment">// Profiling.</font>
+00322 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NQuads += numQuads ;
+00323 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NQuads += numQuads * nPass;
+00324
+00325 <font class="comment">// We have render some prims. inform the VBHard.</font>
+00326 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00327 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;GPURenderingAfterFence= <font class="keyword">true</font>;
+00328 }
+00329
+00330
+00331 <font class="comment">// ***************************************************************************</font>
+<a name="l00332"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c14">00332</a> <font class="keywordtype">void</font> CDriverGL::setupUVPtr(uint stage, CVertexBufferInfo &amp;VB, uint uvId)
+00333 {
+00334 <font class="comment">// sould not be called with vertex program Array setuped.</font>
+00335 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>);
+00336
+00337 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(stage);
+00338 <font class="keywordflow">if</font> (VB.VertexFormat &amp; (CVertexBuffer::TexCoord0Flag&lt;&lt;uvId))
+00339 {
+00340 <font class="comment">// Check type, if not supported, just ignore</font>
+00341 <font class="keywordflow">if</font> (VB.Type[CVertexBuffer::TexCoord0+uvId]==CVertexBuffer::Float2)
+00342 {
+00343 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">true</font>);
+00344 <font class="comment">// Setup ATI VBHard or std ptr.</font>
+00345 <font class="keywordflow">if</font>(VB.ATIVBHardMode)
+00346 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, VB.VertexSize,
+00347 VB.ATIVertexObjectId, VB.ATIValueOffset[CVertexBuffer::TexCoord0+uvId]);
+00348 <font class="keywordflow">else</font>
+00349 glTexCoordPointer(2,GL_FLOAT,VB.VertexSize,VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
+00350 }
+00351 <font class="keywordflow">else</font>
+00352 {
+00353 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
+00354 }
+00355 }
+00356 <font class="keywordflow">else</font>
+00357 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
+00358 }
+00359
+00360
+00361 <font class="comment">// ***************************************************************************</font>
+<a name="l00362"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a45">00362</a> <font class="keywordtype">void</font> CDriverGL::mapTextureStageToUV(uint stage, uint uv)
+00363 {
+00364 <font class="comment">// Just call it for last VertexBuffer setuped.</font>
+00365 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(stage, <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>, uv);
+00366 }
+00367
+00368
+00369
+00370 <font class="comment">// ***************************************************************************</font>
+00371 <font class="comment">// ***************************************************************************</font>
+00372 <font class="comment">// VertexBufferHard</font>
+00373 <font class="comment">// ***************************************************************************</font>
+00374 <font class="comment">// ***************************************************************************</font>
+00375
+00376
+00377 <font class="comment">// ***************************************************************************</font>
+<a name="l00378"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a36">00378</a> <font class="keywordtype">bool</font> CDriverGL::supportVertexBufferHard()<font class="keyword"> const</font>
+00379 <font class="keyword"></font>{
+00380 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_7">_SupportVBHard</a>;
+00381 }
+00382
+00383
+00384 <font class="comment">// ***************************************************************************</font>
+<a name="l00385"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a37">00385</a> <font class="keywordtype">bool</font> CDriverGL::slowUnlockVertexBufferHard()<font class="keyword"> const</font>
+00386 <font class="keyword"></font>{
+00387 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_8">_SlowUnlockVBHard</a>;
+00388 }
+00389
+00390
+00391 <font class="comment">// ***************************************************************************</font>
+<a name="l00392"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a38">00392</a> uint CDriverGL::getMaxVerticesByVertexBufferHard()<font class="keyword"> const</font>
+00393 <font class="keyword"></font>{
+00394 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>;
+00395 }
+00396
+00397
+00398 <font class="comment">// ***************************************************************************</font>
+<a name="l00399"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a40">00399</a> IVertexBufferHard *CDriverGL::createVertexBufferHard(uint16 vertexFormat, <font class="keyword">const</font> uint8 *typeArray, uint32 numVertices, IDriver::TVBHardType vbType)
+00400 {
+00401 <font class="comment">// choose the VertexArrayRange of good type</font>
+00402 IVertexArrayRange *vertexArrayRange= NULL;
+00403 <font class="keywordflow">switch</font>(vbType)
+00404 {
+00405 <font class="keywordflow">case</font> IDriver::VBHardAGP:
+00406 vertexArrayRange= <a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>;
+00407 <font class="keywordflow">break</font>;
+00408 <font class="keywordflow">case</font> IDriver::VBHardVRAM:
+00409 vertexArrayRange= <a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>;
+00410 <font class="keywordflow">break</font>;
+00411 };
+00412
+00413 <font class="comment">// If this one at least created (an extension support it).</font>
+00414 <font class="keywordflow">if</font>( !vertexArrayRange )
+00415 <font class="keywordflow">return</font> NULL;
+00416 <font class="keywordflow">else</font>
+00417 {
+00418 <font class="comment">// check max vertex</font>
+00419 <font class="keywordflow">if</font>(numVertices &gt; <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>)
+00420 <font class="keywordflow">return</font> NULL;
+00421
+00422 <font class="comment">// Create a CVertexBufferHardGL</font>
+00423 IVertexBufferHardGL *vb;
+00424 <font class="comment">// let the VAR create the vbhard.</font>
+00425 vb= vertexArrayRange-&gt;createVBHardGL(vertexFormat, typeArray, numVertices);
+00426 <font class="comment">// if fails</font>
+00427 <font class="keywordflow">if</font>(!vb)
+00428 {
+00429 <font class="keywordflow">return</font> NULL;
+00430 }
+00431 <font class="keywordflow">else</font>
+00432 {
+00433 <font class="comment">// insert in list.</font>
+00434 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.insert(vb);
+00435 }
+00436 }
+00437 }
+00438
+00439
+00440 <font class="comment">// ***************************************************************************</font>
+<a name="l00441"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a41">00441</a> <font class="keywordtype">void</font> CDriverGL::deleteVertexBufferHard(IVertexBufferHard *VB)
+00442 {
+00443 <font class="comment">// If one _CurrentVertexBufferHard enabled, first End its drawning, and disable it.</font>
+00444 <font class="comment">// This is very important, because after deletion, the space is free. </font>
+00445 <font class="comment">// If the GPU has not finisehd his drawing, and if any allocation occurs on this free space, and if </font>
+00446 <font class="comment">// the user locks to fill this space (feww!) Then some data crash may results....</font>
+00447 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+00448 {
+00449 <font class="comment">// Must ensure it has ended any drawing</font>
+00450 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;lock();
+00451 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;unlock();
+00452 <font class="comment">// disable the VBHard.</font>
+00453 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;disable();
+00454 }
+00455
+00456 <font class="comment">// Then just delete the VBuffer hard from list.</font>
+00457 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.erase(safe_cast&lt;IVertexBufferHardGL*&gt;(VB));
+00458 }
+00459
+00460
+00461
+00462 <font class="comment">// ***************************************************************************</font>
+<a name="l00463"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a42">00463</a> <font class="keywordtype">void</font> CDriverGL::activeVertexBufferHard(IVertexBufferHard *iVB)
+00464 {
+00465 <font class="comment">// NB: must duplicate changes in activeVertexBuffer()</font>
+00466
+00467 <a class="code" href="debug_8h.html#a6">nlassert</a>(iVB);
+00468 IVertexBufferHardGL *VB= safe_cast&lt;IVertexBufferHardGL*&gt;(iVB);
+00469
+00470 uint32 flags;
+00471
+00472 <font class="keywordflow">if</font> (VB-&gt;getNumVertices()==0)
+00473 <font class="keywordflow">return</font>;
+00474
+00475 <font class="comment">// Get VB flags, to setup matrixes and arrays.</font>
+00476 flags=VB-&gt;getVertexFormat();
+00477
+00478
+00479 <font class="comment">// 2. Setup Arrays.</font>
+00480 <font class="comment">//===================</font>
+00481
+00482 <font class="comment">// Fence mgt.</font>
+00483 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">fenceOnCurVBHardIfNeeded</a>(VB);
+00484
+00485 <font class="comment">// For MultiPass Material.</font>
+00486 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.setupVertexBufferHard(*VB);
+00487
+00488 <font class="comment">// Enable the vertexArrayRange of this array.</font>
+00489 VB-&gt;enable();
+00490
+00491 <font class="comment">// Setup the OpenGL arrays.</font>
+00492 <a class="code" href="classNL3D_1_1CDriverGL.html#c18">setupGlArrays</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>);
+00493
+00494 }
+00495
+00496
+00497 <font class="comment">// ***************************************************************************</font>
+<a name="l00498"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r1">00498</a> <font class="keyword">const</font> uint CDriverGL::NumCoordinatesType[CVertexBuffer::NumType]=
+00499 {
+00500 1, <font class="comment">// Double1</font>
+00501 1, <font class="comment">// Float1</font>
+00502 1, <font class="comment">// Short1</font>
+00503 2, <font class="comment">// Double2</font>
+00504 2, <font class="comment">// Float2</font>
+00505 2, <font class="comment">// Short2</font>
+00506 3, <font class="comment">// Double3</font>
+00507 3, <font class="comment">// Float3</font>
+00508 3, <font class="comment">// Short3</font>
+00509 4, <font class="comment">// Double4</font>
+00510 4, <font class="comment">// Float4</font>
+00511 4, <font class="comment">// Short4</font>
+00512 4 <font class="comment">// UChar4</font>
+00513 };
+00514
+00515
+00516 <font class="comment">// ***************************************************************************</font>
+<a name="l00517"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r2">00517</a> <font class="keyword">const</font> uint CDriverGL::GLType[CVertexBuffer::NumType]=
+00518 {
+00519 GL_DOUBLE, <font class="comment">// Double1</font>
+00520 GL_FLOAT, <font class="comment">// Float1</font>
+00521 GL_SHORT, <font class="comment">// Short1</font>
+00522 GL_DOUBLE, <font class="comment">// Double2</font>
+00523 GL_FLOAT, <font class="comment">// Float2</font>
+00524 GL_SHORT, <font class="comment">// Short2</font>
+00525 GL_DOUBLE, <font class="comment">// Double3</font>
+00526 GL_FLOAT, <font class="comment">// Float3</font>
+00527 GL_SHORT, <font class="comment">// Short3</font>
+00528 GL_DOUBLE, <font class="comment">// Double4</font>
+00529 GL_FLOAT, <font class="comment">// Float4</font>
+00530 GL_SHORT, <font class="comment">// Short4</font>
+00531 GL_UNSIGNED_BYTE <font class="comment">// UChar4</font>
+00532 };
+00533
+00534
+00535 <font class="comment">// ***************************************************************************</font>
+<a name="l00536"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r3">00536</a> <font class="keyword">const</font> uint CDriverGL::GLVertexAttribIndex[CVertexBuffer::NumValue]=
+00537 {
+00538 0, <font class="comment">// Position</font>
+00539 2, <font class="comment">// Normal</font>
+00540 8, <font class="comment">// TexCoord0</font>
+00541 9, <font class="comment">// TexCoord1</font>
+00542 10, <font class="comment">// TexCoord2</font>
+00543 11, <font class="comment">// TexCoord3</font>
+00544 12, <font class="comment">// TexCoord4</font>
+00545 13, <font class="comment">// TexCoord5</font>
+00546 14, <font class="comment">// TexCoord6</font>
+00547 15, <font class="comment">// TexCoord7</font>
+00548 3, <font class="comment">// PrimaryColor</font>
+00549 4, <font class="comment">// SecondaryColor</font>
+00550 1, <font class="comment">// Weight</font>
+00551 6, <font class="comment">// Empty (PaletteSkin)</font>
+00552 5, <font class="comment">// Fog</font>
+00553 7, <font class="comment">// Empty</font>
+00554 };
+00555
+00556
+00557
+00558 <font class="comment">// ***************************************************************************</font>
+<a name="l00559"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c19">00559</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysStd(CVertexBufferInfo &amp;vb)
+00560 {
+00561 uint32 flags= vb.VertexFormat;
+00562 <font class="comment">// setup vertex ptr.</font>
+00563 <font class="comment">//-----------</font>
+00564 uint numVertexCoord = CVertexBuffer::NumComponentsType[vb.Type[CVertexBuffer::Position]];
+00565 <a class="code" href="debug_8h.html#a6">nlassert</a> (numVertexCoord &gt;= 2);
+00566
+00567 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">true</font>);
+00568 <font class="comment">// Setup ATI VBHard or std ptr.</font>
+00569 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
+00570 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_VERTEX_ARRAY, numVertexCoord, GL_FLOAT, vb.VertexSize,
+00571 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
+00572 <font class="keywordflow">else</font>
+00573 glVertexPointer(numVertexCoord, GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Position]);
+00574
+00575
+00576 <font class="comment">// setup normal ptr.</font>
+00577 <font class="comment">//-----------</font>
+00578 <font class="comment">// Check for normal param in vertex buffer</font>
+00579 <font class="keywordflow">if</font> (flags &amp; CVertexBuffer::NormalFlag)
+00580 {
+00581 <font class="comment">// Check type</font>
+00582 <a class="code" href="debug_8h.html#a6">nlassert</a> (vb.Type[CVertexBuffer::Normal]==CVertexBuffer::Float3);
+00583
+00584 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">true</font>);
+00585 <font class="comment">// Setup ATI VBHard or std ptr.</font>
+00586 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
+00587 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_NORMAL_ARRAY, 3, GL_FLOAT, vb.VertexSize,
+00588 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Normal]);
+00589 <font class="keywordflow">else</font>
+00590 glNormalPointer(GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
+00591 }
+00592 <font class="keywordflow">else</font>
+00593 {
+00594 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
+00595 }
+00596
+00597
+00598 <font class="comment">// Setup Color</font>
+00599 <font class="comment">//-----------</font>
+00600 <font class="comment">// Check for color param in vertex buffer</font>
+00601 <font class="keywordflow">if</font> (flags &amp; CVertexBuffer::PrimaryColorFlag)
+00602 {
+00603 <font class="comment">// Check type</font>
+00604 <a class="code" href="debug_8h.html#a6">nlassert</a> (vb.Type[CVertexBuffer::PrimaryColor]==CVertexBuffer::UChar4);
+00605
+00606 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">true</font>);
+00607 <font class="comment">// Setup ATI VBHard or std ptr.</font>
+00608 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
+00609 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize,
+00610 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
+00611 <font class="keywordflow">else</font>
+00612 glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[CVertexBuffer::PrimaryColor]);
+00613 }
+00614 <font class="keywordflow">else</font>
+00615 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00616
+00617
+00618 <font class="comment">// Setup Uvs</font>
+00619 <font class="comment">//-----------</font>
+00620 <font class="keywordflow">for</font>(sint i=0; i&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
+00621 {
+00622 <font class="comment">// normal behavior: each texture has its own UV.</font>
+00623 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(i, vb, i);
+00624 }
+00625 }
+00626
+00627
+00628
+00629 <font class="comment">// ***************************************************************************</font>
+<a name="l00630"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c22">00630</a> <font class="keywordtype">void</font> CDriverGL::toggleGlArraysForNVVertexProgram()
+00631 {
+00632 <font class="comment">// If change of setup type, must disable olds.</font>
+00633 <font class="comment">//=======================</font>
+00634
+00635 <font class="comment">// If last was a VertexProgram setup, and now it is a standard GL array setup.</font>
+00636 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> &amp;&amp; !<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
+00637 {
+00638
+00639 <font class="comment">// Disable all VertexAttribs.</font>
+00640 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>&lt;CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
+00641 {
+00642 <font class="comment">// Index</font>
+00643 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
+00644 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
+00645 }
+00646 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00647 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
+00648
+00649 <font class="comment">// no more a vertex program setup.</font>
+00650 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">false</font>;
+00651 }
+00652
+00653 <font class="comment">// If last was a standard GL array setup, and now it is a VertexProgram setup.</font>
+00654 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> &amp;&amp; <a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
+00655 {
+00656 <font class="comment">// Disable all standards ptrs.</font>
+00657 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">false</font>);
+00658 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
+00659 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00660 <font class="keywordflow">for</font>(sint i=0; i&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
+00661 {
+00662 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(i);
+00663 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
+00664 }
+00665
+00666
+00667 <font class="comment">// now, vertex program setup.</font>
+00668 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">true</font>;
+00669 }
+00670 }
+00671
+00672
+00673 <font class="comment">// ***************************************************************************</font>
+<a name="l00674"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c23">00674</a> <font class="keywordtype">void</font> CDriverGL::toggleGlArraysForEXTVertexShader()
+00675 {
+00676 <font class="comment">// If change of setup type, must disable olds.</font>
+00677 <font class="comment">//=======================</font>
+00678
+00679
+00680 <font class="comment">// If last was a VertexProgram setup, and now it is a standard GL array setup.</font>
+00681 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> &amp;&amp; !<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
+00682 {
+00683 CVertexProgram *vp = <a class="code" href="classNL3D_1_1CDriverGL.html#o26">_LastSetuppedVP</a>;
+00684 <font class="keywordflow">if</font> (vp)
+00685 {
+00686 <a class="code" href="classNL3D_1_1CDriverGL.html#l1">CVertexProgamDrvInfosGL</a> *drvInfo = NLMISC::safe_cast&lt;CVertexProgamDrvInfosGL *&gt;((<a class="code" href="classNL3D_1_1IDriver.html#l4">IVertexProgramDrvInfos</a> *) vp-&gt;_DrvInfo);
+00687 <font class="keywordflow">if</font> (drvInfo)
+00688 {
+00689 <font class="comment">// Disable all VertexAttribs.</font>
+00690 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>&lt;CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
+00691 {
+00692 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, <font class="keyword">false</font>, drvInfo-&gt;Variants);
+00693 }
+00694 }
+00695 }
+00696 <font class="comment">// no more a vertex program setup.</font>
+00697 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">false</font>;
+00698 }
+00699
+00700 <font class="comment">// If last was a standard GL array setup, and now it is a VertexProgram setup.</font>
+00701 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> &amp;&amp; <a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
+00702 {
+00703 <font class="comment">// Disable all standards ptrs.</font>
+00704 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">false</font>);
+00705 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
+00706 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00707 <font class="keywordflow">for</font>(sint i=0; i&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
+00708 {
+00709 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(i);
+00710 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
+00711 }
+00712
+00713
+00714 <font class="comment">// now, vertex program setup.</font>
+00715 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">true</font>;
+00716 }
+00717 }
+00718
+00719 <font class="comment">// ***************************************************************************</font>
+<a name="l00720"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c20">00720</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &amp;vb)
+00721 {
+00722 uint32 flags= vb.VertexFormat;
+00723
+00724 <font class="comment">// For each value</font>
+00725 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>&lt;CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
+00726 {
+00727 <font class="comment">// Flag</font>
+00728 uint16 flag=1&lt;&lt;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
+00729
+00730 <font class="comment">// Type</font>
+00731 CVertexBuffer::TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=vb.Type[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
+00732
+00733 <font class="comment">// Index</font>
+00734 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
+00735
+00736 <font class="comment">// Not setuped value and used</font>
+00737 <font class="keywordflow">if</font> (flags &amp; flag)
+00738 {
+00739 <font class="comment">/* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.</font>
+00740 <font class="comment"> Don't work and lead to very poor performance (1/10) (VAR is "disabled").</font>
+00741 <font class="comment"> */</font>
+00742 <font class="comment">// Test if can use glColorPointer() / glSecondaryColorPointerEXT() instead.</font>
+00743 <font class="keywordflow">if</font>( (glIndex==3 || glIndex==4) )
+00744 {
+00745 <font class="keywordflow">if</font>( <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == CVertexBuffer::UChar4 )
+00746 {
+00747 <font class="comment">// Must disable VertexAttrib array.</font>
+00748 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
+00749
+00750 <font class="comment">// Active this value, with standard gl calls</font>
+00751 <font class="keywordflow">if</font>(glIndex==3)
+00752 {
+00753 <font class="comment">// Primary color</font>
+00754 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">true</font>);
+00755 glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00756 }
+00757 <font class="keywordflow">else</font>
+00758 {
+00759 <font class="comment">// Secondary color</font>
+00760 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">true</font>);
+00761 <a class="code" href="driver__opengl__extension_8h.html#a170">nglSecondaryColorPointerEXT</a>(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00762 }
+00763 }
+00764 <font class="keywordflow">else</font>
+00765 {
+00766 <font class="comment">// Can use normal VertexAttribArray.</font>
+00767 <font class="comment">// Disable first standard Color Array.</font>
+00768 <font class="keywordflow">if</font>(glIndex==3)
+00769 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00770 <font class="keywordflow">else</font>
+00771 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
+00772
+00773 <font class="comment">// Active this value</font>
+00774 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">true</font>);
+00775 <a class="code" href="driver__opengl__extension_8h.html#a77">nglVertexAttribPointerNV</a> (glIndex, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00776 }
+00777 }
+00778 <font class="comment">// Else normal case, can't do anything for other values with UChar4....</font>
+00779 <font class="keywordflow">else</font>
+00780 {
+00781 <font class="comment">// Active this value</font>
+00782 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">true</font>);
+00783 <a class="code" href="driver__opengl__extension_8h.html#a77">nglVertexAttribPointerNV</a> (glIndex, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00784 }
+00785 }
+00786 <font class="keywordflow">else</font>
+00787 {
+00788 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
+00789 <font class="comment">/* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.</font>
+00790 <font class="comment"> Must also disable colorArray in standard gl calls.</font>
+00791 <font class="comment"> */</font>
+00792 <font class="keywordflow">if</font>(glIndex==3)
+00793 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
+00794 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(glIndex==4)
+00795 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
+00796 }
+00797 }
+00798 }
+00799
+00800
+00801 <font class="comment">// ***************************************************************************</font>
+<a name="l00802"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c21">00802</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysForEXTVertexShader(CVertexBufferInfo &amp;vb)
+00803 {
+00804
+00805 CVertexProgram *vp = <a class="code" href="classNL3D_1_1CDriverGL.html#o26">_LastSetuppedVP</a>;
+00806 <font class="keywordflow">if</font> (!vp) <font class="keywordflow">return</font>;
+00807 <a class="code" href="classNL3D_1_1CDriverGL.html#l1">CVertexProgamDrvInfosGL</a> *drvInfo = NLMISC::safe_cast&lt;CVertexProgamDrvInfosGL *&gt;((<a class="code" href="classNL3D_1_1IDriver.html#l4">IVertexProgramDrvInfos</a> *) vp-&gt;_DrvInfo);
+00808 <font class="keywordflow">if</font> (!drvInfo) <font class="keywordflow">return</font>;
+00809
+00810 uint32 flags= vb.VertexFormat;
+00811
+00812 <font class="comment">// For each value</font>
+00813 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>&lt;CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
+00814 {
+00815 <font class="comment">// Flag</font>
+00816 uint16 flag=1&lt;&lt;<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
+00817
+00818 <font class="comment">// Type</font>
+00819 CVertexBuffer::TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=vb.Type[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
+00820
+00821 <font class="comment">// Index</font>
+00822 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
+00823
+00824 <font class="comment">// Not setuped value and used</font>
+00825 <font class="keywordflow">if</font> (flags &amp; flag &amp; drvInfo-&gt;UsedVertexComponents)
+00826 {
+00827 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(glIndex, <font class="keyword">true</font>, drvInfo-&gt;Variants);
+00828 <font class="comment">// use variant or open gl standard array</font>
+00829 <font class="keywordflow">switch</font>(value)
+00830 {
+00831 <font class="keywordflow">case</font> CVertexBuffer::Position: <font class="comment">// position </font>
+00832 {
+00833 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] &gt;= 2);
+00834 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_VERTEX_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
+00835 <font class="keywordflow">else</font> glVertexPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00836 }
+00837 <font class="keywordflow">break</font>;
+00838 <font class="keywordflow">case</font> CVertexBuffer::Weight: <font class="comment">// skin weight</font>
+00839 {
+00840 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
+00841 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo-&gt;Variants[CDriverGL::EVSSkinWeightVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Weight]);
+00842 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo-&gt;Variants[CDriverGL::EVSSkinWeightVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00843 }
+00844 <font class="keywordflow">break</font>;
+00845 <font class="keywordflow">case</font> CVertexBuffer::Normal: <font class="comment">// normal</font>
+00846 {
+00847 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 3); <font class="comment">// must have 3 components for normals</font>
+00848 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_NORMAL_ARRAY, 3, <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00849 <font class="keywordflow">else</font> glNormalPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
+00850 }
+00851 <font class="keywordflow">break</font>;
+00852 <font class="keywordflow">case</font> CVertexBuffer::PrimaryColor: <font class="comment">// color</font>
+00853 {
+00854 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] &gt;= 3); <font class="comment">// must have 3 or 4 components for primary color</font>
+00855 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_COLOR_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
+00856 <font class="keywordflow">else</font> glColorPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00857 }
+00858 <font class="keywordflow">break</font>;
+00859 <font class="keywordflow">case</font> CVertexBuffer::SecondaryColor: <font class="comment">// secondary color</font>
+00860 {
+00861 <font class="comment">// implemented using a variant, as not available with EXTVertexShader</font>
+00862 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
+00863 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo-&gt;Variants[CDriverGL::EVSSecondaryColorVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::SecondaryColor]);
+00864 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo-&gt;Variants[CDriverGL::EVSSecondaryColorVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00865 }
+00866 <font class="keywordflow">break</font>;
+00867 <font class="keywordflow">case</font> CVertexBuffer::Fog: <font class="comment">// fog coordinate</font>
+00868 {
+00869 <font class="comment">// implemented using a variant</font>
+00870 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
+00871 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo-&gt;Variants[CDriverGL::EVSFogCoordsVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Fog]);
+00872 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo-&gt;Variants[CDriverGL::EVSFogCoordsVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00873 }
+00874 <font class="keywordflow">break</font>;
+00875 <font class="keywordflow">case</font> CVertexBuffer::PaletteSkin: <font class="comment">// palette skin</font>
+00876 {
+00877 <font class="comment">// implemented using a variant</font>
+00878 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
+00879 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo-&gt;Variants[CDriverGL::EVSPaletteSkinVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PaletteSkin]);
+00880 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo-&gt;Variants[CDriverGL::EVSPaletteSkinVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00881 }
+00882 <font class="keywordflow">break</font>;
+00883 <font class="keywordflow">case</font> CVertexBuffer::Empty: <font class="comment">// empty</font>
+00884 <a class="code" href="debug_8h.html#a12">nlstop</a>
+00885 <font class="keywordflow">break</font>;
+00886 <font class="keywordflow">case</font> CVertexBuffer::TexCoord0:
+00887 <font class="keywordflow">case</font> CVertexBuffer::TexCoord1:
+00888 <font class="keywordflow">case</font> CVertexBuffer::TexCoord2:
+00889 <font class="keywordflow">case</font> CVertexBuffer::TexCoord3:
+00890 <font class="keywordflow">case</font> CVertexBuffer::TexCoord4:
+00891 <font class="keywordflow">case</font> CVertexBuffer::TexCoord5:
+00892 <font class="keywordflow">case</font> CVertexBuffer::TexCoord6:
+00893 <font class="keywordflow">case</font> CVertexBuffer::TexCoord7:
+00894 {
+00895 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> - CVertexBuffer::TexCoord0);
+00896 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_TEXTURE_COORD_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
+00897 <font class="keywordflow">else</font> glTexCoordPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> ]);
+00898 }
+00899 <font class="keywordflow">break</font>;
+00900 <font class="keywordflow">default</font>:
+00901 <a class="code" href="debug_8h.html#a12">nlstop</a>; <font class="comment">// invalid value</font>
+00902 <font class="keywordflow">break</font>;
+00903 }
+00904 }
+00905 <font class="keywordflow">else</font>
+00906 {
+00907 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(glIndex, <font class="keyword">false</font>, drvInfo-&gt;Variants);
+00908 }
+00909 }
+00910 }
+00911
+00912
+00913
+00914 <font class="comment">// ***************************************************************************</font>
+<a name="l00915"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c18">00915</a> <font class="keywordtype">void</font> CDriverGL::setupGlArrays(CVertexBufferInfo &amp;vb)
+00916 {
+00917 uint32 flags= vb.VertexFormat;
+00918
+00923 <font class="comment">// Standard case (NVVertexProgram or no vertex program case)</font>
+00924 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVVertexProgram || !<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTVertexShader)
+00925 {
+00926 <a class="code" href="classNL3D_1_1CDriverGL.html#c22">toggleGlArraysForNVVertexProgram</a>();
+00927 <font class="comment">// Use a vertex program ?</font>
+00928 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> ())
+00929 {
+00930 <a class="code" href="classNL3D_1_1CDriverGL.html#c19">setupGlArraysStd</a>(vb);
+00931 }
+00932 <font class="keywordflow">else</font>
+00933 {
+00934 <a class="code" href="classNL3D_1_1CDriverGL.html#c20">setupGlArraysForNVVertexProgram</a>(vb);
+00935 }
+00936 }
+00937 <font class="keywordflow">else</font> <font class="comment">// EXTVertexShader case</font>
+00938 {
+00939 <a class="code" href="classNL3D_1_1CDriverGL.html#c23">toggleGlArraysForEXTVertexShader</a>();
+00940 <font class="comment">// Use a vertex program ?</font>
+00941 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> ())
+00942 {
+00943 <a class="code" href="classNL3D_1_1CDriverGL.html#c19">setupGlArraysStd</a>(vb);
+00944 }
+00945 <font class="keywordflow">else</font>
+00946 {
+00947 <a class="code" href="classNL3D_1_1CDriverGL.html#c21">setupGlArraysForEXTVertexShader</a>(vb);
+00948 }
+00949 }
+00950
+00951 <font class="comment">// Reset specials flags.</font>
+00952 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a>= <font class="keyword">false</font>;
+00953 }
+00954
+00955
+00956 <font class="comment">// ***************************************************************************</font>
+<a name="l00957"></a><a class="code" href="classNL3D_1_1CVertexBufferInfo.html#a0">00957</a> <font class="keywordtype">void</font> CVertexBufferInfo::setupVertexBuffer(CVertexBuffer &amp;vb)
+00958 {
+00959 sint i;
+00960 uint flags= vb.getVertexFormat();
+00961 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>= flags;
+00962 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m1">VertexSize</a>= vb.getVertexSize();
+00963 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m2">NumVertices</a>= vb.getNumVertices();
+00964 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m3">NumWeight</a>= vb.getNumWeight();
+00965
+00966 <font class="comment">// No VBhard.</font>
+00967 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">false</font>;
+00968
+00969 <font class="comment">// Get value pointer</font>
+00970 <font class="keywordflow">for</font> (i=0; i&lt;CVertexBuffer::NumValue; i++)
+00971 {
+00972 <font class="comment">// Value used ?</font>
+00973 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&amp;(1&lt;&lt;i))
+00974 {
+00975 <font class="comment">// Get the pointer</font>
+00976 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m5">ValuePtr</a>[i]=vb.getValueEx ((CVertexBuffer::TValue)i);
+00977
+00978 <font class="comment">// Type of the value</font>
+00979 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]=vb.getValueType (i);
+00980 }
+00981 }
+00982 }
+00983
+00984
+00985 <font class="comment">// ***************************************************************************</font>
+<a name="l00986"></a><a class="code" href="classNL3D_1_1CVertexBufferInfo.html#a1">00986</a> <font class="keywordtype">void</font> CVertexBufferInfo::setupVertexBufferHard(IVertexBufferHardGL &amp;vb)
+00987 {
+00988 sint i;
+00989 uint flags= vb.getVertexFormat();
+00990 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>= flags;
+00991 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m1">VertexSize</a>= vb.getVertexSize();
+00992 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m2">NumVertices</a>= vb.getNumVertices();
+00993 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m3">NumWeight</a>= vb.getNumWeight();
+00994
+00995 <font class="comment">// Not ATI VBHard by default</font>
+00996 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">false</font>;
+00997
+00998 <font class="comment">// Setup differs from ATI or NVidia VBHard.</font>
+00999 <font class="keywordflow">if</font>(vb.NVidiaVertexBufferHard)
+01000 {
+01001 CVertexBufferHardGLNVidia &amp;vbHardNV= static_cast&lt;CVertexBufferHardGLNVidia&amp;&gt;(vb);
+01002
+01003 <font class="comment">// Get value pointer</font>
+01004 <font class="keywordflow">for</font> (i=0; i&lt;CVertexBuffer::NumValue; i++)
+01005 {
+01006 <font class="comment">// Value used ?</font>
+01007 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&amp;(1&lt;&lt;i))
+01008 {
+01009 <font class="comment">// Get the pointer</font>
+01010 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m5">ValuePtr</a>[i]= vbHardNV.getNVidiaValueEx(i);
+01011
+01012 <font class="comment">// Type of the value</font>
+01013 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]= vbHardNV.getValueType (i);
+01014 }
+01015 }
+01016 }
+01017 <font class="keywordflow">else</font>
+01018 {
+01019 <a class="code" href="debug_8h.html#a6">nlassert</a>(vb.ATIVertexBufferHard);
+01020 CVertexBufferHardGLATI &amp;vbHardATI= static_cast&lt;CVertexBufferHardGLATI&amp;&gt;(vb);
+01021
+01022 <font class="comment">// special setup in setupGlArrays()...</font>
+01023 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">true</font>;
+01024
+01025 <font class="comment">// store the VertexObject Id.</font>
+01026 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m7">ATIVertexObjectId</a>= vbHardATI.getATIVertexObjectId();
+01027
+01028 <font class="comment">// Get value offset</font>
+01029 <font class="keywordflow">for</font> (i=0; i&lt;CVertexBuffer::NumValue; i++)
+01030 {
+01031 <font class="comment">// Value used ?</font>
+01032 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&amp;(1&lt;&lt;i))
+01033 {
+01034 <font class="comment">// Get the pointer</font>
+01035 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m8">ATIValueOffset</a>[i]= vbHardATI.getATIValueOffset(i);
+01036
+01037 <font class="comment">// Type of the value</font>
+01038 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]= vbHardATI.getValueType (i);
+01039 }
+01040 }
+01041 }
+01042 }
+01043
+01044
+01045
+01046 <font class="comment">// ***************************************************************************</font>
+<a name="l01047"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z411_0">01047</a> <font class="keywordtype">void</font> CDriverGL::resetVertexArrayRange()
+01048 {
+01049 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
+01050 {
+01051 <font class="comment">// Must ensure it has ended any drawing</font>
+01052 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;lock();
+01053 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;unlock();
+01054 <font class="comment">// disable it</font>
+01055 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;disable();
+01056 }
+01057 <font class="comment">// Clear any VertexBufferHard created.</font>
+01058 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.clear();
+01059
+01060 <font class="comment">// After, Clear the 2 vertexArrayRange, if any.</font>
+01061 <font class="keywordflow">if</font>(_AGPVertexArrayRange)
+01062 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>-&gt;free();
+01063 <font class="keywordflow">if</font>(_VRAMVertexArrayRange)
+01064 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>-&gt;free();
+01065 }
+01066
+01067
+01068 <font class="comment">// ***************************************************************************</font>
+<a name="l01069"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a39">01069</a> <font class="keywordtype">bool</font> CDriverGL::initVertexArrayRange(uint agpMem, uint vramMem)
+01070 {
+01071 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CDriverGL.html#a36">supportVertexBufferHard</a>())
+01072 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+01073
+01074 <font class="comment">// must be supported</font>
+01075 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a> || !<a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>)
+01076 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+01077
+01078 <font class="comment">// First, reset any VBHard created.</font>
+01079 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_0">resetVertexArrayRange</a>();
+01080 <font class="keywordtype">bool</font> ok= <font class="keyword">true</font>;
+01081
+01082 <font class="comment">// Try to allocate AGPMemory.</font>
+01083 <font class="keywordflow">if</font>(agpMem&gt;0)
+01084 {
+01085 agpMem&amp;= ~15; <font class="comment">// ensure 16-bytes aligned mem count (maybe usefull :) ).</font>
+01086 agpMem= max(agpMem, (uint)<a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>);
+01087 <font class="keywordflow">while</font>(agpMem&gt;= <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
+01088 {
+01089 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>-&gt;allocate(agpMem, IDriver::VBHardAGP))
+01090 {
+01091 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: %.d vertices supported"</font>, <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>);
+01092 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: Success to allocate %.1f Mo of AGP VAR Ram"</font>, agpMem / 1000000.f);
+01093 <font class="keywordflow">break</font>;
+01094 }
+01095 <font class="keywordflow">else</font>
+01096 {
+01097 agpMem/=2;
+01098 agpMem &amp;=~15;
+01099 }
+01100 }
+01101
+01102 <font class="keywordflow">if</font>(agpMem&lt; <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
+01103 {
+01104 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: %.d vertices supported"</font>, <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>);
+01105 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: Failed to allocate %.1f Mo of AGP VAR Ram"</font>, <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a> / 1000000.f);
+01106 ok= <font class="keyword">false</font>;
+01107 }
+01108 }
+01109
+01110
+01111 <font class="comment">// Try to allocate VRAMMemory.</font>
+01112 <font class="keywordflow">if</font>(vramMem&gt;0)
+01113 {
+01114 vramMem&amp;= ~15; <font class="comment">// ensure 16-bytes aligned mem count (maybe usefull :) ).</font>
+01115 vramMem= max(vramMem, (uint)<a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>);
+01116 <font class="keywordflow">while</font>(vramMem&gt;= <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
+01117 {
+01118 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>-&gt;allocate(vramMem, IDriver::VBHardVRAM))
+01119 <font class="keywordflow">break</font>;
+01120 <font class="keywordflow">else</font>
+01121 {
+01122 vramMem/=2;
+01123 vramMem &amp;=~15;
+01124 }
+01125 }
+01126
+01127 <font class="keywordflow">if</font>(vramMem&lt; <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
+01128 {
+01129 ok= <font class="keyword">false</font>;
+01130 }
+01131 }
+01132
+01133
+01134 <font class="keywordflow">return</font> ok;
+01135 }
+01136
+01137
+01138 <font class="comment">// ***************************************************************************</font>
+<a name="l01139"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">01139</a> <font class="keywordtype">void</font> CDriverGL::fenceOnCurVBHardIfNeeded(IVertexBufferHardGL *newVBHard)
+01140 {
+01141 <font class="comment">// If old is not a VBHard, or if not a NVidia VBHard, no-op.</font>
+01142 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>==NULL || !<a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>-&gt;NVidiaVertexBufferHard )
+01143 <font class="keywordflow">return</font>;
+01144
+01145 <font class="comment">// if we do not activate the same (NB: newVBHard==NULL if not a VBHard).</font>
+01146 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>!=newVBHard)
+01147 {
+01148 <font class="comment">// get NVidia interface</font>
+01149 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_13">CVertexBufferHardGLNVidia</a> *vbHardNV= static_cast&lt;CVertexBufferHardGLNVidia*&gt;(_CurrentVertexBufferHard);
+01150
+01151 <font class="comment">// If some render() have been done with this VB.</font>
+01152 <font class="keywordflow">if</font>( vbHardNV-&gt;GPURenderingAfterFence )
+01153 {
+01154 <font class="comment">// If an old fence is activated, we wait for him.</font>
+01155 <font class="comment">/* NB: performance issue: maybe a wait for nothing in some cases like this one:</font>
+01156 <font class="comment"> render with VBHard_A ---- end with a fence</font>
+01157 <font class="comment"> render with VBHard_B ....</font>
+01158 <font class="comment"> render with VBHard_A ---- end: must finish prec fence before setting a new one.</font>
+01159 <font class="comment"></font>
+01160 <font class="comment"> This is not a hard issue, if we suppose first A is finished to be rendered during render of VBHard_B.</font>
+01161 <font class="comment"> */</font>
+01162 vbHardNV-&gt;finishFence();
+01163 <font class="comment">// Since we won't work with this VB for a long time, we set a fence.</font>
+01164 vbHardNV-&gt;setFence();
+01165 vbHardNV-&gt;GPURenderingAfterFence= <font class="keyword">false</font>;
+01166 }
+01167 }
+01168 }
+01169
+01170
+01171 } <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>