Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / windows / gldirect / dx7 / gld_driver_dx7.c
1 /****************************************************************************
2 *
3 * Mesa 3-D graphics library
4 * Direct3D Driver Interface
5 *
6 * ========================================================================
7 *
8 * Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 *
28 * ======================================================================
29 *
30 * Language: ANSI C
31 * Environment: Windows 9x/2000/XP/XBox (Win32)
32 *
33 * Description: Driver interface code to Mesa
34 *
35 ****************************************************************************/
36
37 //#include <windows.h>
38 #include "dglcontext.h"
39 #include "ddlog.h"
40 #include "gld_dx7.h"
41
42 #include "glheader.h"
43 #include "context.h"
44 #include "colormac.h"
45 #include "depth.h"
46 #include "extensions.h"
47 #include "macros.h"
48 #include "matrix.h"
49 // #include "mem.h"
50 //#include "mmath.h"
51 #include "mtypes.h"
52 #include "texformat.h"
53 #include "teximage.h"
54 #include "texstore.h"
55 #include "vbo/vbo.h"
56 #include "swrast_setup/swrast_setup.h"
57 #include "swrast_setup/ss_context.h"
58 #include "tnl/tnl.h"
59 #include "tnl/t_context.h"
60 #include "tnl/t_pipeline.h"
61
62 extern BOOL dglSwapBuffers(HDC hDC);
63
64 // HACK: Hack the _33 member of the OpenGL perspective projection matrix
65 const float _fPersp_33 = 1.6f;
66
67 //---------------------------------------------------------------------------
68 // Internal functions
69 //---------------------------------------------------------------------------
70
71 void _gld_mesa_warning(
72 __GLcontext *gc,
73 char *str)
74 {
75 // Intercept Mesa's internal warning mechanism
76 gldLogPrintf(GLDLOG_WARN, "Mesa warning: %s", str);
77 }
78
79 //---------------------------------------------------------------------------
80
81 void _gld_mesa_fatal(
82 __GLcontext *gc,
83 char *str)
84 {
85 // Intercept Mesa's internal fatal-message mechanism
86 gldLogPrintf(GLDLOG_CRITICAL, "Mesa FATAL: %s", str);
87
88 // Mesa calls abort(0) here.
89 ddlogClose();
90 exit(0);
91 }
92
93 //---------------------------------------------------------------------------
94
95 D3DSTENCILOP _gldConvertStencilOp(
96 GLenum StencilOp)
97 {
98 // Used by Stencil: pass, fail and zfail
99
100 switch (StencilOp) {
101 case GL_KEEP:
102 return D3DSTENCILOP_KEEP;
103 case GL_ZERO:
104 return D3DSTENCILOP_ZERO;
105 case GL_REPLACE:
106 return D3DSTENCILOP_REPLACE;
107 case GL_INCR:
108 return D3DSTENCILOP_INCRSAT;
109 case GL_DECR:
110 return D3DSTENCILOP_DECRSAT;
111 case GL_INVERT:
112 return D3DSTENCILOP_INVERT;
113 case GL_INCR_WRAP_EXT: // GL_EXT_stencil_wrap
114 return D3DSTENCILOP_INCR;
115 case GL_DECR_WRAP_EXT: // GL_EXT_stencil_wrap
116 return D3DSTENCILOP_DECR;
117 }
118
119 #ifdef _DEBUG
120 gldLogMessage(GLDLOG_ERROR, "_gldConvertStencilOp: Unknown StencilOp\n");
121 #endif
122
123 return D3DSTENCILOP_KEEP;
124 }
125
126 //---------------------------------------------------------------------------
127
128 D3DCMPFUNC _gldConvertCompareFunc(
129 GLenum CmpFunc)
130 {
131 // Used for Alpha func, depth func and stencil func.
132
133 switch (CmpFunc) {
134 case GL_NEVER:
135 return D3DCMP_NEVER;
136 case GL_LESS:
137 return D3DCMP_LESS;
138 case GL_EQUAL:
139 return D3DCMP_EQUAL;
140 case GL_LEQUAL:
141 return D3DCMP_LESSEQUAL;
142 case GL_GREATER:
143 return D3DCMP_GREATER;
144 case GL_NOTEQUAL:
145 return D3DCMP_NOTEQUAL;
146 case GL_GEQUAL:
147 return D3DCMP_GREATEREQUAL;
148 case GL_ALWAYS:
149 return D3DCMP_ALWAYS;
150 };
151
152 #ifdef _DEBUG
153 gldLogMessage(GLDLOG_ERROR, "_gldConvertCompareFunc: Unknown CompareFunc\n");
154 #endif
155
156 return D3DCMP_ALWAYS;
157 }
158
159 //---------------------------------------------------------------------------
160
161 D3DBLEND _gldConvertBlendFunc(
162 GLenum blend,
163 GLenum DefaultBlend)
164 {
165 switch (blend) {
166 case GL_ZERO:
167 return D3DBLEND_ZERO;
168 case GL_ONE:
169 return D3DBLEND_ONE;
170 case GL_DST_COLOR:
171 return D3DBLEND_DESTCOLOR;
172 case GL_SRC_COLOR:
173 return D3DBLEND_SRCCOLOR;
174 case GL_ONE_MINUS_DST_COLOR:
175 return D3DBLEND_INVDESTCOLOR;
176 case GL_ONE_MINUS_SRC_COLOR:
177 return D3DBLEND_INVSRCCOLOR;
178 case GL_SRC_ALPHA:
179 return D3DBLEND_SRCALPHA;
180 case GL_ONE_MINUS_SRC_ALPHA:
181 return D3DBLEND_INVSRCALPHA;
182 case GL_DST_ALPHA:
183 return D3DBLEND_DESTALPHA;
184 case GL_ONE_MINUS_DST_ALPHA:
185 return D3DBLEND_INVDESTALPHA;
186 case GL_SRC_ALPHA_SATURATE:
187 return D3DBLEND_SRCALPHASAT;
188 }
189
190 #ifdef _DEBUG
191 gldLogMessage(GLDLOG_ERROR, "_gldConvertBlendFunc: Unknown BlendFunc\n");
192 #endif
193
194 return DefaultBlend;
195 }
196
197 //---------------------------------------------------------------------------
198 // Misc. functions
199 //---------------------------------------------------------------------------
200
201 void gld_Noop_DX7(
202 GLcontext *ctx)
203 {
204 #ifdef _DEBUG
205 gldLogMessage(GLDLOG_ERROR, "gld_Noop called!\n");
206 #endif
207 }
208
209 //---------------------------------------------------------------------------
210
211 void gld_Error_DX7(
212 GLcontext *ctx)
213 {
214 #ifdef _DEBUG
215 // Quite useless.
216 // gldLogMessage(GLDLOG_ERROR, "ctx->Driver.Error called!\n");
217 #endif
218 }
219
220 //---------------------------------------------------------------------------
221 // Required Mesa functions
222 //---------------------------------------------------------------------------
223
224 static GLboolean gld_set_draw_buffer_DX7(
225 GLcontext *ctx,
226 GLenum mode)
227 {
228 (void) ctx;
229 if ((mode==GL_FRONT_LEFT) || (mode == GL_BACK_LEFT)) {
230 return GL_TRUE;
231 }
232 else {
233 return GL_FALSE;
234 }
235 }
236
237 //---------------------------------------------------------------------------
238
239 static void gld_set_read_buffer_DX7(
240 GLcontext *ctx,
241 GLframebuffer *buffer,
242 GLenum mode)
243 {
244 /* separate read buffer not supported */
245 /*
246 ASSERT(buffer == ctx->DrawBuffer);
247 ASSERT(mode == GL_FRONT_LEFT);
248 */
249 }
250
251 //---------------------------------------------------------------------------
252
253 void gld_Clear_DX7(
254 GLcontext *ctx,
255 GLbitfield mask,
256 GLboolean all,
257 GLint x,
258 GLint y,
259 GLint width,
260 GLint height)
261 {
262 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
263 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
264
265 DWORD dwFlags = 0;
266 D3DCOLOR Color = 0;
267 float Z = 0.0f;
268 DWORD Stencil = 0;
269 D3DRECT d3dClearRect;
270
271 // TODO: Colourmask
272 const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
273
274 if (!gld->pDev)
275 return;
276
277 if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
278 GLubyte col[4];
279 CLAMPED_FLOAT_TO_UBYTE(col[0], ctx->Color.ClearColor[0]);
280 CLAMPED_FLOAT_TO_UBYTE(col[1], ctx->Color.ClearColor[1]);
281 CLAMPED_FLOAT_TO_UBYTE(col[2], ctx->Color.ClearColor[2]);
282 CLAMPED_FLOAT_TO_UBYTE(col[3], ctx->Color.ClearColor[3]);
283 dwFlags |= D3DCLEAR_TARGET;
284 Color = D3DCOLOR_RGBA(col[0], col[1], col[2], col[3]);
285 // ctx->Color.ClearColor[1],
286 // ctx->Color.ClearColor[2],
287 // ctx->Color.ClearColor[3]);
288 }
289
290 if (mask & DD_DEPTH_BIT) {
291 // D3D7 will fail the Clear call if we try and clear a
292 // depth buffer and we haven't created one.
293 // Also, some apps try and clear a depth buffer,
294 // when a depth buffer hasn't been requested by the app.
295 if (ctx->Visual.depthBits == 0) {
296 mask &= ~DD_DEPTH_BIT; // Remove depth bit from mask
297 } else {
298 dwFlags |= D3DCLEAR_ZBUFFER;
299 Z = ctx->Depth.Clear;
300 }
301 }
302
303 if (mask & DD_STENCIL_BIT) {
304 if (ctx->Visual.stencilBits == 0) {
305 // No stencil bits in depth buffer
306 mask &= ~DD_STENCIL_BIT; // Remove stencil bit from mask
307 } else {
308 dwFlags |= D3DCLEAR_STENCIL;
309 Stencil = ctx->Stencil.Clear;
310 }
311 }
312
313 // Some apps do really weird things with the rect, such as Quake3.
314 if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0)) {
315 all = GL_TRUE;
316 }
317
318 if (!all) {
319 // Calculate clear subrect
320 d3dClearRect.x1 = x;
321 d3dClearRect.y1 = gldCtx->dwHeight - (y + height);
322 d3dClearRect.x2 = x + width;
323 d3dClearRect.y2 = d3dClearRect.y1 + height;
324 }
325
326 // dwFlags will be zero if there's nothing to clear
327 if (dwFlags) {
328 _GLD_DX7_DEV(Clear(
329 gld->pDev,
330 all ? 0 : 1,
331 all ? NULL : &d3dClearRect,
332 dwFlags,
333 Color, Z, Stencil));
334 }
335
336 if (mask & DD_ACCUM_BIT) {
337 // Clear accumulation buffer
338 }
339 }
340
341 //---------------------------------------------------------------------------
342
343 // Mesa 5: Parameter change
344 static void gld_buffer_size_DX7(
345 // GLcontext *ctx,
346 GLframebuffer *fb,
347 GLuint *width,
348 GLuint *height)
349 {
350 // GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
351
352 *width = fb->Width; // gldCtx->dwWidth;
353 *height = fb->Height; // gldCtx->dwHeight;
354 }
355
356 //---------------------------------------------------------------------------
357
358 static void gld_Finish_DX7(
359 GLcontext *ctx)
360 {
361 }
362
363 //---------------------------------------------------------------------------
364
365 static void gld_Flush_DX7(
366 GLcontext *ctx)
367 {
368 GLD_context *gld = GLD_GET_CONTEXT(ctx);
369
370 // TODO: Detect apps that glFlush() then SwapBuffers() ?
371
372 if (gld->EmulateSingle) {
373 // Emulating a single-buffered context.
374 // [Direct3D doesn't allow rendering to front buffer]
375 dglSwapBuffers(gld->hDC);
376 }
377 }
378
379 //---------------------------------------------------------------------------
380
381 void gld_NEW_STENCIL(
382 GLcontext *ctx)
383 {
384 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
385 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
386
387 // Two-sided stencil. New for Mesa 5
388 const GLuint uiFace = 0UL;
389
390 struct gl_stencil_attrib *pStencil = &ctx->Stencil;
391
392 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILENABLE, pStencil->Enabled ? TRUE : FALSE));
393 if (pStencil->Enabled) {
394 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFUNC, _gldConvertCompareFunc(pStencil->Function[uiFace])));
395 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILREF, pStencil->Ref[uiFace]));
396 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILMASK, pStencil->ValueMask[uiFace]));
397 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILWRITEMASK, pStencil->WriteMask[uiFace]));
398 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILFAIL, _gldConvertStencilOp(pStencil->FailFunc[uiFace])));
399 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILZFAIL, _gldConvertStencilOp(pStencil->ZFailFunc[uiFace])));
400 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_STENCILPASS, _gldConvertStencilOp(pStencil->ZPassFunc[uiFace])));
401 }
402 }
403
404 //---------------------------------------------------------------------------
405
406 void gld_NEW_COLOR(
407 GLcontext *ctx)
408 {
409 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
410 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
411
412 DWORD dwFlags = 0;
413 D3DBLEND src;
414 D3DBLEND dest;
415
416 // Alpha func
417 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHAFUNC, _gldConvertCompareFunc(ctx->Color.AlphaFunc)));
418 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHAREF, (DWORD)ctx->Color.AlphaRef));
419 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHATESTENABLE, ctx->Color.AlphaEnabled));
420
421 // Blend func
422 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ALPHABLENDENABLE, ctx->Color.BlendEnabled));
423 src = _gldConvertBlendFunc(ctx->Color.BlendSrcRGB, GL_ONE);
424 dest = _gldConvertBlendFunc(ctx->Color.BlendDstRGB, GL_ZERO);
425 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SRCBLEND, src));
426 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_DESTBLEND, dest));
427
428 /*
429 // Color mask - unsupported by DX7
430 if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
431 if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
432 if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
433 if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
434 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_COLORWRITEENABLE, dwFlags));
435 */
436 }
437
438 //---------------------------------------------------------------------------
439
440 void gld_NEW_DEPTH(
441 GLcontext *ctx)
442 {
443 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
444 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
445
446 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZENABLE, ctx->Depth.Test ? D3DZB_TRUE : D3DZB_FALSE));
447 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZFUNC, _gldConvertCompareFunc(ctx->Depth.Func)));
448 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZWRITEENABLE, ctx->Depth.Mask ? TRUE : FALSE));
449 }
450
451 //---------------------------------------------------------------------------
452
453 void gld_NEW_POLYGON(
454 GLcontext *ctx)
455 {
456 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
457 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
458
459 D3DFILLMODE d3dFillMode = D3DFILL_SOLID;
460 D3DCULL d3dCullMode = D3DCULL_NONE;
461 int iOffset = 0;
462
463 // Fillmode
464 switch (ctx->Polygon.FrontMode) {
465 case GL_POINT:
466 d3dFillMode = D3DFILL_POINT;
467 break;
468 case GL_LINE:
469 d3dFillMode = D3DFILL_WIREFRAME;
470 break;
471 case GL_FILL:
472 d3dFillMode = D3DFILL_SOLID;
473 break;
474 }
475 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FILLMODE, d3dFillMode));
476
477 if (ctx->Polygon.CullFlag) {
478 switch (ctx->Polygon.CullFaceMode) {
479 case GL_BACK:
480 if (ctx->Polygon.FrontFace == GL_CCW)
481 d3dCullMode = D3DCULL_CW;
482 else
483 d3dCullMode = D3DCULL_CCW;
484 break;
485 case GL_FRONT:
486 if (ctx->Polygon.FrontFace == GL_CCW)
487 d3dCullMode = D3DCULL_CCW;
488 else
489 d3dCullMode = D3DCULL_CW;
490 break;
491 case GL_FRONT_AND_BACK:
492 d3dCullMode = D3DCULL_NONE;
493 break;
494 default:
495 break;
496 }
497 } else {
498 d3dCullMode = D3DCULL_NONE;
499 }
500 // d3dCullMode = D3DCULL_NONE; // TODO: DEBUGGING
501 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CULLMODE, d3dCullMode));
502
503 // Polygon offset
504 // ZBIAS ranges from 0 to 16 and can only move towards the viewer
505 // Mesa5: ctx->Polygon._OffsetAny removed
506 if (ctx->Polygon.OffsetFill) {
507 iOffset = (int)ctx->Polygon.OffsetUnits;
508 if (iOffset < 0)
509 iOffset = -iOffset;
510 else
511 iOffset = 0; // D3D can't push away
512 }
513 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_ZBIAS, iOffset));
514 }
515
516 //---------------------------------------------------------------------------
517
518 void gld_NEW_FOG(
519 GLcontext *ctx)
520 {
521 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
522 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
523
524 D3DCOLOR d3dFogColour;
525 D3DFOGMODE d3dFogMode = D3DFOG_LINEAR;
526
527 // TODO: Fog is calculated seperately in the Mesa pipeline
528 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, FALSE));
529 return;
530
531 // Fog enable
532 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, ctx->Fog.Enabled));
533 if (!ctx->Fog.Enabled) {
534 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE));
535 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
536 return; // If disabled, don't bother setting any fog state
537 }
538
539 // Fog colour
540 d3dFogColour = D3DCOLOR_COLORVALUE( ctx->Fog.Color[0],
541 ctx->Fog.Color[1],
542 ctx->Fog.Color[2],
543 ctx->Fog.Color[3]);
544 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGCOLOR, d3dFogColour));
545
546 // Fog density
547 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGDENSITY, *((DWORD*) (&ctx->Fog.Density))));
548
549 // Fog start
550 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGSTART, *((DWORD*) (&ctx->Fog.Start))));
551
552 // Fog end
553 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGEND, *((DWORD*) (&ctx->Fog.End))));
554
555 // Fog mode
556 switch (ctx->Fog.Mode) {
557 case GL_LINEAR:
558 d3dFogMode = D3DFOG_LINEAR;
559 break;
560 case GL_EXP:
561 d3dFogMode = D3DFOG_EXP;
562 break;
563 case GL_EXP2:
564 d3dFogMode = D3DFOG_EXP2;
565 break;
566 }
567 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, d3dFogMode));
568 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
569 }
570
571 //---------------------------------------------------------------------------
572
573 void gld_NEW_LIGHT(
574 GLcontext *ctx)
575 {
576 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
577 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
578 DWORD dwSpecularEnable;
579
580 // Shademode
581 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SHADEMODE, (ctx->Light.ShadeModel == GL_SMOOTH) ? D3DSHADE_GOURAUD : D3DSHADE_FLAT));
582
583 // Separate specular colour
584 if (ctx->Light.Enabled)
585 dwSpecularEnable = (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) ? TRUE: FALSE;
586 else
587 dwSpecularEnable = FALSE;
588 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SPECULARENABLE, dwSpecularEnable));
589 }
590
591 //---------------------------------------------------------------------------
592
593 void gld_NEW_MODELVIEW(
594 GLcontext *ctx)
595 {
596 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
597 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
598
599 D3DMATRIX m;
600 //GLfloat *pM = ctx->ModelView.m;
601 // Mesa5: Model-view is now a stack
602 GLfloat *pM = ctx->ModelviewMatrixStack.Top->m;
603 m._11 = pM[0];
604 m._12 = pM[1];
605 m._13 = pM[2];
606 m._14 = pM[3];
607 m._21 = pM[4];
608 m._22 = pM[5];
609 m._23 = pM[6];
610 m._24 = pM[7];
611 m._31 = pM[8];
612 m._32 = pM[9];
613 m._33 = pM[10];
614 m._34 = pM[11];
615 m._41 = pM[12];
616 m._42 = pM[13];
617 m._43 = pM[14];
618 m._44 = pM[15];
619 /* m[0][0] = pM[0];
620 m[0][1] = pM[1];
621 m[0][2] = pM[2];
622 m[0][3] = pM[3];
623 m[1][0] = pM[4];
624 m[1][1] = pM[5];
625 m[1][2] = pM[6];
626 m[1][3] = pM[7];
627 m[2][0] = pM[8];
628 m[2][1] = pM[9];
629 m[2][2] = pM[10];
630 m[2][3] = pM[11];
631 m[3][0] = pM[12];
632 m[3][1] = pM[13];
633 m[3][2] = pM[14];
634 m[3][3] = pM[15];*/
635
636 gld->matModelView = m;
637 }
638
639 //---------------------------------------------------------------------------
640
641 void gld_NEW_PROJECTION(
642 GLcontext *ctx)
643 {
644 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
645 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
646
647 D3DMATRIX m;
648 //GLfloat *pM = ctx->ProjectionMatrix.m;
649 // Mesa 5: Now a stack
650 GLfloat *pM = ctx->ProjectionMatrixStack.Top->m;
651 m._11 = pM[0];
652 m._12 = pM[1];
653 m._13 = pM[2];
654 m._14 = pM[3];
655
656 m._21 = pM[4];
657 m._22 = pM[5];
658 m._23 = pM[6];
659 m._24 = pM[7];
660
661 m._31 = pM[8];
662 m._32 = pM[9];
663 m._33 = pM[10] / _fPersp_33; // / 1.6f;
664 m._34 = pM[11];
665
666 m._41 = pM[12];
667 m._42 = pM[13];
668 m._43 = pM[14] / 2.0f;
669 m._44 = pM[15];
670
671 gld->matProjection = m;
672 }
673
674 //---------------------------------------------------------------------------
675 /*
676 void gldFrustumHook_DX7(
677 GLdouble left,
678 GLdouble right,
679 GLdouble bottom,
680 GLdouble top,
681 GLdouble nearval,
682 GLdouble farval)
683 {
684 GET_CURRENT_CONTEXT(ctx);
685 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
686 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
687
688 // Pass values on to Mesa first (in case we mess with them)
689 _mesa_Frustum(left, right, bottom, top, nearval, farval);
690
691 _fPersp_33 = farval / (nearval - farval);
692
693 // ddlogPrintf(GLDLOG_SYSTEM, "Frustum: %f", farval/nearval);
694 }
695
696 //---------------------------------------------------------------------------
697
698 void gldOrthoHook_DX7(
699 GLdouble left,
700 GLdouble right,
701 GLdouble bottom,
702 GLdouble top,
703 GLdouble nearval,
704 GLdouble farval)
705 {
706 GET_CURRENT_CONTEXT(ctx);
707 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
708 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
709
710 // Pass values on to Mesa first (in case we mess with them)
711 _mesa_Ortho(left, right, bottom, top, nearval, farval);
712
713 _fPersp_33 = 1.6f;
714
715 // ddlogPrintf(GLDLOG_SYSTEM, "Ortho: %f", farval/nearval);
716 }
717 */
718 //---------------------------------------------------------------------------
719
720 void gld_NEW_VIEWPORT(
721 GLcontext *ctx)
722 {
723 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
724 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
725
726 D3DVIEWPORT7 d3dvp;
727 // GLint x, y;
728 // GLsizei w, h;
729
730 // Set depth range
731 _GLD_DX7_DEV(GetViewport(gld->pDev, &d3dvp));
732 // D3D can't do Quake1/Quake2 z-trick
733 if (ctx->Viewport.Near <= ctx->Viewport.Far) {
734 d3dvp.dvMinZ = ctx->Viewport.Near;
735 d3dvp.dvMaxZ = ctx->Viewport.Far;
736 } else {
737 d3dvp.dvMinZ = ctx->Viewport.Far;
738 d3dvp.dvMaxZ = ctx->Viewport.Near;
739 }
740 /* x = ctx->Viewport.X;
741 y = ctx->Viewport.Y;
742 w = ctx->Viewport.Width;
743 h = ctx->Viewport.Height;
744 if (x < 0) x = 0;
745 if (y < 0) y = 0;
746 if (w > gldCtx->dwWidth) w = gldCtx->dwWidth;
747 if (h > gldCtx->dwHeight) h = gldCtx->dwHeight;
748 // Ditto for D3D viewport dimensions
749 if (w+x > gldCtx->dwWidth) w = gldCtx->dwWidth-x;
750 if (h+y > gldCtx->dwHeight) h = gldCtx->dwHeight-y;
751 d3dvp.X = x;
752 d3dvp.Y = gldCtx->dwHeight - (y + h);
753 d3dvp.Width = w;
754 d3dvp.Height = h;*/
755 _GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp));
756
757 // gld->fFlipWindowY = (float)gldCtx->dwHeight;
758 }
759
760 //---------------------------------------------------------------------------
761
762 __inline BOOL _gldAnyEvalEnabled(
763 GLcontext *ctx)
764 {
765 struct gl_eval_attrib *eval = &ctx->Eval;
766
767 if ((eval->AutoNormal) ||
768 (eval->Map1Color4) ||
769 (eval->Map1Index) ||
770 (eval->Map1Normal) ||
771 (eval->Map1TextureCoord1) ||
772 (eval->Map1TextureCoord2) ||
773 (eval->Map1TextureCoord3) ||
774 (eval->Map1TextureCoord4) ||
775 (eval->Map1Vertex3) ||
776 (eval->Map1Vertex4) ||
777 (eval->Map2Color4) ||
778 (eval->Map2Index) ||
779 (eval->Map2Normal) ||
780 (eval->Map2TextureCoord1) ||
781 (eval->Map2TextureCoord2) ||
782 (eval->Map2TextureCoord3) ||
783 (eval->Map2TextureCoord4) ||
784 (eval->Map2Vertex3) ||
785 (eval->Map2Vertex4)
786 )
787 return TRUE;
788
789 return FALSE;
790 }
791
792 //---------------------------------------------------------------------------
793
794 BOOL _gldChooseInternalPipeline(
795 GLcontext *ctx,
796 GLD_driver_dx7 *gld)
797 {
798 // return TRUE; // DEBUGGING: ALWAYS USE MESA
799 // return FALSE; // DEBUGGING: ALWAYS USE D3D
800
801 if ((glb.dwTnL == GLDS_TNL_MESA) || (gld->bHasHWTnL == FALSE))
802 {
803 gld->PipelineUsage.qwMesa.QuadPart++;
804 return TRUE; // Force Mesa TnL
805 }
806
807 if ((ctx->Light.Enabled) ||
808 (1) ||
809 (ctx->Texture._TexGenEnabled) ||
810 (ctx->Texture._TexMatEnabled) ||
811 // (ctx->Transform._AnyClip) ||
812 (ctx->Scissor.Enabled) ||
813 _gldAnyEvalEnabled(ctx) // Put this last so we can early-out
814 )
815 {
816 gld->PipelineUsage.qwMesa.QuadPart++;
817 return TRUE;
818 }
819
820 gld->PipelineUsage.qwD3DFVF.QuadPart++;
821 return FALSE;
822
823 /* // Force Mesa pipeline?
824 if (glb.dwTnL == GLDS_TNL_MESA) {
825 gld->PipelineUsage.dwMesa.QuadPart++;
826 return GLD_PIPELINE_MESA;
827 }
828
829 // Test for functionality not exposed in the D3D pathways
830 if ((ctx->Texture._GenFlags)) {
831 gld->PipelineUsage.dwMesa.QuadPart++;
832 return GLD_PIPELINE_MESA;
833 }
834
835 // Now decide if vertex shader can be used.
836 // If two sided lighting is enabled then we must either
837 // use Mesa TnL or the vertex shader
838 if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
839 if (gld->VStwosidelight.hShader && !ctx->Fog.Enabled) {
840 // Use Vertex Shader
841 gld->PipelineUsage.dwD3D2SVS.QuadPart++;
842 return GLD_PIPELINE_D3D_VS_TWOSIDE;
843 } else {
844 // Use Mesa TnL
845 gld->PipelineUsage.dwMesa.QuadPart++;
846 return GLD_PIPELINE_MESA;
847 }
848 }
849
850 // Must be D3D fixed-function pipeline
851 gld->PipelineUsage.dwD3DFVF.QuadPart++;
852 return GLD_PIPELINE_D3D_FVF;
853 */
854 }
855
856 //---------------------------------------------------------------------------
857
858 void gld_update_state_DX7(
859 GLcontext *ctx,
860 GLuint new_state)
861 {
862 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
863 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
864 TNLcontext *tnl = TNL_CONTEXT(ctx);
865 GLD_pb_dx7 *gldPB;
866
867 if (!gld || !gld->pDev)
868 return;
869
870 _swsetup_InvalidateState( ctx, new_state );
871 _vbo_InvalidateState( ctx, new_state );
872 _tnl_InvalidateState( ctx, new_state );
873
874 // SetupIndex will be used in the pipelines for choosing setup function
875 if ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_SEPARATE_SPECULAR)) ||
876 (ctx->Fog.Enabled))
877 {
878 if (ctx->_TriangleCaps & DD_FLATSHADE)
879 gld->iSetupFunc = GLD_SI_FLAT_EXTRAS;
880 else
881 gld->iSetupFunc = GLD_SI_SMOOTH_EXTRAS;
882 } else {
883 if (ctx->_TriangleCaps & DD_FLATSHADE)
884 gld->iSetupFunc = GLD_SI_FLAT; // Setup flat shade + texture
885 else
886 gld->iSetupFunc = GLD_SI_SMOOTH; // Setup smooth shade + texture
887 }
888
889 gld->bUseMesaTnL = _gldChooseInternalPipeline(ctx, gld);
890 if (gld->bUseMesaTnL) {
891 gldPB = &gld->PB2d;
892 // DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
893 // _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, TRUE));
894 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, FALSE));
895 // _GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
896 } else {
897 gldPB = &gld->PB3d;
898 _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_CLIPPING, TRUE));
899 // if (gld->TnLPipeline == GLD_PIPELINE_D3D_VS_TWOSIDE) {
900 // _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware));
901 // _GLD_DX7_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
902 // } else {
903 // DX7 Does not implement D3DRS_SOFTWAREVERTEXPROCESSING
904 // _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_SOFTWAREVERTEXPROCESSING, !gld->bHasHWTnL));
905 // _GLD_DX7_DEV(SetVertexShader(gld->pDev, gldPB->dwFVF));
906 // }
907 }
908
909 #define _GLD_TEST_STATE(a) \
910 if (new_state & (a)) { \
911 gld##a(ctx); \
912 new_state &= ~(a); \
913 }
914
915 #define _GLD_TEST_STATE_DX7(a) \
916 if (new_state & (a)) { \
917 gld##a##_DX7(ctx); \
918 new_state &= ~(a); \
919 }
920
921 #define _GLD_IGNORE_STATE(a) new_state &= ~(a);
922
923 // if (!gld->bUseMesaTnL) {
924 // Not required if Mesa is doing the TnL.
925 // Problem: If gld->bUseMesaTnL is TRUE when these are signaled,
926 // then we'll miss updating the D3D TnL pipeline.
927 // Therefore, don't test for gld->bUseMesaTnL
928 _GLD_TEST_STATE(_NEW_MODELVIEW);
929 _GLD_TEST_STATE(_NEW_PROJECTION);
930 // }
931
932 _GLD_TEST_STATE_DX7(_NEW_TEXTURE); // extern, so guard with _DX7
933 _GLD_TEST_STATE(_NEW_COLOR);
934 _GLD_TEST_STATE(_NEW_DEPTH);
935 _GLD_TEST_STATE(_NEW_POLYGON);
936 _GLD_TEST_STATE(_NEW_STENCIL);
937 _GLD_TEST_STATE(_NEW_FOG);
938 _GLD_TEST_STATE(_NEW_LIGHT);
939 _GLD_TEST_STATE(_NEW_VIEWPORT);
940
941 _GLD_IGNORE_STATE(_NEW_TRANSFORM);
942
943
944 // Stubs for future use.
945 /* _GLD_TEST_STATE(_NEW_TEXTURE_MATRIX);
946 _GLD_TEST_STATE(_NEW_COLOR_MATRIX);
947 _GLD_TEST_STATE(_NEW_ACCUM);
948 _GLD_TEST_STATE(_NEW_EVAL);
949 _GLD_TEST_STATE(_NEW_HINT);
950 _GLD_TEST_STATE(_NEW_LINE);
951 _GLD_TEST_STATE(_NEW_PIXEL);
952 _GLD_TEST_STATE(_NEW_POINT);
953 _GLD_TEST_STATE(_NEW_POLYGONSTIPPLE);
954 _GLD_TEST_STATE(_NEW_SCISSOR);
955 _GLD_TEST_STATE(_NEW_PACKUNPACK);
956 _GLD_TEST_STATE(_NEW_ARRAY);
957 _GLD_TEST_STATE(_NEW_RENDERMODE);
958 _GLD_TEST_STATE(_NEW_BUFFERS);
959 _GLD_TEST_STATE(_NEW_MULTISAMPLE);
960 */
961
962 // For debugging.
963 #if 0
964 #define _GLD_TEST_UNHANDLED_STATE(a) \
965 if (new_state & (a)) { \
966 gldLogMessage(GLDLOG_ERROR, "Unhandled " #a "\n"); \
967 }
968 _GLD_TEST_UNHANDLED_STATE(_NEW_TEXTURE_MATRIX);
969 _GLD_TEST_UNHANDLED_STATE(_NEW_COLOR_MATRIX);
970 _GLD_TEST_UNHANDLED_STATE(_NEW_ACCUM);
971 _GLD_TEST_UNHANDLED_STATE(_NEW_EVAL);
972 _GLD_TEST_UNHANDLED_STATE(_NEW_HINT);
973 _GLD_TEST_UNHANDLED_STATE(_NEW_LINE);
974 _GLD_TEST_UNHANDLED_STATE(_NEW_PIXEL);
975 _GLD_TEST_UNHANDLED_STATE(_NEW_POINT);
976 _GLD_TEST_UNHANDLED_STATE(_NEW_POLYGONSTIPPLE);
977 _GLD_TEST_UNHANDLED_STATE(_NEW_SCISSOR);
978 _GLD_TEST_UNHANDLED_STATE(_NEW_PACKUNPACK);
979 _GLD_TEST_UNHANDLED_STATE(_NEW_ARRAY);
980 _GLD_TEST_UNHANDLED_STATE(_NEW_RENDERMODE);
981 _GLD_TEST_UNHANDLED_STATE(_NEW_BUFFERS);
982 _GLD_TEST_UNHANDLED_STATE(_NEW_MULTISAMPLE);
983 #undef _GLD_UNHANDLED_STATE
984 #endif
985
986 #undef _GLD_TEST_STATE
987 }
988
989 //---------------------------------------------------------------------------
990 // Viewport
991 //---------------------------------------------------------------------------
992
993 void gld_Viewport_DX7(
994 GLcontext *ctx,
995 GLint x,
996 GLint y,
997 GLsizei w,
998 GLsizei h)
999 {
1000 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1001 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
1002
1003 D3DVIEWPORT7 d3dvp;
1004
1005 if (!gld || !gld->pDev)
1006 return;
1007
1008 // This is a hack. When the app is minimized, Mesa passes
1009 // w=1 and h=1 for viewport dimensions. Without this test
1010 // we get a GPF in gld_wgl_resize_buffers().
1011 if ((w==1) && (h==1))
1012 return;
1013
1014 // Call ResizeBuffersMESA. This function will early-out
1015 // if no resize is needed.
1016 //ctx->Driver.ResizeBuffersMESA(ctx);
1017 // Mesa 5: Changed parameters
1018 ctx->Driver.ResizeBuffers(gldCtx->glBuffer);
1019
1020 #if 0
1021 ddlogPrintf(GLDLOG_SYSTEM, ">> Viewport x=%d y=%d w=%d h=%d", x,y,w,h);
1022 #endif
1023
1024 // ** D3D viewport must not be outside the render target surface **
1025 // Sanity check the GL viewport dimensions
1026 if (x < 0) x = 0;
1027 if (y < 0) y = 0;
1028 if (w > gldCtx->dwWidth) w = gldCtx->dwWidth;
1029 if (h > gldCtx->dwHeight) h = gldCtx->dwHeight;
1030 // Ditto for D3D viewport dimensions
1031 if (w+x > gldCtx->dwWidth) w = gldCtx->dwWidth-x;
1032 if (h+y > gldCtx->dwHeight) h = gldCtx->dwHeight-y;
1033
1034 d3dvp.dwX = x;
1035 d3dvp.dwY = gldCtx->dwHeight - (y + h);
1036 d3dvp.dwWidth = w;
1037 d3dvp.dwHeight = h;
1038 if (ctx->Viewport.Near <= ctx->Viewport.Far) {
1039 d3dvp.dvMinZ = ctx->Viewport.Near;
1040 d3dvp.dvMaxZ = ctx->Viewport.Far;
1041 } else {
1042 d3dvp.dvMinZ = ctx->Viewport.Far;
1043 d3dvp.dvMaxZ = ctx->Viewport.Near;
1044 }
1045
1046 // TODO: DEBUGGING
1047 // d3dvp.MinZ = 0.0f;
1048 // d3dvp.MaxZ = 1.0f;
1049
1050 _GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp));
1051
1052 }
1053
1054 //---------------------------------------------------------------------------
1055
1056 extern BOOL dglWglResizeBuffers(GLcontext *ctx, BOOL bDefaultDriver);
1057
1058 // Mesa 5: Parameter change
1059 void gldResizeBuffers_DX7(
1060 // GLcontext *ctx)
1061 GLframebuffer *fb)
1062 {
1063 GET_CURRENT_CONTEXT(ctx);
1064 dglWglResizeBuffers(ctx, TRUE);
1065 }
1066
1067 //---------------------------------------------------------------------------
1068 #ifdef _DEBUG
1069 // This is only for debugging.
1070 // To use, plug into ctx->Driver.Enable pointer below.
1071 void gld_Enable(
1072 GLcontext *ctx,
1073 GLenum e,
1074 GLboolean b)
1075 {
1076 char buf[1024];
1077 sprintf(buf, "Enable: %s (%s)\n", _mesa_lookup_enum_by_nr(e), b?"TRUE":"FALSE");
1078 ddlogMessage(DDLOG_SYSTEM, buf);
1079 }
1080 #endif
1081 //---------------------------------------------------------------------------
1082 // Driver pointer setup
1083 //---------------------------------------------------------------------------
1084
1085 extern const GLubyte* _gldGetStringGeneric(GLcontext*, GLenum);
1086
1087 void gldSetupDriverPointers_DX7(
1088 GLcontext *ctx)
1089 {
1090 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1091 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx);
1092
1093 TNLcontext *tnl = TNL_CONTEXT(ctx);
1094
1095 // Mandatory functions
1096 ctx->Driver.GetString = _gldGetStringGeneric;
1097 ctx->Driver.UpdateState = gld_update_state_DX7;
1098 ctx->Driver.Clear = gld_Clear_DX7;
1099 ctx->Driver.DrawBuffer = gld_set_draw_buffer_DX7;
1100 ctx->Driver.GetBufferSize = gld_buffer_size_DX7;
1101 ctx->Driver.Finish = gld_Finish_DX7;
1102 ctx->Driver.Flush = gld_Flush_DX7;
1103 ctx->Driver.Error = gld_Error_DX7;
1104
1105 // Hardware accumulation buffer
1106 ctx->Driver.Accum = NULL; // TODO: gld_Accum;
1107
1108 // Bitmap functions
1109 ctx->Driver.CopyPixels = gld_CopyPixels_DX7;
1110 ctx->Driver.DrawPixels = gld_DrawPixels_DX7;
1111 ctx->Driver.ReadPixels = gld_ReadPixels_DX7;
1112 ctx->Driver.Bitmap = gld_Bitmap_DX7;
1113
1114 // Buffer resize
1115 ctx->Driver.ResizeBuffers = gldResizeBuffers_DX7;
1116
1117 // Texture image functions
1118 ctx->Driver.ChooseTextureFormat = gld_ChooseTextureFormat_DX7;
1119 ctx->Driver.TexImage1D = gld_TexImage1D_DX7;
1120 ctx->Driver.TexImage2D = gld_TexImage2D_DX7;
1121 ctx->Driver.TexImage3D = _mesa_store_teximage3d;
1122 ctx->Driver.TexSubImage1D = gld_TexSubImage1D_DX7;
1123 ctx->Driver.TexSubImage2D = gld_TexSubImage2D_DX7;
1124 ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
1125
1126 ctx->Driver.CopyTexImage1D = gldCopyTexImage1D_DX7; //NULL;
1127 ctx->Driver.CopyTexImage2D = gldCopyTexImage2D_DX7; //NULL;
1128 ctx->Driver.CopyTexSubImage1D = gldCopyTexSubImage1D_DX7; //NULL;
1129 ctx->Driver.CopyTexSubImage2D = gldCopyTexSubImage2D_DX7; //NULL;
1130 ctx->Driver.CopyTexSubImage3D = gldCopyTexSubImage3D_DX7;
1131 ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
1132
1133 // Texture object functions
1134 ctx->Driver.BindTexture = NULL;
1135 ctx->Driver.NewTextureObject = NULL; // Not yet implemented by Mesa!;
1136 ctx->Driver.DeleteTexture = gld_DeleteTexture_DX7;
1137 ctx->Driver.PrioritizeTexture = NULL;
1138
1139 // Imaging functionality
1140 ctx->Driver.CopyColorTable = NULL;
1141 ctx->Driver.CopyColorSubTable = NULL;
1142 ctx->Driver.CopyConvolutionFilter1D = NULL;
1143 ctx->Driver.CopyConvolutionFilter2D = NULL;
1144
1145 // State changing functions
1146 ctx->Driver.AlphaFunc = NULL; //gld_AlphaFunc;
1147 ctx->Driver.BlendFuncSeparate = NULL; //gld_BlendFunc;
1148 ctx->Driver.ClearColor = NULL; //gld_ClearColor;
1149 ctx->Driver.ClearDepth = NULL; //gld_ClearDepth;
1150 ctx->Driver.ClearStencil = NULL; //gld_ClearStencil;
1151 ctx->Driver.ColorMask = NULL; //gld_ColorMask;
1152 ctx->Driver.CullFace = NULL; //gld_CullFace;
1153 ctx->Driver.ClipPlane = NULL; //gld_ClipPlane;
1154 ctx->Driver.FrontFace = NULL; //gld_FrontFace;
1155 ctx->Driver.DepthFunc = NULL; //gld_DepthFunc;
1156 ctx->Driver.DepthMask = NULL; //gld_DepthMask;
1157 ctx->Driver.DepthRange = NULL;
1158 ctx->Driver.Enable = NULL; //gld_Enable;
1159 ctx->Driver.Fogfv = NULL; //gld_Fogfv;
1160 ctx->Driver.Hint = NULL; //gld_Hint;
1161 ctx->Driver.Lightfv = NULL; //gld_Lightfv;
1162 ctx->Driver.LightModelfv = NULL; //gld_LightModelfv;
1163 ctx->Driver.LineStipple = NULL; //gld_LineStipple;
1164 ctx->Driver.LineWidth = NULL; //gld_LineWidth;
1165 ctx->Driver.LogicOpcode = NULL; //gld_LogicOpcode;
1166 ctx->Driver.PointParameterfv = NULL; //gld_PointParameterfv;
1167 ctx->Driver.PointSize = NULL; //gld_PointSize;
1168 ctx->Driver.PolygonMode = NULL; //gld_PolygonMode;
1169 ctx->Driver.PolygonOffset = NULL; //gld_PolygonOffset;
1170 ctx->Driver.PolygonStipple = NULL; //gld_PolygonStipple;
1171 ctx->Driver.RenderMode = NULL; //gld_RenderMode;
1172 ctx->Driver.Scissor = NULL; //gld_Scissor;
1173 ctx->Driver.ShadeModel = NULL; //gld_ShadeModel;
1174 ctx->Driver.StencilFunc = NULL; //gld_StencilFunc;
1175 ctx->Driver.StencilMask = NULL; //gld_StencilMask;
1176 ctx->Driver.StencilOp = NULL; //gld_StencilOp;
1177 ctx->Driver.TexGen = NULL; //gld_TexGen;
1178 ctx->Driver.TexEnv = NULL;
1179 ctx->Driver.TexParameter = NULL;
1180 ctx->Driver.TextureMatrix = NULL; //gld_TextureMatrix;
1181 ctx->Driver.Viewport = gld_Viewport_DX7;
1182
1183 _swsetup_Wakeup(ctx);
1184
1185 tnl->Driver.RunPipeline = _tnl_run_pipeline;
1186 tnl->Driver.Render.ResetLineStipple = gld_ResetLineStipple_DX7;
1187 tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
1188 tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
1189
1190 // Hook into glFrustum() and glOrtho()
1191 // ctx->Exec->Frustum = gldFrustumHook_DX7;
1192 // ctx->Exec->Ortho = gldOrthoHook_DX7;
1193
1194 }
1195
1196 //---------------------------------------------------------------------------