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
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <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>driver_opengl_vertex.cpp</h1><a href="driver__opengl__vertex_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00009 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00012 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00013 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00014 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00015 <font class="comment"> * any later version.</font>
00016 <font class="comment"></font>
00017 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00018 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00019 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00020 <font class="comment"> * General Public License for more details.</font>
00021 <font class="comment"></font>
00022 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00023 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00024 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00025 <font class="comment"> * MA 02111-1307, USA.</font>
00026 <font class="comment"> */</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="stdopengl_8h.html">stdopengl.h</a>"</font>
00029
00030 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="driver__opengl__vertex__buffer__hard_8h.html">driver_opengl_vertex_buffer_hard.h</a>"</font>
00032
00033
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00036
00037
00038
00039 <font class="comment">// ***************************************************************************</font>
00040 <font class="comment">// Flags for software vertex skinning.</font>
<a name="l00041"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a0">00041</a> <font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VNEEDCOMPUTE 3</font>
<a name="l00042"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a1">00042</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VMUSTCOMPUTE 1</font>
<a name="l00043"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a2">00043</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_DRV_SOFTSKIN_VCOMPUTED 0</font>
00044 <font class="preprocessor"></font><font class="comment">// 3 means "vertex may need compute".</font>
00045 <font class="comment">// 1 means "Primitive say vertex must be computed".</font>
00046 <font class="comment">// 0 means "vertex is computed".</font>
00047
00048
00049 <font class="comment">// 500K min.</font>
<a name="l00050"></a><a class="code" href="driver__opengl__vertex_8cpp.html#a3">00050</a> <font class="preprocessor">#define NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE (512*1024)</font>
00051 <font class="preprocessor"></font>
00052
00053
00054 <font class="keyword">namespace </font>NL3D
00055 {
00056
00057
00058
00059 <font class="comment">// ***************************************************************************</font>
<a name="l00060"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c1">00060</a> <font class="keywordtype">bool</font> CDriverGL::setupVertexBuffer(CVertexBuffer& VB)
00061 {
00062 <font class="comment">// 1. Retrieve/Create driver shader.</font>
00063 <font class="comment">//==================================</font>
00064 <font class="keywordflow">if</font> (!VB.DrvInfos)
00065 {
00066 <font class="comment">// insert into driver list. (so it is deleted when driver is deleted).</font>
00067 <a class="code" href="namespaceNL3D.html#a295">ItVBDrvInfoPtrList</a> it= <a class="code" href="classNL3D_1_1IDriver.html#n3">_VBDrvInfos</a>.insert(<a class="code" href="classNL3D_1_1IDriver.html#n3">_VBDrvInfos</a>.end());
00068 <font class="comment">// create and set iterator, for future deletion.</font>
00069 *it= VB.DrvInfos= <font class="keyword">new</font> CVBDrvInfosGL(<font class="keyword">this</font>, it);
00070 }
00071
00072 <font class="comment">// 2. If necessary, do modifications.</font>
00073 <font class="comment">//==================================</font>
00074 <font class="keywordflow">if</font>( VB.getTouchFlags()!=0 )
00075 {
00076 <font class="comment">// nop</font>
00077 <font class="comment">// OK!</font>
00078 VB.resetTouchFlags();
00079 }
00080
00081
00082 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00083 }
00084
00085
00086 <font class="comment">// ***************************************************************************</font>
<a name="l00087"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a44">00087</a> <font class="keywordtype">bool</font> CDriverGL::activeVertexBuffer(CVertexBuffer& VB, uint first, uint end)
00088 {
00089 <font class="comment">// NB: must duplicate changes in activeVertexBufferHard()</font>
00090
00091 uint32 flags;
00092
00093 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c1">setupVertexBuffer</a>(VB))
00094 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00095
00096 <font class="keywordflow">if</font> (VB.getNumVertices()==0)
00097 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00098
00099 <a class="code" href="debug_8h.html#a6">nlassert</a>(end<=VB.getNumVertices());
00100 <a class="code" href="debug_8h.html#a6">nlassert</a>(first<=end);
00101
00102 <font class="comment">// Get VB flags, to setup matrixes and arrays.</font>
00103 flags=VB.getVertexFormat();
00104
00105
00106 <font class="comment">// 2. Setup Arrays.</font>
00107 <font class="comment">//===================</font>
00108
00109 <font class="comment">// Fence mgt.</font>
00110 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">fenceOnCurVBHardIfNeeded</a>(NULL);
00111
00112 <font class="comment">// For MultiPass Material.</font>
00113 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.setupVertexBuffer(VB);
00114
00115 <font class="comment">// Disable the current vertexBufferHard if setuped.</font>
00116 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00117 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->disable();
00118
00119 <font class="comment">// Setup the OpenGL arrays.</font>
00120 <a class="code" href="classNL3D_1_1CDriverGL.html#c18">setupGlArrays</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>);
00121
00122
00123 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00124 }
00125
00126
00127 <font class="comment">// ***************************************************************************</font>
<a name="l00128"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a43">00128</a> <font class="keywordtype">bool</font> CDriverGL::activeVertexBuffer(CVertexBuffer& VB)
00129 {
00130 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#a43">activeVertexBuffer</a>(VB, 0, VB.getNumVertices());
00131 }
00132
00133
00134 <font class="comment">// ***************************************************************************</font>
<a name="l00135"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a46">00135</a> <font class="keywordtype">bool</font> CDriverGL::render(CPrimitiveBlock& PB, CMaterial& Mat)
00136 {
00137 <font class="comment">// update matrix and Light in OpenGL if needed</font>
00138 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
00139
00140 <font class="comment">// setup material</font>
00141 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
00142 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00143
00144
00145 <font class="comment">// render primitives.</font>
00146 <font class="comment">//==============================</font>
00147 <font class="comment">// start multipass.</font>
00148 uint nPass;
00149 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
00150 <font class="comment">// draw all passes.</font>
00151 <font class="keywordflow">for</font>(uint pass=0;pass<nPass; pass++)
00152 {
00153 <font class="comment">// setup the pass.</font>
00154 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
00155 <font class="comment">// draw the primitives.</font>
00156 <font class="keywordflow">if</font>(PB.getNumTri()!=0)
00157 glDrawElements(GL_TRIANGLES,3*PB.getNumTri(),GL_UNSIGNED_INT,PB.getTriPointer());
00158 <font class="keywordflow">if</font>(PB.getNumQuad()!=0)
00159 glDrawElements(GL_QUADS,4*PB.getNumQuad(),GL_UNSIGNED_INT,PB.getQuadPointer());
00160 <font class="keywordflow">if</font>(PB.getNumLine()!=0)
00161 glDrawElements(GL_LINES,2*PB.getNumLine(),GL_UNSIGNED_INT,PB.getLinePointer());
00162 }
00163 <font class="comment">// end multipass.</font>
00164 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
00165
00166
00167 <font class="comment">// Profiling.</font>
00168 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NLines+= PB.getNumLine();
00169 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= PB.getNumTri();
00170 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NQuads+= PB.getNumQuad();
00171 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NLines+= PB.getNumLine() * nPass;
00172 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= PB.getNumTri() * nPass;
00173 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NQuads+= PB.getNumQuad() * nPass;
00174
00175 <font class="comment">// We have render some prims. inform the VBHard.</font>
00176 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00177 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->GPURenderingAfterFence= <font class="keyword">true</font>;
00178
00179 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00180
00181
00182 }
00183
00184
00185 <font class="comment">// ***************************************************************************</font>
<a name="l00186"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a47">00186</a> <font class="keywordtype">void</font> CDriverGL::renderTriangles(CMaterial& Mat, uint32 *tri, uint32 ntris)
00187 {
00188 <font class="comment">// update matrix and Light in OpenGL if needed</font>
00189 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
00190
00191 <font class="comment">// setup material</font>
00192 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
00193 <font class="keywordflow">return</font>;
00194
00195
00196 <font class="comment">// render primitives.</font>
00197 <font class="comment">//==============================</font>
00198 <font class="comment">// start multipass.</font>
00199 uint nPass;
00200 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
00201 <font class="comment">// draw all passes.</font>
00202 <font class="keywordflow">for</font>(uint pass=0;pass<nPass; pass++)
00203 {
00204 <font class="comment">// setup the pass.</font>
00205 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
00206 <font class="comment">// draw the primitives.</font>
00207 <font class="keywordflow">if</font>(ntris!=0)
00208 glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
00209 }
00210 <font class="comment">// end multipass.</font>
00211 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
00212
00213
00214 <font class="comment">// Profiling.</font>
00215 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= ntris;
00216 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= ntris * nPass;
00217
00218 <font class="comment">// We have render some prims. inform the VBHard.</font>
00219 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00220 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->GPURenderingAfterFence= <font class="keyword">true</font>;
00221 }
00222
00223
00224 <font class="comment">// ***************************************************************************</font>
<a name="l00225"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a48">00225</a> <font class="keywordtype">void</font> CDriverGL::renderSimpleTriangles(uint32 *tri, uint32 ntris)
00226 {
00227 <a class="code" href="debug_8h.html#a6">nlassert</a>(ntris>0);
00228
00229 <font class="comment">// update matrix and Light in OpenGL if needed</font>
00230 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
00231
00232
00233 <font class="comment">// Don't setup any material here.</font>
00234
00235 <font class="comment">// render primitives.</font>
00236 <font class="comment">//==============================</font>
00237 <font class="comment">// NO MULTIPASS HERE!!</font>
00238 <font class="comment">// draw the primitives. (nb: ntrsi>0).</font>
00239 glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
00240
00241 <font class="comment">// Profiling.</font>
00242 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NTriangles+= ntris;
00243 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NTriangles+= ntris;
00244
00245 <font class="comment">// We have render some prims. inform the VBHard.</font>
00246 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00247 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->GPURenderingAfterFence= <font class="keyword">true</font>;
00248 }
00249
00250
00251 <font class="comment">// ***************************************************************************</font>
<a name="l00252"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a49">00252</a> <font class="keywordtype">void</font> CDriverGL::renderPoints(CMaterial& Mat, uint32 numPoints)
00253 {
00254 <font class="comment">// update matrix and Light in OpenGL if needed</font>
00255 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
00256
00257 <font class="comment">// setup material</font>
00258 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
00259 <font class="keywordflow">return</font>;
00260
00261
00262 <font class="comment">// render primitives.</font>
00263 <font class="comment">//==============================</font>
00264 <font class="comment">// start multipass.</font>
00265 uint nPass;
00266 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
00267 <font class="comment">// draw all passes.</font>
00268 <font class="keywordflow">for</font>(uint pass=0;pass<nPass; pass++)
00269 {
00270 <font class="comment">// setup the pass.</font>
00271 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
00272 <font class="comment">// draw the primitives.</font>
00273 <font class="keywordflow">if</font>(numPoints)
00274 glDrawArrays(GL_POINTS,0, numPoints);
00275 }
00276 <font class="comment">// end multipass.</font>
00277 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
00278
00279
00280 <font class="comment">// Profiling.</font>
00281 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NPoints+= numPoints;
00282 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NPoints+= numPoints * nPass;
00283
00284 <font class="comment">// We have render some prims. inform the VBHard.</font>
00285 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00286 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->GPURenderingAfterFence= <font class="keyword">true</font>;
00287 }
00288
00289
00290
00291
00292 <font class="comment">// ***************************************************************************</font>
<a name="l00293"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a50">00293</a> <font class="keywordtype">void</font> CDriverGL::renderQuads(CMaterial& Mat, uint32 startIndex, uint32 numQuads)
00294 {
00295 <font class="comment">// update matrix and Light in OpenGL if needed</font>
00296 <a class="code" href="classNL3D_1_1CDriverGL.html#c25">refreshRenderSetup</a>();
00297
00298 <font class="comment">// setup material</font>
00299 <font class="keywordflow">if</font> ( !<a class="code" href="classNL3D_1_1CDriverGL.html#a27">setupMaterial</a>(Mat) )
00300 <font class="keywordflow">return</font>;
00301
00302
00303 <font class="comment">// render primitives.</font>
00304 <font class="comment">//==============================</font>
00305 <font class="comment">// start multipass.</font>
00306 uint nPass;
00307 nPass= <a class="code" href="classNL3D_1_1CDriverGL.html#z406_0">beginMultiPass</a>();
00308 <font class="comment">// draw all passes.</font>
00309 <font class="keywordflow">for</font>(uint pass=0;pass<nPass; pass++)
00310 {
00311 <font class="comment">// setup the pass.</font>
00312 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_1">setupPass</a>(pass);
00313 <font class="comment">// draw the primitives.</font>
00314 <font class="keywordflow">if</font>(numQuads)
00315 glDrawArrays(GL_QUADS, startIndex << 2, numQuads << 2) ;
00316 }
00317 <font class="comment">// end multipass.</font>
00318 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_2">endMultiPass</a>();
00319
00320
00321 <font class="comment">// Profiling.</font>
00322 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_1">_PrimitiveProfileIn</a>.NQuads += numQuads ;
00323 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_2">_PrimitiveProfileOut</a>.NQuads += numQuads * nPass;
00324
00325 <font class="comment">// We have render some prims. inform the VBHard.</font>
00326 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00327 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->GPURenderingAfterFence= <font class="keyword">true</font>;
00328 }
00329
00330
00331 <font class="comment">// ***************************************************************************</font>
<a name="l00332"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c14">00332</a> <font class="keywordtype">void</font> CDriverGL::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
00333 {
00334 <font class="comment">// sould not be called with vertex program Array setuped.</font>
00335 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>);
00336
00337 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(stage);
00338 <font class="keywordflow">if</font> (VB.VertexFormat & (CVertexBuffer::TexCoord0Flag<<uvId))
00339 {
00340 <font class="comment">// Check type, if not supported, just ignore</font>
00341 <font class="keywordflow">if</font> (VB.Type[CVertexBuffer::TexCoord0+uvId]==CVertexBuffer::Float2)
00342 {
00343 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">true</font>);
00344 <font class="comment">// Setup ATI VBHard or std ptr.</font>
00345 <font class="keywordflow">if</font>(VB.ATIVBHardMode)
00346 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, VB.VertexSize,
00347 VB.ATIVertexObjectId, VB.ATIValueOffset[CVertexBuffer::TexCoord0+uvId]);
00348 <font class="keywordflow">else</font>
00349 glTexCoordPointer(2,GL_FLOAT,VB.VertexSize,VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
00350 }
00351 <font class="keywordflow">else</font>
00352 {
00353 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
00354 }
00355 }
00356 <font class="keywordflow">else</font>
00357 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
00358 }
00359
00360
00361 <font class="comment">// ***************************************************************************</font>
<a name="l00362"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a45">00362</a> <font class="keywordtype">void</font> CDriverGL::mapTextureStageToUV(uint stage, uint uv)
00363 {
00364 <font class="comment">// Just call it for last VertexBuffer setuped.</font>
00365 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(stage, <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>, uv);
00366 }
00367
00368
00369
00370 <font class="comment">// ***************************************************************************</font>
00371 <font class="comment">// ***************************************************************************</font>
00372 <font class="comment">// VertexBufferHard</font>
00373 <font class="comment">// ***************************************************************************</font>
00374 <font class="comment">// ***************************************************************************</font>
00375
00376
00377 <font class="comment">// ***************************************************************************</font>
<a name="l00378"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a36">00378</a> <font class="keywordtype">bool</font> CDriverGL::supportVertexBufferHard()<font class="keyword"> const</font>
00379 <font class="keyword"></font>{
00380 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_7">_SupportVBHard</a>;
00381 }
00382
00383
00384 <font class="comment">// ***************************************************************************</font>
<a name="l00385"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a37">00385</a> <font class="keywordtype">bool</font> CDriverGL::slowUnlockVertexBufferHard()<font class="keyword"> const</font>
00386 <font class="keyword"></font>{
00387 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_8">_SlowUnlockVBHard</a>;
00388 }
00389
00390
00391 <font class="comment">// ***************************************************************************</font>
<a name="l00392"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a38">00392</a> uint CDriverGL::getMaxVerticesByVertexBufferHard()<font class="keyword"> const</font>
00393 <font class="keyword"></font>{
00394 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>;
00395 }
00396
00397
00398 <font class="comment">// ***************************************************************************</font>
<a name="l00399"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a40">00399</a> IVertexBufferHard *CDriverGL::createVertexBufferHard(uint16 vertexFormat, <font class="keyword">const</font> uint8 *typeArray, uint32 numVertices, IDriver::TVBHardType vbType)
00400 {
00401 <font class="comment">// choose the VertexArrayRange of good type</font>
00402 IVertexArrayRange *vertexArrayRange= NULL;
00403 <font class="keywordflow">switch</font>(vbType)
00404 {
00405 <font class="keywordflow">case</font> IDriver::VBHardAGP:
00406 vertexArrayRange= <a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>;
00407 <font class="keywordflow">break</font>;
00408 <font class="keywordflow">case</font> IDriver::VBHardVRAM:
00409 vertexArrayRange= <a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>;
00410 <font class="keywordflow">break</font>;
00411 };
00412
00413 <font class="comment">// If this one at least created (an extension support it).</font>
00414 <font class="keywordflow">if</font>( !vertexArrayRange )
00415 <font class="keywordflow">return</font> NULL;
00416 <font class="keywordflow">else</font>
00417 {
00418 <font class="comment">// check max vertex</font>
00419 <font class="keywordflow">if</font>(numVertices > <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>)
00420 <font class="keywordflow">return</font> NULL;
00421
00422 <font class="comment">// Create a CVertexBufferHardGL</font>
00423 IVertexBufferHardGL *vb;
00424 <font class="comment">// let the VAR create the vbhard.</font>
00425 vb= vertexArrayRange->createVBHardGL(vertexFormat, typeArray, numVertices);
00426 <font class="comment">// if fails</font>
00427 <font class="keywordflow">if</font>(!vb)
00428 {
00429 <font class="keywordflow">return</font> NULL;
00430 }
00431 <font class="keywordflow">else</font>
00432 {
00433 <font class="comment">// insert in list.</font>
00434 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.insert(vb);
00435 }
00436 }
00437 }
00438
00439
00440 <font class="comment">// ***************************************************************************</font>
<a name="l00441"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a41">00441</a> <font class="keywordtype">void</font> CDriverGL::deleteVertexBufferHard(IVertexBufferHard *VB)
00442 {
00443 <font class="comment">// If one _CurrentVertexBufferHard enabled, first End its drawning, and disable it.</font>
00444 <font class="comment">// This is very important, because after deletion, the space is free. </font>
00445 <font class="comment">// If the GPU has not finisehd his drawing, and if any allocation occurs on this free space, and if </font>
00446 <font class="comment">// the user locks to fill this space (feww!) Then some data crash may results....</font>
00447 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
00448 {
00449 <font class="comment">// Must ensure it has ended any drawing</font>
00450 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->lock();
00451 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->unlock();
00452 <font class="comment">// disable the VBHard.</font>
00453 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->disable();
00454 }
00455
00456 <font class="comment">// Then just delete the VBuffer hard from list.</font>
00457 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.erase(safe_cast<IVertexBufferHardGL*>(VB));
00458 }
00459
00460
00461
00462 <font class="comment">// ***************************************************************************</font>
<a name="l00463"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a42">00463</a> <font class="keywordtype">void</font> CDriverGL::activeVertexBufferHard(IVertexBufferHard *iVB)
00464 {
00465 <font class="comment">// NB: must duplicate changes in activeVertexBuffer()</font>
00466
00467 <a class="code" href="debug_8h.html#a6">nlassert</a>(iVB);
00468 IVertexBufferHardGL *VB= safe_cast<IVertexBufferHardGL*>(iVB);
00469
00470 uint32 flags;
00471
00472 <font class="keywordflow">if</font> (VB->getNumVertices()==0)
00473 <font class="keywordflow">return</font>;
00474
00475 <font class="comment">// Get VB flags, to setup matrixes and arrays.</font>
00476 flags=VB->getVertexFormat();
00477
00478
00479 <font class="comment">// 2. Setup Arrays.</font>
00480 <font class="comment">//===================</font>
00481
00482 <font class="comment">// Fence mgt.</font>
00483 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">fenceOnCurVBHardIfNeeded</a>(VB);
00484
00485 <font class="comment">// For MultiPass Material.</font>
00486 <a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>.setupVertexBufferHard(*VB);
00487
00488 <font class="comment">// Enable the vertexArrayRange of this array.</font>
00489 VB->enable();
00490
00491 <font class="comment">// Setup the OpenGL arrays.</font>
00492 <a class="code" href="classNL3D_1_1CDriverGL.html#c18">setupGlArrays</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#z406_3">_LastVB</a>);
00493
00494 }
00495
00496
00497 <font class="comment">// ***************************************************************************</font>
<a name="l00498"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r1">00498</a> <font class="keyword">const</font> uint CDriverGL::NumCoordinatesType[CVertexBuffer::NumType]=
00499 {
00500 1, <font class="comment">// Double1</font>
00501 1, <font class="comment">// Float1</font>
00502 1, <font class="comment">// Short1</font>
00503 2, <font class="comment">// Double2</font>
00504 2, <font class="comment">// Float2</font>
00505 2, <font class="comment">// Short2</font>
00506 3, <font class="comment">// Double3</font>
00507 3, <font class="comment">// Float3</font>
00508 3, <font class="comment">// Short3</font>
00509 4, <font class="comment">// Double4</font>
00510 4, <font class="comment">// Float4</font>
00511 4, <font class="comment">// Short4</font>
00512 4 <font class="comment">// UChar4</font>
00513 };
00514
00515
00516 <font class="comment">// ***************************************************************************</font>
<a name="l00517"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r2">00517</a> <font class="keyword">const</font> uint CDriverGL::GLType[CVertexBuffer::NumType]=
00518 {
00519 GL_DOUBLE, <font class="comment">// Double1</font>
00520 GL_FLOAT, <font class="comment">// Float1</font>
00521 GL_SHORT, <font class="comment">// Short1</font>
00522 GL_DOUBLE, <font class="comment">// Double2</font>
00523 GL_FLOAT, <font class="comment">// Float2</font>
00524 GL_SHORT, <font class="comment">// Short2</font>
00525 GL_DOUBLE, <font class="comment">// Double3</font>
00526 GL_FLOAT, <font class="comment">// Float3</font>
00527 GL_SHORT, <font class="comment">// Short3</font>
00528 GL_DOUBLE, <font class="comment">// Double4</font>
00529 GL_FLOAT, <font class="comment">// Float4</font>
00530 GL_SHORT, <font class="comment">// Short4</font>
00531 GL_UNSIGNED_BYTE <font class="comment">// UChar4</font>
00532 };
00533
00534
00535 <font class="comment">// ***************************************************************************</font>
<a name="l00536"></a><a class="code" href="classNL3D_1_1CDriverGL.html#r3">00536</a> <font class="keyword">const</font> uint CDriverGL::GLVertexAttribIndex[CVertexBuffer::NumValue]=
00537 {
00538 0, <font class="comment">// Position</font>
00539 2, <font class="comment">// Normal</font>
00540 8, <font class="comment">// TexCoord0</font>
00541 9, <font class="comment">// TexCoord1</font>
00542 10, <font class="comment">// TexCoord2</font>
00543 11, <font class="comment">// TexCoord3</font>
00544 12, <font class="comment">// TexCoord4</font>
00545 13, <font class="comment">// TexCoord5</font>
00546 14, <font class="comment">// TexCoord6</font>
00547 15, <font class="comment">// TexCoord7</font>
00548 3, <font class="comment">// PrimaryColor</font>
00549 4, <font class="comment">// SecondaryColor</font>
00550 1, <font class="comment">// Weight</font>
00551 6, <font class="comment">// Empty (PaletteSkin)</font>
00552 5, <font class="comment">// Fog</font>
00553 7, <font class="comment">// Empty</font>
00554 };
00555
00556
00557
00558 <font class="comment">// ***************************************************************************</font>
<a name="l00559"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c19">00559</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
00560 {
00561 uint32 flags= vb.VertexFormat;
00562 <font class="comment">// setup vertex ptr.</font>
00563 <font class="comment">//-----------</font>
00564 uint numVertexCoord = CVertexBuffer::NumComponentsType[vb.Type[CVertexBuffer::Position]];
00565 <a class="code" href="debug_8h.html#a6">nlassert</a> (numVertexCoord >= 2);
00566
00567 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">true</font>);
00568 <font class="comment">// Setup ATI VBHard or std ptr.</font>
00569 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
00570 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_VERTEX_ARRAY, numVertexCoord, GL_FLOAT, vb.VertexSize,
00571 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
00572 <font class="keywordflow">else</font>
00573 glVertexPointer(numVertexCoord, GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Position]);
00574
00575
00576 <font class="comment">// setup normal ptr.</font>
00577 <font class="comment">//-----------</font>
00578 <font class="comment">// Check for normal param in vertex buffer</font>
00579 <font class="keywordflow">if</font> (flags & CVertexBuffer::NormalFlag)
00580 {
00581 <font class="comment">// Check type</font>
00582 <a class="code" href="debug_8h.html#a6">nlassert</a> (vb.Type[CVertexBuffer::Normal]==CVertexBuffer::Float3);
00583
00584 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">true</font>);
00585 <font class="comment">// Setup ATI VBHard or std ptr.</font>
00586 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
00587 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_NORMAL_ARRAY, 3, GL_FLOAT, vb.VertexSize,
00588 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Normal]);
00589 <font class="keywordflow">else</font>
00590 glNormalPointer(GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
00591 }
00592 <font class="keywordflow">else</font>
00593 {
00594 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
00595 }
00596
00597
00598 <font class="comment">// Setup Color</font>
00599 <font class="comment">//-----------</font>
00600 <font class="comment">// Check for color param in vertex buffer</font>
00601 <font class="keywordflow">if</font> (flags & CVertexBuffer::PrimaryColorFlag)
00602 {
00603 <font class="comment">// Check type</font>
00604 <a class="code" href="debug_8h.html#a6">nlassert</a> (vb.Type[CVertexBuffer::PrimaryColor]==CVertexBuffer::UChar4);
00605
00606 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">true</font>);
00607 <font class="comment">// Setup ATI VBHard or std ptr.</font>
00608 <font class="keywordflow">if</font>(vb.ATIVBHardMode)
00609 <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize,
00610 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
00611 <font class="keywordflow">else</font>
00612 glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[CVertexBuffer::PrimaryColor]);
00613 }
00614 <font class="keywordflow">else</font>
00615 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00616
00617
00618 <font class="comment">// Setup Uvs</font>
00619 <font class="comment">//-----------</font>
00620 <font class="keywordflow">for</font>(sint i=0; i<<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
00621 {
00622 <font class="comment">// normal behavior: each texture has its own UV.</font>
00623 <a class="code" href="classNL3D_1_1CDriverGL.html#c14">setupUVPtr</a>(i, vb, i);
00624 }
00625 }
00626
00627
00628
00629 <font class="comment">// ***************************************************************************</font>
<a name="l00630"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c22">00630</a> <font class="keywordtype">void</font> CDriverGL::toggleGlArraysForNVVertexProgram()
00631 {
00632 <font class="comment">// If change of setup type, must disable olds.</font>
00633 <font class="comment">//=======================</font>
00634
00635 <font class="comment">// If last was a VertexProgram setup, and now it is a standard GL array setup.</font>
00636 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> && !<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
00637 {
00638
00639 <font class="comment">// Disable all VertexAttribs.</font>
00640 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a><CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
00641 {
00642 <font class="comment">// Index</font>
00643 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
00644 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
00645 }
00646 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00647 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
00648
00649 <font class="comment">// no more a vertex program setup.</font>
00650 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">false</font>;
00651 }
00652
00653 <font class="comment">// If last was a standard GL array setup, and now it is a VertexProgram setup.</font>
00654 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> && <a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
00655 {
00656 <font class="comment">// Disable all standards ptrs.</font>
00657 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">false</font>);
00658 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
00659 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00660 <font class="keywordflow">for</font>(sint i=0; i<<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
00661 {
00662 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(i);
00663 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
00664 }
00665
00666
00667 <font class="comment">// now, vertex program setup.</font>
00668 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">true</font>;
00669 }
00670 }
00671
00672
00673 <font class="comment">// ***************************************************************************</font>
<a name="l00674"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c23">00674</a> <font class="keywordtype">void</font> CDriverGL::toggleGlArraysForEXTVertexShader()
00675 {
00676 <font class="comment">// If change of setup type, must disable olds.</font>
00677 <font class="comment">//=======================</font>
00678
00679
00680 <font class="comment">// If last was a VertexProgram setup, and now it is a standard GL array setup.</font>
00681 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> && !<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
00682 {
00683 CVertexProgram *vp = <a class="code" href="classNL3D_1_1CDriverGL.html#o26">_LastSetuppedVP</a>;
00684 <font class="keywordflow">if</font> (vp)
00685 {
00686 <a class="code" href="classNL3D_1_1CDriverGL.html#l1">CVertexProgamDrvInfosGL</a> *drvInfo = NLMISC::safe_cast<CVertexProgamDrvInfosGL *>((<a class="code" href="classNL3D_1_1IDriver.html#l4">IVertexProgramDrvInfos</a> *) vp->_DrvInfo);
00687 <font class="keywordflow">if</font> (drvInfo)
00688 {
00689 <font class="comment">// Disable all VertexAttribs.</font>
00690 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a><CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
00691 {
00692 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, <font class="keyword">false</font>, drvInfo->Variants);
00693 }
00694 }
00695 }
00696 <font class="comment">// no more a vertex program setup.</font>
00697 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">false</font>;
00698 }
00699
00700 <font class="comment">// If last was a standard GL array setup, and now it is a VertexProgram setup.</font>
00701 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a> && <a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> () )
00702 {
00703 <font class="comment">// Disable all standards ptrs.</font>
00704 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexArray(<font class="keyword">false</font>);
00705 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableNormalArray(<font class="keyword">false</font>);
00706 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00707 <font class="keywordflow">for</font>(sint i=0; i<<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>(); i++)
00708 {
00709 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(i);
00710 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableTexCoordArray(<font class="keyword">false</font>);
00711 }
00712
00713
00714 <font class="comment">// now, vertex program setup.</font>
00715 <a class="code" href="classNL3D_1_1CDriverGL.html#o25">_LastSetupGLArrayVertexProgram</a>= <font class="keyword">true</font>;
00716 }
00717 }
00718
00719 <font class="comment">// ***************************************************************************</font>
<a name="l00720"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c20">00720</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
00721 {
00722 uint32 flags= vb.VertexFormat;
00723
00724 <font class="comment">// For each value</font>
00725 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a><CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
00726 {
00727 <font class="comment">// Flag</font>
00728 uint16 flag=1<<<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
00729
00730 <font class="comment">// Type</font>
00731 CVertexBuffer::TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=vb.Type[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
00732
00733 <font class="comment">// Index</font>
00734 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
00735
00736 <font class="comment">// Not setuped value and used</font>
00737 <font class="keywordflow">if</font> (flags & flag)
00738 {
00739 <font class="comment">/* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.</font>
00740 <font class="comment"> Don't work and lead to very poor performance (1/10) (VAR is "disabled").</font>
00741 <font class="comment"> */</font>
00742 <font class="comment">// Test if can use glColorPointer() / glSecondaryColorPointerEXT() instead.</font>
00743 <font class="keywordflow">if</font>( (glIndex==3 || glIndex==4) )
00744 {
00745 <font class="keywordflow">if</font>( <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == CVertexBuffer::UChar4 )
00746 {
00747 <font class="comment">// Must disable VertexAttrib array.</font>
00748 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
00749
00750 <font class="comment">// Active this value, with standard gl calls</font>
00751 <font class="keywordflow">if</font>(glIndex==3)
00752 {
00753 <font class="comment">// Primary color</font>
00754 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">true</font>);
00755 glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00756 }
00757 <font class="keywordflow">else</font>
00758 {
00759 <font class="comment">// Secondary color</font>
00760 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">true</font>);
00761 <a class="code" href="driver__opengl__extension_8h.html#a170">nglSecondaryColorPointerEXT</a>(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00762 }
00763 }
00764 <font class="keywordflow">else</font>
00765 {
00766 <font class="comment">// Can use normal VertexAttribArray.</font>
00767 <font class="comment">// Disable first standard Color Array.</font>
00768 <font class="keywordflow">if</font>(glIndex==3)
00769 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00770 <font class="keywordflow">else</font>
00771 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
00772
00773 <font class="comment">// Active this value</font>
00774 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">true</font>);
00775 <a class="code" href="driver__opengl__extension_8h.html#a77">nglVertexAttribPointerNV</a> (glIndex, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00776 }
00777 }
00778 <font class="comment">// Else normal case, can't do anything for other values with UChar4....</font>
00779 <font class="keywordflow">else</font>
00780 {
00781 <font class="comment">// Active this value</font>
00782 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">true</font>);
00783 <a class="code" href="driver__opengl__extension_8h.html#a77">nglVertexAttribPointerNV</a> (glIndex, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00784 }
00785 }
00786 <font class="keywordflow">else</font>
00787 {
00788 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArray(glIndex, <font class="keyword">false</font>);
00789 <font class="comment">/* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.</font>
00790 <font class="comment"> Must also disable colorArray in standard gl calls.</font>
00791 <font class="comment"> */</font>
00792 <font class="keywordflow">if</font>(glIndex==3)
00793 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableColorArray(<font class="keyword">false</font>);
00794 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(glIndex==4)
00795 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableSecondaryColorArray(<font class="keyword">false</font>);
00796 }
00797 }
00798 }
00799
00800
00801 <font class="comment">// ***************************************************************************</font>
<a name="l00802"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c21">00802</a> <font class="keywordtype">void</font> CDriverGL::setupGlArraysForEXTVertexShader(CVertexBufferInfo &vb)
00803 {
00804
00805 CVertexProgram *vp = <a class="code" href="classNL3D_1_1CDriverGL.html#o26">_LastSetuppedVP</a>;
00806 <font class="keywordflow">if</font> (!vp) <font class="keywordflow">return</font>;
00807 <a class="code" href="classNL3D_1_1CDriverGL.html#l1">CVertexProgamDrvInfosGL</a> *drvInfo = NLMISC::safe_cast<CVertexProgamDrvInfosGL *>((<a class="code" href="classNL3D_1_1IDriver.html#l4">IVertexProgramDrvInfos</a> *) vp->_DrvInfo);
00808 <font class="keywordflow">if</font> (!drvInfo) <font class="keywordflow">return</font>;
00809
00810 uint32 flags= vb.VertexFormat;
00811
00812 <font class="comment">// For each value</font>
00813 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a><CVertexBuffer::NumValue; <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>++)
00814 {
00815 <font class="comment">// Flag</font>
00816 uint16 flag=1<<<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
00817
00818 <font class="comment">// Type</font>
00819 CVertexBuffer::TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>=vb.Type[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
00820
00821 <font class="comment">// Index</font>
00822 uint glIndex=<a class="code" href="classNL3D_1_1CDriverGL.html#r3">GLVertexAttribIndex</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>];
00823
00824 <font class="comment">// Not setuped value and used</font>
00825 <font class="keywordflow">if</font> (flags & flag & drvInfo->UsedVertexComponents)
00826 {
00827 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(glIndex, <font class="keyword">true</font>, drvInfo->Variants);
00828 <font class="comment">// use variant or open gl standard array</font>
00829 <font class="keywordflow">switch</font>(value)
00830 {
00831 <font class="keywordflow">case</font> CVertexBuffer::Position: <font class="comment">// position </font>
00832 {
00833 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] >= 2);
00834 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_VERTEX_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
00835 <font class="keywordflow">else</font> glVertexPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00836 }
00837 <font class="keywordflow">break</font>;
00838 <font class="keywordflow">case</font> CVertexBuffer::Weight: <font class="comment">// skin weight</font>
00839 {
00840 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
00841 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo->Variants[CDriverGL::EVSSkinWeightVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Weight]);
00842 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo->Variants[CDriverGL::EVSSkinWeightVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00843 }
00844 <font class="keywordflow">break</font>;
00845 <font class="keywordflow">case</font> CVertexBuffer::Normal: <font class="comment">// normal</font>
00846 {
00847 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 3); <font class="comment">// must have 3 components for normals</font>
00848 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_NORMAL_ARRAY, 3, <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00849 <font class="keywordflow">else</font> glNormalPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
00850 }
00851 <font class="keywordflow">break</font>;
00852 <font class="keywordflow">case</font> CVertexBuffer::PrimaryColor: <font class="comment">// color</font>
00853 {
00854 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] >= 3); <font class="comment">// must have 3 or 4 components for primary color</font>
00855 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_COLOR_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
00856 <font class="keywordflow">else</font> glColorPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00857 }
00858 <font class="keywordflow">break</font>;
00859 <font class="keywordflow">case</font> CVertexBuffer::SecondaryColor: <font class="comment">// secondary color</font>
00860 {
00861 <font class="comment">// implemented using a variant, as not available with EXTVertexShader</font>
00862 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
00863 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo->Variants[CDriverGL::EVSSecondaryColorVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::SecondaryColor]);
00864 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo->Variants[CDriverGL::EVSSecondaryColorVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00865 }
00866 <font class="keywordflow">break</font>;
00867 <font class="keywordflow">case</font> CVertexBuffer::Fog: <font class="comment">// fog coordinate</font>
00868 {
00869 <font class="comment">// implemented using a variant</font>
00870 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
00871 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo->Variants[CDriverGL::EVSFogCoordsVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Fog]);
00872 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo->Variants[CDriverGL::EVSFogCoordsVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00873 }
00874 <font class="keywordflow">break</font>;
00875 <font class="keywordflow">case</font> CVertexBuffer::PaletteSkin: <font class="comment">// palette skin</font>
00876 {
00877 <font class="comment">// implemented using a variant</font>
00878 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>] == 4); <font class="comment">// variant, only 4 component supported</font>
00879 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a181">nglVariantArrayObjectATI</a>(drvInfo->Variants[CDriverGL::EVSPaletteSkinVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PaletteSkin]);
00880 <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension_8h.html#a131">nglVariantPointerEXT</a>(drvInfo->Variants[CDriverGL::EVSPaletteSkinVariant], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00881 }
00882 <font class="keywordflow">break</font>;
00883 <font class="keywordflow">case</font> CVertexBuffer::Empty: <font class="comment">// empty</font>
00884 <a class="code" href="debug_8h.html#a12">nlstop</a>
00885 <font class="keywordflow">break</font>;
00886 <font class="keywordflow">case</font> CVertexBuffer::TexCoord0:
00887 <font class="keywordflow">case</font> CVertexBuffer::TexCoord1:
00888 <font class="keywordflow">case</font> CVertexBuffer::TexCoord2:
00889 <font class="keywordflow">case</font> CVertexBuffer::TexCoord3:
00890 <font class="keywordflow">case</font> CVertexBuffer::TexCoord4:
00891 <font class="keywordflow">case</font> CVertexBuffer::TexCoord5:
00892 <font class="keywordflow">case</font> CVertexBuffer::TexCoord6:
00893 <font class="keywordflow">case</font> CVertexBuffer::TexCoord7:
00894 {
00895 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.clientActiveTextureARB(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> - CVertexBuffer::TexCoord0);
00896 <font class="keywordflow">if</font>(vb.ATIVBHardMode) <a class="code" href="driver__opengl__extension_8h.html#a178">nglArrayObjectATI</a>(GL_TEXTURE_COORD_ARRAY, <a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>]);
00897 <font class="keywordflow">else</font> glTexCoordPointer(<a class="code" href="classNL3D_1_1CDriverGL.html#r1">NumCoordinatesType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], <a class="code" href="classNL3D_1_1CDriverGL.html#r2">GLType</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>], vb.VertexSize, vb.ValuePtr[<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> ]);
00898 }
00899 <font class="keywordflow">break</font>;
00900 <font class="keywordflow">default</font>:
00901 <a class="code" href="debug_8h.html#a12">nlstop</a>; <font class="comment">// invalid value</font>
00902 <font class="keywordflow">break</font>;
00903 }
00904 }
00905 <font class="keywordflow">else</font>
00906 {
00907 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.enableVertexAttribArrayForEXTVertexShader(glIndex, <font class="keyword">false</font>, drvInfo->Variants);
00908 }
00909 }
00910 }
00911
00912
00913
00914 <font class="comment">// ***************************************************************************</font>
<a name="l00915"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c18">00915</a> <font class="keywordtype">void</font> CDriverGL::setupGlArrays(CVertexBufferInfo &vb)
00916 {
00917 uint32 flags= vb.VertexFormat;
00918
00923 <font class="comment">// Standard case (NVVertexProgram or no vertex program case)</font>
00924 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVVertexProgram || !<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTVertexShader)
00925 {
00926 <a class="code" href="classNL3D_1_1CDriverGL.html#c22">toggleGlArraysForNVVertexProgram</a>();
00927 <font class="comment">// Use a vertex program ?</font>
00928 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> ())
00929 {
00930 <a class="code" href="classNL3D_1_1CDriverGL.html#c19">setupGlArraysStd</a>(vb);
00931 }
00932 <font class="keywordflow">else</font>
00933 {
00934 <a class="code" href="classNL3D_1_1CDriverGL.html#c20">setupGlArraysForNVVertexProgram</a>(vb);
00935 }
00936 }
00937 <font class="keywordflow">else</font> <font class="comment">// EXTVertexShader case</font>
00938 {
00939 <a class="code" href="classNL3D_1_1CDriverGL.html#c23">toggleGlArraysForEXTVertexShader</a>();
00940 <font class="comment">// Use a vertex program ?</font>
00941 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CDriverGL.html#c27">isVertexProgramEnabled</a> ())
00942 {
00943 <a class="code" href="classNL3D_1_1CDriverGL.html#c19">setupGlArraysStd</a>(vb);
00944 }
00945 <font class="keywordflow">else</font>
00946 {
00947 <a class="code" href="classNL3D_1_1CDriverGL.html#c21">setupGlArraysForEXTVertexShader</a>(vb);
00948 }
00949 }
00950
00951 <font class="comment">// Reset specials flags.</font>
00952 <a class="code" href="classNL3D_1_1CDriverGL.html#z407_10">_LastVertexSetupIsLightMap</a>= <font class="keyword">false</font>;
00953 }
00954
00955
00956 <font class="comment">// ***************************************************************************</font>
<a name="l00957"></a><a class="code" href="classNL3D_1_1CVertexBufferInfo.html#a0">00957</a> <font class="keywordtype">void</font> CVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb)
00958 {
00959 sint i;
00960 uint flags= vb.getVertexFormat();
00961 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>= flags;
00962 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m1">VertexSize</a>= vb.getVertexSize();
00963 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m2">NumVertices</a>= vb.getNumVertices();
00964 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m3">NumWeight</a>= vb.getNumWeight();
00965
00966 <font class="comment">// No VBhard.</font>
00967 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">false</font>;
00968
00969 <font class="comment">// Get value pointer</font>
00970 <font class="keywordflow">for</font> (i=0; i<CVertexBuffer::NumValue; i++)
00971 {
00972 <font class="comment">// Value used ?</font>
00973 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&(1<<i))
00974 {
00975 <font class="comment">// Get the pointer</font>
00976 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m5">ValuePtr</a>[i]=vb.getValueEx ((CVertexBuffer::TValue)i);
00977
00978 <font class="comment">// Type of the value</font>
00979 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]=vb.getValueType (i);
00980 }
00981 }
00982 }
00983
00984
00985 <font class="comment">// ***************************************************************************</font>
<a name="l00986"></a><a class="code" href="classNL3D_1_1CVertexBufferInfo.html#a1">00986</a> <font class="keywordtype">void</font> CVertexBufferInfo::setupVertexBufferHard(IVertexBufferHardGL &vb)
00987 {
00988 sint i;
00989 uint flags= vb.getVertexFormat();
00990 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>= flags;
00991 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m1">VertexSize</a>= vb.getVertexSize();
00992 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m2">NumVertices</a>= vb.getNumVertices();
00993 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m3">NumWeight</a>= vb.getNumWeight();
00994
00995 <font class="comment">// Not ATI VBHard by default</font>
00996 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">false</font>;
00997
00998 <font class="comment">// Setup differs from ATI or NVidia VBHard.</font>
00999 <font class="keywordflow">if</font>(vb.NVidiaVertexBufferHard)
01000 {
01001 CVertexBufferHardGLNVidia &vbHardNV= static_cast<CVertexBufferHardGLNVidia&>(vb);
01002
01003 <font class="comment">// Get value pointer</font>
01004 <font class="keywordflow">for</font> (i=0; i<CVertexBuffer::NumValue; i++)
01005 {
01006 <font class="comment">// Value used ?</font>
01007 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&(1<<i))
01008 {
01009 <font class="comment">// Get the pointer</font>
01010 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m5">ValuePtr</a>[i]= vbHardNV.getNVidiaValueEx(i);
01011
01012 <font class="comment">// Type of the value</font>
01013 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]= vbHardNV.getValueType (i);
01014 }
01015 }
01016 }
01017 <font class="keywordflow">else</font>
01018 {
01019 <a class="code" href="debug_8h.html#a6">nlassert</a>(vb.ATIVertexBufferHard);
01020 CVertexBufferHardGLATI &vbHardATI= static_cast<CVertexBufferHardGLATI&>(vb);
01021
01022 <font class="comment">// special setup in setupGlArrays()...</font>
01023 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m6">ATIVBHardMode</a>= <font class="keyword">true</font>;
01024
01025 <font class="comment">// store the VertexObject Id.</font>
01026 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m7">ATIVertexObjectId</a>= vbHardATI.getATIVertexObjectId();
01027
01028 <font class="comment">// Get value offset</font>
01029 <font class="keywordflow">for</font> (i=0; i<CVertexBuffer::NumValue; i++)
01030 {
01031 <font class="comment">// Value used ?</font>
01032 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m0">VertexFormat</a>&(1<<i))
01033 {
01034 <font class="comment">// Get the pointer</font>
01035 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m8">ATIValueOffset</a>[i]= vbHardATI.getATIValueOffset(i);
01036
01037 <font class="comment">// Type of the value</font>
01038 <a class="code" href="classNL3D_1_1CVertexBufferInfo.html#m4">Type</a>[i]= vbHardATI.getValueType (i);
01039 }
01040 }
01041 }
01042 }
01043
01044
01045
01046 <font class="comment">// ***************************************************************************</font>
<a name="l01047"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z411_0">01047</a> <font class="keywordtype">void</font> CDriverGL::resetVertexArrayRange()
01048 {
01049 <font class="keywordflow">if</font>(_CurrentVertexBufferHard)
01050 {
01051 <font class="comment">// Must ensure it has ended any drawing</font>
01052 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->lock();
01053 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->unlock();
01054 <font class="comment">// disable it</font>
01055 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->disable();
01056 }
01057 <font class="comment">// Clear any VertexBufferHard created.</font>
01058 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_2">_VertexBufferHardSet</a>.clear();
01059
01060 <font class="comment">// After, Clear the 2 vertexArrayRange, if any.</font>
01061 <font class="keywordflow">if</font>(_AGPVertexArrayRange)
01062 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>->free();
01063 <font class="keywordflow">if</font>(_VRAMVertexArrayRange)
01064 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>->free();
01065 }
01066
01067
01068 <font class="comment">// ***************************************************************************</font>
<a name="l01069"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a39">01069</a> <font class="keywordtype">bool</font> CDriverGL::initVertexArrayRange(uint agpMem, uint vramMem)
01070 {
01071 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CDriverGL.html#a36">supportVertexBufferHard</a>())
01072 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01073
01074 <font class="comment">// must be supported</font>
01075 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a> || !<a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>)
01076 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01077
01078 <font class="comment">// First, reset any VBHard created.</font>
01079 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_0">resetVertexArrayRange</a>();
01080 <font class="keywordtype">bool</font> ok= <font class="keyword">true</font>;
01081
01082 <font class="comment">// Try to allocate AGPMemory.</font>
01083 <font class="keywordflow">if</font>(agpMem>0)
01084 {
01085 agpMem&= ~15; <font class="comment">// ensure 16-bytes aligned mem count (maybe usefull :) ).</font>
01086 agpMem= max(agpMem, (uint)<a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>);
01087 <font class="keywordflow">while</font>(agpMem>= <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
01088 {
01089 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_10">_AGPVertexArrayRange</a>->allocate(agpMem, IDriver::VBHardAGP))
01090 {
01091 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: %.d vertices supported"</font>, <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>);
01092 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: Success to allocate %.1f Mo of AGP VAR Ram"</font>, agpMem / 1000000.f);
01093 <font class="keywordflow">break</font>;
01094 }
01095 <font class="keywordflow">else</font>
01096 {
01097 agpMem/=2;
01098 agpMem &=~15;
01099 }
01100 }
01101
01102 <font class="keywordflow">if</font>(agpMem< <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
01103 {
01104 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: %.d vertices supported"</font>, <a class="code" href="classNL3D_1_1CDriverGL.html#z411_9">_MaxVerticesByVBHard</a>);
01105 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"VAR: Failed to allocate %.1f Mo of AGP VAR Ram"</font>, <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a> / 1000000.f);
01106 ok= <font class="keyword">false</font>;
01107 }
01108 }
01109
01110
01111 <font class="comment">// Try to allocate VRAMMemory.</font>
01112 <font class="keywordflow">if</font>(vramMem>0)
01113 {
01114 vramMem&= ~15; <font class="comment">// ensure 16-bytes aligned mem count (maybe usefull :) ).</font>
01115 vramMem= max(vramMem, (uint)<a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>);
01116 <font class="keywordflow">while</font>(vramMem>= <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
01117 {
01118 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_11">_VRAMVertexArrayRange</a>->allocate(vramMem, IDriver::VBHardVRAM))
01119 <font class="keywordflow">break</font>;
01120 <font class="keywordflow">else</font>
01121 {
01122 vramMem/=2;
01123 vramMem &=~15;
01124 }
01125 }
01126
01127 <font class="keywordflow">if</font>(vramMem< <a class="code" href="driver__opengl__vertex_8cpp.html#a3">NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE</a>)
01128 {
01129 ok= <font class="keyword">false</font>;
01130 }
01131 }
01132
01133
01134 <font class="keywordflow">return</font> ok;
01135 }
01136
01137
01138 <font class="comment">// ***************************************************************************</font>
<a name="l01139"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z411_1">01139</a> <font class="keywordtype">void</font> CDriverGL::fenceOnCurVBHardIfNeeded(IVertexBufferHardGL *newVBHard)
01140 {
01141 <font class="comment">// If old is not a VBHard, or if not a NVidia VBHard, no-op.</font>
01142 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>==NULL || !<a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>->NVidiaVertexBufferHard )
01143 <font class="keywordflow">return</font>;
01144
01145 <font class="comment">// if we do not activate the same (NB: newVBHard==NULL if not a VBHard).</font>
01146 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z411_4">_CurrentVertexBufferHard</a>!=newVBHard)
01147 {
01148 <font class="comment">// get NVidia interface</font>
01149 <a class="code" href="classNL3D_1_1CDriverGL.html#z411_13">CVertexBufferHardGLNVidia</a> *vbHardNV= static_cast<CVertexBufferHardGLNVidia*>(_CurrentVertexBufferHard);
01150
01151 <font class="comment">// If some render() have been done with this VB.</font>
01152 <font class="keywordflow">if</font>( vbHardNV->GPURenderingAfterFence )
01153 {
01154 <font class="comment">// If an old fence is activated, we wait for him.</font>
01155 <font class="comment">/* NB: performance issue: maybe a wait for nothing in some cases like this one:</font>
01156 <font class="comment"> render with VBHard_A ---- end with a fence</font>
01157 <font class="comment"> render with VBHard_B ....</font>
01158 <font class="comment"> render with VBHard_A ---- end: must finish prec fence before setting a new one.</font>
01159 <font class="comment"></font>
01160 <font class="comment"> This is not a hard issue, if we suppose first A is finished to be rendered during render of VBHard_B.</font>
01161 <font class="comment"> */</font>
01162 vbHardNV->finishFence();
01163 <font class="comment">// Since we won't work with this VB for a long time, we set a fence.</font>
01164 vbHardNV->setFence();
01165 vbHardNV->GPURenderingAfterFence= <font class="keyword">false</font>;
01166 }
01167 }
01168 }
01169
01170
01171 } <font class="comment">// NL3D</font>
</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>
|