diff options
Diffstat (limited to 'docs/doxygen/nel/dru_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/dru_8cpp-source.html | 527 |
1 files changed, 527 insertions, 0 deletions
diff --git a/docs/doxygen/nel/dru_8cpp-source.html b/docs/doxygen/nel/dru_8cpp-source.html new file mode 100644 index 00000000..76a6e016 --- /dev/null +++ b/docs/doxygen/nel/dru_8cpp-source.html @@ -0,0 +1,527 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>dru.cpp</h1><a href="dru_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font> +00029 +00030 <font class="preprocessor">#include "<a class="code" href="dru_8h.html">3d/dru.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font> +00035 +00036 +00037 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +00038 <font class="preprocessor"></font> +00039 <font class="preprocessor">#include <windows.h></font> +00040 +00041 <font class="preprocessor">#else // NL_OS_WINDOWS</font> +00042 <font class="preprocessor"></font> +00043 <font class="preprocessor">#include <dlfcn.h></font> +00044 +00045 <font class="preprocessor">#endif // NL_OS_WINDOWS</font> +00046 <font class="preprocessor"></font> +00047 <font class="keyword">namespace </font>NL3D +00048 { +00049 +00050 +00051 <font class="keyword">typedef</font> IDriver* (*IDRV_CREATE_PROC)(void); +00052 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a31">IDRV_CREATE_PROC_NAME</a> = <font class="stringliteral">"NL3D_createIDriverInstance"</font>; +00053 +00054 <font class="keyword">typedef</font> <a class="code" href="memory__common_8h.html#a11">uint32</a> (*<a class="code" href="namespaceNL3D.html#a32">IDRV_VERSION_PROC</a>)(void); +00055 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a33">IDRV_VERSION_PROC_NAME</a> = <font class="stringliteral">"NL3D_interfaceVersion"</font>; +00056 +00057 +00058 <font class="comment">// ***************************************************************************</font> +<a name="l00059"></a><a class="code" href="classNL3D_1_1CDRU.html#d0">00059</a> IDriver *CDRU::createGlDriver() <font class="keywordflow">throw</font> (EDru) +00060 { +00061 <a class="code" href="namespaceNL3D.html#a30">IDRV_CREATE_PROC</a> createDriver = NULL; +00062 <a class="code" href="namespaceNL3D.html#a32">IDRV_VERSION_PROC</a> versionDriver = NULL; +00063 +00064 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +00065 <font class="preprocessor"></font> +00066 <font class="comment">// WINDOWS code.</font> +00067 HINSTANCE hInst; +00068 +00069 hInst=LoadLibrary(NL3D_DLL_NAME); +00070 +00071 <font class="keywordflow">if</font> (!hInst) +00072 { +00073 <font class="keywordflow">throw</font> EDruOpenglDriverNotFound(); +00074 } +00075 +00076 <font class="keywordtype">char</font> buffer[1024], *ptr; +00077 SearchPath (NULL, NL3D_DLL_NAME, NULL, 1023, buffer, &ptr); +00078 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Using the library '"</font>NL3D_DLL_NAME<font class="stringliteral">"' that is in the directory: '%s'"</font>, buffer); +00079 +00080 createDriver = (IDRV_CREATE_PROC) GetProcAddress (hInst, <a class="code" href="namespaceNL3D.html#a31">IDRV_CREATE_PROC_NAME</a>); +00081 <font class="keywordflow">if</font> (createDriver == NULL) +00082 { +00083 <font class="keywordflow">throw</font> EDruOpenglDriverCorrupted(); +00084 } +00085 +00086 versionDriver = (IDRV_VERSION_PROC) GetProcAddress (hInst, <a class="code" href="namespaceNL3D.html#a33">IDRV_VERSION_PROC_NAME</a>); +00087 <font class="keywordflow">if</font> (versionDriver != NULL) +00088 { +00089 <font class="keywordflow">if</font> (versionDriver()<IDriver::InterfaceVersion) +00090 <font class="keywordflow">throw</font> EDruOpenglDriverOldVersion(); +00091 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (versionDriver()>IDriver::InterfaceVersion) +00092 <font class="keywordflow">throw</font> EDruOpenglDriverUnknownVersion(); +00093 } +00094 +00095 <font class="preprocessor">#elif defined (NL_OS_UNIX)</font> +00096 <font class="preprocessor"></font> +00097 <font class="keywordtype">void</font> *handle = dlopen(NL3D_DLL_NAME, RTLD_NOW); +00098 +00099 <font class="keywordflow">if</font> (handle == NULL) +00100 { +00101 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"when loading dynamic library '%s': %s"</font>, NL3D_DLL_NAME, dlerror()); +00102 <font class="keywordflow">throw</font> EDruOpenglDriverNotFound(); +00103 } +00104 +00105 <font class="comment">/* Not ANSI. Might produce a warning */</font> +00106 createDriver = (IDRV_CREATE_PROC) dlsym (handle, <a class="code" href="namespaceNL3D.html#a31">IDRV_CREATE_PROC_NAME</a>); +00107 <font class="keywordflow">if</font> (createDriver == NULL) +00108 { +00109 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"when getting function in dynamic library '%s': %s"</font>, NL3D_DLL_NAME, dlerror()); +00110 <font class="keywordflow">throw</font> EDruOpenglDriverCorrupted(); +00111 } +00112 +00113 versionDriver = (IDRV_VERSION_PROC) dlsym (handle, <a class="code" href="namespaceNL3D.html#a33">IDRV_VERSION_PROC_NAME</a>); +00114 <font class="keywordflow">if</font> (versionDriver != NULL) +00115 { +00116 <font class="keywordflow">if</font> (versionDriver()<IDriver::InterfaceVersion) +00117 <font class="keywordflow">throw</font> EDruOpenglDriverOldVersion(); +00118 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (versionDriver()>IDriver::InterfaceVersion) +00119 <font class="keywordflow">throw</font> EDruOpenglDriverUnknownVersion(); +00120 } +00121 +00122 <font class="preprocessor">#else // NL_OS_LINUX</font> +00123 <font class="preprocessor"></font><font class="preprocessor">#error "Dynamic DLL loading not implemented!"</font> +00124 <font class="preprocessor"></font><font class="preprocessor">#endif // NL_OS_LINUX</font> +00125 <font class="preprocessor"></font> +00126 IDriver *ret= createDriver(); +00127 <font class="keywordflow">if</font> (ret == NULL) +00128 { +00129 <font class="keywordflow">throw</font> EDruOpenglDriverCantCreateDriver(); +00130 } +00131 <font class="keywordflow">return</font> ret; +00132 } +00133 +00134 +00135 <font class="comment">// ***************************************************************************</font> +<a name="l00136"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_0">00136</a> <font class="keywordtype">void</font> CDRU::drawBitmap (<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>, ITexture& texture, IDriver& driver, CViewport viewport, <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a286">blend</a>) +00137 { +00138 CMatrix mtx; +00139 mtx.identity(); +00140 driver.setupViewport (viewport); +00141 driver.setupViewMatrix (mtx); +00142 driver.setupModelMatrix (mtx); +00143 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00144 +00145 <font class="keyword">static</font> CMaterial mat; +00146 mat.initUnlit (); +00147 mat.setTexture (0, &texture); +00148 mat.setBlend(<a class="code" href="namespaceNLMISC.html#a286">blend</a>); +00149 +00150 <font class="keyword">static</font> CVertexBuffer vb; +00151 vb.setVertexFormat (CVertexBuffer::PositionFlag|CVertexBuffer::TexCoord0Flag); +00152 vb.setNumVertices (4); +00153 vb.setVertexCoord (0, CVector (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)); +00154 vb.setVertexCoord (1, CVector (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)); +00155 vb.setVertexCoord (2, CVector (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)); +00156 vb.setVertexCoord (3, CVector (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)); +00157 vb.setTexCoord (0, 0, 0.f, 1.f); +00158 vb.setTexCoord (1, 0, 1.f, 1.f); +00159 vb.setTexCoord (2, 0, 1.f, 0.f); +00160 vb.setTexCoord (3, 0, 0.f, 0.f); +00161 driver.activeVertexBuffer(vb); +00162 +00163 CPrimitiveBlock pb; +00164 pb.setNumQuad (1); +00165 pb.setQuad (0, 0, 1, 2, 3); +00166 +00167 driver.render(pb, mat); +00168 } +00169 +00170 +00171 <font class="comment">// ***************************************************************************</font> +<a name="l00172"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_1">00172</a> <font class="keywordtype">void</font> CDRU::drawLine (<font class="keywordtype">float</font> x0, <font class="keywordtype">float</font> y0, <font class="keywordtype">float</font> x1, <font class="keywordtype">float</font> y1, IDriver& driver, CRGBA col, CViewport viewport) +00173 { +00174 CMatrix mtx; +00175 mtx.identity(); +00176 driver.setupViewport (viewport); +00177 driver.setupViewMatrix (mtx); +00178 driver.setupModelMatrix (mtx); +00179 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00180 +00181 <font class="keyword">static</font> CMaterial mat; +00182 mat.initUnlit (); +00183 mat.setSrcBlend(CMaterial::srcalpha); +00184 mat.setDstBlend(CMaterial::invsrcalpha); +00185 mat.setBlend(<font class="keyword">true</font>); +00186 mat.setColor(col); +00187 +00188 <font class="keyword">static</font> CVertexBuffer vb; +00189 vb.setVertexFormat (CVertexBuffer::PositionFlag); +00190 vb.setNumVertices (2); +00191 vb.setVertexCoord (0, CVector (x0, 0, y0)); +00192 vb.setVertexCoord (1, CVector (x1, 0, y1)); +00193 driver.activeVertexBuffer(vb); +00194 +00195 CPrimitiveBlock pb; +00196 pb.setNumLine (1); +00197 pb.setLine (0, 0, 1); +00198 +00199 driver.render(pb, mat); +00200 } +00201 +00202 +00203 <font class="comment">// ***************************************************************************</font> +<a name="l00204"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_2">00204</a> <font class="keywordtype">void</font> CDRU::drawTriangle (<font class="keywordtype">float</font> x0, <font class="keywordtype">float</font> y0, <font class="keywordtype">float</font> x1, <font class="keywordtype">float</font> y1, <font class="keywordtype">float</font> x2, <font class="keywordtype">float</font> y2, IDriver& driver, CRGBA col, CViewport viewport) +00205 { +00206 CMatrix mtx; +00207 mtx.identity(); +00208 driver.setupViewport (viewport); +00209 driver.setupViewMatrix (mtx); +00210 driver.setupModelMatrix (mtx); +00211 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00212 +00213 <font class="keyword">static</font> CMaterial mat; +00214 mat.initUnlit(); +00215 mat.setSrcBlend(CMaterial::srcalpha); +00216 mat.setDstBlend(CMaterial::invsrcalpha); +00217 mat.setBlend(<font class="keyword">true</font>); +00218 mat.setColor(col); +00219 +00220 <font class="keyword">static</font> CVertexBuffer vb; +00221 vb.setVertexFormat (CVertexBuffer::PositionFlag); +00222 vb.setNumVertices (3); +00223 vb.setVertexCoord (0, CVector (x0, 0, y0)); +00224 vb.setVertexCoord (1, CVector (x1, 0, y1)); +00225 vb.setVertexCoord (2, CVector (x2, 0, y2)); +00226 driver.activeVertexBuffer(vb); +00227 +00228 CPrimitiveBlock pb; +00229 pb.setNumTri (1); +00230 pb.setTri (0, 0, 1, 2); +00231 +00232 driver.render(pb, mat); +00233 } +00234 +00235 +00236 +00237 <font class="comment">// ***************************************************************************</font> +<a name="l00238"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_3">00238</a> <font class="keywordtype">void</font> CDRU::drawQuad (<font class="keywordtype">float</font> x0, <font class="keywordtype">float</font> y0, <font class="keywordtype">float</font> x1, <font class="keywordtype">float</font> y1, IDriver& driver, CRGBA col, CViewport viewport) +00239 { +00240 CMatrix mtx; +00241 mtx.identity(); +00242 driver.setupViewport (viewport); +00243 driver.setupViewMatrix (mtx); +00244 driver.setupModelMatrix (mtx); +00245 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00246 +00247 <font class="keyword">static</font> CMaterial mat; +00248 mat.initUnlit(); +00249 mat.setSrcBlend(CMaterial::srcalpha); +00250 mat.setDstBlend(CMaterial::invsrcalpha); +00251 mat.setBlend(<font class="keyword">true</font>); +00252 mat.setColor(col); +00253 +00254 <font class="keyword">static</font> CVertexBuffer vb; +00255 vb.setVertexFormat (CVertexBuffer::PositionFlag); +00256 vb.setNumVertices (4); +00257 vb.setVertexCoord (0, CVector (x0, 0, y0)); +00258 vb.setVertexCoord (1, CVector (x1, 0, y0)); +00259 vb.setVertexCoord (2, CVector (x1, 0, y1)); +00260 vb.setVertexCoord (3, CVector (x0, 0, y1)); +00261 +00262 driver.activeVertexBuffer(vb); +00263 +00264 CPrimitiveBlock pb; +00265 pb.setNumQuad (1); +00266 pb.setQuad (0, 0, 1, 2, 3); +00267 +00268 driver.render(pb, mat); +00269 } +00270 +00271 +00272 <font class="comment">// ***************************************************************************</font> +<a name="l00273"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_5">00273</a> <font class="keywordtype">void</font> CDRU::drawQuad (<font class="keywordtype">float</font> xcenter, <font class="keywordtype">float</font> ycenter, <font class="keywordtype">float</font> radius, IDriver& driver, CRGBA col, CViewport viewport) +00274 { +00275 CMatrix mtx; +00276 mtx.identity(); +00277 driver.setupViewport (viewport); +00278 driver.setupViewMatrix (mtx); +00279 driver.setupModelMatrix (mtx); +00280 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00281 +00282 <font class="keyword">static</font> CMaterial mat; +00283 mat.initUnlit(); +00284 mat.setSrcBlend(CMaterial::srcalpha); +00285 mat.setDstBlend(CMaterial::invsrcalpha); +00286 mat.setBlend(<font class="keyword">true</font>); +00287 mat.setColor(col); +00288 +00289 <font class="keyword">static</font> CVertexBuffer vb; +00290 vb.setVertexFormat (CVertexBuffer::PositionFlag); +00291 vb.setNumVertices (4); +00292 vb.setVertexCoord (0, CVector (xcenter-radius, 0, ycenter-radius)); +00293 vb.setVertexCoord (1, CVector (xcenter+radius, 0, ycenter-radius)); +00294 vb.setVertexCoord (2, CVector (xcenter+radius, 0, ycenter+radius)); +00295 vb.setVertexCoord (3, CVector (xcenter-radius, 0, ycenter+radius)); +00296 +00297 driver.activeVertexBuffer(vb); +00298 +00299 CPrimitiveBlock pb; +00300 pb.setNumQuad (1); +00301 pb.setQuad (0, 0, 1, 2, 3); +00302 +00303 driver.render(pb, mat); +00304 } +00305 +00306 +00307 <font class="comment">// ***************************************************************************</font> +<a name="l00308"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_6">00308</a> <font class="keywordtype">void</font> CDRU::drawWiredQuad (<font class="keywordtype">float</font> x0, <font class="keywordtype">float</font> y0, <font class="keywordtype">float</font> x1, <font class="keywordtype">float</font> y1, IDriver& driver, CRGBA col, CViewport viewport) +00309 { +00310 <font class="comment">// v-left</font> +00311 CDRU::drawLine(x0,y0,x0,y1 ,driver,col,viewport); +00312 <font class="comment">// v-right</font> +00313 CDRU::drawLine(x1,y0,x1,y1 ,driver,col,viewport); +00314 <font class="comment">// h-up</font> +00315 CDRU::drawLine(x0,y1,x1,y1,driver,col,viewport); +00316 <font class="comment">// h-bottom</font> +00317 CDRU::drawLine(x0,y0,x1,y0,driver,col,viewport); +00318 } +00319 +00320 +00321 <font class="comment">// ***************************************************************************</font> +<a name="l00322"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_7">00322</a> <font class="keywordtype">void</font> CDRU::drawWiredQuad (<font class="keywordtype">float</font> xcenter, <font class="keywordtype">float</font> ycenter, <font class="keywordtype">float</font> radius, IDriver& driver, CRGBA col, CViewport viewport) +00323 { +00324 <font class="comment">// v-left</font> +00325 CDRU::drawLine(xcenter-radius,ycenter-radius,xcenter-radius,ycenter+radius,driver,col,viewport); +00326 <font class="comment">// v-right</font> +00327 CDRU::drawLine(xcenter+radius,ycenter-radius,xcenter+radius,ycenter+radius,driver,col,viewport); +00328 <font class="comment">// h-up</font> +00329 CDRU::drawLine(xcenter-radius,ycenter+radius,xcenter+radius,ycenter+radius,driver,col,viewport); +00330 <font class="comment">// h-bottom</font> +00331 CDRU::drawLine(xcenter-radius,ycenter-radius,xcenter+radius,ycenter-radius,driver,col,viewport); +00332 } +00333 +00334 +00335 <font class="comment">// ***************************************************************************</font> +<a name="l00336"></a><a class="code" href="classNL3D_1_1CDRU.html#z453_0">00336</a> <font class="keywordtype">void</font> CDRU::drawTrianglesUnlit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CTriangleUV.html">NLMISC::CTriangleUV</a> *trilist, sint ntris, CMaterial &mat, IDriver& driver) +00337 { +00338 <font class="keyword">static</font> CVertexBuffer vb; +00339 vb.setVertexFormat (CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag); +00340 vb.setNumVertices (ntris*3); +00341 +00342 <font class="keyword">static</font> CPrimitiveBlock pb; +00343 pb.setNumTri(ntris); +00344 +00345 <font class="keywordflow">for</font>(sint i=0;i<ntris;i++) +00346 { +00347 vb.setVertexCoord (i*3+0, trilist[i].V0); +00348 vb.setVertexCoord (i*3+1, trilist[i].V1); +00349 vb.setVertexCoord (i*3+2, trilist[i].V2); +00350 vb.setTexCoord (i*3+0, 0, trilist[i].Uv0); +00351 vb.setTexCoord (i*3+1, 0, trilist[i].Uv1); +00352 vb.setTexCoord (i*3+2, 0, trilist[i].Uv2); +00353 pb.setTri(i, i*3+0, i*3+1, i*3+2); +00354 } +00355 +00356 driver.activeVertexBuffer(vb); +00357 driver.render(pb, mat); +00358 } +00359 +00360 +00361 <font class="comment">// ***************************************************************************</font> +<a name="l00362"></a><a class="code" href="classNL3D_1_1CDRU.html#z453_1">00362</a> <font class="keywordtype">void</font> CDRU::drawTrianglesUnlit(<font class="keyword">const</font> std::vector<NLMISC::CTriangleUV> &trilist, CMaterial &mat, IDriver& driver) +00363 { +00364 <font class="keywordflow">if</font>(trilist.size()==0) +00365 <font class="keywordflow">return</font>; +00366 +00367 CDRU::drawTrianglesUnlit( &(*trilist.begin()), trilist.size(), mat, driver); +00368 } +00369 +00370 +00371 <font class="comment">// ***************************************************************************</font> +<a name="l00372"></a><a class="code" href="classNL3D_1_1CDRU.html#z453_2">00372</a> <font class="keywordtype">void</font> CDRU::drawLinesUnlit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CLine.html">NLMISC::CLine</a> *linelist, sint nlines, CMaterial &mat, IDriver& driver) +00373 { +00374 <font class="keyword">static</font> CVertexBuffer vb; +00375 vb.setVertexFormat (CVertexBuffer::PositionFlag); +00376 vb.setNumVertices (nlines*2); +00377 +00378 <font class="keyword">static</font> CPrimitiveBlock pb; +00379 pb.setNumLine(nlines); +00380 +00381 <font class="keywordflow">for</font>(sint i=0;i<nlines;i++) +00382 { +00383 vb.setVertexCoord (i*2+0, linelist[i].V0); +00384 vb.setVertexCoord (i*2+1, linelist[i].V1); +00385 pb.setLine(i, i*2+0, i*2+1); +00386 } +00387 +00388 driver.activeVertexBuffer(vb); +00389 driver.render(pb, mat); +00390 } +00391 <font class="comment">// ***************************************************************************</font> +<a name="l00392"></a><a class="code" href="classNL3D_1_1CDRU.html#z453_3">00392</a> <font class="keywordtype">void</font> CDRU::drawLinesUnlit(<font class="keyword">const</font> std::vector<NLMISC::CLine> &linelist, CMaterial &mat, IDriver& driver) +00393 { +00394 <font class="keywordflow">if</font>(linelist.size()==0) +00395 <font class="keywordflow">return</font>; +00396 CDRU::drawLinesUnlit( &(*linelist.begin()), linelist.size(), mat, driver); +00397 } +00398 <font class="comment">// ***************************************************************************</font> +<a name="l00399"></a><a class="code" href="classNL3D_1_1CDRU.html#z453_4">00399</a> <font class="keywordtype">void</font> CDRU::drawLine(<font class="keyword">const</font> CVector &a, <font class="keyword">const</font> CVector &b, CRGBA color, IDriver& driver) +00400 { +00401 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CLine.html">NLMISC::CLine</a> line; +00402 <font class="keyword">static</font> CMaterial mat; +00403 <font class="keyword">static</font> <font class="keywordtype">bool</font> inited= <font class="keyword">false</font>; +00404 +00405 <font class="comment">// Setup material.</font> +00406 <font class="keywordflow">if</font>(!inited) +00407 { +00408 inited= <font class="keyword">true</font>; +00409 mat.initUnlit(); +00410 } +00411 mat.setColor(color); +00412 +00413 +00414 line.<a class="code" href="classNLMISC_1_1CLine.html#m0">V0</a>= a; +00415 line.<a class="code" href="classNLMISC_1_1CLine.html#m1">V1</a>= b; +00416 CDRU::drawLinesUnlit(&line, 1, mat, driver); +00417 } +00418 <font class="comment">// ***************************************************************************</font> +<a name="l00419"></a><a class="code" href="classNL3D_1_1CDRU.html#z452_4">00419</a> <font class="keywordtype">void</font> CDRU::drawQuad (<font class="keywordtype">float</font> x0, <font class="keywordtype">float</font> y0, <font class="keywordtype">float</font> x1, <font class="keywordtype">float</font> y1, CRGBA col0, CRGBA col1, CRGBA col2, CRGBA col3, IDriver& driver, CViewport viewport) +00420 { +00421 CMatrix mtx; +00422 mtx.identity(); +00423 driver.setupViewport (viewport); +00424 driver.setupViewMatrix (mtx); +00425 driver.setupModelMatrix (mtx); +00426 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>); +00427 +00428 <font class="keyword">static</font> CMaterial mat; +00429 mat.initUnlit(); +00430 mat.setSrcBlend(CMaterial::srcalpha); +00431 mat.setDstBlend(CMaterial::invsrcalpha); +00432 mat.setBlend(<font class="keyword">true</font>); +00433 +00434 <font class="keyword">static</font> CVertexBuffer vb; +00435 vb.setVertexFormat (CVertexBuffer::PositionFlag|CVertexBuffer::PrimaryColorFlag); +00436 vb.setNumVertices (4); +00437 vb.setVertexCoord (0, CVector (x0, 0, y0)); +00438 vb.setColor (0, col0); +00439 vb.setVertexCoord (1, CVector (x1, 0, y0)); +00440 vb.setColor (1, col1); +00441 vb.setVertexCoord (2, CVector (x1, 0, y1)); +00442 vb.setColor (2, col2); +00443 vb.setVertexCoord (3, CVector (x0, 0, y1)); +00444 vb.setColor (3, col3); +00445 +00446 driver.activeVertexBuffer(vb); +00447 +00448 CPrimitiveBlock pb; +00449 pb.setNumQuad (1); +00450 pb.setQuad (0, 0, 1, 2, 3); +00451 +00452 driver.render(pb, mat); +00453 } +00454 +00455 +00456 +00457 } <font class="comment">// NL3D</font> +00458 +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |