-
Notifications
You must be signed in to change notification settings - Fork 17
/
grguTex.cpp
960 lines (843 loc) · 30.5 KB
/
grguTex.cpp
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
//**************************************************************
//* OpenGLide - Glide to OpenGL Wrapper
//* http://openglide.sourceforge.net
//*
//* Glide Texture Functions
//*
//* OpenGLide is OpenSource under LGPL license
//* Originally made by Fabio Barros
//* Modified by Paul for Glidos (http://www.glidos.net)
//* Linux version by Simon White
//**************************************************************
#include "GlOgl.h"
#include "GLRender.h"
#include "Glextensions.h"
#include "PGTexture.h"
#include "PGUTexture.h"
// Functions
//*************************************************
//* Return the lowest start address for texture downloads
//*************************************************
FX_ENTRY FxU32 FX_CALL
grTexMinAddress( GrChipID_t tmu )
{
#ifdef OGL_DONE
GlideMsg( "grTexMinAddress( %d ) = 0\n", tmu );
#endif
return (FxU32) 0;
}
//*************************************************
//* Return the highest start address for texture downloads
//*************************************************
FX_ENTRY FxU32 FX_CALL
grTexMaxAddress( GrChipID_t tmu )
{
#ifdef OGL_DONE
GlideMsg( "grTexMaxAddress( %d ) = %lu\n", tmu, Glide.TexMemoryMaxPosition );
#endif
return (FxU32)( Glide.TexMemoryMaxPosition );
}
//*************************************************
//* Specify the current texture source for rendering
//*************************************************
FX_ENTRY void FX_CALL
grTexSource( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info )
{
#ifdef OGL_DONE
GlideMsg( "grTexSource( %d, %d, %d, --- )\n", tmu, startAddress, evenOdd );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
Glide.State.TexSource.StartAddress = startAddress;
Glide.State.TexSource.EvenOdd = evenOdd;
Textures->Source( startAddress, evenOdd, info );
}
//*************************************************
//* Return the texture memory consumed by a texture
//*************************************************
FX_ENTRY FxU32 FX_CALL
grTexTextureMemRequired( FxU32 dwEvenOdd, GrTexInfo *texInfo )
{
#ifdef OGL_DONE
GlideMsg( "grTexTextureMemRequired( %u, --- )\n", dwEvenOdd );
#endif
return Textures->TextureMemRequired( dwEvenOdd, texInfo );
}
//*************************************************
//* Return the texture memory consumed by a texture
//*************************************************
FX_ENTRY void FX_CALL
grTexDownloadMipMap( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexDownloadMipMap( %d, %u, %u, --- )\n", tmu,
startAddress, evenOdd );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
info->smallLod = info->largeLod;
Textures->DownloadMipMap( startAddress, evenOdd, info );
}
//*************************************************
FX_ENTRY void FX_CALL
grTexDownloadMipMapLevel( GrChipID_t tmu,
FxU32 startAddress,
GrLOD_t thisLod,
GrLOD_t largeLod,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 evenOdd,
void *data )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexDownloadMipMapLevel( %d, %lu, %d, %d, %d, %d, %d, %lu )\n",
tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, data );
#endif
if ( ( tmu != GR_TMU0 ) || ( thisLod != largeLod ) )
// if ( tmu != GR_TMU0 )
{
return;
}
static GrTexInfo info;
info.smallLod = thisLod;
info.largeLod = largeLod;
info.aspectRatio = aspectRatio;
info.format = format;
info.data = data;
Textures->DownloadMipMap( startAddress, evenOdd, &info );
}
//*************************************************
FX_ENTRY void FX_CALL
grTexDownloadMipMapLevelPartial( GrChipID_t tmu,
FxU32 startAddress,
GrLOD_t thisLod,
GrLOD_t largeLod,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 evenOdd,
void *data,
int start,
int end )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexDownloadMipMapLevelPartial( %d, %lu, %d, %d, %d, %d, %d, ---, %d, %d )\n",
tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, start, end );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
GrTexInfo info;
info.smallLod = thisLod;
info.largeLod = largeLod;
info.aspectRatio = aspectRatio;
info.format = format;
info.data = data;
Textures->DownloadMipMapPartial( startAddress, evenOdd, &info, start, end );
}
//*************************************************
//* Set the texture map clamping/wrapping mode
//*************************************************
FX_ENTRY void FX_CALL
grTexClampMode( GrChipID_t tmu,
GrTextureClampMode_t s_clampmode,
GrTextureClampMode_t t_clampmode )
{
#ifdef OGL_DONE
GlideMsg( "grTexClampMode( %d, %d, %d )\n",
tmu, s_clampmode, t_clampmode );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
Glide.State.SClampMode = s_clampmode;
Glide.State.TClampMode = t_clampmode;
switch ( s_clampmode )
{
case GR_TEXTURECLAMP_CLAMP: OpenGL.SClampMode = GL_CLAMP_TO_EDGE; break;
case GR_TEXTURECLAMP_WRAP: OpenGL.SClampMode = GL_REPEAT; break;
}
switch ( t_clampmode )
{
case GR_TEXTURECLAMP_CLAMP: OpenGL.TClampMode = GL_CLAMP_TO_EDGE; break;
case GR_TEXTURECLAMP_WRAP: OpenGL.TClampMode = GL_REPEAT; break;
}
#ifdef OPENGL_DEBUG
GLErro( "grTexClampMode" );
#endif
}
//*************************************************
//* Set the texture Min/Mag Filter
//*************************************************
FX_ENTRY void FX_CALL
grTexFilterMode( GrChipID_t tmu,
GrTextureFilterMode_t minfilter_mode,
GrTextureFilterMode_t magfilter_mode )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexFilterMode( %d, %d, %d )\n",
tmu, minfilter_mode, magfilter_mode );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
Glide.State.MinFilterMode = minfilter_mode;
Glide.State.MagFilterMode = magfilter_mode;
switch ( minfilter_mode )
{
case GR_TEXTUREFILTER_POINT_SAMPLED:
if ( ( Glide.State.MipMapMode != GR_MIPMAP_DISABLE ) &&
( InternalConfig.EnableMipMaps ) )
{
if ( Glide.State.LodBlend )
{
OpenGL.MinFilterMode = GL_NEAREST_MIPMAP_LINEAR;
}
else
{
OpenGL.MinFilterMode = GL_NEAREST_MIPMAP_NEAREST;
}
}
else
{
OpenGL.MinFilterMode = GL_NEAREST;
}
break;
case GR_TEXTUREFILTER_BILINEAR:
if ( InternalConfig.EnableMipMaps )
{
if ( Glide.State.LodBlend )
{
OpenGL.MinFilterMode = GL_LINEAR_MIPMAP_LINEAR;
}
else
{
OpenGL.MinFilterMode = GL_LINEAR_MIPMAP_NEAREST;
}
}
else
{
OpenGL.MinFilterMode = GL_LINEAR;
}
break;
}
switch ( magfilter_mode )
{
case GR_TEXTUREFILTER_POINT_SAMPLED: OpenGL.MagFilterMode = GL_NEAREST; break;
case GR_TEXTUREFILTER_BILINEAR: OpenGL.MagFilterMode = GL_LINEAR; break;
}
#ifdef OPENGL_DEBUG
GLErro( "grTexFilterMode" );
#endif
}
//*************************************************
//* Set the texture MipMap Mode
//*************************************************
FX_ENTRY void FX_CALL
grTexMipMapMode( GrChipID_t tmu,
GrMipMapMode_t mode,
FxBool lodBlend )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexMipMapMode( %d, %d, %d )\n",
tmu, mode, lodBlend );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
Glide.State.MipMapMode = mode;
Glide.State.LodBlend = lodBlend;
grTexFilterMode( GR_TMU0,
Glide.State.MinFilterMode,
Glide.State.MagFilterMode );
#ifdef OPENGL_DEBUG
GLErro( "grTexMipMapMode" );
#endif
}
//*************************************************
//* Returns the memory occupied by a texture
//*************************************************
FX_ENTRY FxU32 FX_CALL
grTexCalcMemRequired( GrLOD_t lodmin, GrLOD_t lodmax,
GrAspectRatio_t aspect, GrTextureFormat_t fmt )
{
#ifdef OGL_DONE
GlideMsg( "grTexCalcMemRequired( %d, %d, %d, %d )\n",
lodmin, lodmax, aspect, fmt );
#endif
static GrTexInfo texInfo;
texInfo.aspectRatio = aspect;
texInfo.format = fmt;
texInfo.largeLod = lodmax;
texInfo.smallLod = lodmin;
return Textures->TextureMemRequired( 0, &texInfo );
}
//*************************************************
//* Download a subset of an NCC table or color palette
//*************************************************
FX_ENTRY void FX_CALL
grTexDownloadTablePartial( GrChipID_t tmu,
GrTexTable_t type,
void *data,
int start,
int end )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexDownloadTablePartial( %d, %d, ---, %d, %d )\n",
tmu, type, start, end );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
Textures->DownloadTable( type, (FxU32*)data, start, end + 1 - start );
}
//*************************************************
//* download an NCC table or color palette
//*************************************************
FX_ENTRY void FX_CALL
grTexDownloadTable( GrChipID_t tmu,
GrTexTable_t type,
void *data )
{
#ifdef OGL_PARTDONE
GlideMsg( "grTexDownloadTable( %d, %d, --- )\n", tmu, type );
#endif
if ( tmu != GR_TMU0 )
{
return;
}
RenderDrawTriangles( );
Textures->DownloadTable( type, (FxU32*)data, 0, 256 );
}
//*************************************************
FX_ENTRY void FX_CALL
grTexLodBiasValue( GrChipID_t tmu, float bias )
{
#ifdef OGL_NOTDONE
GlideMsg( "grTexLodBiasValue( %d, %d )\n",
tmu, bias );
#endif
if ( InternalConfig.EXT_texture_lod_bias )
{
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, bias );
}
}
//*************************************************
FX_ENTRY void FX_CALL
grTexCombine( GrChipID_t tmu,
GrCombineFunction_t rgb_function,
GrCombineFactor_t rgb_factor,
GrCombineFunction_t alpha_function,
GrCombineFactor_t alpha_factor,
FxBool rgb_invert,
FxBool alpha_invert )
{
#if defined( OGL_PARTDONE ) || defined( OGL_COMBINE )
GlideMsg( "grTexCombine( %d, %d, %d, %d, %d, %d, %d )\n",
tmu, rgb_function, rgb_factor, alpha_function, alpha_factor,
rgb_invert, alpha_invert );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return;
// }
RenderDrawTriangles( );
Glide.State.TextureCombineCFunction = rgb_function;
Glide.State.TextureCombineCFactor = rgb_factor;
Glide.State.TextureCombineAFunction = alpha_function;
Glide.State.TextureCombineAFactor = alpha_factor;
Glide.State.TextureCombineRGBInvert = rgb_invert;
Glide.State.TextureCombineAInvert = alpha_invert;
if ( ( rgb_function != GR_COMBINE_FUNCTION_ZERO ) ||
( alpha_function != GR_COMBINE_FUNCTION_ZERO ) )
{
OpenGL.Texture = true;
}
else
{
OpenGL.Texture = false;
}
/*
switch ( rgb_function )
{
case GR_COMBINE_FUNCTION_ZERO:
OpenGL.Texture = false;
// GlideMsg( "GR_COMBINE_FUNCTION_ZERO," );
break;
case GR_COMBINE_FUNCTION_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
}
switch ( rgb_factor )
{
case GR_COMBINE_FACTOR_ZERO:
// GlideMsg( "GR_COMBINE_FACTOR_ZERO," );
break;
case GR_COMBINE_FACTOR_LOCAL:
// GlideMsg( "GR_COMBINE_FACTOR_LOCAL," );
break;
case GR_COMBINE_FACTOR_OTHER_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_OTHER_ALPHA," );
break;
case GR_COMBINE_FACTOR_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_LOCAL_ALPHA," );
break;
case GR_COMBINE_FACTOR_DETAIL_FACTOR:
// GlideMsg( "GR_COMBINE_FACTOR_DETAIL_FACTOR," );
break;
case GR_COMBINE_FACTOR_LOD_FRACTION:
// GlideMsg( "GR_COMBINE_FACTOR_LOD_FRACTION," );
break;
case GR_COMBINE_FACTOR_ONE:
// GlideMsg( "GR_COMBINE_FACTOR_ONE," );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOCAL:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOCAL," );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA," );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA," );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR," );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION," );
break;
}
switch ( alpha_function )
{
case GR_COMBINE_FUNCTION_ZERO:
// OpenGL.Texture = false;
// GlideMsg( "GR_COMBINE_FUNCTION_ZERO," );
break;
case GR_COMBINE_FUNCTION_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL," );
OpenGL.Texture = true;
break;
case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA," );
OpenGL.Texture = true;
break;
}
switch ( alpha_factor )
{
case GR_COMBINE_FACTOR_ZERO:
// GlideMsg( "GR_COMBINE_FACTOR_ZERO\n" );
break;
case GR_COMBINE_FACTOR_LOCAL:
// GlideMsg( "GR_COMBINE_FACTOR_LOCAL\n" );
break;
case GR_COMBINE_FACTOR_OTHER_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_OTHER_ALPHA\n" );
break;
case GR_COMBINE_FACTOR_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_LOCAL_ALPHA\n" );
break;
case GR_COMBINE_FACTOR_DETAIL_FACTOR:
// GlideMsg( "GR_COMBINE_FACTOR_DETAIL_FACTOR\n" );
break;
case GR_COMBINE_FACTOR_LOD_FRACTION:
// GlideMsg( "GR_COMBINE_FACTOR_LOD_FRACTION\n" );
break;
case GR_COMBINE_FACTOR_ONE:
// GlideMsg( "GR_COMBINE_FACTOR_ONE\n" );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOCAL:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOCAL\n" );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA\n" );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA\n" );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR\n" );
break;
case GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION:
// GlideMsg( "GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION\n" );
break;
}
*/
}
//*************************************************
FX_ENTRY void FX_CALL
grTexNCCTable( GrChipID_t tmu, GrNCCTable_t NCCTable )
{
#ifdef OGL_DONE
GlideMsg( "grTexNCCTable( %d, %u )\n", tmu, NCCTable );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return;
// }
Textures->NCCTable( NCCTable );
}
//*************************************************
FX_ENTRY void FX_CALL
grTexDetailControl( GrChipID_t tmu,
int lod_bias,
FxU8 detail_scale,
float detail_max )
{
#ifdef OGL_NOTDONE
GlideMsg( "grTexDetailControl( %d, %d, %d, %-4.2f )\n",
tmu, lod_bias, detail_scale, detail_max );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grTexMultibase( GrChipID_t tmu,
FxBool enable )
{
#ifdef OGL_NOTDONE
GlideMsg( "grTexMultibase( %d, %d )\n", tmu, enable );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return;
// }
}
//*************************************************
FX_ENTRY void FX_CALL
grTexMultibaseAddress( GrChipID_t tmu,
GrTexBaseRange_t range,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info )
{
#ifdef OGL_NOTDONE
GlideMsg( "grTexMultibaseAddress( %d, %d, %lu, %lu, --- )\n",
tmu, range, startAddress, evenOdd );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grTexCombineFunction( GrChipID_t tmu, GrTextureCombineFnc_t func )
{
#if defined( OGL_PARTDONE ) || defined( OGL_COMBINE )
GlideMsg( "grTexCombineFunction( %d, %d )\n", tmu, func );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return;
// }
switch ( func )
{
case GR_TEXTURECOMBINE_ZERO: // 0x00 per component
grTexCombine( tmu, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO,
GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_DECAL: // Clocal decal texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_OTHER: // Cother pass through
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_ADD: // Cother + Clocal additive texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_MULTIPLY: // Cother * Clocal modulated texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_SUBTRACT: // Cother Clocal subtractive texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_ONE: // 255 0xFF per component
grTexCombine( tmu, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO,
GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO, FXTRUE, FXTRUE );
break;
// case GR_TEXTURECOMBINE_DETAIL: // blend (Cother, Clocal) detail textures with detail on selected TMU
// case GR_TEXTURECOMBINE_DETAIL_OTHER: // blend (Cother, Clocal) detail textures with detail on neighboring TMU
// case GR_TEXTURECOMBINE_TRILINEAR_ODD: // blend (Cother, Clocal) LOD blended textures with odd levels on selected TMU
// case GR_TEXTURECOMBINE_TRILINEAR_EVEN: // blend (Cother, Clocal) LOD blended textures with even levels on selected TMU
// break;
}
}
//*************************************************
//* Return the amount of unallocated texture memory on a Texture Mapping Unit
//*************************************************
FX_ENTRY FxU32 FX_CALL
guTexMemQueryAvail( GrChipID_t tmu )
{
#ifdef OGL_PARTDONE
GlideMsg( "guTexMemQueryAvail( %d ) = %u\n", tmu, UTextures.MemQueryAvail( tmu ) );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return 0;
// }
return UTextures.MemQueryAvail( tmu );
}
//*************************************************
FX_ENTRY void FX_CALL
guTexCombineFunction( GrChipID_t tmu, GrTextureCombineFnc_t func )
{
#if defined( OGL_PARTDONE ) || defined( OGL_COMBINE )
GlideMsg( "guTexCombineFunction( %d, %d )\n", tmu, func );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return;
// }
switch ( func )
{
case GR_TEXTURECOMBINE_ZERO: // 0x00 per component
grTexCombine( tmu, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO,
GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_DECAL: // Clocal decal texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_OTHER: // Cother pass through
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_ADD: // Cother + Clocal additive texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_MULTIPLY: // Cother * Clocal modulated texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_SUBTRACT: // Cother Clocal subtractive texture
grTexCombine( tmu, GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, GR_COMBINE_FACTOR_ONE,
GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE );
break;
case GR_TEXTURECOMBINE_ONE: // 255 0xFF per component
grTexCombine( tmu, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO,
GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_ZERO, FXTRUE, FXTRUE );
break;
// case GR_TEXTURECOMBINE_DETAIL: // blend (Cother, Clocal) detail textures with detail on selected TMU
// case GR_TEXTURECOMBINE_DETAIL_OTHER: // blend (Cother, Clocal) detail textures with detail on neighboring TMU
// case GR_TEXTURECOMBINE_TRILINEAR_ODD: // blend (Cother, Clocal) LOD blended textures with odd levels on selected TMU
// case GR_TEXTURECOMBINE_TRILINEAR_EVEN: // blend (Cother, Clocal) LOD blended textures with even levels on selected TMU
// break;
}
}
//*************************************************
FX_ENTRY GrMipMapId_t FX_CALL
guTexGetCurrentMipMap( GrChipID_t tmu )
{
#ifdef OGL_DONE
GlideMsg( "guTexGetCurrentMipMap( %d ) = %d\n", tmu, UTextures.GetCurrentMipMap( tmu ) );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return GR_NULL_MIPMAP_HANDLE;
// }
return UTextures.GetCurrentMipMap( tmu );
}
//*************************************************
FX_ENTRY FxBool FX_CALL
guTexChangeAttributes( GrMipMapId_t mmid,
int width, int height,
GrTextureFormat_t fmt,
GrMipMapMode_t mm_mode,
GrLOD_t smallest_lod, GrLOD_t largest_lod,
GrAspectRatio_t aspect,
GrTextureClampMode_t s_clamp_mode,
GrTextureClampMode_t t_clamp_mode,
GrTextureFilterMode_t minFilterMode,
GrTextureFilterMode_t magFilterMode )
{
#ifdef OGL_DONE
GlideMsg( "guTexChangeAttributes( %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d )\n",
mmid, width, height, fmt, mm_mode, smallest_lod, largest_lod, aspect,
s_clamp_mode, t_clamp_mode, minFilterMode, magFilterMode );
#endif
return UTextures.ChangeAttributes( mmid, width, height, fmt, mm_mode,
smallest_lod, largest_lod, aspect, s_clamp_mode, t_clamp_mode,
minFilterMode, magFilterMode );
}
//*************************************************
FX_ENTRY GrMipMapInfo * FX_CALL
guTexGetMipMapInfo( GrMipMapId_t mmid )
{
#ifdef OGL_DONE
GlideMsg( "guTexGetMipMapInfo( ) = 0x%p\n" );
#endif
return UTextures.GetMipMapInfo( mmid );
}
//*************************************************
FX_ENTRY void FX_CALL
guTexMemReset( void )
{
#ifdef OGL_PARTDONE
GlideMsg( "guTexMemReset( )\n" );
#endif
UTextures.MemReset( );
Textures->Clear( );
}
//*************************************************
FX_ENTRY void FX_CALL
guTexDownloadMipMapLevel( GrMipMapId_t mmid, GrLOD_t lod, const void **src )
{
#ifdef OGL_DONE
GlideMsg( "guTexDownloadMipMapLevel( %d, %d, 0x%p )\n", mmid, lod, src );
#endif
UTextures.DownloadMipMapLevel( mmid, lod, src );
}
//*************************************************
FX_ENTRY void FX_CALL
guTexDownloadMipMap( GrMipMapId_t mmid, const void *src, const GuNccTable *table )
{
#ifdef OGL_DONE
GlideMsg( "guTexDownloadMipMap( %d, 0x%p, 0x%p )\n", mmid, src, table );
#endif
UTextures.DownloadMipMap( mmid, src, table );
}
//*************************************************
FX_ENTRY GrMipMapId_t FX_CALL
guTexAllocateMemory( GrChipID_t tmu,
FxU8 odd_even_mask,
int width, int height,
GrTextureFormat_t fmt,
GrMipMapMode_t mm_mode,
GrLOD_t smallest_lod, GrLOD_t largest_lod,
GrAspectRatio_t aspect,
GrTextureClampMode_t s_clamp_mode,
GrTextureClampMode_t t_clamp_mode,
GrTextureFilterMode_t minfilter_mode,
GrTextureFilterMode_t magfilter_mode,
float lod_bias,
FxBool trilinear )
{
#ifdef OGL_DONE
GlideMsg( "guTexAllocateMemory( %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d )\n",
tmu, odd_even_mask, width, height, fmt, mm_mode, smallest_lod, largest_lod, aspect,
s_clamp_mode, t_clamp_mode, minfilter_mode, magfilter_mode, lod_bias, trilinear );
#endif
// Ignoring TMU as we are only emulating Glide and assuming a well behaviored program
// if ( tmu != GR_TMU0 )
// {
// return GR_NULL_MIPMAP_HANDLE;
// }
return UTextures.AllocateMemory( tmu, odd_even_mask, width, height, fmt, mm_mode,
smallest_lod, largest_lod, aspect, s_clamp_mode, t_clamp_mode,
minfilter_mode, magfilter_mode, lod_bias, trilinear );
}
//*************************************************
FX_ENTRY void FX_CALL
guTexSource( GrMipMapId_t id )
{
#ifdef OGL_DONE
GlideMsg( "guTexSource( %d )\n", id );
#endif
RenderDrawTriangles( );
UTextures.Source( id );
}
//*************************************************
FX_ENTRY FxU16 * FX_CALL
guTexCreateColorMipMap( void )
{
#ifdef OGL_NOTDONE
GlideMsg( "guTexCreateColorMipMap( ) = NULL\n" );
#endif
return NULL;
}