Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-z64/src/rgl_geometry.cpp
2 views
1
/*
2
* z64
3
*
4
* Copyright (C) 2007 ziggy
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
**/
21
22
#include "rdp.h"
23
#include "rgl.h"
24
25
#include <SDL.h>
26
27
inline float _zscale(uint16_t z)
28
{
29
uint32_t res;
30
int e = z>>(16-3);
31
int m = (z>>2)&((1<<11)-1);
32
33
static struct {
34
int shift;
35
long add;
36
} z_format[8] = {
37
{6, 0x00000},
38
{5, 0x20000},
39
{4, 0x30000},
40
{3, 0x38000},
41
{2, 0x3c000},
42
{1, 0x3e000},
43
{0, 0x3f000},
44
{0, 0x3f800},
45
};
46
47
res = (m << z_format[e].shift) +
48
z_format[e].add;
49
return float(res)/0x3ffff;
50
}
51
52
inline float zscale(uint16_t z)
53
{
54
return float(z)/0xffff;
55
}
56
//#define zscale _zscale
57
58
float rglZscale(uint16_t z)
59
{
60
return _zscale(z);
61
}
62
63
void rglTextureRectangle(rdpTexRect_t * rect, int flip)
64
{
65
int tilenum = rect->tilenum;
66
int x1,x2,y1,y2,z;
67
int s, t;
68
int dx, dy;
69
70
// if (tilenum == 7) {
71
// LOG("Fixing tilenum from 7 to 0\n");
72
// tilenum = 0;
73
// }
74
75
x1 = (rect->xh);
76
x2 = (rect->xl);
77
y1 = (rect->yh);
78
y2 = (rect->yl);
79
s = int(rect->s)<<5;
80
t = int(rect->t)<<5;
81
82
DUMP("texrect %d x %d --> %d x %d s %d t %d flip %d\n",
83
x1, y1, x2, y2, s, t, flip);
84
85
if (RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) == RDP_CYCLE_TYPE_FILL ||
86
RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) == RDP_CYCLE_TYPE_COPY)
87
{
88
rect->dsdx /= 4;
89
//s /= 4;
90
x2 += 4;
91
y2 += 4;
92
} else {
93
x2 += 1;
94
y2 += 1;
95
}
96
97
x1 /= 4;
98
x2 /= 4;
99
y1 /= 4;
100
y2 /= 4;
101
102
if (x2 < x1) x2 = x1+1; // black gauge in SCARS (E)
103
104
int t1 = rglT1Usage(rdpState)? RGL_STRIP_TEX1:0;
105
int t2 = (rect->tilenum < 7 && rglT2Usage(rdpState))? RGL_STRIP_TEX2:0;
106
if (t1)
107
rglPrepareRendering(1, (tilenum==7 && RDP_GETOM_CYCLE_TYPE(rdpState.otherModes)==1)? 0:tilenum, y2-y1, 1);
108
if (t2)
109
rglPrepareRendering(1, tilenum+1, y2-y1, 1);
110
else if (!t1)
111
rglPrepareRendering(0, 0, 0, 1);
112
113
// TO BE REMOVED when we implement depth texture writing
114
curRBuffer->flags |= RGL_RB_HASTRIANGLES;
115
116
// TO CHECK should this before or after the rescaling above ?
117
// s -= (rdpTiles[tilenum].sl << 8);
118
// t -= (rdpTiles[tilenum].tl << 8);
119
// if (/*!tile.ms && */tile.mask_s)
120
// s &= (1<<tile.mask_s+10) - 1;
121
// if (/*!tile.mt && */tile.mask_t)
122
// t &= (1<<tile.mask_t+10) - 1;
123
124
#define XSCALE(x) (float(x))
125
#define YSCALE(y) (float(y))
126
#define ZSCALE(z) (zscale(z))
127
#define SSCALE(s) (float(s)/(1 << 10))
128
#define TSCALE(s) (float(s)/(1 << 10))
129
// #define glTexCoord2f(s, t) printf("tex %g %g\n", s, t), glTexCoord2f(s, t)
130
// #define glVertex3f(s, t, z) printf("vert %g %g %g\n", s, t, z), glVertex3f(s, t, z)
131
132
dx = x2 - x1;
133
dy = y2 - y1;
134
if (RDP_GETOM_Z_SOURCE_SEL(rdpState.otherModes))
135
z = rdpState.primitiveZ;
136
else
137
z = 0xffff;
138
// if (dump)
139
// fprintf(stderr, "fillrect cycle %d\n", other_modes.cycle_type);
140
141
rglStrip_t * strip = strips + nbStrips++;
142
rglAssert(nbStrips < MAX_STRIPS);
143
curChunk->nbStrips++;
144
rglVertex_t * vtx = vtxs + nbVtxs;
145
146
strip->flags = t1 | t2 | RGL_STRIP_ZBUFFER;
147
strip->vtxs = vtx;
148
strip->tilenum = tilenum;
149
150
float s2, tr;
151
s2 = s+int(rect->dsdx)*dx;
152
tr = t+int(rect->dtdy)*dy;
153
//LOG("%d %d\n", rect->dsdx, rect->dtdy);
154
if (0 && RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) < 2)
155
{
156
//if (rect->dsdx == (1<<10))
157
{
158
s += 1<<9;
159
s2 -= 1<<9;
160
}
161
//if (rect->dtdy == (1<<10))
162
{
163
t += 1<<9;
164
tr -= 1<<9;
165
}
166
}
167
168
if (flip) { vtx->t = SSCALE(s2); vtx->s = TSCALE(t);
169
} else { vtx->s = SSCALE(s2); vtx->t = TSCALE(t); }
170
vtx->x = XSCALE(x2); vtx->y = YSCALE(y1); vtx->z = ZSCALE(z); vtx++->w = 1;
171
if (flip) { vtx->t = SSCALE(s); vtx->s = TSCALE(t);
172
} else { vtx->s = SSCALE(s); vtx->t = TSCALE(t); }
173
vtx->x = XSCALE(x1); vtx->y = YSCALE(y1); vtx->z = ZSCALE(z); vtx++->w = 1;
174
if (flip) { vtx->t = SSCALE(s2); vtx->s = TSCALE(tr);
175
} else { vtx->s = SSCALE(s2); vtx->t = TSCALE(tr); }
176
vtx->x = XSCALE(x2); vtx->y = YSCALE(y2); vtx->z = ZSCALE(z); vtx++->w = 1;
177
if (flip) { vtx->t = SSCALE(s); vtx->s = TSCALE(tr);
178
} else { vtx->s = SSCALE(s); vtx->t = TSCALE(tr); }
179
vtx->x = XSCALE(x1); vtx->y = YSCALE(y2); vtx->z = ZSCALE(z); vtx++->w = 1;
180
181
strip->nbVtxs = vtx - strip->vtxs;
182
nbVtxs = vtx - vtxs;
183
}
184
185
void rglFillRectangle(rdpRect_t * rect)
186
{
187
int x1,x2,y1,y2,z;
188
//int s, t;
189
//int dx, dy;
190
191
rglPrepareRendering(0, 0, 0, 1);
192
DUMP("fillrect curRBuffer->flags %x %x %x\n", curRBuffer->flags, curRBuffer->addressStart, rdpZbAddress);
193
// if (/*(curRBuffer->flags & RGL_RB_DEPTH) &&*/
194
// RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) == RDP_CYCLE_TYPE_FILL &&
195
// rect->xh-4 <= rdpState.clip.xh && rect->xl+8 >= rdpState.clip.xl &&
196
// rect->yh-4 <= rdpState.clip.yh && rect->yl+8 >= rdpState.clip.yl
197
// ) {
198
// curChunk->flags |= RGL_CHUNK_CLEAR;
199
// return;
200
// }
201
202
x1 = (rect->xh / 4);
203
x2 = (rect->xl / 4);
204
y1 = (rect->yh / 4);
205
y2 = (rect->yl / 4);
206
207
if (RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) == RDP_CYCLE_TYPE_FILL ||
208
RDP_GETOM_CYCLE_TYPE(rdpState.otherModes) == RDP_CYCLE_TYPE_COPY)
209
{
210
x2 += 1;
211
y2 += 1;
212
} else {
213
//rglAssert(!(curRBuffer->flags & RGL_RB_DEPTH));
214
// x2 -= 1;
215
// y2 -= 1;
216
}
217
218
if (x2 < x1) x2 = x1+1; // black gauge in SCARS (E)
219
220
#define XSCALE(x) (float(x))
221
#define YSCALE(y) (float(y))
222
#define ZSCALE(z) (zscale(z))
223
224
if (RDP_GETOM_Z_SOURCE_SEL(rdpState.otherModes))
225
z = rdpState.primitiveZ;
226
else
227
z = 0xffff;
228
// if (dump)
229
// fprintf(stderr, "fillrect cycle %d\n", other_modes.cycle_type);
230
231
rglStrip_t * strip = strips + nbStrips++;
232
rglAssert(nbStrips < MAX_STRIPS);
233
curChunk->nbStrips++;
234
rglVertex_t * vtx = vtxs + nbVtxs;
235
236
strip->flags = RGL_STRIP_ZBUFFER;
237
strip->vtxs = vtx;
238
239
vtx->x = XSCALE(x2); vtx->y = YSCALE(y1); vtx->z = ZSCALE(z); vtx++->w = 1;
240
vtx->x = XSCALE(x1); vtx->y = YSCALE(y1); vtx->z = ZSCALE(z); vtx++->w = 1;
241
vtx->x = XSCALE(x2); vtx->y = YSCALE(y2); vtx->z = ZSCALE(z); vtx++->w = 1;
242
vtx->x = XSCALE(x1); vtx->y = YSCALE(y2); vtx->z = ZSCALE(z); vtx++->w = 1;
243
244
strip->nbVtxs = vtx - strip->vtxs;
245
nbVtxs = vtx - vtxs;
246
}
247
248
void rglTriangle(uint32_t w1, uint32_t w2, int shade, int texture, int zbuffer,
249
uint32_t * rdp_cmd)
250
{
251
int tilenum = (w1 >> 16) & 0x7;
252
// if (tilenum == 7) {
253
// LOG("Fixing tilenum from 7 to 0\n");
254
// tilenum = 0;
255
// }
256
int j;
257
int xleft, xright, xleft_inc, xright_inc;
258
//int xstart, xend;
259
int r, g, b, a, z, s, t, w;
260
int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0;
261
int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0, dsde = 0, dtde = 0, dwde = 0;
262
int flip = (w1 & 0x800000) ? 1 : 0;
263
264
int32_t yl, ym, yh;
265
int32_t xl, xm, xh;
266
int64_t dxldy, dxhdy, dxmdy;
267
uint32_t w3, w4, w5, w6, w7, w8;
268
269
uint32_t * shade_base = rdp_cmd + 8;
270
uint32_t * texture_base = rdp_cmd + 8;
271
uint32_t * zbuffer_base = rdp_cmd + 8;
272
273
int t1 = (texture && rglT1Usage(rdpState))? RGL_STRIP_TEX1:0;
274
int t2 = (texture && tilenum < 7 && rglT2Usage(rdpState))? RGL_STRIP_TEX2:0;
275
if (t1)
276
rglPrepareRendering(1, (tilenum==7 && RDP_GETOM_CYCLE_TYPE(rdpState.otherModes)==1)? 0:tilenum, 0, zbuffer);
277
if (t2)
278
rglPrepareRendering(1, tilenum+1, 0, zbuffer);
279
else if (!t1)
280
rglPrepareRendering(0, 0, 0, zbuffer);
281
282
curRBuffer->flags |= RGL_RB_HASTRIANGLES;
283
284
if (shade)
285
{
286
texture_base += 16;
287
zbuffer_base += 16;
288
}
289
if (texture)
290
{
291
zbuffer_base += 16;
292
}
293
294
w3 = rdp_cmd[2];
295
w4 = rdp_cmd[3];
296
w5 = rdp_cmd[4];
297
w6 = rdp_cmd[5];
298
w7 = rdp_cmd[6];
299
w8 = rdp_cmd[7];
300
301
yl = (w1 & 0x3fff);
302
ym = ((w2 >> 16) & 0x3fff);
303
yh = ((w2 >> 0) & 0x3fff);
304
xl = (int32_t)(w3);
305
xh = (int32_t)(w5);
306
xm = (int32_t)(w7);
307
dxldy = (int32_t)(w4);
308
dxhdy = (int32_t)(w6);
309
dxmdy = (int32_t)(w8);
310
311
if (yl & (0x800<<2)) yl |= 0xfffff000<<2;
312
if (ym & (0x800<<2)) ym |= 0xfffff000<<2;
313
if (yh & (0x800<<2)) yh |= 0xfffff000<<2;
314
315
yh &= ~3;
316
317
r = 0xff; g = 0xff; b = 0xff; a = 0xff; z = 0xffff0000; s = 0; t = 0; w = 0x30000;
318
319
if (shade)
320
{
321
r = (shade_base[0] & 0xffff0000) | ((shade_base[+4 ] >> 16) & 0x0000ffff);
322
g = ((shade_base[0 ] << 16) & 0xffff0000) | (shade_base[4 ] & 0x0000ffff);
323
b = (shade_base[1 ] & 0xffff0000) | ((shade_base[5 ] >> 16) & 0x0000ffff);
324
a = ((shade_base[1 ] << 16) & 0xffff0000) | (shade_base[5 ] & 0x0000ffff);
325
drdx = (shade_base[2 ] & 0xffff0000) | ((shade_base[6 ] >> 16) & 0x0000ffff);
326
dgdx = ((shade_base[2 ] << 16) & 0xffff0000) | (shade_base[6 ] & 0x0000ffff);
327
dbdx = (shade_base[3 ] & 0xffff0000) | ((shade_base[7 ] >> 16) & 0x0000ffff);
328
dadx = ((shade_base[3 ] << 16) & 0xffff0000) | (shade_base[7 ] & 0x0000ffff);
329
drde = (shade_base[8 ] & 0xffff0000) | ((shade_base[12] >> 16) & 0x0000ffff);
330
dgde = ((shade_base[8 ] << 16) & 0xffff0000) | (shade_base[12] & 0x0000ffff);
331
dbde = (shade_base[9 ] & 0xffff0000) | ((shade_base[13] >> 16) & 0x0000ffff);
332
dade = ((shade_base[9 ] << 16) & 0xffff0000) | (shade_base[13] & 0x0000ffff);
333
}
334
if (texture)
335
{
336
s = (texture_base[0 ] & 0xffff0000) | ((texture_base[4 ] >> 16) & 0x0000ffff);
337
t = ((texture_base[0 ] << 16) & 0xffff0000) | (texture_base[4 ] & 0x0000ffff);
338
w = (texture_base[1 ] & 0xffff0000) | ((texture_base[5 ] >> 16) & 0x0000ffff);
339
dsdx = (texture_base[2 ] & 0xffff0000) | ((texture_base[6 ] >> 16) & 0x0000ffff);
340
dtdx = ((texture_base[2 ] << 16) & 0xffff0000) | (texture_base[6 ] & 0x0000ffff);
341
dwdx = (texture_base[3 ] & 0xffff0000) | ((texture_base[7 ] >> 16) & 0x0000ffff);
342
dsde = (texture_base[8 ] & 0xffff0000) | ((texture_base[12] >> 16) & 0x0000ffff);
343
dtde = ((texture_base[8 ] << 16) & 0xffff0000) | (texture_base[12] & 0x0000ffff);
344
dwde = (texture_base[9 ] & 0xffff0000) | ((texture_base[13] >> 16) & 0x0000ffff);
345
}
346
if (zbuffer)
347
{
348
//rglAssert(!(curRBuffer->flags & RGL_RB_DEPTH));
349
350
z = zbuffer_base[0];
351
dzdx = zbuffer_base[1];
352
dzde = zbuffer_base[2];
353
}
354
355
xh <<= 2; xm <<= 2; xl <<= 2;
356
r <<= 2; g <<= 2; b <<= 2; a <<= 2;
357
dsde >>= 2; dtde >>= 2; dsdx >>= 2; dtdx >>= 2;
358
dzdx >>= 2; dzde >>= 2;
359
dwdx >>= 2; dwde >>= 2;
360
361
362
// #define tile rdpTiles[tilenum]
363
// s -= (rdpTiles[tilenum].sl << 8);
364
// t -= (rdpTiles[tilenum].tl << 8);
365
// if (/*!tile.ms && */tile.mask_s)
366
// s &= (1<<tile.mask_s+10) - 1;
367
// if (/*!tile.mt && */tile.mask_t)
368
// t &= (1<<tile.mask_t+10) - 1;
369
// #undef tile
370
371
372
xleft = xm;
373
xright = xh;
374
xleft_inc = dxmdy;
375
xright_inc = dxhdy;
376
377
while (yh<ym &&
378
!((!flip && xleft < xright+0x10000) ||
379
(flip && xleft > xright-0x10000))) {
380
xleft += xleft_inc; xright += xright_inc;
381
s += dsde; t += dtde; w += dwde;
382
r += drde; g += dgde; b += dbde; a += dade;
383
z += dzde;
384
yh++;
385
}
386
387
j = ym-yh;
388
//rglAssert(j >= 0);
389
#undef XSCALE
390
#undef YSCALE
391
#undef ZSCALE
392
#undef SSCALE
393
#undef TSCALE
394
#define XSCALE(x) (float(x)/(1<<18))
395
#define YSCALE(y) (float(y)/(1<<2))
396
#define ZSCALE(z) (RDP_GETOM_Z_SOURCE_SEL(rdpState.otherModes)? zscale(rdpState.primitiveZ) : zscale((z)>>16))
397
#define WSCALE(z) 1.0f/(RDP_GETOM_PERSP_TEX_EN(rdpState.otherModes)? (float(uint32_t(z) + 0x10000)/0xffff0000) : 1.0f)
398
//#define WSCALE(w) (RDP_GETOM_PERSP_TEX_EN(rdpState.otherModes)? 65536.0f*65536.0f/float((w+ 0x10000)) : 1.0f)
399
#define CSCALE(c) (((c)>0x3ff0000? 0x3ff0000:((c)<0? 0 : (c)))>>18)
400
#define _PERSP(w) ( w )
401
#define PERSP(s, w) ( ((int64_t)(s) << 20) / (_PERSP(w)? _PERSP(w):1) )
402
#define SSCALE(s, _w) (RDP_GETOM_PERSP_TEX_EN(rdpState.otherModes)? float(PERSP(s, _w))/(1 << 10) : float(s)/(1<<21))
403
#define TSCALE(s, w) (RDP_GETOM_PERSP_TEX_EN(rdpState.otherModes)? float(PERSP(s, w))/(1 << 10) : float(s)/(1<<21))
404
405
rglStrip_t * strip = strips + nbStrips++;
406
rglAssert(nbStrips < MAX_STRIPS);
407
curChunk->nbStrips++;
408
rglVertex_t * vtx = vtxs + nbVtxs;
409
410
strip->flags = (shade? RGL_STRIP_SHADE : 0) | t1 | t2
411
| RGL_STRIP_ZBUFFER;
412
//| (zbuffer? RGL_STRIP_ZBUFFER : 0);
413
strip->vtxs = vtx;
414
strip->tilenum = tilenum;
415
416
//int sw;
417
if (j > 0)
418
{
419
int dx = ((xleft-xright)>>16);
420
if ((!flip && xleft < xright) ||
421
(flip/* && xleft > xright*/))
422
{
423
if (shade) {
424
vtx->r = CSCALE(r+drdx*dx);
425
vtx->g = CSCALE(g+dgdx*dx);
426
vtx->b = CSCALE(b+dbdx*dx);
427
vtx->a = CSCALE(a+dadx*dx);
428
}
429
if (texture) {
430
vtx->s = SSCALE(s+dsdx*dx, w+dwdx*dx);
431
vtx->t = TSCALE(t+dtdx*dx, w+dwdx*dx);
432
}
433
vtx->x = XSCALE(xleft);
434
vtx->y = YSCALE(yh);
435
vtx->z = ZSCALE(z+dzdx*dx);
436
vtx->w = WSCALE(w+dwdx*dx);
437
vtx++;
438
}
439
if ((!flip/* && xleft < xright*/) ||
440
(flip && xleft > xright))
441
{
442
if (shade) {
443
vtx->r = CSCALE(r);
444
vtx->g = CSCALE(g);
445
vtx->b = CSCALE(b);
446
vtx->a = CSCALE(a);
447
}
448
if (texture) {
449
vtx->s = SSCALE(s, w);
450
vtx->t = TSCALE(t, w);
451
}
452
vtx->x = XSCALE(xright);
453
vtx->y = YSCALE(yh);
454
vtx->z = ZSCALE(z);
455
vtx->w = WSCALE(w);
456
vtx++;
457
}
458
}
459
xleft += xleft_inc*j; xright += xright_inc*j;
460
s += dsde*j; t += dtde*j; w += dwde*j;
461
r += drde*j; g += dgde*j; b += dbde*j; a += dade*j;
462
z += dzde*j;
463
// render ...
464
465
xleft = xl;
466
467
//if (yl-ym > 0)
468
{
469
int dx = ((xleft-xright)>>16);
470
if ((!flip && xleft <= xright) ||
471
(flip/* && xleft >= xright*/))
472
{
473
if (shade) {
474
vtx->r = CSCALE(r+drdx*dx);
475
vtx->g = CSCALE(g+dgdx*dx);
476
vtx->b = CSCALE(b+dbdx*dx);
477
vtx->a = CSCALE(a+dadx*dx);
478
}
479
if (texture) {
480
vtx->s = SSCALE(s+dsdx*dx, w+dwdx*dx);
481
vtx->t = TSCALE(t+dtdx*dx, w+dwdx*dx);
482
}
483
vtx->x = XSCALE(xleft);
484
vtx->y = YSCALE(ym);
485
vtx->z = ZSCALE(z+dzdx*dx);
486
vtx->w = WSCALE(w+dwdx*dx);
487
vtx++;
488
}
489
if ((!flip/* && xleft <= xright*/) ||
490
(flip && xleft >= xright))
491
{
492
if (shade) {
493
vtx->r = CSCALE(r);
494
vtx->g = CSCALE(g);
495
vtx->b = CSCALE(b);
496
vtx->a = CSCALE(a);
497
}
498
if (texture) {
499
vtx->s = SSCALE(s, w);
500
vtx->t = TSCALE(t, w);
501
}
502
vtx->x = XSCALE(xright);
503
vtx->y = YSCALE(ym);
504
vtx->z = ZSCALE(z);
505
vtx->w = WSCALE(w);
506
vtx++;
507
}
508
}
509
xleft_inc = dxldy;
510
xright_inc = dxhdy;
511
512
j = yl-ym;
513
//rglAssert(j >= 0);
514
//j--; // ?
515
xleft += xleft_inc*j; xright += xright_inc*j;
516
s += dsde*j; t += dtde*j; w += dwde*j;
517
r += drde*j; g += dgde*j; b += dbde*j; a += dade*j;
518
z += dzde*j;
519
520
while (yl>ym &&
521
!((!flip && xleft < xright+0x10000) ||
522
(flip && xleft > xright-0x10000))) {
523
xleft -= xleft_inc; xright -= xright_inc;
524
s -= dsde; t -= dtde; w -= dwde;
525
r -= drde; g -= dgde; b -= dbde; a -= dade;
526
z -= dzde;
527
j--;
528
yl--;
529
}
530
531
// render ...
532
if (j >= 0) {
533
int dx = ((xleft-xright)>>16);
534
if ((!flip && xleft <= xright) ||
535
(flip/* && xleft >= xright*/))
536
{
537
if (shade) {
538
vtx->r = CSCALE(r+drdx*dx);
539
vtx->g = CSCALE(g+dgdx*dx);
540
vtx->b = CSCALE(b+dbdx*dx);
541
vtx->a = CSCALE(a+dadx*dx);
542
}
543
if (texture) {
544
vtx->s = SSCALE(s+dsdx*dx, w+dwdx*dx);
545
vtx->t = TSCALE(t+dtdx*dx, w+dwdx*dx);
546
}
547
vtx->x = XSCALE(xleft);
548
vtx->y = YSCALE(yl);
549
vtx->z = ZSCALE(z+dzdx*dx);
550
vtx->w = WSCALE(w+dwdx*dx);
551
vtx++;
552
}
553
if ((!flip/* && xleft <= xright*/) ||
554
(flip && xleft >= xright))
555
{
556
if (shade) {
557
vtx->r = CSCALE(r);
558
vtx->g = CSCALE(g);
559
vtx->b = CSCALE(b);
560
vtx->a = CSCALE(a);
561
}
562
if (texture) {
563
vtx->s = SSCALE(s, w);
564
vtx->t = TSCALE(t, w);
565
}
566
vtx->x = XSCALE(xright);
567
vtx->y = YSCALE(yl);
568
vtx->z = ZSCALE(z);
569
vtx->w = WSCALE(w);
570
vtx++;
571
}
572
}
573
574
strip->nbVtxs = vtx - strip->vtxs;
575
nbVtxs = vtx - vtxs;
576
}
577
578