Merge branch 'mesa_7_6_branch' of git+ssh://agd5f@git.freedesktop.org/git/mesa/mesa
[mesa.git] / src / mesa / drivers / windows / gldirect / dx7 / gld_primitive_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: Primitive (points/lines/tris/quads) rendering
34 *
35 ****************************************************************************/
36
37 //#include "../GLDirect.h"
38
39 //#include "gld_dx8.h"
40
41 #include "dglcontext.h"
42 #include "ddlog.h"
43 #include "gld_dx7.h"
44
45 #include "glheader.h"
46 #include "context.h"
47 #include "colormac.h"
48 #include "depth.h"
49 #include "extensions.h"
50 #include "macros.h"
51 #include "matrix.h"
52 // #include "mem.h"
53 //#include "mmath.h"
54 #include "mtypes.h"
55 #include "texformat.h"
56 #include "texstore.h"
57 #include "vbo/vbo.h"
58 #include "swrast/swrast.h"
59 #include "swrast_setup/swrast_setup.h"
60 #include "swrast_setup/ss_context.h"
61 #include "swrast/s_context.h"
62 #include "swrast/s_depth.h"
63 #include "swrast/s_lines.h"
64 #include "swrast/s_triangle.h"
65 #include "swrast/s_trispan.h"
66 #include "tnl/tnl.h"
67 #include "tnl/t_context.h"
68 #include "tnl/t_pipeline.h"
69
70 // Disable compiler complaints about unreferenced local variables
71 #pragma warning (disable:4101)
72
73 //---------------------------------------------------------------------------
74 // Helper defines for primitives
75 //---------------------------------------------------------------------------
76
77 //static const float ooZ = 1.0f / 65536.0f; // One over Z
78
79 #define GLD_COLOUR (D3DCOLOR_RGBA(swv->color[0], swv->color[1], swv->color[2], swv->color[3]))
80 #define GLD_SPECULAR (D3DCOLOR_RGBA(swv->specular[0], swv->specular[1], swv->specular[2], swv->specular[3]))
81 #define GLD_FLIP_Y(y) (gldCtx->dwHeight - (y))
82
83 //---------------------------------------------------------------------------
84 // 2D vertex setup
85 //---------------------------------------------------------------------------
86
87 #define GLD_SETUP_2D_VARS_POINTS \
88 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
89 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
90 GLD_2D_VERTEX *pV = (GLD_2D_VERTEX*)gld->PB2d.pPoints; \
91 SScontext *ss = SWSETUP_CONTEXT(ctx); \
92 SWvertex *swv; \
93 DWORD dwSpecularColour; \
94 DWORD dwFlatColour
95
96 #define GLD_SETUP_2D_VARS_LINES \
97 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
98 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
99 GLD_2D_VERTEX *pV = (GLD_2D_VERTEX*)gld->PB2d.pLines; \
100 SScontext *ss = SWSETUP_CONTEXT(ctx); \
101 SWvertex *swv; \
102 DWORD dwSpecularColour; \
103 DWORD dwFlatColour
104
105 #define GLD_SETUP_2D_VARS_TRIANGLES \
106 BOOL bFog = ctx->Fog.Enabled; \
107 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
108 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
109 GLD_2D_VERTEX *pV = (GLD_2D_VERTEX*)gld->PB2d.pTriangles; \
110 SScontext *ss = SWSETUP_CONTEXT(ctx); \
111 SWvertex *swv; \
112 DWORD dwSpecularColour; \
113 DWORD dwFlatColour; \
114 GLuint facing = 0; \
115 struct vertex_buffer *VB; \
116 GLchan (*vbcolor)[4]; \
117 GLchan (*vbspec)[4]
118
119 #define GLD_SETUP_GET_SWVERT(s) \
120 swv = &ss->verts[##s]
121
122 #define GLD_SETUP_2D_VERTEX \
123 pV->x = swv->win[0]; \
124 pV->y = GLD_FLIP_Y(swv->win[1]); \
125 pV->rhw = swv->win[3]
126
127 #define GLD_SETUP_SMOOTH_COLOUR \
128 pV->diffuse = GLD_COLOUR
129
130 #define GLD_SETUP_GET_FLAT_COLOUR \
131 dwFlatColour = GLD_COLOUR
132 #define GLD_SETUP_GET_FLAT_FOG_COLOUR \
133 dwFlatColour = _gldComputeFog(ctx, swv)
134
135 #define GLD_SETUP_USE_FLAT_COLOUR \
136 pV->diffuse = dwFlatColour
137
138 #define GLD_SETUP_GET_FLAT_SPECULAR \
139 dwSpecularColour= GLD_SPECULAR
140
141 #define GLD_SETUP_USE_FLAT_SPECULAR \
142 pV->specular = dwSpecularColour
143
144 #define GLD_SETUP_DEPTH \
145 pV->sz = swv->win[2] / ctx->DepthMaxF
146 // pV->z = swv->win[2] * ooZ;
147
148 #define GLD_SETUP_SPECULAR \
149 pV->specular = GLD_SPECULAR
150
151 #define GLD_SETUP_FOG \
152 pV->diffuse = _gldComputeFog(ctx, swv)
153
154 #define GLD_SETUP_TEX0 \
155 pV->t0_u = swv->texcoord[0][0]; \
156 pV->t0_v = swv->texcoord[0][1]
157
158 #define GLD_SETUP_TEX1 \
159 pV->t1_u = swv->texcoord[1][0]; \
160 pV->t1_v = swv->texcoord[1][1]
161
162 #define GLD_SETUP_LIGHTING(v) \
163 if (facing == 1) { \
164 pV->diffuse = D3DCOLOR_RGBA(vbcolor[##v][0], vbcolor[##v][1], vbcolor[##v][2], vbcolor[##v][3]); \
165 if (vbspec) { \
166 pV->specular = D3DCOLOR_RGBA(vbspec[##v][0], vbspec[##v][1], vbspec[##v][2], vbspec[##v][3]); \
167 } \
168 } else { \
169 if (bFog) \
170 GLD_SETUP_FOG; \
171 else \
172 GLD_SETUP_SMOOTH_COLOUR; \
173 GLD_SETUP_SPECULAR; \
174 }
175
176 #define GLD_SETUP_GET_FLAT_LIGHTING(v) \
177 if (facing == 1) { \
178 dwFlatColour = D3DCOLOR_RGBA(vbcolor[##v][0], vbcolor[##v][1], vbcolor[##v][2], vbcolor[##v][3]); \
179 if (vbspec) { \
180 dwSpecularColour = D3DCOLOR_RGBA(vbspec[##v][0], vbspec[##v][1], vbspec[##v][2], vbspec[##v][3]); \
181 } \
182 }
183
184 #define GLD_SETUP_TWOSIDED_LIGHTING \
185 /* Two-sided lighting */ \
186 if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) { \
187 SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; \
188 SWvertex *v[3]; \
189 GLfloat ex,ey,fx,fy,cc; \
190 /* Get vars for later */ \
191 VB = &TNL_CONTEXT(ctx)->vb; \
192 vbcolor = (GLchan (*)[4])VB->ColorPtr[1]->data; \
193 if (VB->SecondaryColorPtr[1]) { \
194 vbspec = (GLchan (*)[4])VB->SecondaryColorPtr[1]->data; \
195 } else { \
196 vbspec = NULL; \
197 } \
198 v[0] = &verts[v0]; \
199 v[1] = &verts[v1]; \
200 v[2] = &verts[v2]; \
201 ex = v[0]->win[0] - v[2]->win[0]; \
202 ey = v[0]->win[1] - v[2]->win[1]; \
203 fx = v[1]->win[0] - v[2]->win[0]; \
204 fy = v[1]->win[1] - v[2]->win[1]; \
205 cc = ex*fy - ey*fx; \
206 facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; \
207 }
208
209 //---------------------------------------------------------------------------
210 // 3D vertex setup
211 //---------------------------------------------------------------------------
212
213 #define GLD_SETUP_3D_VARS_POINTS \
214 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
215 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
216 GLD_3D_VERTEX *pV = (GLD_3D_VERTEX*)gld->PB3d.pPoints; \
217 TNLcontext *tnl = TNL_CONTEXT(ctx); \
218 struct vertex_buffer *VB = &tnl->vb; \
219 GLfloat (*p4f)[4]; \
220 GLfloat (*tc)[4]; \
221 DWORD dwColor;
222
223 #define GLD_SETUP_3D_VARS_LINES \
224 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
225 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
226 GLD_3D_VERTEX *pV = (GLD_3D_VERTEX*)gld->PB3d.pLines; \
227 TNLcontext *tnl = TNL_CONTEXT(ctx); \
228 struct vertex_buffer *VB = &tnl->vb; \
229 GLfloat (*p4f)[4]; \
230 GLfloat (*tc)[4]; \
231 DWORD dwColor;
232
233 #define GLD_SETUP_3D_VARS_TRIANGLES \
234 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); \
235 GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); \
236 GLD_3D_VERTEX *pV = (GLD_3D_VERTEX*)gld->PB3d.pTriangles; \
237 TNLcontext *tnl = TNL_CONTEXT(ctx); \
238 struct vertex_buffer *VB = &tnl->vb; \
239 GLfloat (*p4f)[4]; \
240 GLfloat (*tc)[4]; \
241 DWORD dwColor;
242
243 #define GLD_SETUP_3D_VERTEX(v) \
244 p4f = VB->ObjPtr->data; \
245 pV->Position.x = p4f[##v][0]; \
246 pV->Position.y = p4f[##v][1]; \
247 pV->Position.z = p4f[##v][2];
248
249 #define GLD_SETUP_SMOOTH_COLOUR_3D(v) \
250 p4f = (GLfloat (*)[4])VB->ColorPtr[0]->data; \
251 pV->Diffuse = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
252
253
254 #define GLD_SETUP_GET_FLAT_COLOUR_3D(v) \
255 p4f = (GLfloat (*)[4])VB->ColorPtr[0]->data; \
256 dwColor = D3DCOLOR_COLORVALUE(p4f[##v][0], p4f[##v][1], p4f[##v][2], p4f[##v][3]);
257
258 #define GLD_SETUP_USE_FLAT_COLOUR_3D \
259 pV->Diffuse = dwColor;
260
261 #define GLD_SETUP_TEX0_3D(v) \
262 if (VB->TexCoordPtr[0]) { \
263 tc = VB->TexCoordPtr[0]->data; \
264 pV->TexUnit0.x = tc[##v][0]; \
265 pV->TexUnit0.y = tc[##v][1]; \
266 }
267
268 #define GLD_SETUP_TEX1_3D(v) \
269 if (VB->TexCoordPtr[1]) { \
270 tc = VB->TexCoordPtr[1]->data; \
271 pV->TexUnit1.x = tc[##v][0]; \
272 pV->TexUnit1.y = tc[##v][1]; \
273 }
274
275 //---------------------------------------------------------------------------
276 // Helper functions
277 //---------------------------------------------------------------------------
278
279 __inline DWORD _gldComputeFog(
280 GLcontext *ctx,
281 SWvertex *swv)
282 {
283 // Full fog calculation.
284 // Based on Mesa code.
285
286 GLchan rFog, gFog, bFog;
287 GLchan fR, fG, fB;
288 const GLfloat f = swv->fog;
289 const GLfloat g = 1.0 - f;
290
291 UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
292 UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
293 UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]);
294 fR = f * swv->color[0] + g * rFog;
295 fG = f * swv->color[1] + g * gFog;
296 fB = f * swv->color[2] + g * bFog;
297 return D3DCOLOR_RGBA(fR, fG, fB, swv->color[3]);
298 }
299
300 //---------------------------------------------------------------------------
301
302 void gld_ResetLineStipple_DX7(
303 GLcontext *ctx)
304 {
305 // TODO: Fake stipple with a 32x32 texture.
306 }
307
308 //---------------------------------------------------------------------------
309 // 2D (post-transformed) primitives
310 //---------------------------------------------------------------------------
311
312 void gld_Points2D_DX7(
313 GLcontext *ctx,
314 GLuint first,
315 GLuint last)
316 {
317 GLD_SETUP_2D_VARS_POINTS;
318
319 unsigned i;
320 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
321
322 // _Size is already clamped to MaxPointSize and MinPointSize
323 // Not supported by DX7
324 // IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_POINTSIZE, *((DWORD*)&ctx->Point._Size));
325
326 if (VB->Elts) {
327 for (i=first; i<last; i++, pV++) {
328 if (VB->ClipMask[VB->Elts[i]] == 0) {
329 // _swrast_Point( ctx, &verts[VB->Elts[i]] );
330 GLD_SETUP_GET_SWVERT(VB->Elts[i]);
331 GLD_SETUP_2D_VERTEX;
332 GLD_SETUP_SMOOTH_COLOUR;
333 GLD_SETUP_DEPTH;
334 GLD_SETUP_SPECULAR;
335 GLD_SETUP_TEX0;
336 GLD_SETUP_TEX1;
337 }
338 }
339 } else {
340 GLD_SETUP_GET_SWVERT(first);
341 for (i=first; i<last; i++, swv++, pV++) {
342 if (VB->ClipMask[i] == 0) {
343 // _swrast_Point( ctx, &verts[i] );
344 GLD_SETUP_2D_VERTEX;
345 GLD_SETUP_SMOOTH_COLOUR;
346 GLD_SETUP_DEPTH;
347 GLD_SETUP_SPECULAR;
348 GLD_SETUP_TEX0;
349 GLD_SETUP_TEX1;
350 }
351 }
352 }
353
354 gld->PB2d.pPoints = (BYTE*)pV;
355 gld->PB2d.nPoints += (last-first);
356 }
357
358 //---------------------------------------------------------------------------
359
360 void gld_Line2DFlat_DX7(
361 GLcontext *ctx,
362 GLuint v0,
363 GLuint v1)
364 {
365 GLD_SETUP_2D_VARS_LINES;
366
367 GLD_SETUP_GET_SWVERT(v1);
368 GLD_SETUP_2D_VERTEX;
369 GLD_SETUP_DEPTH;
370 GLD_SETUP_TEX0;
371 GLD_SETUP_TEX1;
372 GLD_SETUP_GET_FLAT_COLOUR;
373 GLD_SETUP_USE_FLAT_COLOUR;
374 GLD_SETUP_GET_FLAT_SPECULAR;
375 GLD_SETUP_USE_FLAT_SPECULAR;
376 pV++;
377
378 GLD_SETUP_GET_SWVERT(v0);
379 GLD_SETUP_2D_VERTEX;
380 GLD_SETUP_DEPTH;
381 GLD_SETUP_TEX0;
382 GLD_SETUP_TEX1;
383 GLD_SETUP_USE_FLAT_COLOUR;
384 GLD_SETUP_USE_FLAT_SPECULAR;
385 pV++;
386
387 gld->PB2d.pLines = (BYTE*)pV;
388 gld->PB2d.nLines++;
389 }
390
391 //---------------------------------------------------------------------------
392
393 void gld_Line2DSmooth_DX7(
394 GLcontext *ctx,
395 GLuint v0,
396 GLuint v1)
397 {
398 GLD_SETUP_2D_VARS_LINES;
399
400 GLD_SETUP_GET_SWVERT(v0);
401 GLD_SETUP_2D_VERTEX;
402 GLD_SETUP_SMOOTH_COLOUR;
403 GLD_SETUP_DEPTH;
404 GLD_SETUP_SPECULAR;
405 GLD_SETUP_TEX0;
406 GLD_SETUP_TEX1;
407 pV++;
408
409 GLD_SETUP_GET_SWVERT(v1);
410 GLD_SETUP_2D_VERTEX;
411 GLD_SETUP_SMOOTH_COLOUR;
412 GLD_SETUP_SPECULAR;
413 GLD_SETUP_DEPTH;
414 GLD_SETUP_TEX0;
415 GLD_SETUP_TEX1;
416 pV++;
417
418 gld->PB2d.pLines = (BYTE*)pV;
419 gld->PB2d.nLines++;
420 }
421
422 //---------------------------------------------------------------------------
423
424 void gld_Triangle2DFlat_DX7(
425 GLcontext *ctx,
426 GLuint v0,
427 GLuint v1,
428 GLuint v2)
429 {
430 GLD_SETUP_2D_VARS_TRIANGLES;
431
432 GLD_SETUP_GET_SWVERT(v2);
433 GLD_SETUP_2D_VERTEX;
434 GLD_SETUP_DEPTH;
435 GLD_SETUP_TEX0;
436 GLD_SETUP_TEX1;
437 GLD_SETUP_GET_FLAT_COLOUR;
438 GLD_SETUP_USE_FLAT_COLOUR;
439 pV++;;
440
441 GLD_SETUP_GET_SWVERT(v0);
442 GLD_SETUP_2D_VERTEX;
443 GLD_SETUP_DEPTH;
444 GLD_SETUP_TEX0;
445 GLD_SETUP_TEX1;
446 GLD_SETUP_USE_FLAT_COLOUR;
447 pV++;
448
449 GLD_SETUP_GET_SWVERT(v1);
450 GLD_SETUP_2D_VERTEX;
451 GLD_SETUP_DEPTH;
452 GLD_SETUP_TEX0;
453 GLD_SETUP_TEX1;
454 GLD_SETUP_USE_FLAT_COLOUR;
455 pV++;
456
457 gld->PB2d.pTriangles = (BYTE*)pV;
458 gld->PB2d.nTriangles++;
459 }
460
461 //---------------------------------------------------------------------------
462
463 void gld_Triangle2DSmooth_DX7(
464 GLcontext *ctx,
465 GLuint v0,
466 GLuint v1,
467 GLuint v2)
468 {
469
470 GLD_SETUP_2D_VARS_TRIANGLES;
471
472 GLD_SETUP_GET_SWVERT(v0);
473 GLD_SETUP_2D_VERTEX;
474 GLD_SETUP_SMOOTH_COLOUR;
475 GLD_SETUP_DEPTH;
476 GLD_SETUP_TEX0;
477 GLD_SETUP_TEX1;
478 pV++;
479
480 GLD_SETUP_GET_SWVERT(v1);
481 GLD_SETUP_2D_VERTEX;
482 GLD_SETUP_SMOOTH_COLOUR;
483 GLD_SETUP_DEPTH;
484 GLD_SETUP_TEX0;
485 GLD_SETUP_TEX1;
486 pV++;
487
488 GLD_SETUP_GET_SWVERT(v2);
489 GLD_SETUP_2D_VERTEX;
490 GLD_SETUP_SMOOTH_COLOUR;
491 GLD_SETUP_DEPTH;
492 GLD_SETUP_TEX0;
493 GLD_SETUP_TEX1;
494 pV++;
495
496 gld->PB2d.pTriangles = (BYTE*)pV;
497 gld->PB2d.nTriangles++;
498 }
499
500 //---------------------------------------------------------------------------
501
502 void gld_Triangle2DFlatExtras_DX7(
503 GLcontext *ctx,
504 GLuint v0,
505 GLuint v1,
506 GLuint v2)
507 {
508 GLD_SETUP_2D_VARS_TRIANGLES;
509
510 GLD_SETUP_TWOSIDED_LIGHTING(v2);
511
512 GLD_SETUP_GET_SWVERT(v2);
513 GLD_SETUP_2D_VERTEX;
514 GLD_SETUP_DEPTH;
515 GLD_SETUP_TEX0;
516 GLD_SETUP_TEX1;
517 if (bFog)
518 GLD_SETUP_GET_FLAT_FOG_COLOUR;
519 else
520 GLD_SETUP_GET_FLAT_COLOUR;
521 GLD_SETUP_GET_FLAT_SPECULAR;
522 GLD_SETUP_GET_FLAT_LIGHTING(v2);
523 GLD_SETUP_USE_FLAT_COLOUR;
524 GLD_SETUP_USE_FLAT_SPECULAR;
525 pV++;
526
527 GLD_SETUP_GET_SWVERT(v0);
528 GLD_SETUP_2D_VERTEX;
529 GLD_SETUP_DEPTH;
530 GLD_SETUP_TEX0;
531 GLD_SETUP_TEX1;
532 GLD_SETUP_USE_FLAT_COLOUR;
533 GLD_SETUP_USE_FLAT_SPECULAR;
534 pV++;
535
536 GLD_SETUP_GET_SWVERT(v1);
537 GLD_SETUP_2D_VERTEX;
538 GLD_SETUP_DEPTH;
539 GLD_SETUP_TEX0;
540 GLD_SETUP_TEX1;
541 GLD_SETUP_USE_FLAT_COLOUR;
542 GLD_SETUP_USE_FLAT_SPECULAR;
543 pV++;
544
545 gld->PB2d.pTriangles = (BYTE*)pV;
546 gld->PB2d.nTriangles++;
547 }
548
549 //---------------------------------------------------------------------------
550
551 void gld_Triangle2DSmoothExtras_DX7(
552 GLcontext *ctx,
553 GLuint v0,
554 GLuint v1,
555 GLuint v2)
556 {
557 GLD_SETUP_2D_VARS_TRIANGLES;
558
559 GLD_SETUP_TWOSIDED_LIGHTING(v0);
560
561 GLD_SETUP_GET_SWVERT(v0);
562 GLD_SETUP_2D_VERTEX;
563 GLD_SETUP_DEPTH;
564 GLD_SETUP_TEX0;
565 GLD_SETUP_TEX1;
566 GLD_SETUP_LIGHTING(v0);
567 pV++;
568
569 GLD_SETUP_GET_SWVERT(v1);
570 GLD_SETUP_2D_VERTEX;
571 GLD_SETUP_DEPTH;
572 GLD_SETUP_TEX0;
573 GLD_SETUP_TEX1;
574 GLD_SETUP_LIGHTING(v1);
575 pV++;
576
577 GLD_SETUP_GET_SWVERT(v2);
578 GLD_SETUP_2D_VERTEX;
579 GLD_SETUP_DEPTH;
580 GLD_SETUP_TEX0;
581 GLD_SETUP_TEX1;
582 GLD_SETUP_LIGHTING(v2);
583 pV++;
584
585 gld->PB2d.pTriangles = (BYTE*)pV;
586 gld->PB2d.nTriangles++;
587 }
588
589 //---------------------------------------------------------------------------
590
591 void gld_Quad2DFlat_DX7(
592 GLcontext *ctx,
593 GLuint v0,
594 GLuint v1,
595 GLuint v2,
596 GLuint v3)
597 {
598 GLD_SETUP_2D_VARS_TRIANGLES;
599
600 GLD_SETUP_GET_SWVERT(v3);
601 GLD_SETUP_2D_VERTEX;
602 GLD_SETUP_DEPTH;
603 GLD_SETUP_TEX0;
604 GLD_SETUP_TEX1;
605 GLD_SETUP_GET_FLAT_COLOUR;
606 GLD_SETUP_USE_FLAT_COLOUR;
607 pV++;
608
609 GLD_SETUP_GET_SWVERT(v0);
610 GLD_SETUP_2D_VERTEX;
611 GLD_SETUP_DEPTH;
612 GLD_SETUP_TEX0;
613 GLD_SETUP_TEX1;
614 GLD_SETUP_USE_FLAT_COLOUR;
615 pV++;
616
617 GLD_SETUP_GET_SWVERT(v1);
618 GLD_SETUP_2D_VERTEX;
619 GLD_SETUP_DEPTH;
620 GLD_SETUP_TEX0;
621 GLD_SETUP_TEX1;
622 GLD_SETUP_USE_FLAT_COLOUR;
623 pV++;
624
625 GLD_SETUP_GET_SWVERT(v1);
626 GLD_SETUP_2D_VERTEX;
627 GLD_SETUP_DEPTH;
628 GLD_SETUP_TEX0;
629 GLD_SETUP_TEX1;
630 GLD_SETUP_USE_FLAT_COLOUR;
631 pV++;
632
633 GLD_SETUP_GET_SWVERT(v2);
634 GLD_SETUP_2D_VERTEX;
635 GLD_SETUP_DEPTH;
636 GLD_SETUP_TEX0;
637 GLD_SETUP_TEX1;
638 GLD_SETUP_USE_FLAT_COLOUR;
639 pV++;
640
641 GLD_SETUP_GET_SWVERT(v3);
642 GLD_SETUP_2D_VERTEX;
643 GLD_SETUP_DEPTH;
644 GLD_SETUP_TEX0;
645 GLD_SETUP_TEX1;
646 GLD_SETUP_USE_FLAT_COLOUR;
647 pV++;
648
649 gld->PB2d.pTriangles = (BYTE*)pV;
650 gld->PB2d.nTriangles += 2;
651 }
652
653 //---------------------------------------------------------------------------
654
655 void gld_Quad2DSmooth_DX7(
656 GLcontext *ctx,
657 GLuint v0,
658 GLuint v1,
659 GLuint v2,
660 GLuint v3)
661 {
662 GLD_SETUP_2D_VARS_TRIANGLES;
663
664 GLD_SETUP_GET_SWVERT(v0);
665 GLD_SETUP_2D_VERTEX;
666 GLD_SETUP_SMOOTH_COLOUR;
667 GLD_SETUP_DEPTH;
668 GLD_SETUP_TEX0;
669 GLD_SETUP_TEX1;
670 pV++;
671
672 GLD_SETUP_GET_SWVERT(v1);
673 GLD_SETUP_2D_VERTEX;
674 GLD_SETUP_SMOOTH_COLOUR;
675 GLD_SETUP_DEPTH;
676 GLD_SETUP_TEX0;
677 GLD_SETUP_TEX1;
678 pV++;
679
680 GLD_SETUP_GET_SWVERT(v2);
681 GLD_SETUP_2D_VERTEX;
682 GLD_SETUP_SMOOTH_COLOUR;
683 GLD_SETUP_DEPTH;
684 GLD_SETUP_TEX0;
685 GLD_SETUP_TEX1;
686 pV++;
687
688 GLD_SETUP_GET_SWVERT(v2);
689 GLD_SETUP_2D_VERTEX;
690 GLD_SETUP_SMOOTH_COLOUR;
691 GLD_SETUP_DEPTH;
692 GLD_SETUP_TEX0;
693 GLD_SETUP_TEX1;
694 pV++;
695
696 GLD_SETUP_GET_SWVERT(v3);
697 GLD_SETUP_2D_VERTEX;
698 GLD_SETUP_SMOOTH_COLOUR;
699 GLD_SETUP_DEPTH;
700 GLD_SETUP_TEX0;
701 GLD_SETUP_TEX1;
702 pV++;
703
704 GLD_SETUP_GET_SWVERT(v0);
705 GLD_SETUP_2D_VERTEX;
706 GLD_SETUP_SMOOTH_COLOUR;
707 GLD_SETUP_DEPTH;
708 GLD_SETUP_TEX0;
709 GLD_SETUP_TEX1;
710 pV++;
711
712 gld->PB2d.pTriangles = (BYTE*)pV;
713 gld->PB2d.nTriangles += 2;
714 }
715
716 //---------------------------------------------------------------------------
717
718 void gld_Quad2DFlatExtras_DX7(
719 GLcontext *ctx,
720 GLuint v0,
721 GLuint v1,
722 GLuint v2,
723 GLuint v3)
724 {
725 GLD_SETUP_2D_VARS_TRIANGLES;
726
727 GLD_SETUP_TWOSIDED_LIGHTING(v3);
728
729 GLD_SETUP_GET_SWVERT(v3);
730 GLD_SETUP_2D_VERTEX;
731 GLD_SETUP_DEPTH;
732 GLD_SETUP_TEX0;
733 GLD_SETUP_TEX1;
734 if (bFog)
735 GLD_SETUP_GET_FLAT_FOG_COLOUR;
736 else
737 GLD_SETUP_GET_FLAT_COLOUR;
738 GLD_SETUP_GET_FLAT_SPECULAR;
739 GLD_SETUP_GET_FLAT_LIGHTING(v3);
740 GLD_SETUP_USE_FLAT_COLOUR;
741 GLD_SETUP_USE_FLAT_SPECULAR;
742 pV++;
743
744 GLD_SETUP_GET_SWVERT(v0);
745 GLD_SETUP_2D_VERTEX;
746 GLD_SETUP_DEPTH;
747 GLD_SETUP_TEX0;
748 GLD_SETUP_TEX1;
749 GLD_SETUP_USE_FLAT_COLOUR;
750 GLD_SETUP_USE_FLAT_SPECULAR;
751 pV++;
752
753 GLD_SETUP_GET_SWVERT(v1);
754 GLD_SETUP_2D_VERTEX;
755 GLD_SETUP_DEPTH;
756 GLD_SETUP_TEX0;
757 GLD_SETUP_TEX1;
758 GLD_SETUP_USE_FLAT_COLOUR;
759 GLD_SETUP_USE_FLAT_SPECULAR;
760 pV++;
761
762 GLD_SETUP_GET_SWVERT(v1);
763 GLD_SETUP_2D_VERTEX;
764 GLD_SETUP_DEPTH;
765 GLD_SETUP_TEX0;
766 GLD_SETUP_TEX1;
767 GLD_SETUP_USE_FLAT_COLOUR;
768 GLD_SETUP_USE_FLAT_SPECULAR;
769 pV++;
770
771 GLD_SETUP_GET_SWVERT(v2);
772 GLD_SETUP_2D_VERTEX;
773 GLD_SETUP_DEPTH;
774 GLD_SETUP_TEX0;
775 GLD_SETUP_TEX1;
776 GLD_SETUP_USE_FLAT_COLOUR;
777 GLD_SETUP_USE_FLAT_SPECULAR;
778 pV++;
779
780 GLD_SETUP_GET_SWVERT(v3);
781 GLD_SETUP_2D_VERTEX;
782 GLD_SETUP_DEPTH;
783 GLD_SETUP_TEX0;
784 GLD_SETUP_TEX1;
785 GLD_SETUP_USE_FLAT_COLOUR;
786 GLD_SETUP_USE_FLAT_SPECULAR;
787 pV++;
788
789 gld->PB2d.pTriangles = (BYTE*)pV;
790 gld->PB2d.nTriangles += 2;
791 }
792
793 //---------------------------------------------------------------------------
794
795 void gld_Quad2DSmoothExtras_DX7(
796 GLcontext *ctx,
797 GLuint v0,
798 GLuint v1,
799 GLuint v2,
800 GLuint v3)
801 {
802 GLD_SETUP_2D_VARS_TRIANGLES;
803
804 GLD_SETUP_TWOSIDED_LIGHTING(v0);
805
806 GLD_SETUP_GET_SWVERT(v0);
807 GLD_SETUP_2D_VERTEX;
808 GLD_SETUP_DEPTH;
809 GLD_SETUP_TEX0;
810 GLD_SETUP_TEX1;
811 GLD_SETUP_LIGHTING(v0);
812 pV++;
813
814 GLD_SETUP_GET_SWVERT(v1);
815 GLD_SETUP_2D_VERTEX;
816 GLD_SETUP_DEPTH;
817 GLD_SETUP_TEX0;
818 GLD_SETUP_TEX1;
819 GLD_SETUP_LIGHTING(v1);
820 pV++;
821
822 GLD_SETUP_GET_SWVERT(v2);
823 GLD_SETUP_2D_VERTEX;
824 GLD_SETUP_DEPTH;
825 GLD_SETUP_TEX0;
826 GLD_SETUP_TEX1;
827 GLD_SETUP_LIGHTING(v2);
828 pV++;
829
830 GLD_SETUP_GET_SWVERT(v2);
831 GLD_SETUP_2D_VERTEX;
832 GLD_SETUP_DEPTH;
833 GLD_SETUP_TEX0;
834 GLD_SETUP_TEX1;
835 GLD_SETUP_LIGHTING(v2);
836 pV++;
837
838 GLD_SETUP_GET_SWVERT(v3);
839 GLD_SETUP_2D_VERTEX;
840 GLD_SETUP_DEPTH;
841 GLD_SETUP_TEX0;
842 GLD_SETUP_TEX1;
843 GLD_SETUP_LIGHTING(v3);
844 pV++;
845
846 GLD_SETUP_GET_SWVERT(v0);
847 GLD_SETUP_2D_VERTEX;
848 GLD_SETUP_DEPTH;
849 GLD_SETUP_TEX0;
850 GLD_SETUP_TEX1;
851 GLD_SETUP_LIGHTING(v0);
852 pV++;
853
854 gld->PB2d.pTriangles = (BYTE*)pV;
855 gld->PB2d.nTriangles += 2;
856 }
857
858 //---------------------------------------------------------------------------
859 // 3D (pre-transformed) primitives
860 //---------------------------------------------------------------------------
861
862 void gld_Points3D_DX7(
863 GLcontext *ctx,
864 GLuint first,
865 GLuint last)
866 {
867 GLD_SETUP_3D_VARS_POINTS
868
869 unsigned i;
870 // struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
871
872 // _Size is already clamped to MaxPointSize and MinPointSize
873 // Not supported by DX7
874 // IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_POINTSIZE, *((DWORD*)&ctx->Point._Size));
875
876 if (VB->Elts) {
877 for (i=first; i<last; i++, pV++) {
878 if (VB->ClipMask[VB->Elts[i]] == 0) {
879 // _swrast_Point( ctx, &verts[VB->Elts[i]] );
880 // GLD_SETUP_GET_SWVERT(VB->Elts[i]);
881 GLD_SETUP_3D_VERTEX(VB->Elts[i])
882 GLD_SETUP_SMOOTH_COLOUR_3D(i)
883 GLD_SETUP_TEX0_3D(i)
884 GLD_SETUP_TEX1_3D(i)
885 }
886 }
887 } else {
888 // GLD_SETUP_GET_SWVERT(first);
889 for (i=first; i<last; i++, pV++) {
890 if (VB->ClipMask[i] == 0) {
891 // _swrast_Point( ctx, &verts[i] );
892 GLD_SETUP_3D_VERTEX(i)
893 GLD_SETUP_SMOOTH_COLOUR_3D(i)
894 GLD_SETUP_TEX0_3D(i)
895 GLD_SETUP_TEX1_3D(i)
896 }
897 }
898 }
899 /*
900 for (i=first; i<last; i++, pV++) {
901 GLD_SETUP_3D_VERTEX(i)
902 GLD_SETUP_SMOOTH_COLOUR_3D(i)
903 GLD_SETUP_TEX0_3D(i)
904 GLD_SETUP_TEX1_3D(i)
905 }
906 */
907 gld->PB3d.pPoints = (BYTE*)pV;
908 gld->PB3d.nPoints += (last-first);
909 }
910
911 //---------------------------------------------------------------------------
912 // Line functions
913 //---------------------------------------------------------------------------
914
915 void gld_Line3DFlat_DX7(
916 GLcontext *ctx,
917 GLuint v0,
918 GLuint v1)
919 {
920 GLD_SETUP_3D_VARS_LINES
921
922 GLD_SETUP_3D_VERTEX(v1)
923 GLD_SETUP_GET_FLAT_COLOUR_3D(v1)
924 GLD_SETUP_USE_FLAT_COLOUR_3D
925 GLD_SETUP_TEX0_3D(v1)
926 GLD_SETUP_TEX1_3D(v1)
927 pV++;
928
929 GLD_SETUP_3D_VERTEX(v0)
930 GLD_SETUP_USE_FLAT_COLOUR_3D
931 GLD_SETUP_TEX0_3D(v0)
932 GLD_SETUP_TEX1_3D(v0)
933 pV++;
934
935 gld->PB3d.pLines = (BYTE*)pV;
936 gld->PB3d.nLines++;
937 }
938
939 //---------------------------------------------------------------------------
940
941 void gld_Line3DSmooth_DX7(
942 GLcontext *ctx,
943 GLuint v0,
944 GLuint v1)
945 {
946 GLD_SETUP_3D_VARS_LINES
947
948 GLD_SETUP_3D_VERTEX(v1)
949 GLD_SETUP_SMOOTH_COLOUR_3D(v1)
950 GLD_SETUP_TEX0_3D(v1)
951 GLD_SETUP_TEX1_3D(v1)
952 pV++;
953
954 GLD_SETUP_3D_VERTEX(v0)
955 GLD_SETUP_SMOOTH_COLOUR_3D(v0)
956 GLD_SETUP_TEX0_3D(v0)
957 GLD_SETUP_TEX1_3D(v0)
958 pV++;
959
960 gld->PB3d.pLines = (BYTE*)pV;
961 gld->PB3d.nLines++;
962 }
963
964 //---------------------------------------------------------------------------
965 // Triangle functions
966 //---------------------------------------------------------------------------
967
968 void gld_Triangle3DFlat_DX7(
969 GLcontext *ctx,
970 GLuint v0,
971 GLuint v1,
972 GLuint v2)
973 {
974 GLD_SETUP_3D_VARS_TRIANGLES
975
976 GLD_SETUP_3D_VERTEX(v2)
977 GLD_SETUP_TEX0_3D(v2)
978 GLD_SETUP_TEX1_3D(v2)
979 GLD_SETUP_GET_FLAT_COLOUR_3D(v2)
980 GLD_SETUP_USE_FLAT_COLOUR_3D
981 pV++;
982
983 GLD_SETUP_3D_VERTEX(v0)
984 GLD_SETUP_TEX0_3D(v0)
985 GLD_SETUP_TEX1_3D(v0)
986 GLD_SETUP_USE_FLAT_COLOUR_3D
987 pV++;
988
989 GLD_SETUP_3D_VERTEX(v1)
990 GLD_SETUP_TEX0_3D(v1)
991 GLD_SETUP_TEX1_3D(v1)
992 GLD_SETUP_USE_FLAT_COLOUR_3D
993 pV++;
994
995 gld->PB3d.pTriangles = (BYTE*)pV;
996 gld->PB3d.nTriangles++;
997 }
998
999 //---------------------------------------------------------------------------
1000
1001 void gld_Triangle3DSmooth_DX7(
1002 GLcontext *ctx,
1003 GLuint v0,
1004 GLuint v1,
1005 GLuint v2)
1006 {
1007 GLD_SETUP_3D_VARS_TRIANGLES
1008
1009 GLD_SETUP_3D_VERTEX(v0)
1010 GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1011 GLD_SETUP_TEX0_3D(v0)
1012 GLD_SETUP_TEX1_3D(v0)
1013 pV++;
1014
1015 GLD_SETUP_3D_VERTEX(v1)
1016 GLD_SETUP_SMOOTH_COLOUR_3D(v1)
1017 GLD_SETUP_TEX0_3D(v1)
1018 GLD_SETUP_TEX1_3D(v1)
1019 pV++;
1020
1021 GLD_SETUP_3D_VERTEX(v2)
1022 GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1023 GLD_SETUP_TEX0_3D(v2)
1024 GLD_SETUP_TEX1_3D(v2)
1025 pV++;
1026
1027 gld->PB3d.pTriangles = (BYTE*)pV;
1028 gld->PB3d.nTriangles++;
1029 }
1030
1031 //---------------------------------------------------------------------------
1032 // Quad functions
1033 //---------------------------------------------------------------------------
1034
1035 void gld_Quad3DFlat_DX7(
1036 GLcontext *ctx,
1037 GLuint v0,
1038 GLuint v1,
1039 GLuint v2,
1040 GLuint v3)
1041 {
1042 GLD_SETUP_3D_VARS_TRIANGLES
1043
1044 GLD_SETUP_3D_VERTEX(v3)
1045 GLD_SETUP_GET_FLAT_COLOUR_3D(v3)
1046 GLD_SETUP_USE_FLAT_COLOUR_3D
1047 GLD_SETUP_TEX0_3D(v3)
1048 GLD_SETUP_TEX1_3D(v3)
1049 pV++;
1050
1051 GLD_SETUP_3D_VERTEX(v0)
1052 GLD_SETUP_USE_FLAT_COLOUR_3D
1053 GLD_SETUP_TEX0_3D(v0)
1054 GLD_SETUP_TEX1_3D(v0)
1055 pV++;
1056
1057 GLD_SETUP_3D_VERTEX(v1)
1058 GLD_SETUP_USE_FLAT_COLOUR_3D
1059 GLD_SETUP_TEX0_3D(v1)
1060 GLD_SETUP_TEX1_3D(v1)
1061 pV++;
1062
1063 GLD_SETUP_3D_VERTEX(v1)
1064 GLD_SETUP_USE_FLAT_COLOUR_3D
1065 GLD_SETUP_TEX0_3D(v1)
1066 GLD_SETUP_TEX1_3D(v1)
1067 pV++;
1068
1069 GLD_SETUP_3D_VERTEX(v2)
1070 GLD_SETUP_USE_FLAT_COLOUR_3D
1071 GLD_SETUP_TEX0_3D(v2)
1072 GLD_SETUP_TEX1_3D(v2)
1073 pV++;
1074
1075 GLD_SETUP_3D_VERTEX(v3)
1076 GLD_SETUP_USE_FLAT_COLOUR_3D
1077 GLD_SETUP_TEX0_3D(v3)
1078 GLD_SETUP_TEX1_3D(v3)
1079 pV++;
1080
1081 gld->PB3d.pTriangles = (BYTE*)pV;
1082 gld->PB3d.nTriangles += 2;
1083 }
1084
1085 //---------------------------------------------------------------------------
1086
1087 void gld_Quad3DSmooth_DX7(
1088 GLcontext *ctx,
1089 GLuint v0,
1090 GLuint v1,
1091 GLuint v2,
1092 GLuint v3)
1093 {
1094 GLD_SETUP_3D_VARS_TRIANGLES
1095
1096 GLD_SETUP_3D_VERTEX(v0)
1097 GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1098 GLD_SETUP_TEX0_3D(v0)
1099 GLD_SETUP_TEX1_3D(v0)
1100 pV++;
1101
1102 GLD_SETUP_3D_VERTEX(v1)
1103 GLD_SETUP_SMOOTH_COLOUR_3D(v1)
1104 GLD_SETUP_TEX0_3D(v1)
1105 GLD_SETUP_TEX1_3D(v1)
1106 pV++;
1107
1108 GLD_SETUP_3D_VERTEX(v2)
1109 GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1110 GLD_SETUP_TEX0_3D(v2)
1111 GLD_SETUP_TEX1_3D(v2)
1112 pV++;
1113
1114 GLD_SETUP_3D_VERTEX(v2)
1115 GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1116 GLD_SETUP_TEX0_3D(v2)
1117 GLD_SETUP_TEX1_3D(v2)
1118 pV++;
1119
1120 GLD_SETUP_3D_VERTEX(v3)
1121 GLD_SETUP_SMOOTH_COLOUR_3D(v3)
1122 GLD_SETUP_TEX0_3D(v3)
1123 GLD_SETUP_TEX1_3D(v3)
1124 pV++;
1125
1126 GLD_SETUP_3D_VERTEX(v0)
1127 GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1128 GLD_SETUP_TEX0_3D(v0)
1129 GLD_SETUP_TEX1_3D(v0)
1130 pV++;
1131
1132 gld->PB3d.pTriangles = (BYTE*)pV;
1133 gld->PB3d.nTriangles += 2;
1134 }
1135
1136 //---------------------------------------------------------------------------
1137 // Vertex setup for two-sided-lighting vertex shader
1138 //---------------------------------------------------------------------------
1139
1140 /*
1141
1142 void gld_Points2DTwoside_DX8(GLcontext *ctx, GLuint first, GLuint last)
1143 {
1144 // NOTE: Two-sided lighting does not apply to Points
1145 }
1146
1147 //---------------------------------------------------------------------------
1148
1149 void gld_Line2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1)
1150 {
1151 // NOTE: Two-sided lighting does not apply to Lines
1152 }
1153
1154 //---------------------------------------------------------------------------
1155
1156 void gld_Line2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1)
1157 {
1158 // NOTE: Two-sided lighting does not apply to Lines
1159 }
1160
1161 //---------------------------------------------------------------------------
1162
1163 void gld_Triangle2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
1164 {
1165 }
1166
1167 //---------------------------------------------------------------------------
1168
1169 void gld_Triangle2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
1170 {
1171 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1172 GLD_driver_dx8 *gld = GLD_GET_DX8_DRIVER(gldCtx);
1173 GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1174 SScontext *ss = SWSETUP_CONTEXT(ctx);
1175 SWvertex *swv;
1176 DWORD dwSpecularColour;
1177 DWORD dwFlatColour;
1178 GLuint facing = 0;
1179 struct vertex_buffer *VB;
1180 GLchan (*vbcolor)[4];
1181 GLchan (*vbspec)[4];
1182
1183 // Reciprocal of DepthMax
1184 const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1185
1186 // 1st vert
1187 swv = &ss->verts[v0];
1188 pV->Position.x = swv->win[0];
1189 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1190 pV->Position.z = swv->win[2] * ooDepthMax;
1191 pV->Position.w = swv->win[3];
1192 pV->TexUnit0.x = swv->texcoord[0][0];
1193 pV->TexUnit0.y = swv->texcoord[0][1];
1194 pV->TexUnit1.x = swv->texcoord[1][0];
1195 pV->TexUnit1.y = swv->texcoord[1][1];
1196 pV->FrontDiffuse = GLD_COLOUR;
1197 pV->FrontSpecular = GLD_SPECULAR;
1198 pV++;
1199
1200 // 2nd vert
1201 swv = &ss->verts[v1];
1202 pV->Position.x = swv->win[0];
1203 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1204 pV->Position.z = swv->win[2] * ooDepthMax;
1205 pV->Position.w = swv->win[3];
1206 pV->TexUnit0.x = swv->texcoord[0][0];
1207 pV->TexUnit0.y = swv->texcoord[0][1];
1208 pV->TexUnit1.x = swv->texcoord[1][0];
1209 pV->TexUnit1.y = swv->texcoord[1][1];
1210 pV->FrontDiffuse = GLD_COLOUR;
1211 pV->FrontSpecular = GLD_SPECULAR;
1212 pV++;
1213
1214 // 3rd vert
1215 swv = &ss->verts[v2];
1216 pV->Position.x = swv->win[0];
1217 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1218 pV->Position.z = swv->win[2] * ooDepthMax;
1219 pV->Position.w = swv->win[3];
1220 pV->TexUnit0.x = swv->texcoord[0][0];
1221 pV->TexUnit0.y = swv->texcoord[0][1];
1222 pV->TexUnit1.x = swv->texcoord[1][0];
1223 pV->TexUnit1.y = swv->texcoord[1][1];
1224 pV->FrontDiffuse = GLD_COLOUR;
1225 pV->FrontSpecular = GLD_SPECULAR;
1226 pV++;
1227
1228 gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1229 gld->PBtwosidelight.nTriangles++;
1230 }
1231
1232 //---------------------------------------------------------------------------
1233
1234 void gld_Quad2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1235 {
1236 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1237 GLD_driver_dx8 *gld = GLD_GET_DX8_DRIVER(gldCtx);
1238 GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1239 SScontext *ss = SWSETUP_CONTEXT(ctx);
1240 SWvertex *swv;
1241 DWORD dwSpecularColour;
1242 DWORD dwFlatColour;
1243 GLuint facing = 0;
1244 struct vertex_buffer *VB;
1245 GLchan (*vbcolor)[4];
1246 GLchan (*vbspec)[4];
1247
1248 // Reciprocal of DepthMax
1249 const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1250
1251 // 1st vert
1252 swv = &ss->verts[v0];
1253 pV->Position.x = swv->win[0];
1254 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1255 pV->Position.z = swv->win[2] * ooDepthMax;
1256 pV->Position.w = swv->win[3];
1257 pV->TexUnit0.x = swv->texcoord[0][0];
1258 pV->TexUnit0.y = swv->texcoord[0][1];
1259 pV->TexUnit1.x = swv->texcoord[1][0];
1260 pV->TexUnit1.y = swv->texcoord[1][1];
1261 pV->FrontDiffuse = GLD_COLOUR;
1262 pV->FrontSpecular = GLD_SPECULAR;
1263 pV++;
1264
1265 // 2nd vert
1266 swv = &ss->verts[v1];
1267 pV->Position.x = swv->win[0];
1268 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1269 pV->Position.z = swv->win[2] * ooDepthMax;
1270 pV->Position.w = swv->win[3];
1271 pV->TexUnit0.x = swv->texcoord[0][0];
1272 pV->TexUnit0.y = swv->texcoord[0][1];
1273 pV->TexUnit1.x = swv->texcoord[1][0];
1274 pV->TexUnit1.y = swv->texcoord[1][1];
1275 pV->FrontDiffuse = GLD_COLOUR;
1276 pV->FrontSpecular = GLD_SPECULAR;
1277 pV++;
1278
1279 // 3rd vert
1280 swv = &ss->verts[v2];
1281 pV->Position.x = swv->win[0];
1282 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1283 pV->Position.z = swv->win[2] * ooDepthMax;
1284 pV->Position.w = swv->win[3];
1285 pV->TexUnit0.x = swv->texcoord[0][0];
1286 pV->TexUnit0.y = swv->texcoord[0][1];
1287 pV->TexUnit1.x = swv->texcoord[1][0];
1288 pV->TexUnit1.y = swv->texcoord[1][1];
1289 pV->FrontDiffuse = GLD_COLOUR;
1290 pV->FrontSpecular = GLD_SPECULAR;
1291 pV++;
1292
1293 // 4th vert
1294 swv = &ss->verts[v2];
1295 pV->Position.x = swv->win[0];
1296 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1297 pV->Position.z = swv->win[2] * ooDepthMax;
1298 pV->Position.w = swv->win[3];
1299 pV->TexUnit0.x = swv->texcoord[0][0];
1300 pV->TexUnit0.y = swv->texcoord[0][1];
1301 pV->TexUnit1.x = swv->texcoord[1][0];
1302 pV->TexUnit1.y = swv->texcoord[1][1];
1303 pV->FrontDiffuse = GLD_COLOUR;
1304 pV->FrontSpecular = GLD_SPECULAR;
1305 pV++;
1306
1307 // 5th vert
1308 swv = &ss->verts[v3];
1309 pV->Position.x = swv->win[0];
1310 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1311 pV->Position.z = swv->win[2] * ooDepthMax;
1312 pV->Position.w = swv->win[3];
1313 pV->TexUnit0.x = swv->texcoord[0][0];
1314 pV->TexUnit0.y = swv->texcoord[0][1];
1315 pV->TexUnit1.x = swv->texcoord[1][0];
1316 pV->TexUnit1.y = swv->texcoord[1][1];
1317 pV->FrontDiffuse = GLD_COLOUR;
1318 pV->FrontSpecular = GLD_SPECULAR;
1319 pV++;
1320
1321 // 6th vert
1322 swv = &ss->verts[v0];
1323 pV->Position.x = swv->win[0];
1324 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1325 pV->Position.z = swv->win[2] * ooDepthMax;
1326 pV->Position.w = swv->win[3];
1327 pV->TexUnit0.x = swv->texcoord[0][0];
1328 pV->TexUnit0.y = swv->texcoord[0][1];
1329 pV->TexUnit1.x = swv->texcoord[1][0];
1330 pV->TexUnit1.y = swv->texcoord[1][1];
1331 pV->FrontDiffuse = GLD_COLOUR;
1332 pV->FrontSpecular = GLD_SPECULAR;
1333 pV++;
1334
1335 gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1336 gld->PBtwosidelight.nTriangles += 2;
1337 }
1338
1339 //---------------------------------------------------------------------------
1340
1341 void gld_Quad2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1342 {
1343 GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1344 GLD_driver_dx8 *gld = GLD_GET_DX8_DRIVER(gldCtx);
1345 GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1346 SScontext *ss = SWSETUP_CONTEXT(ctx);
1347 SWvertex *swv;
1348 DWORD dwSpecularColour;
1349 DWORD dwFlatColour;
1350 GLuint facing = 0;
1351 struct vertex_buffer *VB;
1352 GLchan (*vbcolor)[4];
1353 GLchan (*vbspec)[4];
1354
1355 // Reciprocal of DepthMax
1356 const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1357
1358 // 1st vert
1359 swv = &ss->verts[v0];
1360 pV->Position.x = swv->win[0];
1361 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1362 pV->Position.z = swv->win[2] * ooDepthMax;
1363 pV->Position.w = swv->win[3];
1364 pV->TexUnit0.x = swv->texcoord[0][0];
1365 pV->TexUnit0.y = swv->texcoord[0][1];
1366 pV->TexUnit1.x = swv->texcoord[1][0];
1367 pV->TexUnit1.y = swv->texcoord[1][1];
1368 pV->FrontDiffuse = GLD_COLOUR;
1369 pV->FrontSpecular = GLD_SPECULAR;
1370 pV++;
1371
1372 // 2nd vert
1373 swv = &ss->verts[v1];
1374 pV->Position.x = swv->win[0];
1375 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1376 pV->Position.z = swv->win[2] * ooDepthMax;
1377 pV->Position.w = swv->win[3];
1378 pV->TexUnit0.x = swv->texcoord[0][0];
1379 pV->TexUnit0.y = swv->texcoord[0][1];
1380 pV->TexUnit1.x = swv->texcoord[1][0];
1381 pV->TexUnit1.y = swv->texcoord[1][1];
1382 pV->FrontDiffuse = GLD_COLOUR;
1383 pV->FrontSpecular = GLD_SPECULAR;
1384 pV++;
1385
1386 // 3rd vert
1387 swv = &ss->verts[v2];
1388 pV->Position.x = swv->win[0];
1389 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1390 pV->Position.z = swv->win[2] * ooDepthMax;
1391 pV->Position.w = swv->win[3];
1392 pV->TexUnit0.x = swv->texcoord[0][0];
1393 pV->TexUnit0.y = swv->texcoord[0][1];
1394 pV->TexUnit1.x = swv->texcoord[1][0];
1395 pV->TexUnit1.y = swv->texcoord[1][1];
1396 pV->FrontDiffuse = GLD_COLOUR;
1397 pV->FrontSpecular = GLD_SPECULAR;
1398 pV++;
1399
1400 // 4th vert
1401 swv = &ss->verts[v2];
1402 pV->Position.x = swv->win[0];
1403 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1404 pV->Position.z = swv->win[2] * ooDepthMax;
1405 pV->Position.w = swv->win[3];
1406 pV->TexUnit0.x = swv->texcoord[0][0];
1407 pV->TexUnit0.y = swv->texcoord[0][1];
1408 pV->TexUnit1.x = swv->texcoord[1][0];
1409 pV->TexUnit1.y = swv->texcoord[1][1];
1410 pV->FrontDiffuse = GLD_COLOUR;
1411 pV->FrontSpecular = GLD_SPECULAR;
1412 pV++;
1413
1414 // 5th vert
1415 swv = &ss->verts[v3];
1416 pV->Position.x = swv->win[0];
1417 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1418 pV->Position.z = swv->win[2] * ooDepthMax;
1419 pV->Position.w = swv->win[3];
1420 pV->TexUnit0.x = swv->texcoord[0][0];
1421 pV->TexUnit0.y = swv->texcoord[0][1];
1422 pV->TexUnit1.x = swv->texcoord[1][0];
1423 pV->TexUnit1.y = swv->texcoord[1][1];
1424 pV->FrontDiffuse = GLD_COLOUR;
1425 pV->FrontSpecular = GLD_SPECULAR;
1426 pV++;
1427
1428 // 6th vert
1429 swv = &ss->verts[v0];
1430 pV->Position.x = swv->win[0];
1431 pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1432 pV->Position.z = swv->win[2] * ooDepthMax;
1433 pV->Position.w = swv->win[3];
1434 pV->TexUnit0.x = swv->texcoord[0][0];
1435 pV->TexUnit0.y = swv->texcoord[0][1];
1436 pV->TexUnit1.x = swv->texcoord[1][0];
1437 pV->TexUnit1.y = swv->texcoord[1][1];
1438 pV->FrontDiffuse = GLD_COLOUR;
1439 pV->FrontSpecular = GLD_SPECULAR;
1440 pV++;
1441
1442 gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1443 gld->PBtwosidelight.nTriangles += 2;
1444 }
1445
1446 //---------------------------------------------------------------------------
1447
1448 */