1
/****************************************************************************
3
* Mesa 3-D graphics library
4
* Direct3D Driver Interface
6
* ========================================================================
8
* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
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:
17
* The above copyright notice and this permission notice shall be included
18
* in all copies or substantial portions of the Software.
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
28
* ======================================================================
31
* Environment: Windows 9x/2000/XP/XBox (Win32)
33
* Description: Primitive (points/lines/tris/quads) rendering
35
****************************************************************************/
37
//#include "../GLDirect.h"
39
//#include "gld_dx8.h"
41
#include "dglcontext.h"
49
#include "extensions.h"
55
#include "texformat.h"
57
#include "array_cache/acache.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"
67
#include "tnl/t_context.h"
68
#include "tnl/t_pipeline.h"
70
// Disable compiler complaints about unreferenced local variables
71
#pragma warning (disable:4101)
73
//---------------------------------------------------------------------------
74
// Helper defines for primitives
75
//---------------------------------------------------------------------------
77
//static const float ooZ = 1.0f / 65536.0f; // One over Z
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))
83
//---------------------------------------------------------------------------
85
//---------------------------------------------------------------------------
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); \
93
DWORD dwSpecularColour; \
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); \
102
DWORD dwSpecularColour; \
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); \
112
DWORD dwSpecularColour; \
113
DWORD dwFlatColour; \
115
struct vertex_buffer *VB; \
116
GLchan (*vbcolor)[4]; \
119
#define GLD_SETUP_GET_SWVERT(s) \
120
swv = &ss->verts[##s]
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]
127
#define GLD_SETUP_SMOOTH_COLOUR \
128
pV->diffuse = GLD_COLOUR
130
#define GLD_SETUP_GET_FLAT_COLOUR \
131
dwFlatColour = GLD_COLOUR
132
#define GLD_SETUP_GET_FLAT_FOG_COLOUR \
133
dwFlatColour = _gldComputeFog(ctx, swv)
135
#define GLD_SETUP_USE_FLAT_COLOUR \
136
pV->diffuse = dwFlatColour
138
#define GLD_SETUP_GET_FLAT_SPECULAR \
139
dwSpecularColour= GLD_SPECULAR
141
#define GLD_SETUP_USE_FLAT_SPECULAR \
142
pV->specular = dwSpecularColour
144
#define GLD_SETUP_DEPTH \
145
pV->sz = swv->win[2] / ctx->DepthMaxF
146
// pV->z = swv->win[2] * ooZ;
148
#define GLD_SETUP_SPECULAR \
149
pV->specular = GLD_SPECULAR
151
#define GLD_SETUP_FOG \
152
pV->diffuse = _gldComputeFog(ctx, swv)
154
#define GLD_SETUP_TEX0 \
155
pV->t0_u = swv->texcoord[0][0]; \
156
pV->t0_v = swv->texcoord[0][1]
158
#define GLD_SETUP_TEX1 \
159
pV->t1_u = swv->texcoord[1][0]; \
160
pV->t1_v = swv->texcoord[1][1]
162
#define GLD_SETUP_LIGHTING(v) \
164
pV->diffuse = D3DCOLOR_RGBA(vbcolor[##v][0], vbcolor[##v][1], vbcolor[##v][2], vbcolor[##v][3]); \
166
pV->specular = D3DCOLOR_RGBA(vbspec[##v][0], vbspec[##v][1], vbspec[##v][2], vbspec[##v][3]); \
172
GLD_SETUP_SMOOTH_COLOUR; \
173
GLD_SETUP_SPECULAR; \
176
#define GLD_SETUP_GET_FLAT_LIGHTING(v) \
178
dwFlatColour = D3DCOLOR_RGBA(vbcolor[##v][0], vbcolor[##v][1], vbcolor[##v][2], vbcolor[##v][3]); \
180
dwSpecularColour = D3DCOLOR_RGBA(vbspec[##v][0], vbspec[##v][1], vbspec[##v][2], vbspec[##v][3]); \
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; \
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; \
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; \
209
//---------------------------------------------------------------------------
211
//---------------------------------------------------------------------------
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; \
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; \
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; \
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];
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]);
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]);
258
#define GLD_SETUP_USE_FLAT_COLOUR_3D \
259
pV->Diffuse = dwColor;
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]; \
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]; \
275
//---------------------------------------------------------------------------
277
//---------------------------------------------------------------------------
279
__inline DWORD _gldComputeFog(
283
// Full fog calculation.
284
// Based on Mesa code.
286
GLchan rFog, gFog, bFog;
288
const GLfloat f = swv->fog;
289
const GLfloat g = 1.0 - f;
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]);
300
//---------------------------------------------------------------------------
302
void gld_ResetLineStipple_DX7(
305
// TODO: Fake stipple with a 32x32 texture.
308
//---------------------------------------------------------------------------
309
// 2D (post-transformed) primitives
310
//---------------------------------------------------------------------------
312
void gld_Points2D_DX7(
317
GLD_SETUP_2D_VARS_POINTS;
320
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
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));
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]);
332
GLD_SETUP_SMOOTH_COLOUR;
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] );
345
GLD_SETUP_SMOOTH_COLOUR;
354
gld->PB2d.pPoints = (BYTE*)pV;
355
gld->PB2d.nPoints += (last-first);
358
//---------------------------------------------------------------------------
360
void gld_Line2DFlat_DX7(
365
GLD_SETUP_2D_VARS_LINES;
367
GLD_SETUP_GET_SWVERT(v1);
372
GLD_SETUP_GET_FLAT_COLOUR;
373
GLD_SETUP_USE_FLAT_COLOUR;
374
GLD_SETUP_GET_FLAT_SPECULAR;
375
GLD_SETUP_USE_FLAT_SPECULAR;
378
GLD_SETUP_GET_SWVERT(v0);
383
GLD_SETUP_USE_FLAT_COLOUR;
384
GLD_SETUP_USE_FLAT_SPECULAR;
387
gld->PB2d.pLines = (BYTE*)pV;
391
//---------------------------------------------------------------------------
393
void gld_Line2DSmooth_DX7(
398
GLD_SETUP_2D_VARS_LINES;
400
GLD_SETUP_GET_SWVERT(v0);
402
GLD_SETUP_SMOOTH_COLOUR;
409
GLD_SETUP_GET_SWVERT(v1);
411
GLD_SETUP_SMOOTH_COLOUR;
418
gld->PB2d.pLines = (BYTE*)pV;
422
//---------------------------------------------------------------------------
424
void gld_Triangle2DFlat_DX7(
430
GLD_SETUP_2D_VARS_TRIANGLES;
432
GLD_SETUP_GET_SWVERT(v2);
437
GLD_SETUP_GET_FLAT_COLOUR;
438
GLD_SETUP_USE_FLAT_COLOUR;
441
GLD_SETUP_GET_SWVERT(v0);
446
GLD_SETUP_USE_FLAT_COLOUR;
449
GLD_SETUP_GET_SWVERT(v1);
454
GLD_SETUP_USE_FLAT_COLOUR;
457
gld->PB2d.pTriangles = (BYTE*)pV;
458
gld->PB2d.nTriangles++;
461
//---------------------------------------------------------------------------
463
void gld_Triangle2DSmooth_DX7(
470
GLD_SETUP_2D_VARS_TRIANGLES;
472
GLD_SETUP_GET_SWVERT(v0);
474
GLD_SETUP_SMOOTH_COLOUR;
480
GLD_SETUP_GET_SWVERT(v1);
482
GLD_SETUP_SMOOTH_COLOUR;
488
GLD_SETUP_GET_SWVERT(v2);
490
GLD_SETUP_SMOOTH_COLOUR;
496
gld->PB2d.pTriangles = (BYTE*)pV;
497
gld->PB2d.nTriangles++;
500
//---------------------------------------------------------------------------
502
void gld_Triangle2DFlatExtras_DX7(
508
GLD_SETUP_2D_VARS_TRIANGLES;
510
GLD_SETUP_TWOSIDED_LIGHTING(v2);
512
GLD_SETUP_GET_SWVERT(v2);
518
GLD_SETUP_GET_FLAT_FOG_COLOUR;
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;
527
GLD_SETUP_GET_SWVERT(v0);
532
GLD_SETUP_USE_FLAT_COLOUR;
533
GLD_SETUP_USE_FLAT_SPECULAR;
536
GLD_SETUP_GET_SWVERT(v1);
541
GLD_SETUP_USE_FLAT_COLOUR;
542
GLD_SETUP_USE_FLAT_SPECULAR;
545
gld->PB2d.pTriangles = (BYTE*)pV;
546
gld->PB2d.nTriangles++;
549
//---------------------------------------------------------------------------
551
void gld_Triangle2DSmoothExtras_DX7(
557
GLD_SETUP_2D_VARS_TRIANGLES;
559
GLD_SETUP_TWOSIDED_LIGHTING(v0);
561
GLD_SETUP_GET_SWVERT(v0);
566
GLD_SETUP_LIGHTING(v0);
569
GLD_SETUP_GET_SWVERT(v1);
574
GLD_SETUP_LIGHTING(v1);
577
GLD_SETUP_GET_SWVERT(v2);
582
GLD_SETUP_LIGHTING(v2);
585
gld->PB2d.pTriangles = (BYTE*)pV;
586
gld->PB2d.nTriangles++;
589
//---------------------------------------------------------------------------
591
void gld_Quad2DFlat_DX7(
598
GLD_SETUP_2D_VARS_TRIANGLES;
600
GLD_SETUP_GET_SWVERT(v3);
605
GLD_SETUP_GET_FLAT_COLOUR;
606
GLD_SETUP_USE_FLAT_COLOUR;
609
GLD_SETUP_GET_SWVERT(v0);
614
GLD_SETUP_USE_FLAT_COLOUR;
617
GLD_SETUP_GET_SWVERT(v1);
622
GLD_SETUP_USE_FLAT_COLOUR;
625
GLD_SETUP_GET_SWVERT(v1);
630
GLD_SETUP_USE_FLAT_COLOUR;
633
GLD_SETUP_GET_SWVERT(v2);
638
GLD_SETUP_USE_FLAT_COLOUR;
641
GLD_SETUP_GET_SWVERT(v3);
646
GLD_SETUP_USE_FLAT_COLOUR;
649
gld->PB2d.pTriangles = (BYTE*)pV;
650
gld->PB2d.nTriangles += 2;
653
//---------------------------------------------------------------------------
655
void gld_Quad2DSmooth_DX7(
662
GLD_SETUP_2D_VARS_TRIANGLES;
664
GLD_SETUP_GET_SWVERT(v0);
666
GLD_SETUP_SMOOTH_COLOUR;
672
GLD_SETUP_GET_SWVERT(v1);
674
GLD_SETUP_SMOOTH_COLOUR;
680
GLD_SETUP_GET_SWVERT(v2);
682
GLD_SETUP_SMOOTH_COLOUR;
688
GLD_SETUP_GET_SWVERT(v2);
690
GLD_SETUP_SMOOTH_COLOUR;
696
GLD_SETUP_GET_SWVERT(v3);
698
GLD_SETUP_SMOOTH_COLOUR;
704
GLD_SETUP_GET_SWVERT(v0);
706
GLD_SETUP_SMOOTH_COLOUR;
712
gld->PB2d.pTriangles = (BYTE*)pV;
713
gld->PB2d.nTriangles += 2;
716
//---------------------------------------------------------------------------
718
void gld_Quad2DFlatExtras_DX7(
725
GLD_SETUP_2D_VARS_TRIANGLES;
727
GLD_SETUP_TWOSIDED_LIGHTING(v3);
729
GLD_SETUP_GET_SWVERT(v3);
735
GLD_SETUP_GET_FLAT_FOG_COLOUR;
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;
744
GLD_SETUP_GET_SWVERT(v0);
749
GLD_SETUP_USE_FLAT_COLOUR;
750
GLD_SETUP_USE_FLAT_SPECULAR;
753
GLD_SETUP_GET_SWVERT(v1);
758
GLD_SETUP_USE_FLAT_COLOUR;
759
GLD_SETUP_USE_FLAT_SPECULAR;
762
GLD_SETUP_GET_SWVERT(v1);
767
GLD_SETUP_USE_FLAT_COLOUR;
768
GLD_SETUP_USE_FLAT_SPECULAR;
771
GLD_SETUP_GET_SWVERT(v2);
776
GLD_SETUP_USE_FLAT_COLOUR;
777
GLD_SETUP_USE_FLAT_SPECULAR;
780
GLD_SETUP_GET_SWVERT(v3);
785
GLD_SETUP_USE_FLAT_COLOUR;
786
GLD_SETUP_USE_FLAT_SPECULAR;
789
gld->PB2d.pTriangles = (BYTE*)pV;
790
gld->PB2d.nTriangles += 2;
793
//---------------------------------------------------------------------------
795
void gld_Quad2DSmoothExtras_DX7(
802
GLD_SETUP_2D_VARS_TRIANGLES;
804
GLD_SETUP_TWOSIDED_LIGHTING(v0);
806
GLD_SETUP_GET_SWVERT(v0);
811
GLD_SETUP_LIGHTING(v0);
814
GLD_SETUP_GET_SWVERT(v1);
819
GLD_SETUP_LIGHTING(v1);
822
GLD_SETUP_GET_SWVERT(v2);
827
GLD_SETUP_LIGHTING(v2);
830
GLD_SETUP_GET_SWVERT(v2);
835
GLD_SETUP_LIGHTING(v2);
838
GLD_SETUP_GET_SWVERT(v3);
843
GLD_SETUP_LIGHTING(v3);
846
GLD_SETUP_GET_SWVERT(v0);
851
GLD_SETUP_LIGHTING(v0);
854
gld->PB2d.pTriangles = (BYTE*)pV;
855
gld->PB2d.nTriangles += 2;
858
//---------------------------------------------------------------------------
859
// 3D (pre-transformed) primitives
860
//---------------------------------------------------------------------------
862
void gld_Points3D_DX7(
867
GLD_SETUP_3D_VARS_POINTS
870
// struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
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));
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)
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)
900
for (i=first; i<last; i++, pV++) {
901
GLD_SETUP_3D_VERTEX(i)
902
GLD_SETUP_SMOOTH_COLOUR_3D(i)
907
gld->PB3d.pPoints = (BYTE*)pV;
908
gld->PB3d.nPoints += (last-first);
911
//---------------------------------------------------------------------------
913
//---------------------------------------------------------------------------
915
void gld_Line3DFlat_DX7(
920
GLD_SETUP_3D_VARS_LINES
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)
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)
935
gld->PB3d.pLines = (BYTE*)pV;
939
//---------------------------------------------------------------------------
941
void gld_Line3DSmooth_DX7(
946
GLD_SETUP_3D_VARS_LINES
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)
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)
960
gld->PB3d.pLines = (BYTE*)pV;
964
//---------------------------------------------------------------------------
965
// Triangle functions
966
//---------------------------------------------------------------------------
968
void gld_Triangle3DFlat_DX7(
974
GLD_SETUP_3D_VARS_TRIANGLES
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
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
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
995
gld->PB3d.pTriangles = (BYTE*)pV;
996
gld->PB3d.nTriangles++;
999
//---------------------------------------------------------------------------
1001
void gld_Triangle3DSmooth_DX7(
1007
GLD_SETUP_3D_VARS_TRIANGLES
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)
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)
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)
1027
gld->PB3d.pTriangles = (BYTE*)pV;
1028
gld->PB3d.nTriangles++;
1031
//---------------------------------------------------------------------------
1033
//---------------------------------------------------------------------------
1035
void gld_Quad3DFlat_DX7(
1042
GLD_SETUP_3D_VARS_TRIANGLES
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)
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)
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)
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)
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)
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)
1081
gld->PB3d.pTriangles = (BYTE*)pV;
1082
gld->PB3d.nTriangles += 2;
1085
//---------------------------------------------------------------------------
1087
void gld_Quad3DSmooth_DX7(
1094
GLD_SETUP_3D_VARS_TRIANGLES
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)
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)
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)
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)
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)
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)
1132
gld->PB3d.pTriangles = (BYTE*)pV;
1133
gld->PB3d.nTriangles += 2;
1136
//---------------------------------------------------------------------------
1137
// Vertex setup for two-sided-lighting vertex shader
1138
//---------------------------------------------------------------------------
1142
void gld_Points2DTwoside_DX8(GLcontext *ctx, GLuint first, GLuint last)
1144
// NOTE: Two-sided lighting does not apply to Points
1147
//---------------------------------------------------------------------------
1149
void gld_Line2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1)
1151
// NOTE: Two-sided lighting does not apply to Lines
1154
//---------------------------------------------------------------------------
1156
void gld_Line2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1)
1158
// NOTE: Two-sided lighting does not apply to Lines
1161
//---------------------------------------------------------------------------
1163
void gld_Triangle2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
1167
//---------------------------------------------------------------------------
1169
void gld_Triangle2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
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);
1176
DWORD dwSpecularColour;
1179
struct vertex_buffer *VB;
1180
GLchan (*vbcolor)[4];
1181
GLchan (*vbspec)[4];
1183
// Reciprocal of DepthMax
1184
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
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;
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;
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;
1228
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1229
gld->PBtwosidelight.nTriangles++;
1232
//---------------------------------------------------------------------------
1234
void gld_Quad2DFlatTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
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);
1241
DWORD dwSpecularColour;
1244
struct vertex_buffer *VB;
1245
GLchan (*vbcolor)[4];
1246
GLchan (*vbspec)[4];
1248
// Reciprocal of DepthMax
1249
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
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;
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;
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;
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;
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;
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;
1335
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1336
gld->PBtwosidelight.nTriangles += 2;
1339
//---------------------------------------------------------------------------
1341
void gld_Quad2DSmoothTwoside_DX8(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
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);
1348
DWORD dwSpecularColour;
1351
struct vertex_buffer *VB;
1352
GLchan (*vbcolor)[4];
1353
GLchan (*vbspec)[4];
1355
// Reciprocal of DepthMax
1356
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
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;
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;
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;
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;
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;
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;
1442
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1443
gld->PBtwosidelight.nTriangles += 2;
1446
//---------------------------------------------------------------------------