aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/driver__opengl__texture_8cpp-source.html
blob: 9d345fea185c052eca491aaebfc4a9fc45fb5ab9 (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
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
<!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_texture.cpp</h1><a href="driver__opengl__texture_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00011 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00012 <font class="comment"> *</font>
00013 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00014 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00015 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00016 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00017 <font class="comment"> * any later version.</font>
00018 <font class="comment"></font>
00019 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00020 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00021 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00022 <font class="comment"> * General Public License for more details.</font>
00023 <font class="comment"></font>
00024 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00025 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00026 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00027 <font class="comment"> * MA 02111-1307, USA.</font>
00028 <font class="comment"> */</font>
00029 
00030 <font class="preprocessor">#include "<a class="code" href="stdopengl_8h.html">stdopengl.h</a>"</font>
00031 
00032 <font class="preprocessor">#include "<a class="code" href="texture__cube_8h.html">3d/texture_cube.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="rect_8h.html">nel/misc/rect.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font> <font class="comment">// temp</font>
00035 
00036 
00037 <font class="keyword">using</font>   <font class="keyword">namespace </font>NLMISC;
00038 <font class="keyword">using</font>   <font class="keyword">namespace </font>std;
00039 
00040 
00041 <font class="keyword">namespace </font>NL3D
00042 {
00043 
00044 
00045 <font class="comment">// ***************************************************************************</font>
<a name="l00046"></a><a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#a0">00046</a> CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, <a class="code" href="namespaceNL3D.html#a246">ItTexDrvInfoPtrMap</a> it, CDriverGL *drvGl) : ITextureDrvInfos(drv, it)
00047 {
00048         <font class="comment">// The id is auto created here.</font>
00049         glGenTextures(1,&amp;<a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m0">ID</a>);
00050         
00051         <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m1">Compressed</a>= <font class="keyword">false</font>;
00052         <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m2">TextureMemory</a>= 0;
00053 
00054         <font class="comment">// Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid.</font>
00055         <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m3">_Driver</a>= drvGl;
00056 }
00057 <font class="comment">// ***************************************************************************</font>
<a name="l00058"></a><a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#a1">00058</a> CTextureDrvInfosGL::~CTextureDrvInfosGL()
00059 {
00060         <font class="comment">// The id is auto deleted here.</font>
00061         glDeleteTextures(1,&amp;<a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m0">ID</a>);
00062 
00063         <font class="comment">// release profiling texture mem.</font>
00064         <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m3">_Driver</a>-&gt;_AllocatedTextureMemory-= <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m2">TextureMemory</a>;
00065 
00066         <font class="comment">// release in TextureUsed.</font>
00067         <a class="code" href="classNL3D_1_1CTextureDrvInfosGL.html#m3">_Driver</a>-&gt;_TextureUsed.erase (<font class="keyword">this</font>);
00068 }
00069 
00070 
00071 
00072 <font class="comment">// ***************************************************************************</font>
00073 <font class="comment">// Get the glText mirror of an existing setuped texture.</font>
00074 <font class="keyword">static</font>  <font class="keyword">inline</font> CTextureDrvInfosGL*      <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a>(ITexture&amp; tex)
00075 {
00076         CTextureDrvInfosGL*     gltex;
00077         gltex= (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex.TextureDrvShare-&gt;DrvTexture);
00078         <font class="keywordflow">return</font> gltex;
00079 }
00080 
00081 
00082 <font class="comment">// ***************************************************************************</font>
00083 <font class="comment">// Translation of TexFmt mode.</font>
<a name="l00084"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c12">00084</a> GLint   CDriverGL::getGlTextureFormat(ITexture&amp; tex, <font class="keywordtype">bool</font> &amp;compressed)
00085 {
00086         ITexture::TUploadFormat         texfmt= tex.getUploadFormat();
00087 
00088         <font class="comment">// If auto, retrieve the pixel format of the bitmap.</font>
00089         <font class="keywordflow">if</font>(texfmt== ITexture::Auto)
00090         {
00091                 <font class="keywordflow">switch</font>(tex.getPixelFormat())
00092                 {
00093                         <font class="keywordflow">case</font> CBitmap::RGBA: 
00094                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#o27">_ForceDXTCCompression</a> &amp;&amp; tex.allowDegradation() )
00095                                         texfmt= ITexture::DXTC5;
00096                                 <font class="keywordflow">else</font>
00097                                         texfmt= ITexture::RGBA8888;
00098                                 <font class="keywordflow">break</font>;
00099                         <font class="keywordflow">case</font> CBitmap::DXTC1: texfmt= ITexture::DXTC1; <font class="keywordflow">break</font>;
00100                         <font class="keywordflow">case</font> CBitmap::DXTC1Alpha: texfmt= ITexture::DXTC1Alpha; <font class="keywordflow">break</font>;
00101                         <font class="keywordflow">case</font> CBitmap::DXTC3: texfmt= ITexture::DXTC3; <font class="keywordflow">break</font>;
00102                         <font class="keywordflow">case</font> CBitmap::DXTC5: texfmt= ITexture::DXTC5; <font class="keywordflow">break</font>;
00103                         <font class="keywordflow">case</font> CBitmap::Luminance: texfmt= ITexture::Luminance; <font class="keywordflow">break</font>;
00104                         <font class="keywordflow">case</font> CBitmap::Alpha: texfmt= ITexture::Alpha; <font class="keywordflow">break</font>;
00105                         <font class="keywordflow">case</font> CBitmap::AlphaLuminance: texfmt= ITexture::AlphaLuminance; <font class="keywordflow">break</font>;
00106                         <font class="keywordflow">case</font> CBitmap::DsDt: texfmt= ITexture::DsDt; <font class="keywordflow">break</font>;
00107                         <font class="keywordflow">default</font>: texfmt= ITexture::RGBA8888; <font class="keywordflow">break</font>;
00108                 }
00109         }
00110 
00111 
00112         <font class="comment">// Get gl tex format, try S3TC compressed ones.</font>
00113         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTTextureCompressionS3TC)
00114         {
00115                 compressed= <font class="keyword">true</font>;
00116                 <font class="comment">// Try Compressed ones.</font>
00117                 <font class="keywordflow">switch</font>(texfmt)
00118                 {
00119                         <font class="keywordflow">case</font> ITexture::DXTC1:           <font class="keywordflow">return</font> GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
00120                         <font class="keywordflow">case</font> ITexture::DXTC1Alpha:      <font class="keywordflow">return</font> GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
00121                         <font class="keywordflow">case</font> ITexture::DXTC3:           <font class="keywordflow">return</font> GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
00122                         <font class="keywordflow">case</font> ITexture::DXTC5:           <font class="keywordflow">return</font> GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
00123                         <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00124                 }
00125         }
00126 
00127 
00128         <font class="comment">// Get standard gl tex format.</font>
00129         compressed= <font class="keyword">false</font>;
00130         <font class="keywordflow">switch</font>(texfmt)
00131         {
00132                 <font class="keywordflow">case</font> ITexture::RGBA8888: <font class="keywordflow">return</font> GL_RGBA8;
00133                 <font class="keywordflow">case</font> ITexture::RGBA4444: <font class="keywordflow">return</font> GL_RGBA4;
00134                 <font class="keywordflow">case</font> ITexture::RGBA5551: <font class="keywordflow">return</font> GL_RGB5_A1;
00135                 <font class="keywordflow">case</font> ITexture::RGB888: <font class="keywordflow">return</font> GL_RGB8;
00136                 <font class="keywordflow">case</font> ITexture::RGB565: <font class="keywordflow">return</font> GL_RGB5;
00137                 <font class="keywordflow">case</font> ITexture::Luminance: <font class="keywordflow">return</font> GL_LUMINANCE8;
00138                 <font class="keywordflow">case</font> ITexture::Alpha: <font class="keywordflow">return</font> GL_ALPHA8;
00139                 <font class="keywordflow">case</font> ITexture::AlphaLuminance: <font class="keywordflow">return</font> GL_LUMINANCE8_ALPHA8;
00140                 <font class="keywordflow">case</font> ITexture::DsDt: 
00141                         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.NVTextureShader) <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a180">GL_DSDT_NV</a>;
00142                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ATIEnvMapBumpMap) <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a351">GL_DU8DV8_ATI</a>;
00143                         <font class="keywordflow">else</font>
00144                         {                       
00145                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(0);
00146                                 <font class="keywordflow">return</font> 0;
00147                         }
00148                 <font class="keywordflow">break</font>;
00149                 <font class="keywordflow">default</font>: <font class="keywordflow">return</font> GL_RGBA8;
00150         }
00151 }
00152 
00153 
00154 <font class="comment">// ***************************************************************************</font>
00155 <font class="keyword">static</font> GLint    <a class="code" href="namespaceNL3D.html#a348">getGlSrcTextureFormat</a>(ITexture &amp;tex, GLint glfmt)
00156 {
00157         <font class="comment">// Is destination format is alpha or lumiance ?</font>
00158         <font class="keywordflow">if</font> ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8))
00159         {
00160                 <font class="keywordflow">switch</font>(tex.getPixelFormat())
00161                 {
00162                 <font class="keywordflow">case</font> CBitmap::Alpha:    <font class="keywordflow">return</font> GL_ALPHA;
00163                 <font class="keywordflow">case</font> CBitmap::AlphaLuminance:   <font class="keywordflow">return</font> GL_LUMINANCE_ALPHA;
00164                 <font class="keywordflow">case</font> CBitmap::Luminance:        <font class="keywordflow">return</font> GL_LUMINANCE;
00165                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00166                 }
00167         }
00168 
00169         <font class="keywordflow">if</font> (glfmt == <a class="code" href="driver__opengl__extension__def_8h.html#a180">GL_DSDT_NV</a>)
00170         {
00171                 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a180">GL_DSDT_NV</a>;
00172         }
00173 
00174         <font class="keywordflow">if</font> (glfmt == <a class="code" href="driver__opengl__extension__def_8h.html#a351">GL_DU8DV8_ATI</a>)
00175         {
00176                 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a350">GL_DUDV_ATI</a>;
00177         }
00178 
00179         <font class="comment">// Else, not a Src format for upload, or RGBA.</font>
00180         <font class="keywordflow">return</font> GL_RGBA;
00181 }
00182 
00183 <font class="comment">// ***************************************************************************</font>
00184 <font class="keyword">static</font> GLenum <a class="code" href="namespaceNL3D.html#a349">getGlSrcTextureComponentType</a>(GLint texSrcFormat)
00185 {
00186         <font class="keywordflow">switch</font> (texSrcFormat)
00187         {
00188                 <font class="keywordflow">case</font> <a class="code" href="driver__opengl__extension__def_8h.html#a180">GL_DSDT_NV</a>:
00189                 <font class="keywordflow">case</font> <a class="code" href="driver__opengl__extension__def_8h.html#a351">GL_DU8DV8_ATI</a>:
00190                         <font class="keywordflow">return</font> GL_BYTE; <font class="comment">// these are signed format                      </font>
00191                 <font class="keywordflow">break</font>;          
00192                 <font class="keywordflow">default</font>:
00193                         <font class="keywordflow">return</font> GL_UNSIGNED_BYTE;
00194                 <font class="keywordflow">break</font>;
00195 
00196         }
00197 }
00198 
00199 <font class="comment">// ***************************************************************************</font>
<a name="l00200"></a><a class="code" href="classNL3D_1_1CDriverGL.html#z412_0">00200</a> uint                            CDriverGL::computeMipMapMemoryUsage(uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint h, GLint glfmt)<font class="keyword"> const</font>
00201 <font class="keyword"></font>{
00202         <font class="keywordflow">switch</font>(glfmt)
00203         {
00204         <font class="keywordflow">case</font> GL_RGBA8:          <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 4;
00205         <font class="comment">// Well this is ugly, but simple :). GeForce 888 is stored as 32 bits.</font>
00206         <font class="keywordflow">case</font> GL_RGB8:           <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 4;
00207         <font class="keywordflow">case</font> GL_RGBA4:          <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 2;
00208         <font class="keywordflow">case</font> GL_RGB5_A1:        <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 2;
00209         <font class="keywordflow">case</font> GL_RGB5:           <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 2;
00210         <font class="keywordflow">case</font> GL_LUMINANCE8:     <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 1;
00211         <font class="keywordflow">case</font> GL_ALPHA8:         <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 1;
00212         <font class="keywordflow">case</font> GL_LUMINANCE8_ALPHA8:      <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 2;
00213         <font class="keywordflow">case</font> GL_COMPRESSED_RGB_S3TC_DXT1_EXT:   <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h /2;
00214         <font class="keywordflow">case</font> GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:  <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h /2;
00215         <font class="keywordflow">case</font> GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:  <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 1;
00216         <font class="keywordflow">case</font> GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:  <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 1;
00217         <font class="keywordflow">case</font> <a class="code" href="driver__opengl__extension__def_8h.html#a351">GL_DU8DV8_ATI</a>:
00218         <font class="keywordflow">case</font> <a class="code" href="driver__opengl__extension__def_8h.html#a180">GL_DSDT_NV</a>:                                                <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 2;
00219         };
00220 
00221         <font class="comment">// One format has not been coded.</font>
00222         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00223 
00225         <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h* 4;
00226 }
00227 
00228 
00229 <font class="comment">// ***************************************************************************</font>
00230 <font class="comment">// Translation of Wrap mode.</font>
00231 <font class="keyword">static</font> <font class="keyword">inline</font> GLenum    <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(ITexture::TWrapMode mode, <font class="keyword">const</font> CGlExtensions &amp;extensions)
00232 {
00233         <font class="keywordflow">if</font>(mode== ITexture::Repeat)
00234                 <font class="keywordflow">return</font> GL_REPEAT;
00235         <font class="keywordflow">else</font>
00236         {
00237                 <font class="keywordflow">if</font>(extensions.Version1_2)
00238                         <font class="keywordflow">return</font> GL_CLAMP_TO_EDGE;
00239                 <font class="keywordflow">else</font>
00240                         <font class="keywordflow">return</font> GL_CLAMP;
00241         }
00242 }
00243 
00244 
00245 <font class="comment">// ***************************************************************************</font>
00246 <font class="keyword">static</font> <font class="keyword">inline</font> GLenum    <a class="code" href="namespaceNL3D.html#a351">translateMagFilterToGl</a>(ITexture::TMagFilter mode)
00247 {       
00248         <font class="keywordflow">switch</font>(mode)
00249         {
00250                 <font class="keywordflow">case</font> ITexture::Linear: <font class="keywordflow">return</font> GL_LINEAR;
00251                 <font class="keywordflow">case</font> ITexture::Nearest: <font class="keywordflow">return</font> GL_NEAREST;
00252                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00253         }
00254 
00255         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00256         <font class="keywordflow">return</font> GL_LINEAR;
00257 }
00258 
00259 
00260 <font class="comment">// ***************************************************************************</font>
00261 <font class="keyword">static</font> <font class="keyword">inline</font> GLenum    <a class="code" href="namespaceNL3D.html#a352">translateMinFilterToGl</a>(ITexture::TMinFilter mode)
00262 {
00263         <font class="keywordflow">switch</font>(mode)
00264         {
00265                 <font class="keywordflow">case</font> ITexture::NearestMipMapOff: <font class="keywordflow">return</font> GL_NEAREST;
00266                 <font class="keywordflow">case</font> ITexture::NearestMipMapNearest: <font class="keywordflow">return</font> GL_NEAREST_MIPMAP_NEAREST;
00267                 <font class="keywordflow">case</font> ITexture::NearestMipMapLinear: <font class="keywordflow">return</font> GL_NEAREST_MIPMAP_LINEAR;
00268                 <font class="keywordflow">case</font> ITexture::LinearMipMapOff: <font class="keywordflow">return</font> GL_LINEAR;
00269                 <font class="keywordflow">case</font> ITexture::LinearMipMapNearest: <font class="keywordflow">return</font> GL_LINEAR_MIPMAP_NEAREST;
00270                 <font class="keywordflow">case</font> ITexture::LinearMipMapLinear: <font class="keywordflow">return</font> GL_LINEAR_MIPMAP_LINEAR;
00271                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00272         }
00273 
00274         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00275         <font class="keywordflow">return</font> GL_LINEAR;
00276 }
00277 
00278 
00279 <font class="comment">// ***************************************************************************</font>
00280 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">bool</font>              <a class="code" href="namespaceNL3D.html#a353">sameDXTCFormat</a>(ITexture &amp;tex, GLint glfmt)
00281 {
00282         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT &amp;&amp; tex.PixelFormat==CBitmap::DXTC1)
00283                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00284         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT &amp;&amp; tex.PixelFormat==CBitmap::DXTC1Alpha)
00285                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00286         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT &amp;&amp; tex.PixelFormat==CBitmap::DXTC3)
00287                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00288         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT &amp;&amp; tex.PixelFormat==CBitmap::DXTC5)
00289                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00290 
00291         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00292 }
00293 
00294 
00295 <font class="comment">// ***************************************************************************</font>
00296 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">bool</font>              <a class="code" href="namespaceNL3D.html#a354">isDXTCFormat</a>(GLint glfmt)
00297 {
00298         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
00299                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00300         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
00301                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00302         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)
00303                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00304         <font class="keywordflow">if</font>(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
00305                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00306 
00307         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00308 }
00309 
00310 
00311 <font class="comment">// ***************************************************************************</font>
<a name="l00312"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a18">00312</a> <font class="keywordtype">bool</font> CDriverGL::setupTexture (ITexture&amp; tex)
00313 {
00314         <font class="keywordtype">bool</font> nTmp;
00315         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CDriverGL.html#a19">setupTextureEx</a> (tex, <font class="keyword">true</font>, nTmp);
00316 }
00317 
00318 <font class="comment">// ***************************************************************************</font>
<a name="l00319"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a19">00319</a> <font class="keywordtype">bool</font> CDriverGL::setupTextureEx (ITexture&amp; tex, <font class="keywordtype">bool</font> bUpload, <font class="keywordtype">bool</font> &amp;bAllUploaded, <font class="keywordtype">bool</font> bMustRecreateSharedTexture)
00320 {
00321         bAllUploaded = <font class="keyword">false</font>;
00322         
00323         <font class="keywordflow">if</font>(tex.isTextureCube() &amp;&amp; (!<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ARBTextureCubeMap))
00324                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00325 
00326         <font class="comment">// 0. Create/Retrieve the driver texture.</font>
00327         <font class="comment">//=======================================</font>
00328         <font class="keywordtype">bool</font> mustCreate = <font class="keyword">false</font>;
00329         <font class="keywordflow">if</font> ( !tex.TextureDrvShare )
00330         {
00331                 <font class="comment">// insert into driver list. (so it is deleted when driver is deleted).</font>
00332                 <a class="code" href="namespaceNL3D.html#a247">ItTexDrvSharePtrList</a>    it= <a class="code" href="classNL3D_1_1IDriver.html#n1">_TexDrvShares</a>.insert(<a class="code" href="classNL3D_1_1IDriver.html#n1">_TexDrvShares</a>.end());
00333                 <font class="comment">// create and set iterator, for future deletion.</font>
00334                 *it= tex.TextureDrvShare= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1IDriver.html#l1">CTextureDrvShare</a>(<font class="keyword">this</font>, it);
00335 
00336                 <font class="comment">// Must (re)-create the texture.</font>
00337                 mustCreate = <font class="keyword">true</font>;
00338         }
00339 
00340         <font class="keywordflow">if</font> ( (!tex.touched()) &amp;&amp; (!mustCreate) )
00341                 <font class="keywordflow">return</font> <font class="keyword">true</font>; <font class="comment">// Do not do anything</font>
00342 
00343 
00344         <font class="comment">// 1. If modified, may (re)load texture part or all of the texture.</font>
00345         <font class="comment">//=================================================================</font>
00346 
00347 
00348         <font class="keywordtype">bool</font>    mustLoadAll= <font class="keyword">false</font>;
00349         <font class="keywordtype">bool</font>    mustLoadPart= <font class="keyword">false</font>;
00350 
00351 
00352         <font class="comment">// To avoid any delete/new ptr problem, disable all texturing.</font>
00353         <font class="comment">/* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid. </font>
00354 <font class="comment">                But this is grave only if a new texture is created, with the same pointer (bad luck). </font>
00355 <font class="comment">                Since an newly allocated texture always pass here before use, we are sure to avoid any problems.</font>
00356 <font class="comment">        */</font>
00357         <font class="keywordflow">for</font>(sint stage=0 ; stage&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>() ; stage++)
00358         {
00359                 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage, NULL);
00360         }
00361 
00362 
00363         <font class="comment">// A. Share mgt.</font>
00364         <font class="comment">//==============</font>
00365         <font class="keywordflow">if</font>(tex.supportSharing())
00366         {
00367                 <font class="comment">// Try to get the shared texture.</font>
00368 
00369                 <font class="comment">// Create the shared Name.</font>
00370                 std::string     name;
00371                 <a class="code" href="classNL3D_1_1IDriver.html#d0">getTextureShareName</a> (tex, name);
00372 
00373                 <font class="comment">// insert or get the texture.</font>
00374                 {
00375                         CSynchronized&lt;TTexDrvInfoPtrMap&gt;::CAccessor access(&amp;<a class="code" href="classNL3D_1_1IDriver.html#n0">_SyncTexDrvInfos</a>);
00376                         TTexDrvInfoPtrMap &amp;rTexDrvInfos = access.value();
00377 
00378                         <a class="code" href="namespaceNL3D.html#a246">ItTexDrvInfoPtrMap</a>      itTex;
00379                         itTex= rTexDrvInfos.find(name);
00380 
00381                         <font class="comment">// texture not found?</font>
00382                         <font class="keywordflow">if</font>( itTex==rTexDrvInfos.end() )
00383                         {
00384                                 <font class="comment">// insert into driver map. (so it is deleted when driver is deleted).</font>
00385                                 itTex= (rTexDrvInfos.insert(make_pair(name, (<a class="code" href="classNL3D_1_1IDriver.html#l2">ITextureDrvInfos</a>*)NULL))).first;
00386                                 <font class="comment">// create and set iterator, for future deletion.</font>
00387                                 itTex-&gt;second= tex.TextureDrvShare-&gt;DrvTexture= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>(<font class="keyword">this</font>, itTex, <font class="keyword">this</font>);
00388 
00389                                 <font class="comment">// need to load ALL this texture.</font>
00390                                 mustLoadAll= <font class="keyword">true</font>;
00391                         }
00392                         <font class="keywordflow">else</font>
00393                         {
00394                                 tex.TextureDrvShare-&gt;DrvTexture= itTex-&gt;second;
00395 
00396                                 <font class="keywordflow">if</font>(bMustRecreateSharedTexture)
00397                                         <font class="comment">// reload this shared texture (user request)</font>
00398                                         mustLoadAll= <font class="keyword">true</font>;
00399                                 <font class="keywordflow">else</font>
00400                                         <font class="comment">// Do not need to reload this texture, even if the format/mipmap has changed, since we found this </font>
00401                                         <font class="comment">// couple in the map.</font>
00402                                         mustLoadAll= <font class="keyword">false</font>;
00403                         }
00404                 }
00405                 <font class="comment">// Do not test if part of texture may need to be computed, because Rect invalidation is incompatible </font>
00406                 <font class="comment">// with texture sharing.</font>
00407         }
00408         <font class="keywordflow">else</font>
00409         {
00410                 <font class="comment">// If texture not already created.</font>
00411                 <font class="keywordflow">if</font>(!tex.TextureDrvShare-&gt;DrvTexture)
00412                 {
00413                         <font class="comment">// Must create it. Create auto a GL id (in constructor).</font>
00414                         <font class="comment">// Do not insert into the map. This un-shared texture will be deleted at deletion of the texture.</font>
00415                         <font class="comment">// Inform ITextureDrvInfos by passing NULL _Driver.</font>
00416                         tex.TextureDrvShare-&gt;DrvTexture= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>(NULL, <a class="code" href="namespaceNL3D.html#a246">ItTexDrvInfoPtrMap</a>(), <font class="keyword">this</font>);
00417 
00418                         <font class="comment">// need to load ALL this texture.</font>
00419                         mustLoadAll= <font class="keyword">true</font>;
00420                 }
00421                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(tex.isAllInvalidated())
00422                         mustLoadAll= <font class="keyword">true</font>;
00423                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(tex.touched())
00424                         mustLoadPart= <font class="keyword">true</font>;
00425         }
00426 
00427         <font class="comment">// B. Setup texture.</font>
00428         <font class="comment">//==================</font>
00429         <font class="keywordflow">if</font>(mustLoadAll || mustLoadPart)
00430         {
00431                 <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>*     gltext;
00432                 gltext= <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a>(tex);
00433 
00434                 <font class="comment">// system of "backup the previous binded texture" seems to not work with some drivers....</font>
00435                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(0);
00436                 <font class="keywordflow">if</font>(tex.isTextureCube())
00437                 {
00438                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureCubeMap);
00439                         <font class="comment">// Bind this texture, for reload...</font>
00440                         glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext-&gt;ID);                             
00441                 }
00442                 <font class="keywordflow">else</font>
00443                 {
00444                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::Texture2D);
00445                         <font class="comment">// Bind this texture, for reload...</font>
00446                         glBindTexture(GL_TEXTURE_2D, gltext-&gt;ID);                               
00447                 }
00448 
00449 
00450                 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
00451 
00452                 <font class="comment">// a. Load All the texture case.</font>
00453                 <font class="comment">//==============================</font>
00454                 <font class="keywordflow">if</font> (mustLoadAll)
00455                 {
00456                         <font class="comment">// profiling. sub old textre memory usage, and reset.</font>
00457                         <a class="code" href="classNL3D_1_1CDriverGL.html#z412_3">_AllocatedTextureMemory</a>-= gltext-&gt;TextureMemory;
00458                         gltext-&gt;TextureMemory= 0;
00459 
00460 
00461                         <font class="keywordflow">if</font>(tex.isTextureCube())
00462                         {
00463                                 <font class="keyword">static</font> GLenum face_map[6] = {   GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
00464                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
00465                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
00466                                                                                                 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
00467                                                                                                 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
00468                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB };
00469                                 CTextureCube *pTC = NLMISC::safe_cast&lt;CTextureCube *&gt;(&amp;tex);
00470                                 <font class="comment">// Regenerate all the texture.</font>
00471                                 tex.generate();                                 
00472                                 <font class="keywordflow">for</font>(uint nText = 0; nText &lt; 6; ++nText)
00473                                 <font class="keywordflow">if</font>(pTC-&gt;getTexture((CTextureCube::TFace)nText) != NULL)
00474                                 {
00475                                         ITexture *pTInTC = pTC-&gt;getTexture((CTextureCube::TFace)nText);
00476                                         <font class="comment">// Get the correct texture format from texture...</font>
00477                                         GLint   glfmt= <a class="code" href="classNL3D_1_1CDriverGL.html#c12">getGlTextureFormat</a>(*pTInTC, gltext-&gt;Compressed);
00478                                         GLint   glSrcFmt= <a class="code" href="namespaceNL3D.html#a348">getGlSrcTextureFormat</a>(*pTInTC, glfmt);
00479                                         GLenum  glSrcType= <a class="code" href="namespaceNL3D.html#a349">getGlSrcTextureComponentType</a>(glSrcFmt);
00480 
00481                                         sint    nMipMaps;
00482                                         <font class="keywordflow">if</font>(glSrcFmt==GL_RGBA &amp;&amp; pTInTC-&gt;getPixelFormat()!=CBitmap::RGBA )
00483                                                 pTInTC-&gt;convertToType(CBitmap::RGBA);
00484                                         <font class="keywordflow">if</font>(tex.mipMapOn())
00485                                         {
00486                                                 pTInTC-&gt;buildMipMaps();
00487                                                 nMipMaps= pTInTC-&gt;getMipMapCount();
00488                                         }
00489                                         <font class="keywordflow">else</font>
00490                                                 nMipMaps= 1;
00491 
00492                                         <font class="comment">// Fill mipmaps.</font>
00493                                         <font class="keywordflow">for</font>(sint i=0;i&lt;nMipMaps;i++)
00494                                         {
00495                                                 <font class="keywordtype">void</font>    *ptr= &amp;(*pTInTC-&gt;getPixels(i).begin());
00496                                                 uint    <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= pTInTC-&gt;getWidth(i);
00497                                                 uint    h= pTInTC-&gt;getHeight(i);
00498                                                 <font class="keywordflow">if</font> (bUpload)
00499                                                 {
00500                                                         glTexImage2D (face_map[nText], i, glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, 0, glSrcFmt, glSrcType, ptr);
00501                                                         bAllUploaded = <font class="keyword">true</font>;
00502                                                 }
00503                                                 <font class="keywordflow">else</font>
00504                                                 {
00505                                                         glTexImage2D (face_map[nText], i, glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, 0, glSrcFmt, glSrcType, NULL);
00506                                                 }
00507                                                 <font class="comment">// profiling: count TextureMemory usage.</font>
00508                                                 gltext-&gt;TextureMemory+= <a class="code" href="classNL3D_1_1CDriverGL.html#z412_0">computeMipMapMemoryUsage</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, glfmt);
00509                                         }
00510                                 }
00511                         }
00512                         <font class="keywordflow">else</font>
00513                         {
00514                                 <font class="comment">// Regenerate all the texture.</font>
00515                                 tex.generate();
00516 
00517                                 <font class="keywordflow">if</font>(tex.getSize()&gt;0)
00518                                 {
00519                                         <font class="comment">// Get the correct texture format from texture...</font>
00520                                         GLint   glfmt= <a class="code" href="classNL3D_1_1CDriverGL.html#c12">getGlTextureFormat</a>(tex, gltext-&gt;Compressed);
00521                                         GLint   glSrcFmt= <a class="code" href="namespaceNL3D.html#a348">getGlSrcTextureFormat</a>(tex, glfmt);
00522                                         GLenum  glSrcType= <a class="code" href="namespaceNL3D.html#a349">getGlSrcTextureComponentType</a>(glSrcFmt);
00523 
00524                                         <font class="comment">// DXTC: if same format, and same mipmapOn/Off, use glTexCompressedImage*.</font>
00525                                         <font class="comment">// We cannot build the mipmaps if they are not here.</font>
00526                                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTTextureCompressionS3TC &amp;&amp; <a class="code" href="namespaceNL3D.html#a353">sameDXTCFormat</a>(tex, glfmt) &amp;&amp;
00527                                                 (tex.mipMapOff() || tex.getMipMapCount()&gt;1) )
00528                                         {
00529                                                 sint    nMipMaps;
00530                                                 <font class="keywordflow">if</font>(tex.mipMapOn())
00531                                                         nMipMaps= tex.getMipMapCount();
00532                                                 <font class="keywordflow">else</font>
00533                                                         nMipMaps= 1;
00534 
00535                                                 <font class="comment">// Degradation in Size allowed only if DXTC texture are provided with mipmaps.</font>
00536                                                 <font class="comment">// Because use them to resize !!!</font>
00537                                                 uint    decalMipMapResize= 0;
00538                                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>&gt;0 &amp;&amp; tex.allowDegradation() &amp;&amp; nMipMaps&gt;1)
00539                                                 {
00540                                                         decalMipMapResize= <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>, (uint)(nMipMaps-1));
00541                                                 }
00542 
00543                                                 <font class="comment">// Fill mipmaps.</font>
00544                                                 <font class="keywordflow">for</font>(sint i=decalMipMapResize;i&lt;nMipMaps;i++)
00545                                                 {
00546                                                         <font class="keywordtype">void</font>    *ptr= &amp;(*tex.getPixels(i).begin());
00547                                                         sint    size= tex.getPixels(i).size();
00548                                                         <font class="keywordflow">if</font> (bUpload)
00549                                                         {
00550                                                                 <a class="code" href="driver__opengl__extension_8h.html#a35">nglCompressedTexImage2DARB</a> (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, 
00551                                                                                                                         tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
00552                                                                 bAllUploaded = <font class="keyword">true</font>;
00553                                                         }
00554                                                         <font class="keywordflow">else</font>
00555                                                         {
00556                                                                 <font class="comment">//nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, </font>
00557                                                                 <font class="comment">//                                                      tex.getWidth(i),tex.getHeight(i), 0, size, NULL);</font>
00558                                                                 glTexImage2D (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, tex.getWidth(i), tex.getHeight(i), 
00559                                                                                                 0, glSrcFmt, glSrcType, NULL);
00560                                                         }
00561 
00562                                                         <font class="comment">// profiling: count TextureMemory usage.</font>
00563                                                         gltext-&gt;TextureMemory+= tex.getPixels(i).size();
00564                                                 }
00565                                         }
00566                                         <font class="keywordflow">else</font>
00567                                         {
00568                                                 sint    nMipMaps;
00569                                                 <font class="keywordflow">if</font>(glSrcFmt==GL_RGBA &amp;&amp; tex.getPixelFormat()!=CBitmap::RGBA )
00570                                                 {
00571                                                         bUpload = <font class="keyword">true</font>; <font class="comment">// Force all upload</font>
00572                                                         tex.convertToType(CBitmap::RGBA);
00573                                                 }
00574 
00575                                                 <font class="comment">// Degradation in Size.</font>
00576                                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>&gt;0 &amp;&amp; tex.allowDegradation())
00577                                                 {
00578                                                         uint    <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= tex.getWidth(0) &gt;&gt; <a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>;
00579                                                         uint    h= tex.getHeight(0) &gt;&gt; <a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>;
00580                                                         <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= max(1U, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00581                                                         h= max(1U, h);
00582                                                         tex.resample(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h);
00583                                                 }
00584 
00585                                                 <font class="keywordflow">if</font>(tex.mipMapOn())
00586                                                 {
00587                                                         tex.buildMipMaps();
00588                                                         nMipMaps= tex.getMipMapCount();
00589                                                 }
00590                                                 <font class="keywordflow">else</font>
00591                                                         nMipMaps= 1;
00592 
00593                                                 <font class="comment">// Fill mipmaps.</font>
00594                                                 <font class="keywordflow">for</font>(sint i=0;i&lt;nMipMaps;i++)
00595                                                 {
00596                                                         <font class="keywordtype">void</font>    *ptr= &amp;(*tex.getPixels(i).begin());
00597                                                         uint    <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= tex.getWidth(i);
00598                                                         uint    h= tex.getHeight(i);
00599 
00600                                                         <font class="keywordflow">if</font> (bUpload)
00601                                                         {                                                                                                                               
00602                                                                 glTexImage2D (GL_TEXTURE_2D, i, glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, 0,glSrcFmt, glSrcType, ptr);
00603                                                                 bAllUploaded = <font class="keyword">true</font>;
00604                                                         }
00605                                                         <font class="keywordflow">else</font>
00606                                                         {                                                               
00607                                                                 glTexImage2D (GL_TEXTURE_2D, i, glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, 0,glSrcFmt, glSrcType, NULL);                                                              
00608                                                         }
00609                                                         <font class="comment">// profiling: count TextureMemory usage.</font>
00610                                                         gltext-&gt;TextureMemory += <a class="code" href="classNL3D_1_1CDriverGL.html#z412_0">computeMipMapMemoryUsage</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, glfmt);
00611                                                 }
00612                                         }
00613                                 }
00614                         }
00615                         <font class="comment">//printf("%d,%d,%d\n", tex.getMipMapCount(), tex.getWidth(0), tex.getHeight(0));</font>
00616 
00617 
00618                         <font class="comment">// profiling. add new TextureMemory usage.</font>
00619                         <a class="code" href="classNL3D_1_1CDriverGL.html#z412_3">_AllocatedTextureMemory</a>+= gltext-&gt;TextureMemory;
00620                 }
00621                 <font class="comment">// b. Load part of the texture case.</font>
00622                 <font class="comment">//==================================</font>
00623                 <font class="comment">// \todo yoyo: TODO_DXTC</font>
00624                 <font class="comment">// Replace parts of a compressed image. Maybe don't work with the actual system of invalidateRect()...</font>
00625                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (mustLoadPart &amp;&amp; !gltext-&gt;Compressed)
00626                 {
00627                         <font class="comment">// Regenerate wanted part of the texture.</font>
00628                         tex.generate();
00629 
00630                         <font class="keywordflow">if</font>(tex.getSize()&gt;0)
00631                         {
00632                                 <font class="comment">// Get the correct texture format from texture...</font>
00633                                 <font class="comment">//===============================================</font>
00634                                 <font class="keywordtype">bool</font>    dummy;
00635                                 GLint   glfmt= <a class="code" href="classNL3D_1_1CDriverGL.html#c12">getGlTextureFormat</a>(tex, dummy);
00636                                 GLint   glSrcFmt= <a class="code" href="namespaceNL3D.html#a348">getGlSrcTextureFormat</a>(tex, glfmt);
00637                                 GLenum  glSrcType= <a class="code" href="namespaceNL3D.html#a349">getGlSrcTextureComponentType</a>(glSrcFmt);
00638 
00639                                 sint    nMipMaps;
00640                                 <font class="keywordflow">if</font>(glSrcFmt==GL_RGBA &amp;&amp; tex.getPixelFormat()!=CBitmap::RGBA )
00641                                         tex.convertToType(CBitmap::RGBA);
00642                                 <font class="keywordflow">if</font>(tex.mipMapOn())
00643                                 {
00644                                         <font class="keywordtype">bool</font>    hadMipMap= tex.getMipMapCount()&gt;1;
00645                                         tex.buildMipMaps();
00646                                         nMipMaps= tex.getMipMapCount();
00647                                         <font class="comment">// If the texture had no mipmap before, release them.</font>
00648                                         <font class="keywordflow">if</font>(!hadMipMap)
00649                                         {
00650                                                 tex.releaseMipMaps();
00651                                         }
00652                                 }
00653                                 <font class="keywordflow">else</font>
00654                                         nMipMaps= 1;
00655 
00656                                 <font class="comment">// For all rect, update the texture/mipmap.</font>
00657                                 <font class="comment">//===============================================</font>
00658                                 list&lt;NLMISC::CRect&gt;::iterator   itRect;
00659                                 <font class="keywordflow">for</font>(itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++)
00660                                 {
00661                                         CRect   &amp;rect= *itRect;
00662                                         sint    x0= rect.X;
00663                                         sint    y0= rect.Y;
00664                                         sint    x1= rect.X+rect.Width;
00665                                         sint    y1= rect.Y+rect.Height;
00666 
00667                                         <font class="comment">// Fill mipmaps.</font>
00668                                         <font class="keywordflow">for</font>(sint i=0;i&lt;nMipMaps;i++)
00669                                         {
00670                                                 <font class="keywordtype">void</font>    *ptr= &amp;(*tex.getPixels(i).begin());
00671                                                 sint    <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= tex.getWidth(i);
00672                                                 sint    h= tex.getHeight(i);
00673                                                 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(x0, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00674                                                 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(y0, 0, h);
00675                                                 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(x1, x0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00676                                                 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(y1, y0, h);
00677 
00678                                                 glPixelStorei(GL_UNPACK_ROW_LENGTH, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00679                                                 glPixelStorei(GL_UNPACK_SKIP_ROWS, y0);
00680                                                 glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0);
00681                                                 <font class="keywordflow">if</font> (bUpload)
00682                                                         glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr);
00683                                                 <font class="keywordflow">else</font>
00684                                                         glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL);
00685 
00686                                                 <font class="comment">// Next mipmap!!</font>
00687                                                 <font class="comment">// floor .</font>
00688                                                 x0= x0/2;
00689                                                 y0= y0/2;
00690                                                 <font class="comment">// ceil.</font>
00691                                                 x1= (x1+1)/2;
00692                                                 y1= (y1+1)/2;
00693                                         }
00694                                 }
00695 
00696                                 <font class="comment">// Reset the transfer mode...</font>
00697                                 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
00698                                 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
00699                                 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
00700                         }
00701                 }
00702 
00703 
00704                 <font class="comment">// Release, if wanted.</font>
00705                 <font class="keywordflow">if</font>(tex.getReleasable())
00706                         tex.release();
00707 
00708                 <font class="comment">// Basic parameters.</font>
00709                 <font class="comment">//==================</font>
00710                 gltext-&gt;WrapS= tex.getWrapS();
00711                 gltext-&gt;WrapT= tex.getWrapT();
00712                 gltext-&gt;MagFilter= tex.getMagFilter();
00713                 gltext-&gt;MinFilter= tex.getMinFilter();
00714                 <font class="keywordflow">if</font>(tex.isTextureCube())
00715                 {
00716                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(ITexture::Clamp, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00717                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(ITexture::Clamp, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00718                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(ITexture::Clamp, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00719                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, <a class="code" href="namespaceNL3D.html#a351">translateMagFilterToGl</a>(gltext-&gt;MagFilter));
00720                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, <a class="code" href="namespaceNL3D.html#a352">translateMinFilterToGl</a>(gltext-&gt;MinFilter));
00721                 }
00722                 <font class="keywordflow">else</font>
00723                 {
00724                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(gltext-&gt;WrapS, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00725                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(gltext-&gt;WrapT, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00726                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, <a class="code" href="namespaceNL3D.html#a351">translateMagFilterToGl</a>(gltext-&gt;MagFilter));
00727                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, <a class="code" href="namespaceNL3D.html#a352">translateMinFilterToGl</a>(gltext-&gt;MinFilter));
00728                 }
00729 
00730 
00731 
00732                 <font class="comment">// Disable texture 0</font>
00733                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_4">_CurrentTexture</a>[0]= NULL;
00734                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[0]= NULL;
00735                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureDisabled);
00736         }
00737 
00738 
00739         <font class="comment">// The texture is correctly setuped.</font>
00740         tex.clearTouched();
00741         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00742 }
00743 
00744 
00745 <font class="comment">// ***************************************************************************</font>
<a name="l00746"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a20">00746</a> <font class="keywordtype">bool</font> CDriverGL::uploadTexture (ITexture&amp; tex, CRect&amp; rect, uint8 nNumMipMap)
00747 {
00748         <font class="keywordflow">if</font> (tex.TextureDrvShare == NULL)
00749                 <font class="keywordflow">return</font> <font class="keyword">false</font>; <font class="comment">// Texture not created</font>
00750         <font class="keywordflow">if</font> (tex.TextureDrvShare-&gt;DrvTexture == NULL)
00751                 <font class="keywordflow">return</font> <font class="keyword">false</font>; <font class="comment">// Texture not created</font>
00752         <font class="keywordflow">if</font> (tex.isTextureCube())
00753                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00754 
00755         <a class="code" href="debug_8h.html#a6">nlassert</a>(nNumMipMap&lt;(uint8)tex.getMipMapCount());
00756 
00757         <font class="comment">// validate rect.</font>
00758         sint x0 = rect.X;
00759         sint y0 = rect.Y;
00760         sint x1 = rect.X+rect.Width;
00761         sint y1 = rect.Y+rect.Height;
00762         sint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = tex.getWidth (nNumMipMap);
00763         sint h = tex.getHeight (nNumMipMap);
00764         <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (x0, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00765         <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (y0, 0, h);
00766         <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (x1, x0, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00767         <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (y1, y0, h);
00768 
00769         <font class="comment">// bind the texture to upload </font>
00770         <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>*     gltext;
00771         gltext = <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a> (tex);
00772 
00773         <font class="comment">// system of "backup the previous binded texture" seems to not work with some drivers....</font>
00774         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB (0);
00775         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode (CDriverGLStates::Texture2D);
00776         <font class="comment">// Bind this texture, for reload...</font>
00777         glBindTexture (GL_TEXTURE_2D, gltext-&gt;ID);
00778 
00779         glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
00780 
00781         <font class="keywordtype">bool</font> dummy;
00782         GLint glfmt = <a class="code" href="classNL3D_1_1CDriverGL.html#c12">getGlTextureFormat</a> (tex, dummy);
00783         GLint glSrcFmt = <a class="code" href="namespaceNL3D.html#a348">getGlSrcTextureFormat</a> (tex, glfmt);
00784         GLenum  glSrcType= <a class="code" href="namespaceNL3D.html#a349">getGlSrcTextureComponentType</a>(glSrcFmt);
00785         <font class="comment">// If DXTC format</font>
00786         <font class="comment">//if (isDXTCFormat(glfmt))</font>
00787         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTTextureCompressionS3TC &amp;&amp; <a class="code" href="namespaceNL3D.html#a353">sameDXTCFormat</a>(tex, glfmt) &amp;&amp;
00788                         (tex.mipMapOff() || tex.getMipMapCount()&gt;1) )
00789         {
00790                 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTTextureCompressionS3TC &amp;&amp; <a class="code" href="namespaceNL3D.html#a353">sameDXTCFormat</a>(tex, glfmt) &amp;&amp;
00791                                         (tex.mipMapOff() || tex.getMipMapCount()&gt;1) );
00792 
00793                 sint nUploadMipMaps;
00794                 <font class="keywordflow">if</font> (tex.mipMapOn())
00795                         nUploadMipMaps = tex.getMipMapCount();
00796                 <font class="keywordflow">else</font>
00797                         nUploadMipMaps = 1;
00798 
00799                 uint decalMipMapResize = 0;
00800                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>&gt;0 &amp;&amp; tex.allowDegradation() &amp;&amp; nUploadMipMaps&gt;1)
00801                 {
00802                         decalMipMapResize = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>, (uint)(nUploadMipMaps-1));
00803                 }
00804 
00805                 <font class="comment">// Compute src compressed size and location</font>
00806                 sint <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a> = (x1-x0)*(y1-y0);
00807                 <font class="keywordtype">void</font> *ptr = &amp;(*tex.getPixels(nNumMipMap).begin());
00808 
00809                 <font class="comment">// If DXTC1 or DXTC1A, then 4 bits/texel else 8 bits/texel</font>
00810                 <font class="keywordflow">if</font> (glfmt == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || glfmt == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
00811                 {
00812                         <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a> /= 2;
00813                         ptr = (uint8*)ptr + y0*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>/2 + x0/2;
00814                 }
00815                 <font class="keywordflow">else</font>
00816                 {
00817                         ptr = (uint8*)ptr + y0*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + x0;
00818                 }
00819 
00820                 <font class="comment">// Upload</font>
00821 
00822                 <font class="keywordflow">if</font> (decalMipMapResize &gt; nNumMipMap)
00823                 {
00824                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_4">_CurrentTexture</a>[0]= NULL;
00825                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[0]= NULL;
00826                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode (CDriverGLStates::TextureDisabled);
00827                         <font class="keywordflow">return</font> <font class="keyword">false</font>;
00828                 }
00829                         
00830 
00831                 <a class="code" href="debug_8h.html#a6">nlassert</a> (((x0&amp;3) == 0) &amp;&amp; ((y0&amp;3) == 0));
00832                 <font class="keywordflow">if</font> ((<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>&gt;=4) &amp;&amp; (h&gt;=4))
00833                 {
00834                         <a class="code" href="driver__opengl__extension_8h.html#a38">nglCompressedTexSubImage2DARB</a> ( GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, 
00835                                                                                         x0, y0, (x1-x0), (y1-y0), glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a>, ptr );
00836                 }
00837                 <font class="keywordflow">else</font>
00838                 {
00839                         <font class="comment">// The CompressedTexSubImage2DARB function do not functionnate properly if width or height</font>
00840                         <font class="comment">// of the mipmap is less than 4 pixel so we use the other form. (its not really time critical</font>
00841                         <font class="comment">// to upload 16 bytes so we can do it twice if texture is cut)</font>
00842                         <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a> = tex.getPixels(nNumMipMap).size();
00843                         <a class="code" href="driver__opengl__extension_8h.html#a35">nglCompressedTexImage2DARB</a> (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, 
00844                                                                                 glfmt, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, 0, <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a>, ptr);
00845                 }
00846         }
00847         <font class="keywordflow">else</font>
00848         {
00849                 <font class="comment">// glSrcFmt and ITexture format must be identical</font>
00850                 <a class="code" href="debug_8h.html#a6">nlassert</a> (glSrcFmt!=GL_RGBA || tex.getPixelFormat()==CBitmap::RGBA);
00851 
00852                 <font class="keywordtype">void</font>    *ptr= &amp;(*tex.getPixels(nNumMipMap).begin());
00853                 glPixelStorei (GL_UNPACK_ROW_LENGTH, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00854                 glPixelStorei (GL_UNPACK_SKIP_ROWS, y0);
00855                 glPixelStorei (GL_UNPACK_SKIP_PIXELS, x0);
00856                 glTexSubImage2D (GL_TEXTURE_2D, nNumMipMap, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr);
00857 
00858                 <font class="comment">// Reset the transfer mode...</font>
00859                 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
00860                 glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
00861                 glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
00862         }
00863 
00864         <font class="comment">// Disable texture 0</font>
00865         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_4">_CurrentTexture</a>[0]= NULL;
00866         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[0]= NULL;
00867         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode (CDriverGLStates::TextureDisabled);
00868 
00869         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00870 }
00871 
00872 <font class="comment">// ***************************************************************************</font>
<a name="l00873"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a21">00873</a> <font class="keywordtype">bool</font> CDriverGL::uploadTextureCube (ITexture&amp; tex, CRect&amp; rect, uint8 nNumMipMap, uint8 nNumFace)
00874 {
00875         <font class="keywordflow">if</font> (tex.TextureDrvShare == NULL)
00876                 <font class="keywordflow">return</font> <font class="keyword">false</font>; <font class="comment">// Texture not created</font>
00877         <font class="keywordflow">if</font> (!tex.isTextureCube())
00878                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00879 
00880         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00881 }
00882 
00883 <font class="comment">// ***************************************************************************</font>
<a name="l00884"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c2">00884</a> <font class="keywordtype">bool</font> CDriverGL::activateTexture(uint stage, ITexture *tex)
00885 {       
00886         <font class="keywordflow">if</font> (this-&gt;<a class="code" href="classNL3D_1_1CDriverGL.html#z405_4">_CurrentTexture</a>[stage]!=tex)
00887         {
00888                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
00889                 <font class="keywordflow">if</font>(tex)
00890                 {
00891                         <font class="comment">// get the drv info. should be not NULL.</font>
00892                         <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>*     gltext;
00893                         gltext= <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a>(*tex);
00894 
00895                         <font class="comment">// Profile, log the use of this texture</font>
00896                         <font class="comment">//=========================================</font>
00897                         <font class="keywordflow">if</font> (_SumTextureMemoryUsed)
00898                         {
00899                                 <font class="comment">// Insert the pointer of this texture</font>
00900                                 <a class="code" href="classNL3D_1_1CDriverGL.html#z412_7">_TextureUsed</a>.insert (gltext);
00901                         }
00902 
00903 
00904                         <font class="keywordflow">if</font>(tex-&gt;isTextureCube())
00905                         {
00906                                 <font class="comment">// setup texture mode, after activeTextureARB()</font>
00907                                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureCubeMap);
00908 
00909                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.ARBTextureCubeMap)
00910                                 {
00911                                         <font class="comment">// Activate texturing...</font>
00912                                         <font class="comment">//======================</font>
00913 
00914                                         <font class="comment">// If the shared texture is the same than before, no op.</font>
00915                                         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[stage] != gltext)
00916                                         {
00917                                                 <font class="comment">// Cache setup.</font>
00918                                                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[stage]= gltext;
00919 
00920                                                 <font class="comment">// setup this texture</font>
00921                                                 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext-&gt;ID);
00922                                                 
00923 
00924                                                 <font class="comment">// Change parameters of texture, if necessary.</font>
00925                                                 <font class="comment">//============================================</font>
00926                                                 <font class="keywordflow">if</font>(gltext-&gt;MagFilter!= tex-&gt;getMagFilter())
00927                                                 {
00928                                                         gltext-&gt;MagFilter= tex-&gt;getMagFilter();
00929                                                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, <a class="code" href="namespaceNL3D.html#a351">translateMagFilterToGl</a>(gltext-&gt;MagFilter));
00930                                                 }
00931                                                 <font class="keywordflow">if</font>(gltext-&gt;MinFilter!= tex-&gt;getMinFilter())
00932                                                 {
00933                                                         gltext-&gt;MinFilter= tex-&gt;getMinFilter();
00934                                                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, <a class="code" href="namespaceNL3D.html#a352">translateMinFilterToGl</a>(gltext-&gt;MinFilter));
00935                                                 }
00936                                         }
00937                                 }
00938                         }
00939                         <font class="keywordflow">else</font>
00940                         {
00941                                 <font class="comment">// setup texture mode, after activeTextureARB()</font>
00942                                 <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::Texture2D);                                                             
00943 
00944                                 <font class="comment">// Activate texture...</font>
00945                                 <font class="comment">//======================</font>
00946 
00947                                 <font class="comment">// If the shared texture is the same than before, no op.</font>
00948                                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[stage] != gltext)
00949                                 {
00950                                         <font class="comment">// Cache setup.</font>
00951                                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[stage]= gltext;
00952 
00953                                         <font class="comment">// setup this texture</font>
00954                                         glBindTexture(GL_TEXTURE_2D, gltext-&gt;ID);                                                               
00955 
00956 
00957                                         <font class="comment">// Change parameters of texture, if necessary.</font>
00958                                         <font class="comment">//============================================</font>
00959                                         <font class="keywordflow">if</font>(gltext-&gt;WrapS!= tex-&gt;getWrapS())
00960                                         {
00961                                                 gltext-&gt;WrapS= tex-&gt;getWrapS();
00962                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(gltext-&gt;WrapS, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00963                                         }
00964                                         <font class="keywordflow">if</font>(gltext-&gt;WrapT!= tex-&gt;getWrapT())
00965                                         {
00966                                                 gltext-&gt;WrapT= tex-&gt;getWrapT();
00967                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, <a class="code" href="namespaceNL3D.html#a350">translateWrapToGl</a>(gltext-&gt;WrapT, <a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>));
00968                                         }
00969                                         <font class="keywordflow">if</font>(gltext-&gt;MagFilter!= tex-&gt;getMagFilter())
00970                                         {
00971                                                 gltext-&gt;MagFilter= tex-&gt;getMagFilter();
00972                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, <a class="code" href="namespaceNL3D.html#a351">translateMagFilterToGl</a>(gltext-&gt;MagFilter));
00973                                         }
00974                                         <font class="keywordflow">if</font>(gltext-&gt;MinFilter!= tex-&gt;getMinFilter())
00975                                         {
00976                                                 gltext-&gt;MinFilter= tex-&gt;getMinFilter();                                 
00977                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, <a class="code" href="namespaceNL3D.html#a352">translateMinFilterToGl</a>(gltext-&gt;MinFilter));
00978                                         }
00979                                 }
00980                         }
00981                 }
00982                 <font class="keywordflow">else</font>
00983                 {
00984                         <font class="comment">// Force no texturing for this stage.</font>
00985                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_5">_CurrentTextureInfoGL</a>[stage]= NULL;
00986                         <font class="comment">// setup texture mode, after activeTextureARB()</font>
00987                         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.setTextureMode(CDriverGLStates::TextureDisabled);                                                                       
00988                 }
00989 
00990                 this-&gt;<a class="code" href="classNL3D_1_1CDriverGL.html#z405_4">_CurrentTexture</a>[stage]= tex;      
00991         }       
00992 
00993         <font class="keywordflow">return</font> <font class="keyword">true</font>;
00994 }
00995 
00996 <font class="comment">// ***************************************************************************</font>
<a name="l00997"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c5">00997</a> <font class="keywordtype">void</font>            CDriverGL::forceActivateTexEnvMode(uint stage, <font class="keyword">const</font> CMaterial::CTexEnv  &amp;env)
00998 {
00999         <font class="comment">// This maps the CMaterial::TTexOperator</font>
01000         <font class="keyword">static</font>  <font class="keyword">const</font>   GLenum  operatorLUT[9]= { GL_REPLACE, GL_MODULATE, GL_ADD, GL_ADD_SIGNED_EXT, 
01001                 GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, <a class="code" href="driver__opengl__extension__def_8h.html#a352">GL_BUMP_ENVMAP_ATI</a> };
01002 
01003         <font class="comment">// This maps the CMaterial::TTexSource</font>
01004         <font class="keyword">static</font>  <font class="keyword">const</font>   GLenum  sourceLUT[4]= { GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
01005 
01006         <font class="comment">// This maps the CMaterial::TTexOperand</font>
01007         <font class="keyword">static</font>  <font class="keyword">const</font>   GLenum  operandLUT[4]= { GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
01008 
01009         <font class="comment">// This maps the CMaterial::TTexOperator, used for openGL Arg2 setup.</font>
01010         <font class="keyword">static</font>  <font class="keyword">const</font>   GLenum  interpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, 
01011                 GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
01012 
01013 
01014 
01015         <font class="comment">// cache mgt.</font>
01016         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_6">_CurrentTexEnv</a>[stage].EnvPacked= env.EnvPacked;
01017         <font class="comment">// Disable Special tex env f().</font>
01018         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[stage]= <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u0">TexEnvSpecialDisabled</a>;
01019 
01020 
01021         <font class="comment">// Setup the gl env mode.</font>
01022         <a class="code" href="classNL3D_1_1CDriverGL.html#z405_11">_DriverGLStates</a>.activeTextureARB(stage);
01023         <font class="comment">// "Normal drivers", setup EnvCombine.</font>
01024         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z403_0">_Extensions</a>.EXTTextureEnvCombine)
01025         {
01026                 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
01027 
01028 
01029                 <font class="comment">// RGB.</font>
01030                 <font class="comment">//=====</font>
01031                 <font class="comment">// Operator.</font>
01032                 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, operatorLUT[env.Env.OpRGB] );
01033                 <font class="comment">// Arg0.</font>
01034                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, sourceLUT[env.Env.SrcArg0RGB] );
01035                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, operandLUT[env.Env.OpArg0RGB]);
01036                 <font class="comment">// Arg1.</font>
01037                 <font class="keywordflow">if</font>(env.Env.OpRGB &gt; CMaterial::Replace)
01038                 {
01039                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, sourceLUT[env.Env.SrcArg1RGB] );
01040                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, operandLUT[env.Env.OpArg1RGB]);
01041                         <font class="comment">// Arg2.</font>
01042                         <font class="keywordflow">if</font>(env.Env.OpRGB &gt;= CMaterial::InterpolateTexture )
01043                         {
01044                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, interpolateSrcLUT[env.Env.OpRGB] );
01045                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
01046                         }
01047                 }
01048 
01049 
01050                 <font class="comment">// Alpha.</font>
01051                 <font class="comment">//=====</font>
01052                 <font class="comment">// Operator.</font>
01053                 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, operatorLUT[env.Env.OpAlpha] );
01054                 <font class="comment">// Arg0.</font>
01055                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, sourceLUT[env.Env.SrcArg0Alpha] );
01056                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, operandLUT[env.Env.OpArg0Alpha]);
01057                 <font class="comment">// Arg1.</font>
01058                 <font class="keywordflow">if</font>(env.Env.OpAlpha &gt; CMaterial::Replace)
01059                 {
01060                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, sourceLUT[env.Env.SrcArg1Alpha] );
01061                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, operandLUT[env.Env.OpArg1Alpha]);
01062                         <font class="comment">// Arg2.</font>
01063                         <font class="keywordflow">if</font>(env.Env.OpAlpha &gt;= CMaterial::InterpolateTexture )
01064                         {
01065                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, interpolateSrcLUT[env.Env.OpAlpha] );
01066                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
01067                         }
01068                 }
01069         }
01070         <font class="comment">// Very Bad drivers.</font>
01071         <font class="keywordflow">else</font>
01072         {
01073                 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
01074         }
01075 
01076 }
01077 
01078 
01079 <font class="comment">// ***************************************************************************</font>
<a name="l01080"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c6">01080</a> <font class="keywordtype">void</font>            CDriverGL::activateTexEnvColor(uint stage, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col)
01081 {       
01082         <font class="keywordflow">if</font> (col != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_6">_CurrentTexEnv</a>[stage].ConstantColor)
01083         {       
01084                 <a class="code" href="classNL3D_1_1CDriverGL.html#c7">forceActivateTexEnvColor</a>(stage, col);   
01085         }
01086 }
01087 
01088 
01089 <font class="comment">// ***************************************************************************</font>
<a name="l01090"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c3">01090</a> <font class="keywordtype">void</font>            CDriverGL::activateTexEnvMode(uint stage, <font class="keyword">const</font> CMaterial::CTexEnv  &amp;env)
01091 {
01092         <font class="comment">// If a special Texture environnement is setuped, or if not the same normal texture environnement,</font>
01093         <font class="comment">// must setup a new normal Texture environnement.</font>
01094         <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CDriverGL.html#z405_7">_CurrentTexEnvSpecial</a>[stage] != <a class="code" href="classNL3D_1_1CDriverGL.html#z405_0u0">TexEnvSpecialDisabled</a> || <a class="code" href="classNL3D_1_1CDriverGL.html#z405_6">_CurrentTexEnv</a>[stage].EnvPacked!= env.EnvPacked)
01095         { 
01096                 <a class="code" href="classNL3D_1_1CDriverGL.html#c5">forceActivateTexEnvMode</a>(stage, env);
01097         }
01098 }
01099 
01100 
01101 <font class="comment">// ***************************************************************************</font>
<a name="l01102"></a><a class="code" href="classNL3D_1_1CDriverGL.html#c4">01102</a> <font class="keywordtype">void</font>            CDriverGL::activateTexEnvColor(uint stage, <font class="keyword">const</font> CMaterial::CTexEnv  &amp;env)
01103 {
01104         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CDriverGL.html#z405_6">_CurrentTexEnv</a>[stage].ConstantColor!= env.ConstantColor)
01105         { 
01106                 <a class="code" href="classNL3D_1_1CDriverGL.html#c7">forceActivateTexEnvColor</a>(stage, env);
01107         }
01108 }
01109 
01110 
01111 <font class="comment">// ***************************************************************************</font>
<a name="l01112"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a22">01112</a> <font class="keywordtype">void</font>            CDriverGL::forceDXTCCompression(<font class="keywordtype">bool</font> dxtcComp)
01113 {
01114         <a class="code" href="classNL3D_1_1CDriverGL.html#o27">_ForceDXTCCompression</a>= dxtcComp;
01115 }
01116 
01117 <font class="comment">// ***************************************************************************</font>
<a name="l01118"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a23">01118</a> <font class="keywordtype">void</font>            CDriverGL::forceTextureResize(uint divisor)
01119 {
01120         <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(divisor, 1U, 256U);
01121 
01122         <font class="comment">// 16 -&gt; 4.</font>
01123         <a class="code" href="classNL3D_1_1CDriverGL.html#o28">_ForceTextureResizePower</a>= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(divisor);
01124 }
01125 
01126 
01127 <font class="comment">// ***************************************************************************</font>
<a name="l01128"></a><a class="code" href="classNL3D_1_1CDriverGL.html#a87">01128</a> <font class="keywordtype">void</font>            CDriverGL::swapTextureHandle(ITexture &amp;tex0, ITexture &amp;tex1)
01129 {
01130         <font class="comment">// ensure creation of both texture</font>
01131         <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(tex0);
01132         <a class="code" href="classNL3D_1_1CDriverGL.html#a18">setupTexture</a>(tex1);
01133 
01134         <font class="comment">// avoid any problem, disable all textures</font>
01135         <font class="keywordflow">for</font>(sint stage=0; stage&lt;<a class="code" href="classNL3D_1_1CDriverGL.html#c28">inlGetNumTextStages</a>() ; stage++)
01136         {
01137                 <a class="code" href="classNL3D_1_1CDriverGL.html#c2">activateTexture</a>(stage, NULL);
01138         }
01139 
01140         <font class="comment">// get the handle.</font>
01141         <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>      *t0= <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a>(tex0);
01142         <a class="code" href="classNL3D_1_1CDriverGL.html#l0">CTextureDrvInfosGL</a>      *t1= <a class="code" href="namespaceNL3D.html#a347">getTextureGl</a>(tex1);
01143 
01144         <font class="comment">/* Swap contents. Can't swap directly the pointers cause would have to change all CTextureDrvShare which point on</font>
01145 <font class="comment">                Can't do swap(*t0, *t1), because must keep the correct _DriverIterator</font>
01146 <font class="comment">        */</font>
01147         swap(t0-&gt;ID, t1-&gt;ID);
01148         swap(t0-&gt;Compressed, t1-&gt;Compressed);
01149         swap(t0-&gt;TextureMemory, t1-&gt;TextureMemory);
01150         swap(t0-&gt;WrapS, t1-&gt;WrapS);
01151         swap(t0-&gt;WrapT, t1-&gt;WrapT);
01152         swap(t0-&gt;MagFilter, t1-&gt;MagFilter);
01153         swap(t0-&gt;MinFilter, t1-&gt;MinFilter);
01154 
01155 }
01156 
01157 
01158 } <font class="comment">// NL3D</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>