1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
<!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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><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="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/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="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.2 on Wed May 30 22:01:08 2001 -->
<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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>dru.cpp</h1><a href="dru_cpp.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="types_nl_h.html">nel/misc/types_nl.h</a>"</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="dru_h.html">nel/3d/dru.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="driver_h.html">nel/3d/driver.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="material_h.html">nel/3d/material.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="vertex_buffer_h.html">nel/3d/vertex_buffer.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="primitive_block_h.html">nel/3d/primitive_block.h</a>"</font>
00033
00034
00035 <font class="preprocessor">#ifdef NL_OS_WINDOWS
</font>00036 <font class="preprocessor"></font>
00037 <font class="preprocessor">#include <windows.h></font>
00038
00039 <font class="preprocessor">#else // NL_OS_WINDOWS
</font>00040 <font class="preprocessor"></font>
00041 <font class="preprocessor">#include <dlfcn.h></font>
00042
00043 <font class="preprocessor">#endif // NL_OS_WINDOWS
</font>00044 <font class="preprocessor"></font>
00045 <font class="keyword">namespace</font> NL3D
00046 {
00047
00048
00049 <font class="keyword">typedef</font> IDriver* (*IDRV_CREATE_PROC)(<font class="keywordtype">void</font>);
<a name="l00050"></a><a class="code" href="namespace_NL3D.html#a128">00050</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *IDRV_CREATE_PROC_NAME = <font class="stringliteral">"NL3D_createIDriverInstance"</font>;
00051
00052 <font class="keyword">typedef</font> <a class="code" href="types_nl_h.html#a9">uint32</a> (*IDRV_VERSION_PROC)(<font class="keywordtype">void</font>);
<a name="l00053"></a><a class="code" href="namespace_NL3D.html#a130">00053</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *IDRV_VERSION_PROC_NAME = <font class="stringliteral">"NL3D_interfaceVersion"</font>;
00054
00055
00056 <font class="comment">// ***************************************************************************</font>
<a name="l00057"></a><a class="code" href="class_NL3D__CDRU.html#d0">00057</a> IDriver *CDRU::createGlDriver() <font class="keywordflow">throw</font> (EDru)
00058 {
00059 IDRV_CREATE_PROC createDriver = NULL;
00060 IDRV_VERSION_PROC versionDriver = NULL;
00061
00062 <font class="preprocessor">#ifdef NL_OS_WINDOWS
</font>00063 <font class="preprocessor"></font>
00064 <font class="comment">// WINDOWS code.</font>
00065 HINSTANCE hInst;
00066
00067 hInst=LoadLibrary(NL3D_DLL_NAME);
00068
00069 <font class="keywordflow">if</font> (!hInst)
00070 {
00071 <font class="keywordflow">throw</font> EDruOpenglDriverNotFound();
00072 }
00073
00074 createDriver = (IDRV_CREATE_PROC) GetProcAddress (hInst, IDRV_CREATE_PROC_NAME);
00075 <font class="keywordflow">if</font> (createDriver == NULL)
00076 {
00077 <font class="keywordflow">throw</font> EDruOpenglDriverCorrupted();
00078 }
00079
00080 versionDriver = (IDRV_VERSION_PROC) GetProcAddress (hInst, IDRV_VERSION_PROC_NAME);
00081 <font class="keywordflow">if</font> (versionDriver != NULL)
00082 {
00083 <font class="keywordflow">if</font> (versionDriver()<IDriver::InterfaceVersion)
00084 <font class="keywordflow">throw</font> EDruOpenglDriverOldVersion();
00085 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (versionDriver()>IDriver::InterfaceVersion)
00086 <font class="keywordflow">throw</font> EDruOpenglDriverUnknownVersion();
00087 }
00088
00089 <font class="preprocessor">#elif defined (NL_OS_UNIX)
</font>00090 <font class="preprocessor"></font>
00091 <font class="keywordtype">void</font> *handle = dlopen(NL3D_DLL_NAME, RTLD_NOW);
00092
00093 <font class="keywordflow">if</font> (handle == NULL)
00094 {
00095 <a class="code" href="debug_h.html#a2">nlwarning</a> (<font class="stringliteral">"when loading dynamic library '%s': %s"</font>, NL3D_DLL_NAME, dlerror());
00096 <font class="keywordflow">throw</font> EDruOpenglDriverNotFound();
00097 }
00098
00099 <font class="comment">/* Not ANSI. Might produce a warning */</font>
00100 createDriver = (IDRV_CREATE_PROC) dlsym (handle, IDRV_CREATE_PROC_NAME);
00101 <font class="keywordflow">if</font> (createDriver == NULL)
00102 {
00103 <a class="code" href="debug_h.html#a2">nlwarning</a> (<font class="stringliteral">"when getting function in dynamic library '%s': %s"</font>, NL3D_DLL_NAME, dlerror());
00104 <font class="keywordflow">throw</font> EDruOpenglDriverCorrupted();
00105 }
00106
00107 versionDriver = (IDRV_VERSION_PROC) dlsym (handle, IDRV_VERSION_PROC_NAME);
00108 <font class="keywordflow">if</font> (versionDriver != NULL)
00109 {
00110 <font class="keywordflow">if</font> (versionDriver()<IDriver::InterfaceVersion)
00111 <font class="keywordflow">throw</font> EDruOpenglDriverOldVersion();
00112 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (versionDriver()>IDriver::InterfaceVersion)
00113 <font class="keywordflow">throw</font> EDruOpenglDriverUnknownVersion();
00114 }
00115
00116 <font class="preprocessor">#else // NL_OS_LINUX
</font>00117 <font class="preprocessor"></font><font class="preprocessor">#error "Dynamic DLL loading not implemented!"
</font>00118 <font class="preprocessor"></font><font class="preprocessor">#endif // NL_OS_LINUX
</font>00119 <font class="preprocessor"></font>
00120 IDriver *ret= createDriver();
00121 <font class="keywordflow">if</font> (ret == NULL)
00122 {
00123 <font class="keywordflow">throw</font> EDruOpenglDriverCantCreateDriver();
00124 }
00125 <font class="keywordflow">return</font> ret;
00126 }
00127
00128
00129 <font class="comment">// ***************************************************************************</font>
<a name="l00130"></a><a class="code" href="class_NL3D__CDRU.html#d1">00130</a> <font class="keywordtype">void</font> CDRU::drawBitmap (<font class="keywordtype">float</font> x, <font class="keywordtype">float</font> y, <font class="keywordtype">float</font> width, <font class="keywordtype">float</font> height, ITexture& texture, IDriver& driver, CViewport viewport, <font class="keywordtype">bool</font> blend)<font class="keyword">
</font>00131 <font class="keyword"></font>{
00132 CMatrix mtx;
00133 mtx.identity();
00134 driver.setupViewport (viewport);
00135 driver.setupViewMatrix (mtx);
00136 driver.setupModelMatrix (mtx);
00137 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00138
00139 <font class="keyword">static</font> CMaterial mat;
00140 mat.initUnlit ();
00141 mat.setTexture (0, &texture);
00142 mat.setBlend(blend);
00143
00144 <font class="keyword">static</font> CVertexBuffer vb;
00145 vb.setVertexFormat (IDRV_VF_XYZ|IDRV_VF_UV[0]);
00146 vb.setNumVertices (4);
00147 vb.setVertexCoord (0, CVector (x, 0, y));
00148 vb.setVertexCoord (1, CVector (x+width, 0, y));
00149 vb.setVertexCoord (2, CVector (x+width, 0, y+height));
00150 vb.setVertexCoord (3, CVector (x, 0, y+height));
00151 vb.setTexCoord (0, 0, 0.f, 1.f);
00152 vb.setTexCoord (1, 0, 1.f, 1.f);
00153 vb.setTexCoord (2, 0, 1.f, 0.f);
00154 vb.setTexCoord (3, 0, 0.f, 0.f);
00155 driver.activeVertexBuffer(vb);
00156
00157 CPrimitiveBlock pb;
00158 pb.setNumQuad (1);
00159 pb.setQuad (0, 0, 1, 2, 3);
00160
00161 driver.render(pb, mat);
00162 }
00163
00164
00165 <font class="comment">// ***************************************************************************</font>
<a name="l00166"></a><a class="code" href="class_NL3D__CDRU.html#d2">00166</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)<font class="keyword">
</font>00167 <font class="keyword"></font>{
00168 CMatrix mtx;
00169 mtx.identity();
00170 driver.setupViewport (viewport);
00171 driver.setupViewMatrix (mtx);
00172 driver.setupModelMatrix (mtx);
00173 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00174
00175 <font class="keyword">static</font> CMaterial mat;
00176 mat.initUnlit ();
00177 mat.setSrcBlend(CMaterial::srcalpha);
00178 mat.setDstBlend(CMaterial::invsrcalpha);
00179 mat.setBlend(<font class="keyword">true</font>);
00180 mat.setColor(col);
00181
00182 <font class="keyword">static</font> CVertexBuffer vb;
00183 vb.setVertexFormat (IDRV_VF_XYZ);
00184 vb.setNumVertices (2);
00185 vb.setVertexCoord (0, CVector (x0, 0, y0));
00186 vb.setVertexCoord (1, CVector (x1, 0, y1));
00187 driver.activeVertexBuffer(vb);
00188
00189 CPrimitiveBlock pb;
00190 pb.setNumLine (1);
00191 pb.setLine (0, 0, 1);
00192
00193 driver.render(pb, mat);
00194 }
00195
00196
00197 <font class="comment">// ***************************************************************************</font>
<a name="l00198"></a><a class="code" href="class_NL3D__CDRU.html#d3">00198</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)<font class="keyword">
</font>00199 <font class="keyword"></font>{
00200 CMatrix mtx;
00201 mtx.identity();
00202 driver.setupViewport (viewport);
00203 driver.setupViewMatrix (mtx);
00204 driver.setupModelMatrix (mtx);
00205 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00206
00207 <font class="keyword">static</font> CMaterial mat;
00208 mat.initUnlit();
00209 mat.setSrcBlend(CMaterial::srcalpha);
00210 mat.setDstBlend(CMaterial::invsrcalpha);
00211 mat.setBlend(<font class="keyword">true</font>);
00212 mat.setColor(col);
00213
00214 <font class="keyword">static</font> CVertexBuffer vb;
00215 vb.setVertexFormat (IDRV_VF_XYZ);
00216 vb.setNumVertices (3);
00217 vb.setVertexCoord (0, CVector (x0, 0, y0));
00218 vb.setVertexCoord (1, CVector (x1, 0, y1));
00219 vb.setVertexCoord (2, CVector (x2, 0, y2));
00220 driver.activeVertexBuffer(vb);
00221
00222 CPrimitiveBlock pb;
00223 pb.setNumTri (1);
00224 pb.setTri (0, 0, 1, 2);
00225
00226 driver.render(pb, mat);
00227 }
00228
00229
00230
00231 <font class="comment">// ***************************************************************************</font>
<a name="l00232"></a><a class="code" href="class_NL3D__CDRU.html#d4">00232</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)<font class="keyword">
</font>00233 <font class="keyword"></font>{
00234 CMatrix mtx;
00235 mtx.identity();
00236 driver.setupViewport (viewport);
00237 driver.setupViewMatrix (mtx);
00238 driver.setupModelMatrix (mtx);
00239 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00240
00241 <font class="keyword">static</font> CMaterial mat;
00242 mat.initUnlit();
00243 mat.setSrcBlend(CMaterial::srcalpha);
00244 mat.setDstBlend(CMaterial::invsrcalpha);
00245 mat.setBlend(<font class="keyword">true</font>);
00246 mat.setColor(col);
00247
00248 <font class="keyword">static</font> CVertexBuffer vb;
00249 vb.setVertexFormat (IDRV_VF_XYZ);
00250 vb.setNumVertices (4);
00251 vb.setVertexCoord (0, CVector (x0, 0, y0));
00252 vb.setVertexCoord (1, CVector (x1, 0, y0));
00253 vb.setVertexCoord (2, CVector (x1, 0, y1));
00254 vb.setVertexCoord (3, CVector (x0, 0, y1));
00255
00256 driver.activeVertexBuffer(vb);
00257
00258 CPrimitiveBlock pb;
00259 pb.setNumQuad (1);
00260 pb.setQuad (0, 0, 1, 2, 3);
00261
00262 driver.render(pb, mat);
00263 }
00264
00265
00266 <font class="comment">// ***************************************************************************</font>
<a name="l00267"></a><a class="code" href="class_NL3D__CDRU.html#d6">00267</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)<font class="keyword">
</font>00268 <font class="keyword"></font>{
00269 CMatrix mtx;
00270 mtx.identity();
00271 driver.setupViewport (viewport);
00272 driver.setupViewMatrix (mtx);
00273 driver.setupModelMatrix (mtx);
00274 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00275
00276 <font class="keyword">static</font> CMaterial mat;
00277 mat.initUnlit();
00278 mat.setSrcBlend(CMaterial::srcalpha);
00279 mat.setDstBlend(CMaterial::invsrcalpha);
00280 mat.setBlend(<font class="keyword">true</font>);
00281 mat.setColor(col);
00282
00283 <font class="keyword">static</font> CVertexBuffer vb;
00284 vb.setVertexFormat (IDRV_VF_XYZ);
00285 vb.setNumVertices (4);
00286 vb.setVertexCoord (0, CVector (xcenter-radius, 0, ycenter-radius));
00287 vb.setVertexCoord (1, CVector (xcenter+radius, 0, ycenter-radius));
00288 vb.setVertexCoord (2, CVector (xcenter+radius, 0, ycenter+radius));
00289 vb.setVertexCoord (3, CVector (xcenter-radius, 0, ycenter+radius));
00290
00291 driver.activeVertexBuffer(vb);
00292
00293 CPrimitiveBlock pb;
00294 pb.setNumQuad (1);
00295 pb.setQuad (0, 0, 1, 2, 3);
00296
00297 driver.render(pb, mat);
00298 }
00299
00300
00301 <font class="comment">// ***************************************************************************</font>
<a name="l00302"></a><a class="code" href="class_NL3D__CDRU.html#d7">00302</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)<font class="keyword">
</font>00303 <font class="keyword"></font>{
00304 <font class="comment">// v-left</font>
00305 CDRU::drawLine(x0,y0,x0,y1 ,driver,col,viewport);
00306 <font class="comment">// v-right</font>
00307 CDRU::drawLine(x1,y0,x1,y1 ,driver,col,viewport);
00308 <font class="comment">// h-up</font>
00309 CDRU::drawLine(x0,y1,x1,y1,driver,col,viewport);
00310 <font class="comment">// h-bottom</font>
00311 CDRU::drawLine(x0,y0,x1,y0,driver,col,viewport);
00312 }
00313
00314
00315 <font class="comment">// ***************************************************************************</font>
<a name="l00316"></a><a class="code" href="class_NL3D__CDRU.html#d8">00316</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)<font class="keyword">
</font>00317 <font class="keyword"></font>{
00318 <font class="comment">// v-left</font>
00319 CDRU::drawLine(xcenter-radius,ycenter-radius,xcenter-radius,ycenter+radius,driver,col,viewport);
00320 <font class="comment">// v-right</font>
00321 CDRU::drawLine(xcenter+radius,ycenter-radius,xcenter+radius,ycenter+radius,driver,col,viewport);
00322 <font class="comment">// h-up</font>
00323 CDRU::drawLine(xcenter-radius,ycenter+radius,xcenter+radius,ycenter+radius,driver,col,viewport);
00324 <font class="comment">// h-bottom</font>
00325 CDRU::drawLine(xcenter-radius,ycenter-radius,xcenter+radius,ycenter-radius,driver,col,viewport);
00326 }
00327
00328
00329 <font class="comment">// ***************************************************************************</font>
<a name="l00330"></a><a class="code" href="class_NL3D__CDRU.html#d9">00330</a> <font class="keywordtype">void</font> CDRU::drawTrianglesUnlit(<font class="keyword">const</font> <a class="code" href="class_NLMISC__CTriangleUV.html">NLMISC::CTriangleUV</a> *trilist, sint ntris, CMaterial &mat, IDriver& driver)<font class="keyword">
</font>00331 <font class="keyword"></font>{
00332 <font class="keyword">static</font> CVertexBuffer vb;
00333 vb.setVertexFormat (IDRV_VF_XYZ | IDRV_VF_UV[0]);
00334 vb.setNumVertices (ntris*3);
00335
00336 <font class="keyword">static</font> CPrimitiveBlock pb;
00337 pb.setNumTri(ntris);
00338
00339 <font class="keywordflow">for</font>(sint i=0;i<ntris;i++)
00340 {
00341 vb.setVertexCoord (i*3+0, trilist[i].V0);
00342 vb.setVertexCoord (i*3+1, trilist[i].V1);
00343 vb.setVertexCoord (i*3+2, trilist[i].V2);
00344 vb.setTexCoord (i*3+0, 0, trilist[i].Uv0);
00345 vb.setTexCoord (i*3+1, 0, trilist[i].Uv1);
00346 vb.setTexCoord (i*3+2, 0, trilist[i].Uv2);
00347 pb.setTri(i, i*3+0, i*3+1, i*3+2);
00348 }
00349
00350 driver.activeVertexBuffer(vb);
00351 driver.render(pb, mat);
00352 }
00353
00354
00355 <font class="comment">// ***************************************************************************</font>
<a name="l00356"></a><a class="code" href="class_NL3D__CDRU.html#d10">00356</a> <font class="keywordtype">void</font> CDRU::drawTrianglesUnlit(<font class="keyword">const</font> std::vector<NLMISC::CTriangleUV> &trilist, CMaterial &mat, IDriver& driver)<font class="keyword">
</font>00357 <font class="keyword"></font>{
00358 <font class="keywordflow">if</font>(trilist.<a class="code" href="lexlang_cpp.html#a56">size</a>()==0)
00359 <font class="keywordflow">return</font>;
00360
00361 CDRU::drawTrianglesUnlit( &(*trilist.begin()), trilist.<a class="code" href="lexlang_cpp.html#a56">size</a>(), mat, driver);
00362 }
00363
00364
00365 <font class="comment">// ***************************************************************************</font>
<a name="l00366"></a><a class="code" href="class_NL3D__CDRU.html#d11">00366</a> <font class="keywordtype">void</font> CDRU::drawLinesUnlit(<font class="keyword">const</font> <a class="code" href="class_NLMISC__CLine.html">NLMISC::CLine</a> *linelist, sint nlines, CMaterial &mat, IDriver& driver)<font class="keyword">
</font>00367 <font class="keyword"></font>{
00368 <font class="keyword">static</font> CVertexBuffer vb;
00369 vb.setVertexFormat (IDRV_VF_XYZ);
00370 vb.setNumVertices (nlines*2);
00371
00372 <font class="keyword">static</font> CPrimitiveBlock pb;
00373 pb.setNumLine(nlines);
00374
00375 <font class="keywordflow">for</font>(sint i=0;i<nlines;i++)
00376 {
00377 vb.setVertexCoord (i*2+0, linelist[i].V0);
00378 vb.setVertexCoord (i*2+1, linelist[i].V1);
00379 pb.setLine(i, i*2+0, i*2+1);
00380 }
00381
00382 driver.activeVertexBuffer(vb);
00383 driver.render(pb, mat);
00384 }
00385 <font class="comment">// ***************************************************************************</font>
<a name="l00386"></a><a class="code" href="class_NL3D__CDRU.html#d12">00386</a> <font class="keywordtype">void</font> CDRU::drawLinesUnlit(<font class="keyword">const</font> std::vector<NLMISC::CLine> &linelist, CMaterial &mat, IDriver& driver)<font class="keyword">
</font>00387 <font class="keyword"></font>{
00388 <font class="keywordflow">if</font>(linelist.<a class="code" href="lexlang_cpp.html#a56">size</a>()==0)
00389 <font class="keywordflow">return</font>;
00390 CDRU::drawLinesUnlit( &(*linelist.begin()), linelist.<a class="code" href="lexlang_cpp.html#a56">size</a>(), mat, driver);
00391 }
00392 <font class="comment">// ***************************************************************************</font>
<a name="l00393"></a><a class="code" href="class_NL3D__CDRU.html#d13">00393</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)<font class="keyword">
</font>00394 <font class="keyword"></font>{
00395 <font class="keyword">static</font> <a class="code" href="class_NLMISC__CLine.html">NLMISC::CLine</a> line;
00396 <font class="keyword">static</font> CMaterial mat;
00397 <font class="keyword">static</font> <font class="keywordtype">bool</font> inited= <font class="keyword">false</font>;
00398
00399 <font class="comment">// Setup material.</font>
00400 <font class="keywordflow">if</font>(!inited)
00401 {
00402 inited= <font class="keyword">true</font>;
00403 mat.initUnlit();
00404 }
00405 mat.setColor(color);
00406
00407
00408 line.V0= a;
00409 line.V1= b;
00410 CDRU::drawLinesUnlit(&line, 1, mat, driver);
00411 }
00412 <font class="comment">// ***************************************************************************</font>
<a name="l00413"></a><a class="code" href="class_NL3D__CDRU.html#d5">00413</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)<font class="keyword">
</font>00414 <font class="keyword"></font>{
00415 CMatrix mtx;
00416 mtx.identity();
00417 driver.setupViewport (viewport);
00418 driver.setupViewMatrix (mtx);
00419 driver.setupModelMatrix (mtx);
00420 driver.setFrustum (0.f, 1.f, 0.f, 1.f, -1.f, 1.f, <font class="keyword">false</font>);
00421
00422 <font class="keyword">static</font> CMaterial mat;
00423 mat.initUnlit();
00424 mat.setSrcBlend(CMaterial::srcalpha);
00425 mat.setDstBlend(CMaterial::invsrcalpha);
00426 mat.setBlend(<font class="keyword">true</font>);
00427
00428 <font class="keyword">static</font> CVertexBuffer vb;
00429 vb.setVertexFormat (IDRV_VF_XYZ|IDRV_VF_COLOR);
00430 vb.setNumVertices (4);
00431 vb.setVertexCoord (0, CVector (x0, 0, y0));
00432 vb.setColor (0, col0);
00433 vb.setVertexCoord (1, CVector (x1, 0, y0));
00434 vb.setColor (1, col1);
00435 vb.setVertexCoord (2, CVector (x1, 0, y1));
00436 vb.setColor (2, col2);
00437 vb.setVertexCoord (3, CVector (x0, 0, y1));
00438 vb.setColor (3, col3);
00439
00440 driver.activeVertexBuffer(vb);
00441
00442 CPrimitiveBlock pb;
00443 pb.setNumQuad (1);
00444 pb.setQuad (0, 0, 1, 2, 3);
00445
00446 driver.render(pb, mat);
00447 }
00448
00449
00450
00451 } <font class="comment">// NL3D</font>
00452
</div></pre>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|