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
|
/****************************************************************************
*
* Mesa 3-D graphics library
* Direct3D Driver Interface
*
* ========================================================================
*
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* ======================================================================
*
* Language: ANSI C
* Environment: Windows 9x/2000/XP/XBox (Win32)
*
* Description: Driver interface code to Mesa
*
****************************************************************************/
//#include <windows.h>
#include "dglcontext.h"
#include "ddlog.h"
#include "gld_dx7.h"
#include "glheader.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
// #include "mem.h"
//#include "mmath.h"
#include "mtypes.h"
#include "texformat.h"
#include "teximage.h"
#include "texstore.h"
#include "array_cache/acache.h"
#include "swrast_setup/swrast_setup.h"
#include "swrast_setup/ss_context.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
extern BOOL dglSwapBuffers(HDC hDC);
// HACK: Hack the _33 member of the OpenGL perspective projection matrix
const float _fPersp_33 = 1.6f;
//---------------------------------------------------------------------------
// Internal functions
//---------------------------------------------------------------------------
void _gld_mesa_warning(
__GLcontext *gc,
char *str)
{
// Intercept Mesa's internal warning mechanism
gldLogPrintf(GLDLOG_WARN, "Mesa warning: %s", str);
}
//---------------------------------------------------------------------------
void _gld_mesa_fatal(
__GLcontext *gc,
char *str)
{
// Intercept Mesa's internal fatal-message mechanism
gldLogPrintf(GLDLOG_CRITICAL, "Mesa FATAL: %s", str);
// Mesa calls abort(0) here.
ddlogClose();
exit(0);
}
//---------------------------------------------------------------------------
D3DSTENCILOP _gldConvertStencilOp(
GLenum StencilOp)
{
// Used by Stencil: pass, fail and zfail
switch (StencilOp) {
case GL_KEEP:
return D3DSTENCILOP_KEEP;
case GL_ZERO:
return D3DSTENCILOP_ZERO;
case GL_REPLACE:
return D3DSTENCILOP_REPLACE;
case GL_INCR:
return D3DSTENCILOP_INCRSAT;
case GL_DECR:
return D3DSTENCILOP_DECRSAT;
case GL_INVERT:
return D3DSTENCILOP_INVERT;
case GL_INCR_WRAP_EXT: // GL_EXT_stencil_wrap
return D3DSTENCILOP_INCR;
case GL_DECR_WRAP_EXT: // GL_EXT_stencil_wrap
return D3DSTENCILOP_DECR;
}
#ifdef _DEBUG
gldLogMessage(GLDLOG_ERROR, "_gldConvertStencilOp: Unknown StencilOp\n");
#endif
return D3DSTENCILOP_KEEP;
}
//---------------------------------------------------------------------------
D3DCMPFUNC _gldConvertCompareFunc(
GLenum CmpFunc)
{
// Used for Alpha func, depth func and stencil func.
switch (CmpFunc) {
case GL_NEVER:
return D3DCMP_NEVER;
case GL_LESS:
return D3DCMP_LESS;
case GL_EQUAL:
return D3DCMP_EQUAL;
case GL_LEQUAL:
return D3DCMP_LESSEQUAL;
case GL_GREATER:
return D3DCMP_GREATER;
case GL_NOTEQUAL:
return D3DCMP_NOTEQUAL;
case GL_GEQUAL:
return D3DCMP_GREATEREQUAL;
case GL_ALWAYS:
return D3DCMP_ALWAYS;
};
#ifdef _DEBUG
gldLogMessage(GLDLOG_ERROR, "_gldConvertCompareFunc: Unknown CompareFunc\n");
#endif
return D3DCMP_ALWAYS;
}
//---------------------------------------------------------------------------
D3DBLEND _gldConvertBlendFunc(
GLenum blend,
GLenum DefaultBlend)
{
switch (blend) {
case GL_ZERO:
return D3DBLEND_ZERO;
case GL_ONE:
return D3DBLEND_ONE;
case GL_DST_COLOR:
return D3DBLEND_DESTCOLOR;
case GL_SRC_COLOR:
return D3DBLEND_SRCCOLOR;
case GL_ONE_MINUS_DST_COLOR:
return D3DBLEND_INVDESTCOLOR;
case GL_ONE_MINUS_SRC_COLOR:
return D3DBLEND_INVSRCCOLOR;
case GL_SRC_ALPHA:
return D3DBLEND_SRCALPHA;
case GL_ONE_MINUS_SRC_ALPHA:
return D3DBLEND_INVSRCALPHA;
case GL_DST_ALPHA:
return D3DBLEND_DESTALPHA;
case GL_ONE_MINUS_DST_ALPHA:
return D3DBLEND_INVDESTALPHA;
case GL_SRC_ALPHA_SATURATE:
return D3DBLEND_SRCALPHASAT;
}
#ifdef _DEBUG
gldLogMessage(GLDLOG_ERROR, "_gldConvertBlendFunc: Unknown BlendFunc\n");
#endif
return DefaultBlend;
}
//---------------------------------------------------------------------------
// Misc. functions
//---------------------------------------------------------------------------
void gld_Noop_DX7(
GLcontext *ctx)
{
#ifdef _DEBUG
gldLogMessage(GLDLOG_ERROR, "gld_Noop called!\n");
#endif
}
//---------------------------------------------------------------------------
void gld_Error_DX7(
GLcontext *ctx)
{
#ifdef _DEBUG
// Quite useless.
// gldLogMessage(GLDLOG_ERROR, "ctx->Driver.Error called!\n");
#endif
}
//---------------------------------------------------------------------------
// Required Mesa functions
//---------------------------------------------------------------------------
static GLboolean gld_set_draw_buffer_DX7(
GLcontext *ctx,
GLenum mode)
{
(void) ctx;
if ((mode==GL_FRONT_LEFT) || (mode == GL_BACK_LEFT)) {
return GL_TRUE;
}
else {
return GL_FALSE;
}
}
//---------------------------------------------------------------------------
static void gld_set_read_buffer_DX7(
GLcontext *ctx,
GLframebuffer *buffer,
GLenum mode)
{
/* separate read buffer not supported */
/*
ASSERT(buffer == ctx->DrawBuffer);
ASSERT(mode == GL_FRONT_LEFT);
*/
}
//---------------------------------------------------------------------------
void gld_Clear_DX7(
GLcontext *ctx,
GLbitfield mask,
GLboolean all,
GLint x,
GLint y,
GLint width,
GLint height)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
DWORD dwFlags = 0;
D3DCOLOR Color = 0;
float Z = 0.0f;
DWORD Stencil = 0;
D3DRECT d3dClearRect;
// TODO: Colourmask
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
if (!gld->pDev)
return;
if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
GLubyte col[4];
CLAMPED_FLOAT_TO_UBYTE(col[0], ctx->Color.ClearColor[0]);
CLAMPED_FLOAT_TO_UBYTE(col[1], ctx->Color.ClearColor[1]);
CLAMPED_FLOAT_TO_UBYTE(col[2], ctx->Color.ClearColor[2]);
CLAMPED_FLOAT_TO_UBYTE(col[3], ctx->Color.ClearColor[3]);
dwFlags |= D3DCLEAR_TARGET;
Color = D3DCOLOR_RGBA(col[0], col[1], col[2], col[3]);
// ctx->Color.ClearColor[1],
// ctx->Color.ClearColor[2],
// ctx->Color.ClearColor[3]);
}
if (mask & DD_DEPTH_BIT) {
// D3D7 will fail the Clear call if we try and clear a
// depth buffer and we haven't created one.
// Also, some apps try and clear a depth buffer,
// when a depth buffer hasn't been requested by the app.
if (ctx->Visual.depthBits == 0) {
mask &= ~DD_DEPTH_BIT; // Remove depth bit from mask
} else {
dwFlags |= D3DCLEAR_ZBUFFER;
Z = ctx->Depth.Clear;
}
}
if (mask & DD_STENCIL_BIT) {
if (ctx->Visual.stencilBits == 0) {
// No stencil bits in depth buffer
mask &= ~DD_STENCIL_BIT; // Remove stencil bit from mask
} else {
dwFlags |= D3DCLEAR_STENCIL;
Stencil = ctx->Stencil.Clear;
}
}
// Some apps do really weird things with the rect, such as Quake3.
if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0)) {
all = GL_TRUE;
}
if (!all) {
// Calculate clear subrect
d3dClearRect.x1 = x;
d3dClearRect.y1 = gldCtx->dwHeight - (y + height);
d3dClearRect.x2 = x + width;
d3dClearRect.y2 = d3dClearRect.y1 + height;
}
// dwFlags will be zero if there's nothing to clear
if (dwFlags) {
_GLD_DX7_DEV(Clear(
gld->pDev,
all ? 0 : 1,
all ? NULL : &d3dClearRect,
dwFlags,
Color, Z, Stencil));
}
if (mask & DD_ACCUM_BIT) {
// Clear accumulation buffer
}
}
//---------------------------------------------------------------------------
// Mesa 5: Parameter change
static void gld_buffer_size_DX7(
// GLcontext *ctx,
GLframebuffer *fb,
GLuint *width,
GLuint *height)
{
// GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
*width = fb->Width; // gldCtx->dwWidth;
*height = fb->Height; // gldCtx->dwHeight;
}
//---------------------------------------------------------------------------
static void gld_Finish_DX7(
GLcontext *ctx)
{
}
//---------------------------------------------------------------------------
static void gld_Flush_DX7(
GLcontext *ctx)
{
GLD_context *gld = GLD_GET_CONTEXT(ctx);
// TODO: Detect apps that glFlush() then SwapBuffers() ?
if (gld->EmulateSingle) {
// Emulating a single-buffered context.
// [Direct3D doesn't allow rendering to front buffer]
dglSwapBuffers(gld->hDC);
}
}
//---------------------------------------------------------------------------
void gld_NEW_STENCIL(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
// Two-sided stencil. New for Mesa 5
const GLuint uiFace = 0UL;
struct gl_stencil_attrib *pStencil = &ctx->Stencil;
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILENABLE, pStencil->Enabled ? TRUE : FALSE));
if (pStencil->Enabled) {
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFUNC, _gldConvertCompareFunc(pStencil->Function[uiFace])));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILREF, pStencil->Ref[uiFace]));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILMASK, pStencil->ValueMask[uiFace]));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILWRITEMASK, pStencil->WriteMask[uiFace]));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFAIL, _gldConvertStencilOp(pStencil->FailFunc[uiFace])));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILZFAIL, _gldConvertStencilOp(pStencil->ZFailFunc[uiFace])));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILPASS, _gldConvertStencilOp(pStencil->ZPassFunc[uiFace])));
}
}
//---------------------------------------------------------------------------
void gld_NEW_COLOR(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
DWORD dwFlags = 0;
D3DBLEND src;
D3DBLEND dest;
// Alpha func
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHAFUNC, _gldConvertCompareFunc(ctx->Color.AlphaFunc)));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHAREF, (DWORD)ctx->Color.AlphaRef));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHATESTENABLE, ctx->Color.AlphaEnabled));
// Blend func
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHABLENDENABLE, ctx->Color.BlendEnabled));
src = _gldConvertBlendFunc(ctx->Color.BlendSrcRGB, GL_ONE);
dest = _gldConvertBlendFunc(ctx->Color.BlendDstRGB, GL_ZERO);
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SRCBLEND, src));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_DESTBLEND, dest));
/*
// Color mask - unsupported by DX7
if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_COLORWRITEENABLE, dwFlags));
*/
}
//---------------------------------------------------------------------------
void gld_NEW_DEPTH(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZENABLE, ctx->Depth.Test ? D3DZB_TRUE : D3DZB_FALSE));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZFUNC, _gldConvertCompareFunc(ctx->Depth.Func)));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZWRITEENABLE, ctx->Depth.Mask ? TRUE : FALSE));
}
//---------------------------------------------------------------------------
void gld_NEW_POLYGON(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DFILLMODE d3dFillMode = D3DFILL_SOLID;
D3DCULL d3dCullMode = D3DCULL_NONE;
int iOffset = 0;
// Fillmode
switch (ctx->Polygon.FrontMode) {
case GL_POINT:
d3dFillMode = D3DFILL_POINT;
break;
case GL_LINE:
d3dFillMode = D3DFILL_WIREFRAME;
break;
case GL_FILL:
d3dFillMode = D3DFILL_SOLID;
break;
}
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FILLMODE, d3dFillMode));
if (ctx->Polygon.CullFlag) {
switch (ctx->Polygon.CullFaceMode) {
case GL_BACK:
if (ctx->Polygon.FrontFace == GL_CCW)
d3dCullMode = D3DCULL_CW;
else
d3dCullMode = D3DCULL_CCW;
break;
case GL_FRONT:
if (ctx->Polygon.FrontFace == GL_CCW)
d3dCullMode = D3DCULL_CCW;
else
d3dCullMode = D3DCULL_CW;
break;
case GL_FRONT_AND_BACK:
d3dCullMode = D3DCULL_NONE;
break;
default:
break;
}
} else {
d3dCullMode = D3DCULL_NONE;
}
// d3dCullMode = D3DCULL_NONE; // TODO: DEBUGGING
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CULLMODE, d3dCullMode));
// Polygon offset
// ZBIAS ranges from 0 to 16 and can only move towards the viewer
// Mesa5: ctx->Polygon._OffsetAny removed
if (ctx->Polygon.OffsetFill) {
iOffset = (int)ctx->Polygon.OffsetUnits;
if (iOffset < 0)
iOffset = -iOffset;
else
iOffset = 0; // D3D can't push away
}
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZBIAS, iOffset));
}
//---------------------------------------------------------------------------
void gld_NEW_FOG(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DCOLOR d3dFogColour;
D3DFOGMODE d3dFogMode = D3DFOG_LINEAR;
// TODO: Fog is calculated seperately in the Mesa pipeline
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, FALSE));
return;
// Fog enable
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, ctx->Fog.Enabled));
if (!ctx->Fog.Enabled) {
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
return; // If disabled, don't bother setting any fog state
}
// Fog colour
d3dFogColour = D3DCOLOR_COLORVALUE( ctx->Fog.Color[0],
ctx->Fog.Color[1],
ctx->Fog.Color[2],
ctx->Fog.Color[3]);
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGCOLOR, d3dFogColour));
// Fog density
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGDENSITY, *((DWORD*) (&ctx->Fog.Density))));
// Fog start
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGSTART, *((DWORD*) (&ctx->Fog.Start))));
// Fog end
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGEND, *((DWORD*) (&ctx->Fog.End))));
// Fog mode
switch (ctx->Fog.Mode) {
case GL_LINEAR:
d3dFogMode = D3DFOG_LINEAR;
break;
case GL_EXP:
d3dFogMode = D3DFOG_EXP;
break;
case GL_EXP2:
d3dFogMode = D3DFOG_EXP2;
break;
}
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, d3dFogMode));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
}
//---------------------------------------------------------------------------
void gld_NEW_LIGHT(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
DWORD dwSpecularEnable;
// Shademode
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SHADEMODE, (ctx->Light.ShadeModel == GL_SMOOTH) ? D3DSHADE_GOURAUD : D3DSHADE_FLAT));
// Separate specular colour
if (ctx->Light.Enabled)
dwSpecularEnable = (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) ? TRUE: FALSE;
else
dwSpecularEnable = FALSE;
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SPECULARENABLE, dwSpecularEnable));
}
//---------------------------------------------------------------------------
void gld_NEW_MODELVIEW(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DMATRIX m;
//GLfloat *pM = ctx->ModelView.m;
// Mesa5: Model-view is now a stack
GLfloat *pM = ctx->ModelviewMatrixStack.Top->m;
m._11 = pM[0];
m._12 = pM[1];
m._13 = pM[2];
m._14 = pM[3];
m._21 = pM[4];
m._22 = pM[5];
m._23 = pM[6];
m._24 = pM[7];
m._31 = pM[8];
m._32 = pM[9];
m._33 = pM[10];
m._34 = pM[11];
m._41 = pM[12];
m._42 = pM[13];
m._43 = pM[14];
m._44 = pM[15];
/* m[0][0] = pM[0];
m[0][1] = pM[1];
m[0][2] = pM[2];
m[0][3] = pM[3];
m[1][0] = pM[4];
m[1][1] = pM[5];
m[1][2] = pM[6];
m[1][3] = pM[7];
m[2][0] = pM[8];
m[2][1] = pM[9];
m[2][2] = pM[10];
m[2][3] = pM[11];
m[3][0] = pM[12];
m[3][1] = pM[13];
m[3][2] = pM[14];
m[3][3] = pM[15];*/
gld->matModelView = m;
}
//---------------------------------------------------------------------------
void gld_NEW_PROJECTION(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DMATRIX m;
//GLfloat *pM = ctx->ProjectionMatrix.m;
// Mesa 5: Now a stack
GLfloat *pM = ctx->ProjectionMatrixStack.Top->m;
m._11 = pM[0];
m._12 = pM[1];
m._13 = pM[2];
m._14 = pM[3];
m._21 = pM[4];
m._22 = pM[5];
m._23 = pM[6];
m._24 = pM[7];
m._31 = pM[8];
m._32 = pM[9];
m._33 = pM[10] / _fPersp_33; // / 1.6f;
m._34 = pM[11];
m._41 = pM[12];
m._42 = pM[13];
m._43 = pM[14] / 2.0f;
m._44 = pM[15];
gld->matProjection = m;
}
//---------------------------------------------------------------------------
/*
void gldFrustumHook_DX7(
GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble nearval,
GLdouble farval)
{
GET_CURRENT_CONTEXT(ctx);
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
// Pass values on to Mesa first (in case we mess with them)
_mesa_Frustum(left, right, bottom, top, nearval, farval);
_fPersp_33 = farval / (nearval - farval);
// ddlogPrintf(GLDLOG_SYSTEM, "Frustum: %f", farval/nearval);
}
//---------------------------------------------------------------------------
void gldOrthoHook_DX7(
GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble nearval,
GLdouble farval)
{
GET_CURRENT_CONTEXT(ctx);
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
// Pass values on to Mesa first (in case we mess with them)
_mesa_Ortho(left, right, bottom, top, nearval, farval);
_fPersp_33 = 1.6f;
// ddlogPrintf(GLDLOG_SYSTEM, "Ortho: %f", farval/nearval);
}
*/
//---------------------------------------------------------------------------
void gld_NEW_VIEWPORT(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DVIEWPORT7 d3dvp;
// GLint x, y;
// GLsizei w, h;
// Set depth range
_GLD_DX7_DEV(GetViewport(gld->pDev, &d3dvp));
// D3D can't do Quake1/Quake2 z-trick
if (ctx->Viewport.Near <= ctx->Viewport.Far) {
d3dvp.dvMinZ = ctx->Viewport.Near;
d3dvp.dvMaxZ = ctx->Viewport.Far;
} else {
d3dvp.dvMinZ = ctx->Viewport.Far;
d3dvp.dvMaxZ = ctx->Viewport.Near;
}
/* x = ctx->Viewport.X;
y = ctx->Viewport.Y;
w = ctx->Viewport.Width;
h = ctx->Viewport.Height;
if (x < 0) x = 0;
if (y < 0) y = 0;
if (w > gldCtx->dwWidth) w = gldCtx->dwWidth;
if (h > gldCtx->dwHeight) h = gldCtx->dwHeight;
// Ditto for D3D viewport dimensions
if (w+x > gldCtx->dwWidth) w = gldCtx->dwWidth-x;
if (h+y > gldCtx->dwHeight) h = gldCtx->dwHeight-y;
d3dvp.X = x;
d3dvp.Y = gldCtx->dwHeight - (y + h);
d3dvp.Width = w;
d3dvp.Height = h;*/
_GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp));
// gld->fFlipWindowY = (float)gldCtx->dwHeight;
}
//---------------------------------------------------------------------------
__inline BOOL _gldAnyEvalEnabled(
GLcontext *ctx)
{
struct gl_eval_attrib *eval = &ctx->Eval;
if ((eval->AutoNormal) ||
(eval->Map1Color4) ||
(eval->Map1Index) ||
(eval->Map1Normal) ||
(eval->Map1TextureCoord1) ||
(eval->Map1TextureCoord2) ||
(eval->Map1TextureCoord3) ||
(eval->Map1TextureCoord4) ||
(eval->Map1Vertex3) ||
(eval->Map1Vertex4) ||
(eval->Map2Color4) ||
(eval->Map2Index) ||
(eval->Map2Normal) ||
(eval->Map2TextureCoord1) ||
(eval->Map2TextureCoord2) ||
(eval->Map2TextureCoord3) ||
(eval->Map2TextureCoord4) ||
(eval->Map2Vertex3) ||
(eval->Map2Vertex4)
)
return TRUE;
return FALSE;
}
//---------------------------------------------------------------------------
BOOL _gldChooseInternalPipeline(
GLcontext *ctx,
GLD_driver_dx7 *gld)
{
// return TRUE; // DEBUGGING: ALWAYS USE MESA
// return FALSE; // DEBUGGING: ALWAYS USE D3D
if ((glb.dwTnL == GLDS_TNL_MESA) || (gld->bHasHWTnL == FALSE))
{
gld->PipelineUsage.qwMesa.QuadPart++;
return TRUE; // Force Mesa TnL
}
if ((ctx->Light.Enabled) ||
(1) ||
(ctx->Texture._TexGenEnabled) ||
(ctx->Texture._TexMatEnabled) ||
// (ctx->Transform._AnyClip) ||
(ctx->Scissor.Enabled) ||
_gldAnyEvalEnabled(ctx) // Put this last so we can early-out
)
{
gld->PipelineUsage.qwMesa.QuadPart++;
return TRUE;
}
gld->PipelineUsage.qwD3DFVF.QuadPart++;
return FALSE;
/* // Force Mesa pipeline?
if (glb.dwTnL == GLDS_TNL_MESA) {
gld->PipelineUsage.dwMesa.QuadPart++;
return GLD_PIPELINE_MESA;
}
// Test for functionality not exposed in the D3D pathways
if ((ctx->Texture._GenFlags)) {
gld->PipelineUsage.dwMesa.QuadPart++;
return GLD_PIPELINE_MESA;
}
// Now decide if vertex shader can be used.
// If two sided lighting is enabled then we must either
// use Mesa TnL or the vertex shader
if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
if (gld->VStwosidelight.hShader && !ctx->Fog.Enabled) {
// Use Vertex Shader
gld->PipelineUsage.dwD3D2SVS.QuadPart++;
return GLD_PIPELINE_D3D_VS_TWOSIDE;
} else {
// Use Mesa TnL
gld->PipelineUsage.dwMesa.QuadPart++;
return GLD_PIPELINE_MESA;
}
}
// Must be D3D fixed-function pipeline
gld->PipelineUsage.dwD3DFVF.QuadPart++;
return GLD_PIPELINE_D3D_FVF;
*/
}
//---------------------------------------------------------------------------
void gld_update_state_DX7(
GLcontext *ctx,
GLuint new_state)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLD_pb_dx7 *gldPB;
if (!gld || !gld->pDev)
return;
_swsetup_InvalidateState( ctx, new_state );
_ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
// SetupIndex will be used in the pipelines for choosing setup function
if ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_SEPARATE_SPECULAR)) ||
(ctx->Fog.Enabled))
{
if (ctx->_TriangleCaps & DD_FLATSHADE)
gld->iSetupFunc = GLD_SI_FLAT_EXTRAS;
else
gld->iSetupFunc = GLD_SI_SMOOTH_EXTRAS;
} else {
if (ctx->_TriangleCaps & DD_FLATSHADE)
gld->iSetupFunc = GLD_SI_FLAT; // Setup flat shade + texture
else
gld->iSetupFunc = GLD_SI_SMOOTH; // Setup smooth shade + texture
}
gld->bUseMesaTnL = _gldChooseInternalPipeline(ctx, gld);
if (gld->bUseMesaTnL) {
gldPB = &gld->PB2d;
// DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
// _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, TRUE));
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, FALSE));
// _GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
} else {
gldPB = &gld->PB3d;
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, TRUE));
// if (gld->TnLPipeline == GLD_PIPELINE_D3D_VS_TWOSIDE) {
// _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware));
// _GLD_DX7_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
// } else {
// DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
// _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->bHasHWTnL));
// _GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
// }
}
#define _GLD_TEST_STATE(a) \
if (new_state & (a)) { \
gld##a(ctx); \
new_state &= ~(a); \
}
#define _GLD_TEST_STATE_DX7(a) \
if (new_state & (a)) { \
gld##a##_DX7(ctx); \
new_state &= ~(a); \
}
#define _GLD_IGNORE_STATE(a) new_state &= ~(a);
// if (!gld->bUseMesaTnL) {
// Not required if Mesa is doing the TnL.
// Problem: If gld->bUseMesaTnL is TRUE when these are signaled,
// then we'll miss updating the D3D TnL pipeline.
// Therefore, don't test for gld->bUseMesaTnL
_GLD_TEST_STATE(_NEW_MODELVIEW);
_GLD_TEST_STATE(_NEW_PROJECTION);
// }
_GLD_TEST_STATE_DX7(_NEW_TEXTURE); // extern, so guard with _DX7
_GLD_TEST_STATE(_NEW_COLOR);
_GLD_TEST_STATE(_NEW_DEPTH);
_GLD_TEST_STATE(_NEW_POLYGON);
_GLD_TEST_STATE(_NEW_STENCIL);
_GLD_TEST_STATE(_NEW_FOG);
_GLD_TEST_STATE(_NEW_LIGHT);
_GLD_TEST_STATE(_NEW_VIEWPORT);
_GLD_IGNORE_STATE(_NEW_TRANSFORM);
// Stubs for future use.
/* _GLD_TEST_STATE(_NEW_TEXTURE_MATRIX);
_GLD_TEST_STATE(_NEW_COLOR_MATRIX);
_GLD_TEST_STATE(_NEW_ACCUM);
_GLD_TEST_STATE(_NEW_EVAL);
_GLD_TEST_STATE(_NEW_HINT);
_GLD_TEST_STATE(_NEW_LINE);
_GLD_TEST_STATE(_NEW_PIXEL);
_GLD_TEST_STATE(_NEW_POINT);
_GLD_TEST_STATE(_NEW_POLYGONSTIPPLE);
_GLD_TEST_STATE(_NEW_SCISSOR);
_GLD_TEST_STATE(_NEW_PACKUNPACK);
_GLD_TEST_STATE(_NEW_ARRAY);
_GLD_TEST_STATE(_NEW_RENDERMODE);
_GLD_TEST_STATE(_NEW_BUFFERS);
_GLD_TEST_STATE(_NEW_MULTISAMPLE);
*/
// For debugging.
#if 0
#define _GLD_TEST_UNHANDLED_STATE(a) \
if (new_state & (a)) { \
gldLogMessage(GLDLOG_ERROR, "Unhandled " #a "\n"); \
}
_GLD_TEST_UNHANDLED_STATE(_NEW_TEXTURE_MATRIX);
_GLD_TEST_UNHANDLED_STATE(_NEW_COLOR_MATRIX);
_GLD_TEST_UNHANDLED_STATE(_NEW_ACCUM);
_GLD_TEST_UNHANDLED_STATE(_NEW_EVAL);
_GLD_TEST_UNHANDLED_STATE(_NEW_HINT);
_GLD_TEST_UNHANDLED_STATE(_NEW_LINE);
_GLD_TEST_UNHANDLED_STATE(_NEW_PIXEL);
_GLD_TEST_UNHANDLED_STATE(_NEW_POINT);
_GLD_TEST_UNHANDLED_STATE(_NEW_POLYGONSTIPPLE);
_GLD_TEST_UNHANDLED_STATE(_NEW_SCISSOR);
_GLD_TEST_UNHANDLED_STATE(_NEW_PACKUNPACK);
_GLD_TEST_UNHANDLED_STATE(_NEW_ARRAY);
_GLD_TEST_UNHANDLED_STATE(_NEW_RENDERMODE);
_GLD_TEST_UNHANDLED_STATE(_NEW_BUFFERS);
_GLD_TEST_UNHANDLED_STATE(_NEW_MULTISAMPLE);
#undef _GLD_UNHANDLED_STATE
#endif
#undef _GLD_TEST_STATE
}
//---------------------------------------------------------------------------
// Viewport
//---------------------------------------------------------------------------
void gld_Viewport_DX7(
GLcontext *ctx,
GLint x,
GLint y,
GLsizei w,
GLsizei h)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
D3DVIEWPORT7 d3dvp;
if (!gld || !gld->pDev)
return;
// This is a hack. When the app is minimized, Mesa passes
// w=1 and h=1 for viewport dimensions. Without this test
// we get a GPF in gld_wgl_resize_buffers().
if ((w==1) && (h==1))
return;
// Call ResizeBuffersMESA. This function will early-out
// if no resize is needed.
//ctx->Driver.ResizeBuffersMESA(ctx);
// Mesa 5: Changed parameters
ctx->Driver.ResizeBuffers(gldCtx->glBuffer);
#if 0
ddlogPrintf(GLDLOG_SYSTEM, ">> Viewport x=%d y=%d w=%d h=%d", x,y,w,h);
#endif
// ** D3D viewport must not be outside the render target surface **
// Sanity check the GL viewport dimensions
if (x < 0) x = 0;
if (y < 0) y = 0;
if (w > gldCtx->dwWidth) w = gldCtx->dwWidth;
if (h > gldCtx->dwHeight) h = gldCtx->dwHeight;
// Ditto for D3D viewport dimensions
if (w+x > gldCtx->dwWidth) w = gldCtx->dwWidth-x;
if (h+y > gldCtx->dwHeight) h = gldCtx->dwHeight-y;
d3dvp.dwX = x;
d3dvp.dwY = gldCtx->dwHeight - (y + h);
d3dvp.dwWidth = w;
d3dvp.dwHeight = h;
if (ctx->Viewport.Near <= ctx->Viewport.Far) {
d3dvp.dvMinZ = ctx->Viewport.Near;
d3dvp.dvMaxZ = ctx->Viewport.Far;
} else {
d3dvp.dvMinZ = ctx->Viewport.Far;
d3dvp.dvMaxZ = ctx->Viewport.Near;
}
// TODO: DEBUGGING
// d3dvp.MinZ = 0.0f;
// d3dvp.MaxZ = 1.0f;
_GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp));
}
//---------------------------------------------------------------------------
extern BOOL dglWglResizeBuffers(GLcontext *ctx, BOOL bDefaultDriver);
// Mesa 5: Parameter change
void gldResizeBuffers_DX7(
// GLcontext *ctx)
GLframebuffer *fb)
{
GET_CURRENT_CONTEXT(ctx);
dglWglResizeBuffers(ctx, TRUE);
}
//---------------------------------------------------------------------------
#ifdef _DEBUG
// This is only for debugging.
// To use, plug into ctx->Driver.Enable pointer below.
void gld_Enable(
GLcontext *ctx,
GLenum e,
GLboolean b)
{
char buf[1024];
sprintf(buf, "Enable: %s (%s)\n", _mesa_lookup_enum_by_nr(e), b?"TRUE":"FALSE");
ddlogMessage(DDLOG_SYSTEM, buf);
}
#endif
//---------------------------------------------------------------------------
// Driver pointer setup
//---------------------------------------------------------------------------
extern const GLubyte* _gldGetStringGeneric(GLcontext*, GLenum);
void gldSetupDriverPointers_DX7(
GLcontext *ctx)
{
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
// Mandatory functions
ctx->Driver.GetString = _gldGetStringGeneric;
ctx->Driver.UpdateState = gld_update_state_DX7;
ctx->Driver.Clear = gld_Clear_DX7;
ctx->Driver.DrawBuffer = gld_set_draw_buffer_DX7;
ctx->Driver.GetBufferSize = gld_buffer_size_DX7;
ctx->Driver.Finish = gld_Finish_DX7;
ctx->Driver.Flush = gld_Flush_DX7;
ctx->Driver.Error = gld_Error_DX7;
// Hardware accumulation buffer
ctx->Driver.Accum = NULL; // TODO: gld_Accum;
// Bitmap functions
ctx->Driver.CopyPixels = gld_CopyPixels_DX7;
ctx->Driver.DrawPixels = gld_DrawPixels_DX7;
ctx->Driver.ReadPixels = gld_ReadPixels_DX7;
ctx->Driver.Bitmap = gld_Bitmap_DX7;
// Buffer resize
ctx->Driver.ResizeBuffers = gldResizeBuffers_DX7;
// Texture image functions
ctx->Driver.ChooseTextureFormat = gld_ChooseTextureFormat_DX7;
ctx->Driver.TexImage1D = gld_TexImage1D_DX7;
ctx->Driver.TexImage2D = gld_TexImage2D_DX7;
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
ctx->Driver.TexSubImage1D = gld_TexSubImage1D_DX7;
ctx->Driver.TexSubImage2D = gld_TexSubImage2D_DX7;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.CopyTexImage1D = gldCopyTexImage1D_DX7; //NULL;
ctx->Driver.CopyTexImage2D = gldCopyTexImage2D_DX7; //NULL;
ctx->Driver.CopyTexSubImage1D = gldCopyTexSubImage1D_DX7; //NULL;
ctx->Driver.CopyTexSubImage2D = gldCopyTexSubImage2D_DX7; //NULL;
ctx->Driver.CopyTexSubImage3D = gldCopyTexSubImage3D_DX7;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
// Texture object functions
ctx->Driver.BindTexture = NULL;
ctx->Driver.NewTextureObject = NULL; // Not yet implemented by Mesa!;
ctx->Driver.DeleteTexture = gld_DeleteTexture_DX7;
ctx->Driver.PrioritizeTexture = NULL;
// Imaging functionality
ctx->Driver.CopyColorTable = NULL;
ctx->Driver.CopyColorSubTable = NULL;
ctx->Driver.CopyConvolutionFilter1D = NULL;
ctx->Driver.CopyConvolutionFilter2D = NULL;
// State changing functions
ctx->Driver.AlphaFunc = NULL; //gld_AlphaFunc;
ctx->Driver.BlendFuncSeparate = NULL; //gld_BlendFunc;
ctx->Driver.ClearColor = NULL; //gld_ClearColor;
ctx->Driver.ClearDepth = NULL; //gld_ClearDepth;
ctx->Driver.ClearStencil = NULL; //gld_ClearStencil;
ctx->Driver.ColorMask = NULL; //gld_ColorMask;
ctx->Driver.CullFace = NULL; //gld_CullFace;
ctx->Driver.ClipPlane = NULL; //gld_ClipPlane;
ctx->Driver.FrontFace = NULL; //gld_FrontFace;
ctx->Driver.DepthFunc = NULL; //gld_DepthFunc;
ctx->Driver.DepthMask = NULL; //gld_DepthMask;
ctx->Driver.DepthRange = NULL;
ctx->Driver.Enable = NULL; //gld_Enable;
ctx->Driver.Fogfv = NULL; //gld_Fogfv;
ctx->Driver.Hint = NULL; //gld_Hint;
ctx->Driver.Lightfv = NULL; //gld_Lightfv;
ctx->Driver.LightModelfv = NULL; //gld_LightModelfv;
ctx->Driver.LineStipple = NULL; //gld_LineStipple;
ctx->Driver.LineWidth = NULL; //gld_LineWidth;
ctx->Driver.LogicOpcode = NULL; //gld_LogicOpcode;
ctx->Driver.PointParameterfv = NULL; //gld_PointParameterfv;
ctx->Driver.PointSize = NULL; //gld_PointSize;
ctx->Driver.PolygonMode = NULL; //gld_PolygonMode;
ctx->Driver.PolygonOffset = NULL; //gld_PolygonOffset;
ctx->Driver.PolygonStipple = NULL; //gld_PolygonStipple;
ctx->Driver.RenderMode = NULL; //gld_RenderMode;
ctx->Driver.Scissor = NULL; //gld_Scissor;
ctx->Driver.ShadeModel = NULL; //gld_ShadeModel;
ctx->Driver.StencilFunc = NULL; //gld_StencilFunc;
ctx->Driver.StencilMask = NULL; //gld_StencilMask;
ctx->Driver.StencilOp = NULL; //gld_StencilOp;
ctx->Driver.TexGen = NULL; //gld_TexGen;
ctx->Driver.TexEnv = NULL;
ctx->Driver.TexParameter = NULL;
ctx->Driver.TextureMatrix = NULL; //gld_TextureMatrix;
ctx->Driver.Viewport = gld_Viewport_DX7;
_swsetup_Wakeup(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
tnl->Driver.Render.ResetLineStipple = gld_ResetLineStipple_DX7;
tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
// Hook into glFrustum() and glOrtho()
// ctx->Exec->Frustum = gldFrustumHook_DX7;
// ctx->Exec->Ortho = gldOrthoHook_DX7;
}
//---------------------------------------------------------------------------
|