aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/driver__opengl__vertex__buffer__hard_8cpp-source.html
blob: 34ccd5cf2fa25f5858243e4b2868e4ed2e8636b2 (plain)
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
<!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>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><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="/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>
&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="/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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>driver_opengl_vertex_buffer_hard.cpp</h1><a href="driver__opengl__vertex__buffer__hard_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="stdopengl_8h.html">stdopengl.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="driver__opengl__vertex__buffer__hard_8h.html">driver_opengl_vertex_buffer_hard.h</a>"</font>
00029 
00030 
00031 <font class="keyword">using</font>   <font class="keyword">namespace </font>std;
00032 <font class="keyword">using</font>   <font class="keyword">namespace </font>NLMISC;
00033 
00034 <font class="keyword">namespace </font>NL3D 
00035 {
00036 
00037 
00038 
00039 <font class="comment">// ***************************************************************************</font>
00040 <font class="comment">// ***************************************************************************</font>
00041 <font class="comment">// ***************************************************************************</font>
00042 <font class="comment">//</font>
00043 <font class="comment">// VBHard interface for both NVidia / ATI extension.</font>
00044 <font class="comment">//</font>
00045 <font class="comment">// ***************************************************************************</font>
00046 <font class="comment">// ***************************************************************************</font>
00047 <font class="comment">// ***************************************************************************</font>
00048 
00049 
00050 
00051 <font class="comment">// ***************************************************************************</font>
<a name="l00052"></a><a class="code" href="classNL3D_1_1IVertexArrayRange.html#a0">00052</a> IVertexArrayRange::IVertexArrayRange(CDriverGL *drv)
00053 {
00054         <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>= drv;
00055 }
00056 <font class="comment">// ***************************************************************************</font>
<a name="l00057"></a><a class="code" href="classNL3D_1_1IVertexArrayRange.html#a1">00057</a> IVertexArrayRange::~IVertexArrayRange()
00058 {
00059 }
00060 
00061 <font class="comment">// ***************************************************************************</font>
<a name="l00062"></a><a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#a0">00062</a> IVertexBufferHardGL::IVertexBufferHardGL(CDriverGL *drv)
00063 {
00064         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>= drv;
00065         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m0">NVidiaVertexBufferHard</a>= <font class="keyword">false</font>;
00066         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m1">ATIVertexBufferHard</a>= <font class="keyword">false</font>;
00067         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m2">GPURenderingAfterFence</a>= <font class="keyword">false</font>;
00068 }
00069 <font class="comment">// ***************************************************************************</font>
<a name="l00070"></a><a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#a1">00070</a> IVertexBufferHardGL::~IVertexBufferHardGL()
00071 {
00072 }
00073 
00074 
00075 
00076 <font class="comment">// ***************************************************************************</font>
00077 <font class="comment">// ***************************************************************************</font>
00078 <font class="comment">// ***************************************************************************</font>
00079 <font class="comment">//</font>
00080 <font class="comment">// NVidia implementation</font>
00081 <font class="comment">//</font>
00082 <font class="comment">// ***************************************************************************</font>
00083 <font class="comment">// ***************************************************************************</font>
00084 <font class="comment">// ***************************************************************************</font>
00085 
00086 
00087 
00088 <font class="comment">// ***************************************************************************</font>
00089 <font class="comment">// CVertexArrayRangeNVidia</font>
00090 <font class="comment">// ***************************************************************************</font>
00091 
00092 
00093 <font class="comment">// ***************************************************************************</font>
<a name="l00094"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#a0">00094</a> CVertexArrayRangeNVidia::CVertexArrayRangeNVidia(CDriverGL *drv) : IVertexArrayRange(drv)
00095 {
00096         <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>= NULL;
00097         <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>= 0;
00098 }
00099 
00100 
00101 <font class="comment">// ***************************************************************************</font>
<a name="l00102"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#z423_0">00102</a> <font class="keywordtype">bool</font>                    CVertexArrayRangeNVidia::allocate(uint32 size, IDriver::TVBHardType vbType)
00103 {
00104         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>==NULL);
00105 
00106 <font class="preprocessor">#ifdef  NL_OS_WINDOWS</font>
00107 <font class="preprocessor"></font>        <font class="comment">// try to allocate AGP or VRAM data.</font>
00108         <font class="keywordflow">switch</font>(vbType)
00109         {
00110         <font class="keywordflow">case</font> IDriver::VBHardAGP: 
00111                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>= wglAllocateMemoryNV(size, 0, 0, 0.5f);
00112                 <font class="keywordflow">break</font>;
00113         <font class="keywordflow">case</font> IDriver::VBHardVRAM:
00114                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>= wglAllocateMemoryNV(size, 0, 0, 1.0f);
00115                 <font class="keywordflow">break</font>;
00116         };
00117 <font class="preprocessor">#endif  // NL_OS_WINDOWS</font>
00118 <font class="preprocessor"></font>
00119 
00120         <font class="comment">// init the allocator.</font>
00121         <font class="keywordflow">if</font>(_VertexArrayPtr)
00122         {
00123                 <font class="comment">/* Init with an alignment of 8. Not sure it is usefull, but GDC01_Performance.pdf papers talks about</font>
00124 <font class="comment">                  "Data arrays must be 8-byte aligned". Don't know what "Data" is.</font>
00125 <font class="comment">                */</font>
00126                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o2">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a3">initHeap</a>(<a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>, size, 8);
00127 
00128                 <font class="comment">// set the size</font>
00129                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>= size;
00130         }
00131 
00132 
00133         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>!=NULL;
00134 }
00135 
00136 
00137 <font class="comment">// ***************************************************************************</font>
<a name="l00138"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#z423_3">00138</a> uint                    CVertexArrayRangeNVidia::sizeAllocated()<font class="keyword"> const</font>
00139 <font class="keyword"></font>{
00140         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>;
00141 }
00142 
00143 
00144 <font class="comment">// ***************************************************************************</font>
<a name="l00145"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#z423_1">00145</a> <font class="keywordtype">void</font>                    CVertexArrayRangeNVidia::free()
00146 {
00147         <font class="comment">// release the ptr.</font>
00148         <font class="keywordflow">if</font>(_VertexArrayPtr)
00149         {
00150                 <font class="comment">// reset the allocator.</font>
00151                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o2">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a2">reset</a>();
00152 
00153 
00154                 <font class="comment">// Free special memory.</font>
00155 <font class="preprocessor">#ifdef  NL_OS_WINDOWS</font>
00156 <font class="preprocessor"></font>                wglFreeMemoryNV(<a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>);
00157 <font class="preprocessor">#endif  // NL_OS_WINDOWS</font>
00158 <font class="preprocessor"></font>
00159 
00160                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>= NULL;
00161                 <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>= 0;
00162         }
00163 }
00164 
00165 
00166 <font class="comment">// ***************************************************************************</font>
<a name="l00167"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#a1">00167</a> <font class="keywordtype">void</font>                    CVertexArrayRangeNVidia::enable()
00168 {
00169         <font class="comment">// if not already enabled.</font>
00170         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange!=<font class="keyword">this</font>)
00171         {
00172                 <font class="comment">// Setup the ptrs only if differnets from last time (may rarely happens)</font>
00173                 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_NVCurrentVARSize != <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a> || <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_NVCurrentVARPtr != <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>)
00174                 {
00175                         <font class="comment">// Yoyo: fucking NVidia Bug ?? must do this strange thing, this ensure that it is correclty setuped.</font>
00176                         glFinish();
00177                         <a class="code" href="driver__opengl__extension_8h.html#a42">nglVertexArrayRangeNV</a>(<a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>, <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>);
00178                         glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
00179                         glVertexPointer(3,GL_FLOAT, 0, <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>);
00180                         <font class="comment">// cache.</font>
00181                         <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_NVCurrentVARSize= <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o1">_VertexArraySize</a>;
00182                         <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_NVCurrentVARPtr= <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o0">_VertexArrayPtr</a>;
00183                 }
00184                 <font class="comment">// enable VAR. NB: flush is unesufull, so don't flush if extension is OK</font>
00185                 glEnableClientState(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_Extensions.NVStateVARWithoutFlush);
00186                 <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange= <font class="keyword">this</font>;
00187         }
00188 }
00189 
00190 
00191 <font class="comment">// ***************************************************************************</font>
<a name="l00192"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#a2">00192</a> <font class="keywordtype">void</font>                    CVertexArrayRangeNVidia::disable()
00193 {
00194         <font class="comment">// if not already disabled.</font>
00195         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange!=NULL)
00196         {
00197                 <font class="comment">// just disable the state, don't change VAR ptr setup.</font>
00198                 <font class="comment">// NB: flush is unesufull, so don't flush if extension is OK</font>
00199                 glDisableClientState(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_Extensions.NVStateVARWithoutFlush);
00200                 <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange= NULL;
00201         }
00202 }
00203 
00204 
00205 <font class="comment">// ***************************************************************************</font>
<a name="l00206"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#c1">00206</a> <font class="keywordtype">void</font>                    *CVertexArrayRangeNVidia::allocateVB(uint32 size)
00207 {
00208         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o2">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a6">allocate</a>(size);
00209 }
00210 
00211 
00212 <font class="comment">// ***************************************************************************</font>
<a name="l00213"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#a3">00213</a> <font class="keywordtype">void</font>                    CVertexArrayRangeNVidia::freeVB(<font class="keywordtype">void</font>    *ptr)
00214 {
00215         <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#o2">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a7">free</a>(ptr);
00216 }
00217 
00218 
00219 <font class="comment">// ***************************************************************************</font>
<a name="l00220"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#z423_2">00220</a> IVertexBufferHardGL             *CVertexArrayRangeNVidia::createVBHardGL(uint16 vertexFormat, <font class="keyword">const</font> uint8 *typeArray, uint32 numVertices)
00221 {
00222         <font class="comment">// create a NVidia VBHard</font>
00223         CVertexBufferHardGLNVidia       *newVbHard= <font class="keyword">new</font> CVertexBufferHardGLNVidia(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>);
00224 
00225         <font class="comment">// Init the format of the VB.</font>
00226         newVbHard-&gt;initFormat(vertexFormat, typeArray, numVertices);
00227 
00228         <font class="comment">// compute size to allocate.</font>
00229         uint32  size= newVbHard-&gt;getVertexSize() * newVbHard-&gt;getNumVertices();
00230 
00231         <font class="comment">// try to allocate</font>
00232         <font class="keywordtype">void</font>    *vertexPtr;
00233         <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#c0">allocated</a>() )
00234         {
00235                  vertexPtr= <a class="code" href="classNL3D_1_1CVertexArrayRangeNVidia.html#c1">allocateVB</a>(size);
00236         }
00237 
00238         <font class="comment">// If allocation fails.</font>
00239         <font class="keywordflow">if</font>( !vertexPtr )
00240         {
00241                 <font class="comment">// just destroy this object (no free()).</font>
00242                 <font class="keyword">delete</font> newVbHard;
00243                 <font class="keywordflow">return</font> NULL;
00244         }
00245         <font class="keywordflow">else</font>
00246         {
00247                 <font class="comment">// Ok, setup, and allocate the fence.</font>
00248                 newVbHard-&gt;initGL(<font class="keyword">this</font>, vertexPtr);
00249                 <font class="keywordflow">return</font> newVbHard;
00250         }
00251 }
00252 
00253 
00254 <font class="comment">// ***************************************************************************</font>
00255 <font class="comment">// CVertexBufferHardGLNVidia</font>
00256 <font class="comment">// ***************************************************************************</font>
00257 
00258 
00259 <font class="comment">// ***************************************************************************</font>
<a name="l00260"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a0">00260</a> CVertexBufferHardGLNVidia::CVertexBufferHardGLNVidia(CDriverGL *drv) : IVertexBufferHardGL(drv)
00261 {
00262         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>= NULL;
00263         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o1">_VertexPtr</a>= NULL;
00264 
00265         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m2">GPURenderingAfterFence</a>= <font class="keyword">false</font>;
00266         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o3">_FenceSet</a>= <font class="keyword">false</font>;
00267 
00268         <font class="comment">// Flag our type</font>
00269         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m0">NVidiaVertexBufferHard</a>= <font class="keyword">true</font>;
00270 }
00271 
00272 
00273 <font class="comment">// ***************************************************************************</font>
<a name="l00274"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a1">00274</a> CVertexBufferHardGLNVidia::~CVertexBufferHardGLNVidia()
00275 {
00276         <font class="keywordflow">if</font>(_VertexArrayRange)
00277         {
00278                 <font class="comment">// Destroy Fence.</font>
00279                 <font class="comment">// First wait for completion.</font>
00280                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a5">finishFence</a>();
00281                 <font class="comment">// then delete.</font>
00282                 <a class="code" href="driver__opengl__extension_8h.html#a43">nglDeleteFencesNV</a>(1, &amp;<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o2">_Fence</a>);
00283 
00284                 <font class="comment">// Then free the VAR.</font>
00285                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>-&gt;freeVB(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o1">_VertexPtr</a>);
00286                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o1">_VertexPtr</a>= NULL;
00287                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>= NULL;
00288         }
00289 }
00290 
00291 
00292 <font class="comment">// ***************************************************************************</font>
<a name="l00293"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a2">00293</a> <font class="keywordtype">void</font>            CVertexBufferHardGLNVidia::initGL(CVertexArrayRangeNVidia *var, <font class="keywordtype">void</font> *vertexPtr)
00294 {
00295         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>= var;
00296         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o1">_VertexPtr</a>= vertexPtr;
00297         <a class="code" href="driver__opengl__extension_8h.html#a44">nglGenFencesNV</a>(1, &amp;<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o2">_Fence</a>);
00298 }
00299 
00300 
00301 <font class="comment">// ***************************************************************************</font>
<a name="l00302"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#z424_0">00302</a> <font class="keywordtype">void</font>            *CVertexBufferHardGLNVidia::lock()
00303 {
00304         <font class="comment">// sync the 3d card with the system.</font>
00305 
00306         <font class="comment">// Ensure the GPU has finished with the current VBHard.</font>
00307         <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a5">finishFence</a>();
00308         <font class="comment">// If the user lock an activated VBHard, after rendering some primitives, we must stall the CPU</font>
00309         <font class="keywordflow">if</font>(GPURenderingAfterFence)
00310         {
00311                 <font class="comment">// Set a fence at the current position in the command stream.</font>
00312                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a4">setFence</a>();
00313                 <font class="comment">// wait for him to finish.</font>
00314                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a5">finishFence</a>();
00315                 <font class="comment">// And so the GPU render all our primitives.</font>
00316                 <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m2">GPURenderingAfterFence</a>= <font class="keyword">false</font>;
00317         }
00318 
00319 
00320         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o1">_VertexPtr</a>;
00321 }
00322 
00323 
00324 <font class="comment">// ***************************************************************************</font>
<a name="l00325"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#z424_1">00325</a> <font class="keywordtype">void</font>            CVertexBufferHardGLNVidia::unlock()
00326 {
00327         <font class="comment">// no op.</font>
00328 }
00329 
00330 <font class="comment">// ***************************************************************************</font>
<a name="l00331"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#z424_2">00331</a> <font class="keywordtype">void</font>            CVertexBufferHardGLNVidia::unlock(uint startVert, uint endVert)
00332 {
00333         <font class="comment">// no op.</font>
00334         <font class="comment">// NB: start-end only usefull for ATI ext.</font>
00335 }
00336 
00337 <font class="comment">// ***************************************************************************</font>
<a name="l00338"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#z424_3">00338</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLNVidia::enable()
00339 {
00340         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard != <font class="keyword">this</font>)
00341         {
00342                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>);
00343                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>-&gt;enable();
00344                 <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard= <font class="keyword">this</font>;
00345         }
00346 }
00347 
00348 
00349 <font class="comment">// ***************************************************************************</font>
<a name="l00350"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#z424_4">00350</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLNVidia::disable()
00351 {
00352         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard != NULL)
00353         {
00354                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>);
00355                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o0">_VertexArrayRange</a>-&gt;disable();
00356                 <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard= NULL;
00357         }
00358 }
00359 
00360 
00361 <font class="comment">// ***************************************************************************</font>
<a name="l00362"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a4">00362</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLNVidia::setFence()
00363 {
00364         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a3">isFenceSet</a>())
00365         {
00366                 <a class="code" href="driver__opengl__extension_8h.html#a49">nglSetFenceNV</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o2">_Fence</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a144">GL_ALL_COMPLETED_NV</a>);
00367                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o3">_FenceSet</a>= <font class="keyword">true</font>;
00368         }
00369 }
00370 
00371 <font class="comment">// ***************************************************************************</font>
<a name="l00372"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a5">00372</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLNVidia::finishFence()
00373 {
00374         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#a3">isFenceSet</a>())
00375         {
00376                 <font class="comment">// Stall CPU while the fence command is not reached in the GPU command stream.</font>
00377                 <a class="code" href="driver__opengl__extension_8h.html#a48">nglFinishFenceNV</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o2">_Fence</a>);
00378                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLNVidia.html#o3">_FenceSet</a>= <font class="keyword">false</font>;
00379         }
00380 }
00381 
00382 
00383 
00384 <font class="comment">// ***************************************************************************</font>
00385 <font class="comment">// ***************************************************************************</font>
00386 <font class="comment">// ***************************************************************************</font>
00387 <font class="comment">//</font>
00388 <font class="comment">// ATI implementation</font>
00389 <font class="comment">//</font>
00390 <font class="comment">// ***************************************************************************</font>
00391 <font class="comment">// ***************************************************************************</font>
00392 <font class="comment">// ***************************************************************************</font>
00393 
00394 
00395 <font class="comment">// ***************************************************************************</font>
00396 <font class="comment">// CVertexArrayRangeATI</font>
00397 <font class="comment">// ***************************************************************************</font>
00398 
00399 
00400 <font class="comment">// ***************************************************************************</font>
<a name="l00401"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#a0">00401</a> CVertexArrayRangeATI::CVertexArrayRangeATI(CDriverGL *drv) : IVertexArrayRange(drv)
00402 {
00403         <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o1">_Allocated</a>= <font class="keyword">false</font>;
00404         <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o0">_VertexObjectId</a>= 0;
00405         <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o2">_VertexArraySize</a>= 0;
00406 }
00407 <font class="comment">// ***************************************************************************</font>
<a name="l00408"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#z425_0">00408</a> <font class="keywordtype">bool</font>                                    CVertexArrayRangeATI::allocate(uint32 size, IDriver::TVBHardType vbType)
00409 {
00410         <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o1">_Allocated</a>);
00411 
00412         <font class="comment">// try to allocate AGP (suppose mean ATI dynamic) or VRAM (suppose mean ATI static) data.</font>
00413         <font class="keywordflow">switch</font>(vbType)
00414         {
00415         <font class="keywordflow">case</font> IDriver::VBHardAGP: 
00416                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o0">_VertexObjectId</a>= <a class="code" href="driver__opengl__extension_8h.html#a172">nglNewObjectBufferATI</a>(size, NULL, <a class="code" href="driver__opengl__extension__def_8h.html#a334">GL_DYNAMIC_ATI</a>);
00417                 <font class="keywordflow">break</font>;
00418         <font class="keywordflow">case</font> IDriver::VBHardVRAM:
00419                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o0">_VertexObjectId</a>= <a class="code" href="driver__opengl__extension_8h.html#a172">nglNewObjectBufferATI</a>(size, NULL, <a class="code" href="driver__opengl__extension__def_8h.html#a333">GL_STATIC_ATI</a>);
00420                 <font class="keywordflow">break</font>;
00421         };
00422 
00423 
00424         <font class="comment">// init the allocator, if success</font>
00425         <font class="keywordflow">if</font>( <a class="code" href="driver__opengl__extension_8h.html#a173">nglIsObjectBufferATI</a>(<a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o0">_VertexObjectId</a>) )
00426         {
00427                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o1">_Allocated</a>= <font class="keyword">true</font>;
00428                 <font class="comment">/* Init with an alignment of 8. Not sure if it is usefull.</font>
00429 <font class="comment">                        Init With a FAKE memory starting at NL3D_DRV_ATI_FAKE_MEM_START</font>
00430 <font class="comment">                */</font>
00431                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o3">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a3">initHeap</a>((<font class="keywordtype">void</font>*)<a class="code" href="driver__opengl__vertex__buffer__hard_8h.html#a0">NL3D_DRV_ATI_FAKE_MEM_START</a>, size, 8);
00432 
00433                 <font class="comment">// set the size</font>
00434                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o2">_VertexArraySize</a>= size;
00435 
00436                 <font class="comment">// Ok!</font>
00437                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00438         }
00439         <font class="keywordflow">else</font>
00440         {
00441                 <font class="comment">// failure.</font>
00442                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00443         }
00444 }
00445 <font class="comment">// ***************************************************************************</font>
<a name="l00446"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#z425_3">00446</a> uint                                    CVertexArrayRangeATI::sizeAllocated()<font class="keyword"> const</font>
00447 <font class="keyword"></font>{
00448         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o2">_VertexArraySize</a>;
00449 }
00450 <font class="comment">// ***************************************************************************</font>
<a name="l00451"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#z425_1">00451</a> <font class="keywordtype">void</font>                                    CVertexArrayRangeATI::free()
00452 {
00453         <font class="comment">// release the ptr.</font>
00454         <font class="keywordflow">if</font>(_Allocated)
00455         {
00456                 <font class="comment">// reset the allocator.</font>
00457                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o3">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a2">reset</a>();
00458 
00459                 <font class="comment">// Free special memory.</font>
00460                 <a class="code" href="driver__opengl__extension_8h.html#a177">nglDeleteObjectBufferATI</a>(<a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o0">_VertexObjectId</a>);
00461 
00462                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o1">_Allocated</a>= <font class="keyword">false</font>;
00463                 <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o2">_VertexArraySize</a>= 0;
00464         }
00465 }
00466 <font class="comment">// ***************************************************************************</font>
<a name="l00467"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#z425_2">00467</a> IVertexBufferHardGL             *CVertexArrayRangeATI::createVBHardGL(uint16 vertexFormat, <font class="keyword">const</font> uint8 *typeArray, uint32 numVertices)
00468 {
00469         <font class="comment">// create a ATI VBHard</font>
00470         CVertexBufferHardGLATI  *newVbHard= <font class="keyword">new</font> CVertexBufferHardGLATI(<a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>);
00471 
00472         <font class="comment">// Init the format of the VB.</font>
00473         newVbHard-&gt;initFormat(vertexFormat, typeArray, numVertices);
00474 
00475         <font class="comment">// compute size to allocate.</font>
00476         uint32  size= newVbHard-&gt;getVertexSize() * newVbHard-&gt;getNumVertices();
00477 
00478         <font class="comment">// try to allocate</font>
00479         <font class="keywordtype">void</font>    *vertexPtr =NULL;
00480         <font class="keywordflow">if</font>( _Allocated )
00481         {
00482                  vertexPtr= <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#c0">allocateVB</a>(size);
00483         }
00484 
00485         <font class="comment">// If allocation fails.</font>
00486         <font class="keywordflow">if</font>( !vertexPtr )
00487         {
00488                 <font class="comment">// just destroy this object (no free()).</font>
00489                 <font class="keyword">delete</font> newVbHard;
00490                 <font class="keywordflow">return</font> NULL;
00491         }
00492         <font class="keywordflow">else</font>
00493         {
00494                 <font class="comment">// Then try to create a RAM mirror in the VB.</font>
00495                 <font class="keywordflow">if</font>( newVbHard-&gt;createRAMMirror(size) )
00496                 {
00497                         <font class="comment">// Ok, setup</font>
00498                         newVbHard-&gt;initGL(<font class="keyword">this</font>, vertexPtr);
00499                         <font class="keywordflow">return</font> newVbHard;
00500                 }
00501                 <font class="keywordflow">else</font>
00502                 {
00503                         <font class="comment">// Discard the VB.</font>
00504                         <font class="keyword">delete</font> newVbHard;
00505                         <font class="keywordflow">return</font> NULL;
00506                 }
00507         }
00508 }
00509 <font class="comment">// ***************************************************************************</font>
<a name="l00510"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#a1">00510</a> <font class="keywordtype">void</font>                    CVertexArrayRangeATI::enable()
00511 {
00512         <font class="comment">// No-op for ATI !!!</font>
00513         <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange= <font class="keyword">this</font>;
00514 }
00515 <font class="comment">// ***************************************************************************</font>
<a name="l00516"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#a2">00516</a> <font class="keywordtype">void</font>                    CVertexArrayRangeATI::disable()
00517 {
00518         <font class="comment">// No-op for ATI !!!</font>
00519         <a class="code" href="classNL3D_1_1IVertexArrayRange.html#n0">_Driver</a>-&gt;_CurrentVertexArrayRange= NULL;
00520 }
00521 <font class="comment">// ***************************************************************************</font>
<a name="l00522"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#c0">00522</a> <font class="keywordtype">void</font>                    *CVertexArrayRangeATI::allocateVB(uint32 size)
00523 {
00524         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o3">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a6">allocate</a>(size);
00525 }
00526 <font class="comment">// ***************************************************************************</font>
<a name="l00527"></a><a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#a3">00527</a> <font class="keywordtype">void</font>                    CVertexArrayRangeATI::freeVB(<font class="keywordtype">void</font>       *ptr)
00528 {
00529         <a class="code" href="classNL3D_1_1CVertexArrayRangeATI.html#o3">_HeapMemory</a>.<a class="code" href="classNLMISC_1_1CHeapMemory.html#a7">free</a>(ptr);
00530 }
00531 
00532 
00533 <font class="comment">// ***************************************************************************</font>
00534 <font class="comment">// CVertexBufferHardGLATI</font>
00535 <font class="comment">// ***************************************************************************</font>
00536 
00537 
00538 <font class="comment">// ***************************************************************************</font>
<a name="l00539"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a0">00539</a> CVertexBufferHardGLATI::CVertexBufferHardGLATI(CDriverGL *drv) : IVertexBufferHardGL(drv)
00540 {
00541         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>= NULL;
00542         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a>= NULL;
00543         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>= NULL;
00544         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o3">_RAMMirrorVertexSize</a>= 0;
00545 
00546         <font class="comment">// Flag our type</font>
00547         <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#m1">ATIVertexBufferHard</a>= <font class="keyword">true</font>;
00548 }
00549 
00550 
00551 <font class="comment">// ***************************************************************************</font>
<a name="l00552"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a1">00552</a> CVertexBufferHardGLATI::~CVertexBufferHardGLATI()
00553 {
00554         <font class="keywordflow">if</font>(_VertexArrayRange)
00555         {
00556                 <font class="comment">// free the VAR.</font>
00557                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>-&gt;freeVB(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a>);
00558                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a>= NULL;
00559                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>= NULL;
00560         }
00561 
00562         <font class="keywordflow">if</font>(_RAMMirrorVertexPtr)
00563         {
00564                 <font class="keyword">delete</font> [] ((uint8*)<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>);
00565                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>= NULL;
00566                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o3">_RAMMirrorVertexSize</a>= 0;
00567         }
00568 }
00569 
00570 
00571 <font class="comment">// ***************************************************************************</font>
<a name="l00572"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a2">00572</a> <font class="keywordtype">bool</font>            CVertexBufferHardGLATI::createRAMMirror(uint memSize)
00573 {
00574         <font class="comment">// delete old if any</font>
00575         <font class="keywordflow">if</font>(_RAMMirrorVertexPtr)
00576         {
00577                 free(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>);
00578                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>= NULL;
00579                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o3">_RAMMirrorVertexSize</a>= 0;
00580         }
00581         <font class="comment">// create</font>
00582         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a> = (<font class="keywordtype">void</font>*)<font class="keyword">new</font> uint8[memSize];
00583         <font class="keywordflow">if</font>(_RAMMirrorVertexPtr)
00584         {
00585                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o3">_RAMMirrorVertexSize</a>= memSize;
00586                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00587         }
00588         <font class="keywordflow">else</font>
00589                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00590 }
00591 
00592 
00593 <font class="comment">// ***************************************************************************</font>
<a name="l00594"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a3">00594</a> <font class="keywordtype">void</font>            CVertexBufferHardGLATI::initGL(CVertexArrayRangeATI *var, <font class="keywordtype">void</font> *vertexPtr)
00595 {
00596         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>= var;
00597         <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a>= vertexPtr;
00598 }
00599 
00600 
00601 <font class="comment">// ***************************************************************************</font>
<a name="l00602"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#z426_0">00602</a> <font class="keywordtype">void</font>            *CVertexBufferHardGLATI::lock()
00603 {
00604         <font class="comment">// return directly the mirror one. =&gt; client will write into RAM.</font>
00605         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>;
00606 }
00607 
00608 
00609 <font class="comment">// ***************************************************************************</font>
<a name="l00610"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#z426_1">00610</a> <font class="keywordtype">void</font>            CVertexBufferHardGLATI::unlock()
00611 {
00612         <font class="comment">// Copy All mirror into the ATI Vertex Object</font>
00613         <a class="code" href="driver__opengl__extension_8h.html#a174">nglUpdateObjectBufferATI</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a5">getATIVertexObjectId</a>(), (uint)<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a> - <a class="code" href="driver__opengl__vertex__buffer__hard_8h.html#a0">NL3D_DRV_ATI_FAKE_MEM_START</a>,
00614                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o3">_RAMMirrorVertexSize</a>, <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a335">GL_PRESERVE_ATI</a>);
00615 }
00616 
00617 
00618 <font class="comment">// ***************************************************************************</font>
<a name="l00619"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#z426_2">00619</a> <font class="keywordtype">void</font>            CVertexBufferHardGLATI::unlock(uint startVert, uint endVert)
00620 {
00621         <font class="comment">// clamp endVert.</font>
00622         <font class="keywordflow">if</font>(endVert&gt;<a class="code" href="classNL3D_1_1IVertexBufferHard.html#z902_2">getNumVertices</a>())
00623                 endVert=<a class="code" href="classNL3D_1_1IVertexBufferHard.html#z902_2">getNumVertices</a>();
00624 
00625         <font class="comment">// verify bound.</font>
00626         <font class="keywordflow">if</font>(startVert&gt;=endVert)
00627                 <font class="keywordflow">return</font>;
00628 
00629         <font class="comment">// Copy a subset of the mirror into the ATI Vertex Object</font>
00630         uint    size= (endVert-startVert)*<a class="code" href="classNL3D_1_1IVertexBufferHard.html#z902_1">getVertexSize</a>();
00631         uint    srcOffStart= startVert*<a class="code" href="classNL3D_1_1IVertexBufferHard.html#z902_1">getVertexSize</a>();
00632         uint    dstOffStart= ((uint)<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o1">_VertexPtr</a> - <a class="code" href="driver__opengl__vertex__buffer__hard_8h.html#a0">NL3D_DRV_ATI_FAKE_MEM_START</a>) + srcOffStart;
00633         <font class="comment">// copy.</font>
00634         <a class="code" href="driver__opengl__extension_8h.html#a174">nglUpdateObjectBufferATI</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#a5">getATIVertexObjectId</a>(), dstOffStart,
00635                 size, (uint8*)<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o2">_RAMMirrorVertexPtr</a> + srcOffStart, <a class="code" href="driver__opengl__extension__def_8h.html#a335">GL_PRESERVE_ATI</a>);
00636 }
00637 
00638 
00639 <font class="comment">// ***************************************************************************</font>
<a name="l00640"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#z426_3">00640</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLATI::enable()
00641 {
00642         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard != <font class="keyword">this</font>)
00643         {
00644                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>);
00645                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>-&gt;enable();
00646                 <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard= <font class="keyword">this</font>;
00647         }
00648 }
00649 
00650 
00651 <font class="comment">// ***************************************************************************</font>
<a name="l00652"></a><a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#z426_4">00652</a> <font class="keywordtype">void</font>                    CVertexBufferHardGLATI::disable()
00653 {
00654         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard != NULL)
00655         {
00656                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>);
00657                 <a class="code" href="classNL3D_1_1CVertexBufferHardGLATI.html#o0">_VertexArrayRange</a>-&gt;disable();
00658                 <a class="code" href="classNL3D_1_1IVertexBufferHardGL.html#n0">_Driver</a>-&gt;_CurrentVertexBufferHard= NULL;
00659         }
00660 }
00661 
00662 
00663 }
00664 
</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=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>