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_dx9 *gld = GLD_GET_DX9_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_dx9 *gld = GLD_GET_DX9_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_dx9 *gld = GLD_GET_DX9_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_dx9 *gld = GLD_GET_DX9_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_dx9 *gld = GLD_GET_DX9_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_dx9 *gld = GLD_GET_DX9_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_DX9(
305
// TODO: Fake stipple with a 32x32 texture.
308
//---------------------------------------------------------------------------
309
// 2D (post-transformed) primitives
310
//---------------------------------------------------------------------------
312
void gld_Points2D_DX9(
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
IDirect3DDevice9_SetRenderState(gld->pDev, D3DRS_POINTSIZE, *((DWORD*)&ctx->Point._Size));
326
for (i=first; i<last; i++, pV++) {
327
if (VB->ClipMask[VB->Elts[i]] == 0) {
328
// _swrast_Point( ctx, &verts[VB->Elts[i]] );
329
GLD_SETUP_GET_SWVERT(VB->Elts[i]);
331
GLD_SETUP_SMOOTH_COLOUR;
339
GLD_SETUP_GET_SWVERT(first);
340
for (i=first; i<last; i++, swv++, pV++) {
341
if (VB->ClipMask[i] == 0) {
342
// _swrast_Point( ctx, &verts[i] );
344
GLD_SETUP_SMOOTH_COLOUR;
353
gld->PB2d.pPoints = (BYTE*)pV;
354
gld->PB2d.nPoints += (last-first);
357
//---------------------------------------------------------------------------
359
void gld_Line2DFlat_DX9(
364
GLD_SETUP_2D_VARS_LINES;
366
GLD_SETUP_GET_SWVERT(v1);
371
GLD_SETUP_GET_FLAT_COLOUR;
372
GLD_SETUP_USE_FLAT_COLOUR;
373
GLD_SETUP_GET_FLAT_SPECULAR;
374
GLD_SETUP_USE_FLAT_SPECULAR;
377
GLD_SETUP_GET_SWVERT(v0);
382
GLD_SETUP_USE_FLAT_COLOUR;
383
GLD_SETUP_USE_FLAT_SPECULAR;
386
gld->PB2d.pLines = (BYTE*)pV;
390
//---------------------------------------------------------------------------
392
void gld_Line2DSmooth_DX9(
397
GLD_SETUP_2D_VARS_LINES;
399
GLD_SETUP_GET_SWVERT(v0);
401
GLD_SETUP_SMOOTH_COLOUR;
408
GLD_SETUP_GET_SWVERT(v1);
410
GLD_SETUP_SMOOTH_COLOUR;
417
gld->PB2d.pLines = (BYTE*)pV;
421
//---------------------------------------------------------------------------
423
void gld_Triangle2DFlat_DX9(
429
GLD_SETUP_2D_VARS_TRIANGLES;
431
GLD_SETUP_GET_SWVERT(v2);
436
GLD_SETUP_GET_FLAT_COLOUR;
437
GLD_SETUP_USE_FLAT_COLOUR;
440
GLD_SETUP_GET_SWVERT(v0);
445
GLD_SETUP_USE_FLAT_COLOUR;
448
GLD_SETUP_GET_SWVERT(v1);
453
GLD_SETUP_USE_FLAT_COLOUR;
456
gld->PB2d.pTriangles = (BYTE*)pV;
457
gld->PB2d.nTriangles++;
460
//---------------------------------------------------------------------------
462
void gld_Triangle2DSmooth_DX9(
469
GLD_SETUP_2D_VARS_TRIANGLES;
471
GLD_SETUP_GET_SWVERT(v0);
473
GLD_SETUP_SMOOTH_COLOUR;
479
GLD_SETUP_GET_SWVERT(v1);
481
GLD_SETUP_SMOOTH_COLOUR;
487
GLD_SETUP_GET_SWVERT(v2);
489
GLD_SETUP_SMOOTH_COLOUR;
495
gld->PB2d.pTriangles = (BYTE*)pV;
496
gld->PB2d.nTriangles++;
499
//---------------------------------------------------------------------------
501
void gld_Triangle2DFlatExtras_DX9(
507
GLD_SETUP_2D_VARS_TRIANGLES;
509
GLD_SETUP_TWOSIDED_LIGHTING(v2);
511
GLD_SETUP_GET_SWVERT(v2);
517
GLD_SETUP_GET_FLAT_FOG_COLOUR;
519
GLD_SETUP_GET_FLAT_COLOUR;
520
GLD_SETUP_GET_FLAT_SPECULAR;
521
GLD_SETUP_GET_FLAT_LIGHTING(v2);
522
GLD_SETUP_USE_FLAT_COLOUR;
523
GLD_SETUP_USE_FLAT_SPECULAR;
526
GLD_SETUP_GET_SWVERT(v0);
531
GLD_SETUP_USE_FLAT_COLOUR;
532
GLD_SETUP_USE_FLAT_SPECULAR;
535
GLD_SETUP_GET_SWVERT(v1);
540
GLD_SETUP_USE_FLAT_COLOUR;
541
GLD_SETUP_USE_FLAT_SPECULAR;
544
gld->PB2d.pTriangles = (BYTE*)pV;
545
gld->PB2d.nTriangles++;
548
//---------------------------------------------------------------------------
550
void gld_Triangle2DSmoothExtras_DX9(
556
GLD_SETUP_2D_VARS_TRIANGLES;
558
GLD_SETUP_TWOSIDED_LIGHTING(v0);
560
GLD_SETUP_GET_SWVERT(v0);
565
GLD_SETUP_LIGHTING(v0);
568
GLD_SETUP_GET_SWVERT(v1);
573
GLD_SETUP_LIGHTING(v1);
576
GLD_SETUP_GET_SWVERT(v2);
581
GLD_SETUP_LIGHTING(v2);
584
gld->PB2d.pTriangles = (BYTE*)pV;
585
gld->PB2d.nTriangles++;
588
//---------------------------------------------------------------------------
590
void gld_Quad2DFlat_DX9(
597
GLD_SETUP_2D_VARS_TRIANGLES;
599
GLD_SETUP_GET_SWVERT(v3);
604
GLD_SETUP_GET_FLAT_COLOUR;
605
GLD_SETUP_USE_FLAT_COLOUR;
608
GLD_SETUP_GET_SWVERT(v0);
613
GLD_SETUP_USE_FLAT_COLOUR;
616
GLD_SETUP_GET_SWVERT(v1);
621
GLD_SETUP_USE_FLAT_COLOUR;
624
GLD_SETUP_GET_SWVERT(v1);
629
GLD_SETUP_USE_FLAT_COLOUR;
632
GLD_SETUP_GET_SWVERT(v2);
637
GLD_SETUP_USE_FLAT_COLOUR;
640
GLD_SETUP_GET_SWVERT(v3);
645
GLD_SETUP_USE_FLAT_COLOUR;
648
gld->PB2d.pTriangles = (BYTE*)pV;
649
gld->PB2d.nTriangles += 2;
652
//---------------------------------------------------------------------------
654
void gld_Quad2DSmooth_DX9(
661
GLD_SETUP_2D_VARS_TRIANGLES;
663
GLD_SETUP_GET_SWVERT(v0);
665
GLD_SETUP_SMOOTH_COLOUR;
671
GLD_SETUP_GET_SWVERT(v1);
673
GLD_SETUP_SMOOTH_COLOUR;
679
GLD_SETUP_GET_SWVERT(v2);
681
GLD_SETUP_SMOOTH_COLOUR;
687
GLD_SETUP_GET_SWVERT(v2);
689
GLD_SETUP_SMOOTH_COLOUR;
695
GLD_SETUP_GET_SWVERT(v3);
697
GLD_SETUP_SMOOTH_COLOUR;
703
GLD_SETUP_GET_SWVERT(v0);
705
GLD_SETUP_SMOOTH_COLOUR;
711
gld->PB2d.pTriangles = (BYTE*)pV;
712
gld->PB2d.nTriangles += 2;
715
//---------------------------------------------------------------------------
717
void gld_Quad2DFlatExtras_DX9(
724
GLD_SETUP_2D_VARS_TRIANGLES;
726
GLD_SETUP_TWOSIDED_LIGHTING(v3);
728
GLD_SETUP_GET_SWVERT(v3);
734
GLD_SETUP_GET_FLAT_FOG_COLOUR;
736
GLD_SETUP_GET_FLAT_COLOUR;
737
GLD_SETUP_GET_FLAT_SPECULAR;
738
GLD_SETUP_GET_FLAT_LIGHTING(v3);
739
GLD_SETUP_USE_FLAT_COLOUR;
740
GLD_SETUP_USE_FLAT_SPECULAR;
743
GLD_SETUP_GET_SWVERT(v0);
748
GLD_SETUP_USE_FLAT_COLOUR;
749
GLD_SETUP_USE_FLAT_SPECULAR;
752
GLD_SETUP_GET_SWVERT(v1);
757
GLD_SETUP_USE_FLAT_COLOUR;
758
GLD_SETUP_USE_FLAT_SPECULAR;
761
GLD_SETUP_GET_SWVERT(v1);
766
GLD_SETUP_USE_FLAT_COLOUR;
767
GLD_SETUP_USE_FLAT_SPECULAR;
770
GLD_SETUP_GET_SWVERT(v2);
775
GLD_SETUP_USE_FLAT_COLOUR;
776
GLD_SETUP_USE_FLAT_SPECULAR;
779
GLD_SETUP_GET_SWVERT(v3);
784
GLD_SETUP_USE_FLAT_COLOUR;
785
GLD_SETUP_USE_FLAT_SPECULAR;
788
gld->PB2d.pTriangles = (BYTE*)pV;
789
gld->PB2d.nTriangles += 2;
792
//---------------------------------------------------------------------------
794
void gld_Quad2DSmoothExtras_DX9(
801
GLD_SETUP_2D_VARS_TRIANGLES;
803
GLD_SETUP_TWOSIDED_LIGHTING(v0);
805
GLD_SETUP_GET_SWVERT(v0);
810
GLD_SETUP_LIGHTING(v0);
813
GLD_SETUP_GET_SWVERT(v1);
818
GLD_SETUP_LIGHTING(v1);
821
GLD_SETUP_GET_SWVERT(v2);
826
GLD_SETUP_LIGHTING(v2);
829
GLD_SETUP_GET_SWVERT(v2);
834
GLD_SETUP_LIGHTING(v2);
837
GLD_SETUP_GET_SWVERT(v3);
842
GLD_SETUP_LIGHTING(v3);
845
GLD_SETUP_GET_SWVERT(v0);
850
GLD_SETUP_LIGHTING(v0);
853
gld->PB2d.pTriangles = (BYTE*)pV;
854
gld->PB2d.nTriangles += 2;
857
//---------------------------------------------------------------------------
858
// 3D (pre-transformed) primitives
859
//---------------------------------------------------------------------------
861
void gld_Points3D_DX9(
866
GLD_SETUP_3D_VARS_POINTS
869
// struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
871
// _Size is already clamped to MaxPointSize and MinPointSize
872
IDirect3DDevice9_SetRenderState(gld->pDev, D3DRS_POINTSIZE, *((DWORD*)&ctx->Point._Size));
875
for (i=first; i<last; i++, pV++) {
876
if (VB->ClipMask[VB->Elts[i]] == 0) {
877
// _swrast_Point( ctx, &verts[VB->Elts[i]] );
878
// GLD_SETUP_GET_SWVERT(VB->Elts[i]);
879
GLD_SETUP_3D_VERTEX(VB->Elts[i])
880
GLD_SETUP_SMOOTH_COLOUR_3D(i)
886
// GLD_SETUP_GET_SWVERT(first);
887
for (i=first; i<last; i++, pV++) {
888
if (VB->ClipMask[i] == 0) {
889
// _swrast_Point( ctx, &verts[i] );
890
GLD_SETUP_3D_VERTEX(i)
891
GLD_SETUP_SMOOTH_COLOUR_3D(i)
898
for (i=first; i<last; i++, pV++) {
899
GLD_SETUP_3D_VERTEX(i)
900
GLD_SETUP_SMOOTH_COLOUR_3D(i)
905
gld->PB3d.pPoints = (BYTE*)pV;
906
gld->PB3d.nPoints += (last-first);
909
//---------------------------------------------------------------------------
911
//---------------------------------------------------------------------------
913
void gld_Line3DFlat_DX9(
918
GLD_SETUP_3D_VARS_LINES
920
GLD_SETUP_3D_VERTEX(v1)
921
GLD_SETUP_GET_FLAT_COLOUR_3D(v1)
922
GLD_SETUP_USE_FLAT_COLOUR_3D
923
GLD_SETUP_TEX0_3D(v1)
924
GLD_SETUP_TEX1_3D(v1)
927
GLD_SETUP_3D_VERTEX(v0)
928
GLD_SETUP_USE_FLAT_COLOUR_3D
929
GLD_SETUP_TEX0_3D(v0)
930
GLD_SETUP_TEX1_3D(v0)
933
gld->PB3d.pLines = (BYTE*)pV;
937
//---------------------------------------------------------------------------
939
void gld_Line3DSmooth_DX9(
944
GLD_SETUP_3D_VARS_LINES
946
GLD_SETUP_3D_VERTEX(v1)
947
GLD_SETUP_SMOOTH_COLOUR_3D(v1)
948
GLD_SETUP_TEX0_3D(v1)
949
GLD_SETUP_TEX1_3D(v1)
952
GLD_SETUP_3D_VERTEX(v0)
953
GLD_SETUP_SMOOTH_COLOUR_3D(v0)
954
GLD_SETUP_TEX0_3D(v0)
955
GLD_SETUP_TEX1_3D(v0)
958
gld->PB3d.pLines = (BYTE*)pV;
962
//---------------------------------------------------------------------------
963
// Triangle functions
964
//---------------------------------------------------------------------------
966
void gld_Triangle3DFlat_DX9(
972
GLD_SETUP_3D_VARS_TRIANGLES
974
GLD_SETUP_3D_VERTEX(v2)
975
GLD_SETUP_TEX0_3D(v2)
976
GLD_SETUP_TEX1_3D(v2)
977
GLD_SETUP_GET_FLAT_COLOUR_3D(v2)
978
GLD_SETUP_USE_FLAT_COLOUR_3D
981
GLD_SETUP_3D_VERTEX(v0)
982
GLD_SETUP_TEX0_3D(v0)
983
GLD_SETUP_TEX1_3D(v0)
984
GLD_SETUP_USE_FLAT_COLOUR_3D
987
GLD_SETUP_3D_VERTEX(v1)
988
GLD_SETUP_TEX0_3D(v1)
989
GLD_SETUP_TEX1_3D(v1)
990
GLD_SETUP_USE_FLAT_COLOUR_3D
993
gld->PB3d.pTriangles = (BYTE*)pV;
994
gld->PB3d.nTriangles++;
997
//---------------------------------------------------------------------------
999
void gld_Triangle3DSmooth_DX9(
1005
GLD_SETUP_3D_VARS_TRIANGLES
1007
GLD_SETUP_3D_VERTEX(v0)
1008
GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1009
GLD_SETUP_TEX0_3D(v0)
1010
GLD_SETUP_TEX1_3D(v0)
1013
GLD_SETUP_3D_VERTEX(v1)
1014
GLD_SETUP_SMOOTH_COLOUR_3D(v1)
1015
GLD_SETUP_TEX0_3D(v1)
1016
GLD_SETUP_TEX1_3D(v1)
1019
GLD_SETUP_3D_VERTEX(v2)
1020
GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1021
GLD_SETUP_TEX0_3D(v2)
1022
GLD_SETUP_TEX1_3D(v2)
1025
gld->PB3d.pTriangles = (BYTE*)pV;
1026
gld->PB3d.nTriangles++;
1029
//---------------------------------------------------------------------------
1031
//---------------------------------------------------------------------------
1033
void gld_Quad3DFlat_DX9(
1040
GLD_SETUP_3D_VARS_TRIANGLES
1042
GLD_SETUP_3D_VERTEX(v3)
1043
GLD_SETUP_GET_FLAT_COLOUR_3D(v3)
1044
GLD_SETUP_USE_FLAT_COLOUR_3D
1045
GLD_SETUP_TEX0_3D(v3)
1046
GLD_SETUP_TEX1_3D(v3)
1049
GLD_SETUP_3D_VERTEX(v0)
1050
GLD_SETUP_USE_FLAT_COLOUR_3D
1051
GLD_SETUP_TEX0_3D(v0)
1052
GLD_SETUP_TEX1_3D(v0)
1055
GLD_SETUP_3D_VERTEX(v1)
1056
GLD_SETUP_USE_FLAT_COLOUR_3D
1057
GLD_SETUP_TEX0_3D(v1)
1058
GLD_SETUP_TEX1_3D(v1)
1061
GLD_SETUP_3D_VERTEX(v1)
1062
GLD_SETUP_USE_FLAT_COLOUR_3D
1063
GLD_SETUP_TEX0_3D(v1)
1064
GLD_SETUP_TEX1_3D(v1)
1067
GLD_SETUP_3D_VERTEX(v2)
1068
GLD_SETUP_USE_FLAT_COLOUR_3D
1069
GLD_SETUP_TEX0_3D(v2)
1070
GLD_SETUP_TEX1_3D(v2)
1073
GLD_SETUP_3D_VERTEX(v3)
1074
GLD_SETUP_USE_FLAT_COLOUR_3D
1075
GLD_SETUP_TEX0_3D(v3)
1076
GLD_SETUP_TEX1_3D(v3)
1079
gld->PB3d.pTriangles = (BYTE*)pV;
1080
gld->PB3d.nTriangles += 2;
1083
//---------------------------------------------------------------------------
1085
void gld_Quad3DSmooth_DX9(
1092
GLD_SETUP_3D_VARS_TRIANGLES
1094
GLD_SETUP_3D_VERTEX(v0)
1095
GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1096
GLD_SETUP_TEX0_3D(v0)
1097
GLD_SETUP_TEX1_3D(v0)
1100
GLD_SETUP_3D_VERTEX(v1)
1101
GLD_SETUP_SMOOTH_COLOUR_3D(v1)
1102
GLD_SETUP_TEX0_3D(v1)
1103
GLD_SETUP_TEX1_3D(v1)
1106
GLD_SETUP_3D_VERTEX(v2)
1107
GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1108
GLD_SETUP_TEX0_3D(v2)
1109
GLD_SETUP_TEX1_3D(v2)
1112
GLD_SETUP_3D_VERTEX(v2)
1113
GLD_SETUP_SMOOTH_COLOUR_3D(v2)
1114
GLD_SETUP_TEX0_3D(v2)
1115
GLD_SETUP_TEX1_3D(v2)
1118
GLD_SETUP_3D_VERTEX(v3)
1119
GLD_SETUP_SMOOTH_COLOUR_3D(v3)
1120
GLD_SETUP_TEX0_3D(v3)
1121
GLD_SETUP_TEX1_3D(v3)
1124
GLD_SETUP_3D_VERTEX(v0)
1125
GLD_SETUP_SMOOTH_COLOUR_3D(v0)
1126
GLD_SETUP_TEX0_3D(v0)
1127
GLD_SETUP_TEX1_3D(v0)
1130
gld->PB3d.pTriangles = (BYTE*)pV;
1131
gld->PB3d.nTriangles += 2;
1134
//---------------------------------------------------------------------------
1135
// Vertex setup for two-sided-lighting vertex shader
1136
//---------------------------------------------------------------------------
1140
void gld_Points2DTwoside_DX9(GLcontext *ctx, GLuint first, GLuint last)
1142
// NOTE: Two-sided lighting does not apply to Points
1145
//---------------------------------------------------------------------------
1147
void gld_Line2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1)
1149
// NOTE: Two-sided lighting does not apply to Lines
1152
//---------------------------------------------------------------------------
1154
void gld_Line2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1)
1156
// NOTE: Two-sided lighting does not apply to Lines
1159
//---------------------------------------------------------------------------
1161
void gld_Triangle2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
1165
//---------------------------------------------------------------------------
1167
void gld_Triangle2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2)
1169
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1170
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
1171
GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1172
SScontext *ss = SWSETUP_CONTEXT(ctx);
1174
DWORD dwSpecularColour;
1177
struct vertex_buffer *VB;
1178
GLchan (*vbcolor)[4];
1179
GLchan (*vbspec)[4];
1181
// Reciprocal of DepthMax
1182
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1185
swv = &ss->verts[v0];
1186
pV->Position.x = swv->win[0];
1187
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1188
pV->Position.z = swv->win[2] * ooDepthMax;
1189
pV->Position.w = swv->win[3];
1190
pV->TexUnit0.x = swv->texcoord[0][0];
1191
pV->TexUnit0.y = swv->texcoord[0][1];
1192
pV->TexUnit1.x = swv->texcoord[1][0];
1193
pV->TexUnit1.y = swv->texcoord[1][1];
1194
pV->FrontDiffuse = GLD_COLOUR;
1195
pV->FrontSpecular = GLD_SPECULAR;
1199
swv = &ss->verts[v1];
1200
pV->Position.x = swv->win[0];
1201
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1202
pV->Position.z = swv->win[2] * ooDepthMax;
1203
pV->Position.w = swv->win[3];
1204
pV->TexUnit0.x = swv->texcoord[0][0];
1205
pV->TexUnit0.y = swv->texcoord[0][1];
1206
pV->TexUnit1.x = swv->texcoord[1][0];
1207
pV->TexUnit1.y = swv->texcoord[1][1];
1208
pV->FrontDiffuse = GLD_COLOUR;
1209
pV->FrontSpecular = GLD_SPECULAR;
1213
swv = &ss->verts[v2];
1214
pV->Position.x = swv->win[0];
1215
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1216
pV->Position.z = swv->win[2] * ooDepthMax;
1217
pV->Position.w = swv->win[3];
1218
pV->TexUnit0.x = swv->texcoord[0][0];
1219
pV->TexUnit0.y = swv->texcoord[0][1];
1220
pV->TexUnit1.x = swv->texcoord[1][0];
1221
pV->TexUnit1.y = swv->texcoord[1][1];
1222
pV->FrontDiffuse = GLD_COLOUR;
1223
pV->FrontSpecular = GLD_SPECULAR;
1226
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1227
gld->PBtwosidelight.nTriangles++;
1230
//---------------------------------------------------------------------------
1232
void gld_Quad2DFlatTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1234
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1235
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
1236
GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1237
SScontext *ss = SWSETUP_CONTEXT(ctx);
1239
DWORD dwSpecularColour;
1242
struct vertex_buffer *VB;
1243
GLchan (*vbcolor)[4];
1244
GLchan (*vbspec)[4];
1246
// Reciprocal of DepthMax
1247
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1250
swv = &ss->verts[v0];
1251
pV->Position.x = swv->win[0];
1252
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1253
pV->Position.z = swv->win[2] * ooDepthMax;
1254
pV->Position.w = swv->win[3];
1255
pV->TexUnit0.x = swv->texcoord[0][0];
1256
pV->TexUnit0.y = swv->texcoord[0][1];
1257
pV->TexUnit1.x = swv->texcoord[1][0];
1258
pV->TexUnit1.y = swv->texcoord[1][1];
1259
pV->FrontDiffuse = GLD_COLOUR;
1260
pV->FrontSpecular = GLD_SPECULAR;
1264
swv = &ss->verts[v1];
1265
pV->Position.x = swv->win[0];
1266
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1267
pV->Position.z = swv->win[2] * ooDepthMax;
1268
pV->Position.w = swv->win[3];
1269
pV->TexUnit0.x = swv->texcoord[0][0];
1270
pV->TexUnit0.y = swv->texcoord[0][1];
1271
pV->TexUnit1.x = swv->texcoord[1][0];
1272
pV->TexUnit1.y = swv->texcoord[1][1];
1273
pV->FrontDiffuse = GLD_COLOUR;
1274
pV->FrontSpecular = GLD_SPECULAR;
1278
swv = &ss->verts[v2];
1279
pV->Position.x = swv->win[0];
1280
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1281
pV->Position.z = swv->win[2] * ooDepthMax;
1282
pV->Position.w = swv->win[3];
1283
pV->TexUnit0.x = swv->texcoord[0][0];
1284
pV->TexUnit0.y = swv->texcoord[0][1];
1285
pV->TexUnit1.x = swv->texcoord[1][0];
1286
pV->TexUnit1.y = swv->texcoord[1][1];
1287
pV->FrontDiffuse = GLD_COLOUR;
1288
pV->FrontSpecular = GLD_SPECULAR;
1292
swv = &ss->verts[v2];
1293
pV->Position.x = swv->win[0];
1294
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1295
pV->Position.z = swv->win[2] * ooDepthMax;
1296
pV->Position.w = swv->win[3];
1297
pV->TexUnit0.x = swv->texcoord[0][0];
1298
pV->TexUnit0.y = swv->texcoord[0][1];
1299
pV->TexUnit1.x = swv->texcoord[1][0];
1300
pV->TexUnit1.y = swv->texcoord[1][1];
1301
pV->FrontDiffuse = GLD_COLOUR;
1302
pV->FrontSpecular = GLD_SPECULAR;
1306
swv = &ss->verts[v3];
1307
pV->Position.x = swv->win[0];
1308
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1309
pV->Position.z = swv->win[2] * ooDepthMax;
1310
pV->Position.w = swv->win[3];
1311
pV->TexUnit0.x = swv->texcoord[0][0];
1312
pV->TexUnit0.y = swv->texcoord[0][1];
1313
pV->TexUnit1.x = swv->texcoord[1][0];
1314
pV->TexUnit1.y = swv->texcoord[1][1];
1315
pV->FrontDiffuse = GLD_COLOUR;
1316
pV->FrontSpecular = GLD_SPECULAR;
1320
swv = &ss->verts[v0];
1321
pV->Position.x = swv->win[0];
1322
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1323
pV->Position.z = swv->win[2] * ooDepthMax;
1324
pV->Position.w = swv->win[3];
1325
pV->TexUnit0.x = swv->texcoord[0][0];
1326
pV->TexUnit0.y = swv->texcoord[0][1];
1327
pV->TexUnit1.x = swv->texcoord[1][0];
1328
pV->TexUnit1.y = swv->texcoord[1][1];
1329
pV->FrontDiffuse = GLD_COLOUR;
1330
pV->FrontSpecular = GLD_SPECULAR;
1333
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1334
gld->PBtwosidelight.nTriangles += 2;
1337
//---------------------------------------------------------------------------
1339
void gld_Quad2DSmoothTwoside_DX9(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1341
GLD_context *gldCtx = GLD_GET_CONTEXT(ctx);
1342
GLD_driver_dx9 *gld = GLD_GET_DX9_DRIVER(gldCtx);
1343
GLD_TWOSIDED_VERTEX *pV = (GLD_TWOSIDED_VERTEX*)gld->PBtwosidelight.pTriangles;
1344
SScontext *ss = SWSETUP_CONTEXT(ctx);
1346
DWORD dwSpecularColour;
1349
struct vertex_buffer *VB;
1350
GLchan (*vbcolor)[4];
1351
GLchan (*vbspec)[4];
1353
// Reciprocal of DepthMax
1354
const float ooDepthMax = 1.0f / ctx->DepthMaxF;
1357
swv = &ss->verts[v0];
1358
pV->Position.x = swv->win[0];
1359
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1360
pV->Position.z = swv->win[2] * ooDepthMax;
1361
pV->Position.w = swv->win[3];
1362
pV->TexUnit0.x = swv->texcoord[0][0];
1363
pV->TexUnit0.y = swv->texcoord[0][1];
1364
pV->TexUnit1.x = swv->texcoord[1][0];
1365
pV->TexUnit1.y = swv->texcoord[1][1];
1366
pV->FrontDiffuse = GLD_COLOUR;
1367
pV->FrontSpecular = GLD_SPECULAR;
1371
swv = &ss->verts[v1];
1372
pV->Position.x = swv->win[0];
1373
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1374
pV->Position.z = swv->win[2] * ooDepthMax;
1375
pV->Position.w = swv->win[3];
1376
pV->TexUnit0.x = swv->texcoord[0][0];
1377
pV->TexUnit0.y = swv->texcoord[0][1];
1378
pV->TexUnit1.x = swv->texcoord[1][0];
1379
pV->TexUnit1.y = swv->texcoord[1][1];
1380
pV->FrontDiffuse = GLD_COLOUR;
1381
pV->FrontSpecular = GLD_SPECULAR;
1385
swv = &ss->verts[v2];
1386
pV->Position.x = swv->win[0];
1387
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1388
pV->Position.z = swv->win[2] * ooDepthMax;
1389
pV->Position.w = swv->win[3];
1390
pV->TexUnit0.x = swv->texcoord[0][0];
1391
pV->TexUnit0.y = swv->texcoord[0][1];
1392
pV->TexUnit1.x = swv->texcoord[1][0];
1393
pV->TexUnit1.y = swv->texcoord[1][1];
1394
pV->FrontDiffuse = GLD_COLOUR;
1395
pV->FrontSpecular = GLD_SPECULAR;
1399
swv = &ss->verts[v2];
1400
pV->Position.x = swv->win[0];
1401
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1402
pV->Position.z = swv->win[2] * ooDepthMax;
1403
pV->Position.w = swv->win[3];
1404
pV->TexUnit0.x = swv->texcoord[0][0];
1405
pV->TexUnit0.y = swv->texcoord[0][1];
1406
pV->TexUnit1.x = swv->texcoord[1][0];
1407
pV->TexUnit1.y = swv->texcoord[1][1];
1408
pV->FrontDiffuse = GLD_COLOUR;
1409
pV->FrontSpecular = GLD_SPECULAR;
1413
swv = &ss->verts[v3];
1414
pV->Position.x = swv->win[0];
1415
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1416
pV->Position.z = swv->win[2] * ooDepthMax;
1417
pV->Position.w = swv->win[3];
1418
pV->TexUnit0.x = swv->texcoord[0][0];
1419
pV->TexUnit0.y = swv->texcoord[0][1];
1420
pV->TexUnit1.x = swv->texcoord[1][0];
1421
pV->TexUnit1.y = swv->texcoord[1][1];
1422
pV->FrontDiffuse = GLD_COLOUR;
1423
pV->FrontSpecular = GLD_SPECULAR;
1427
swv = &ss->verts[v0];
1428
pV->Position.x = swv->win[0];
1429
pV->Position.y = GLD_FLIP_Y(swv->win[1]);
1430
pV->Position.z = swv->win[2] * ooDepthMax;
1431
pV->Position.w = swv->win[3];
1432
pV->TexUnit0.x = swv->texcoord[0][0];
1433
pV->TexUnit0.y = swv->texcoord[0][1];
1434
pV->TexUnit1.x = swv->texcoord[1][0];
1435
pV->TexUnit1.y = swv->texcoord[1][1];
1436
pV->FrontDiffuse = GLD_COLOUR;
1437
pV->FrontSpecular = GLD_SPECULAR;
1440
gld->PBtwosidelight.pTriangles = (BYTE*)pV;
1441
gld->PBtwosidelight.nTriangles += 2;
1444
//---------------------------------------------------------------------------