TINYGL: properly handle color for FLAT mode and lines drawing. Respect FLAT/SMOOTH mode for triangle drawing

This commit is contained in:
Pawel Kolodziejski 2014-07-05 20:54:14 +02:00
parent 26b0a7f614
commit 9a81f8997c
6 changed files with 74 additions and 117 deletions

View file

@ -801,7 +801,7 @@ void GfxTinyGL::drawEMIModelFace(const EMIModel *model, const EMIMeshFace *face)
tglEnable(TGL_TEXTURE_2D); tglEnable(TGL_TEXTURE_2D);
tglEnable(TGL_DEPTH_TEST); tglEnable(TGL_DEPTH_TEST);
tglEnable(TGL_ALPHA_TEST); tglEnable(TGL_ALPHA_TEST);
//tglEnable(GL_LIGHTING); // not apply here in TinyGL //tglEnable(TGL_LIGHTING); // not apply here in TinyGL
tglDisable(TGL_BLEND); tglDisable(TGL_BLEND);
tglDepthMask(TGL_TRUE); tglDepthMask(TGL_TRUE);
tglColor3f(1.0f, 1.0f, 1.0f); tglColor3f(1.0f, 1.0f, 1.0f);

View file

@ -209,7 +209,8 @@ static inline void updateTmp(GLContext *c, GLVertex *q, GLVertex *p0, GLVertex *
} }
if (c->texture_2d_enabled) { if (c->texture_2d_enabled) {
//NOTE: This could be implemented with operator overloading, but i'm not 100% sure that we can completely disregard Z and W components so I'm leaving it like this for now. // NOTE: This could be implemented with operator overloading,
// but i'm not 100% sure that we can completely disregard Z and W components so I'm leaving it like this for now.
q->tex_coord.X = (p0->tex_coord.X + (p1->tex_coord.X - p0->tex_coord.X) * t); q->tex_coord.X = (p0->tex_coord.X + (p1->tex_coord.X - p0->tex_coord.X) * t);
q->tex_coord.Y = (p0->tex_coord.Y + (p1->tex_coord.Y - p0->tex_coord.Y) * t); q->tex_coord.Y = (p0->tex_coord.Y + (p1->tex_coord.Y - p0->tex_coord.Y) * t);
} }
@ -397,7 +398,11 @@ void gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p
count_triangles_textured++; count_triangles_textured++;
#endif #endif
c->fb->setTexture(c->current_texture->images[0].pixmap); c->fb->setTexture(c->current_texture->images[0].pixmap);
c->fb->fillTriangleMappingPerspective(&p0->zp, &p1->zp, &p2->zp); if (c->current_shade_model == TGL_SMOOTH) {
c->fb->fillTriangleTextureMappingPerspectiveSmooth(&p0->zp, &p1->zp, &p2->zp);
} else {
c->fb->fillTriangleTextureMappingPerspectiveFlat(&p0->zp, &p1->zp, &p2->zp);
}
} else if (c->current_shade_model == TGL_SMOOTH) { } else if (c->current_shade_model == TGL_SMOOTH) {
c->fb->fillTriangleSmooth(&p0->zp, &p1->zp, &p2->zp); c->fb->fillTriangleSmooth(&p0->zp, &p1->zp, &p2->zp);
} else { } else {

View file

@ -251,9 +251,8 @@ void gl_shade_vertex(GLContext *c, GLVertex *v) {
vcoord.Z = v->ec.Z; vcoord.Z = v->ec.Z;
vcoord.normalize(); vcoord.normalize();
s.X = d.X - vcoord.X; s.X = d.X - vcoord.X;
s.Y = d.Y - vcoord.X; s.Y = d.Y - vcoord.Y;
s.Z = d.Z - vcoord.X; s.Z = d.Z - vcoord.Z;
//NOTE: this operation is rather suspicious, this code should be tested.
} else { } else {
s.X = d.X; s.X = d.X;
s.Y = d.Y; s.Y = d.Y;

View file

@ -26,15 +26,13 @@ namespace TinyGL {
#define ZB_POINT_ALPHA_MIN ( (1 << 10) ) #define ZB_POINT_ALPHA_MIN ( (1 << 10) )
#define ZB_POINT_ALPHA_MAX ( (1 << 16) - (1 << 10) ) #define ZB_POINT_ALPHA_MAX ( (1 << 16) - (1 << 10) )
#define RGB_TO_PIXEL(r, g, b) cmode.ARGBToColor(255, r, g, b) // Default to 255 alpha aka solid colour. #define RGB_TO_PIXEL(r, g, b) cmode.ARGBToColor(255, r >> 8, g >> 8, b >> 8) // Default to 255 alpha aka solid colour.
static const int DRAW_DEPTH_ONLY = 0; static const int DRAW_DEPTH_ONLY = 0;
static const int DRAW_FLAT = 1; static const int DRAW_FLAT = 1;
static const int DRAW_SMOOTH = 2; static const int DRAW_SMOOTH = 2;
static const int DRAW_MAPPING = 3; static const int DRAW_SHADOW_MASK = 3;
static const int DRAW_MAPPING_PERSPECTIVE = 4; static const int DRAW_SHADOW = 4;
static const int DRAW_SHADOW_MASK = 5;
static const int DRAW_SHADOW = 6;
extern uint8 PSZB; extern uint8 PSZB;
@ -295,13 +293,13 @@ struct FrameBuffer {
template <bool interpRGB, bool interpZ, bool depthWrite> template <bool interpRGB, bool interpZ, bool depthWrite>
void fillLineGeneric(ZBufferPoint *p1, ZBufferPoint *p2, int color); void fillLineGeneric(ZBufferPoint *p1, ZBufferPoint *p2, int color);
void fillTriangleMappingPerspective(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); void fillTriangleTextureMappingPerspectiveSmooth(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleTextureMappingPerspectiveFlat(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleDepthOnly(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); void fillTriangleDepthOnly(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleFlat(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); void fillTriangleFlat(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleSmooth(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleFlatShadowMask(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); void fillTriangleFlatShadowMask(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleFlatShadow(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2); void fillTriangleFlatShadow(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleSmooth(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void fillTriangleMapping(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2);
void plot(ZBufferPoint *p); void plot(ZBufferPoint *p);
void fillLine(ZBufferPoint *p1, ZBufferPoint *p2); void fillLine(ZBufferPoint *p1, ZBufferPoint *p2);

View file

@ -10,7 +10,7 @@ FORCEINLINE static void putPixel(FrameBuffer *buffer, int pixelOffset,
if (interpZ) { if (interpZ) {
if (buffer->compareDepth(z, *pz)) { if (buffer->compareDepth(z, *pz)) {
if (interpRGB) { if (interpRGB) {
buffer->writePixel(pixelOffset, RGB_TO_PIXEL(r >> 8, g >> 8, b >> 8)); buffer->writePixel(pixelOffset, RGB_TO_PIXEL(r, g, b));
} else { } else {
buffer->writePixel(pixelOffset, color); buffer->writePixel(pixelOffset, color);
} }
@ -20,7 +20,7 @@ FORCEINLINE static void putPixel(FrameBuffer *buffer, int pixelOffset,
} }
} else { } else {
if (interpRGB) { if (interpRGB) {
buffer->writePixel(pixelOffset, RGB_TO_PIXEL(r >> 8, g >> 8, b >> 8)); buffer->writePixel(pixelOffset, RGB_TO_PIXEL(r, g, b));
} else { } else {
buffer->writePixel(pixelOffset, color); buffer->writePixel(pixelOffset, color);
} }

View file

@ -9,24 +9,6 @@ static const int NB_INTERP = 8;
#define SAR_RND_TO_ZERO(v,n) (v / (1 << n)) #define SAR_RND_TO_ZERO(v,n) (v / (1 << n))
template <bool depthWrite>
FORCEINLINE static void putPixelMapping(FrameBuffer *buffer, int buf, unsigned int *pz,
Graphics::PixelBuffer &texture, int _a, unsigned int &z, unsigned int &t, unsigned int &s,
int &dzdx, int &dsdx, int &dtdx) {
if (buffer->compareDepth(z, pz[_a])) {
unsigned sss = (s & buffer->_textureSizeMask) >> ZB_POINT_ST_FRAC_BITS;
unsigned ttt = (t & buffer->_textureSizeMask) >> ZB_POINT_ST_FRAC_BITS;
int pixel = ttt * buffer->_textureSize + sss;
buffer->writePixel(buf + _a, texture.getRawBuffer()[pixel]);
if (depthWrite) {
pz[_a] = z;
}
}
z += dzdx;
s += dsdx;
t += dtdx;
}
template <bool depthWrite> template <bool depthWrite>
FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
unsigned int &z, int color, int &dzdx) { unsigned int &z, int color, int &dzdx) {
@ -39,16 +21,6 @@ FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int
z += dzdx; z += dzdx;
} }
template <bool depthWrite>
FORCEINLINE static void putPixelDepth(FrameBuffer *buffer, unsigned int *pz, int _a, unsigned int &z, int &dzdx) {
if (buffer->compareDepth(z, pz[_a])) {
if (depthWrite) {
pz[_a] = z;
}
}
z += dzdx;
}
template <bool depthWrite> template <bool depthWrite>
FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a,
unsigned int &z, int &tmp, unsigned int &rgb, int &dzdx, unsigned int &drgbdx) { unsigned int &z, int &tmp, unsigned int &rgb, int &dzdx, unsigned int &drgbdx) {
@ -64,7 +36,17 @@ FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned in
} }
template <bool depthWrite> template <bool depthWrite>
FORCEINLINE static void putPixelMappingPerspective(FrameBuffer *buffer, int buf, FORCEINLINE static void putPixelDepth(FrameBuffer *buffer, unsigned int *pz, int _a, unsigned int &z, int &dzdx) {
if (buffer->compareDepth(z, pz[_a])) {
if (depthWrite) {
pz[_a] = z;
}
}
z += dzdx;
}
template <bool depthWrite, bool lightsMode, bool smoothMode>
FORCEINLINE static void putPixelTextureMappingPerspective(FrameBuffer *buffer, int buf,
Graphics::PixelFormat &textureFormat, Graphics::PixelBuffer &texture, unsigned int *pz, int _a, Graphics::PixelFormat &textureFormat, Graphics::PixelBuffer &texture, unsigned int *pz, int _a,
unsigned int &z, unsigned int &t, unsigned int &s, int &tmp, unsigned int &rgba, unsigned int &a, unsigned int &z, unsigned int &t, unsigned int &s, int &tmp, unsigned int &rgba, unsigned int &a,
int &dzdx, int &dsdx, int &dtdx, unsigned int &drgbdx, unsigned int dadx) { int &dzdx, int &dsdx, int &dtdx, unsigned int &drgbdx, unsigned int dadx) {
@ -79,16 +61,18 @@ FORCEINLINE static void putPixelMappingPerspective(FrameBuffer *buffer, int buf,
c_r = (col >> textureFormat.rShift) & 0xFF; c_r = (col >> textureFormat.rShift) & 0xFF;
c_g = (col >> textureFormat.gShift) & 0xFF; c_g = (col >> textureFormat.gShift) & 0xFF;
c_b = (col >> textureFormat.bShift) & 0xFF; c_b = (col >> textureFormat.bShift) & 0xFF;
unsigned int l_a = (a / 256);
c_a = (c_a * l_a) / 256;
if (lightsMode) {
tmp = rgba & 0xF81F07E0; tmp = rgba & 0xF81F07E0;
unsigned int light = tmp | (tmp >> 16); unsigned int light = tmp | (tmp >> 16);
unsigned int l_r = (light & 0xF800) >> 8; unsigned int l_r = (light & 0xF800) >> 8;
unsigned int l_g = (light & 0x07E0) >> 3; unsigned int l_g = (light & 0x07E0) >> 3;
unsigned int l_b = (light & 0x001F) << 3; unsigned int l_b = (light & 0x001F) << 3;
unsigned int l_a = (a / 256);
c_a = (c_a * l_a) / 256;
c_r = (c_r * l_r) / 256; c_r = (c_r * l_r) / 256;
c_g = (c_g * l_g) / 256; c_g = (c_g * l_g) / 256;
c_b = (c_b * l_b) / 256; c_b = (c_b * l_b) / 256;
}
buffer->writePixel(buf + _a, c_a, c_r, c_g, c_b); buffer->writePixel(buf + _a, c_a, c_r, c_g, c_b);
if (depthWrite) { if (depthWrite) {
pz[_a] = z; pz[_a] = z;
@ -97,13 +81,16 @@ FORCEINLINE static void putPixelMappingPerspective(FrameBuffer *buffer, int buf,
z += dzdx; z += dzdx;
s += dsdx; s += dsdx;
t += dtdx; t += dtdx;
if (smoothMode) {
a += dadx; a += dadx;
rgba = (rgba + drgbdx) & (~0x00200800); rgba = (rgba + drgbdx) & (~0x00200800);
}
} }
template <bool interpRGB, bool interpZ, bool interpST, bool interpSTZ, int drawLogic, bool depthWrite> template <bool interpRGB, bool interpZ, bool interpST, bool interpSTZ, int drawLogic, bool depthWrite>
void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
Graphics::PixelBuffer texture; Graphics::PixelBuffer texture;
Graphics::PixelFormat textureFormat;
float fdzdx = 0, fndzdx = 0, ndszdx = 0, ndtzdx = 0; float fdzdx = 0, fndzdx = 0, ndszdx = 0, ndtzdx = 0;
int _drgbdx = 0; int _drgbdx = 0;
@ -256,12 +243,14 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
_drgbdx |= SAR_RND_TO_ZERO(dgdx, 5) & 0x000007FF; _drgbdx |= SAR_RND_TO_ZERO(dgdx, 5) & 0x000007FF;
_drgbdx |= (SAR_RND_TO_ZERO(dbdx, 7) << 12) & 0x001FF000; _drgbdx |= (SAR_RND_TO_ZERO(dbdx, 7) << 12) & 0x001FF000;
break; break;
case DRAW_MAPPING: default:
texture = current_texture;
break; break;
case DRAW_MAPPING_PERSPECTIVE: }
if ((interpST || interpSTZ) && (drawLogic == DRAW_FLAT || drawLogic == DRAW_SMOOTH)) {
texture = current_texture; texture = current_texture;
assert(texture.getFormat().bytesPerPixel == 4); textureFormat = texture.getFormat();
assert(textureFormat.bytesPerPixel == 4);
fdzdx = (float)dzdx; fdzdx = (float)dzdx;
fndzdx = NB_INTERP * fdzdx; fndzdx = NB_INTERP * fdzdx;
ndszdx = NB_INTERP * dszdx; ndszdx = NB_INTERP * dszdx;
@ -269,13 +258,8 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
_drgbdx = ((drdx / (1 << 6)) << 22) & 0xFFC00000; _drgbdx = ((drdx / (1 << 6)) << 22) & 0xFFC00000;
_drgbdx |= (dgdx / (1 << 5)) & 0x000007FF; _drgbdx |= (dgdx / (1 << 5)) & 0x000007FF;
_drgbdx |= ((dbdx / (1 << 7)) << 12) & 0x001FF000; _drgbdx |= ((dbdx / (1 << 7)) << 12) & 0x001FF000;
break;
default:
break;
} }
Graphics::PixelFormat textureFormat = texture.getFormat();
for (part = 0; part < 2; part++) { for (part = 0; part < 2; part++) {
if (part == 0) { if (part == 0) {
if (fz0 > 0) { if (fz0 > 0) {
@ -386,25 +370,18 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
while (nb_lines > 0) { while (nb_lines > 0) {
nb_lines--; nb_lines--;
{ {
switch (drawLogic) { if (drawLogic == DRAW_DEPTH_ONLY ||
case DRAW_DEPTH_ONLY: (drawLogic == DRAW_FLAT && !(interpST || interpSTZ))) {
case DRAW_FLAT:
case DRAW_MAPPING: {
int pp; int pp;
int n; int n;
unsigned int *pz; unsigned int *pz;
unsigned int z; unsigned int z;
unsigned int s, t;
n = (x2 >> 16) - x1; n = (x2 >> 16) - x1;
pp = pp1 + x1; pp = pp1 + x1;
if (interpZ) { if (interpZ) {
pz = pz1 + x1; pz = pz1 + x1;
z = z1; z = z1;
} }
if (interpST) {
s = s1;
t = t1;
}
while (n >= 3) { while (n >= 3) {
if (drawLogic == DRAW_DEPTH_ONLY) { if (drawLogic == DRAW_DEPTH_ONLY) {
putPixelDepth<depthWrite>(this, pz, 0, z, dzdx); putPixelDepth<depthWrite>(this, pz, 0, z, dzdx);
@ -418,12 +395,6 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
putPixelFlat<depthWrite>(this, pp, pz, 2, z, color, dzdx); putPixelFlat<depthWrite>(this, pp, pz, 2, z, color, dzdx);
putPixelFlat<depthWrite>(this, pp, pz, 3, z, color, dzdx); putPixelFlat<depthWrite>(this, pp, pz, 3, z, color, dzdx);
} }
if (drawLogic == DRAW_MAPPING) {
putPixelMapping<depthWrite>(this, pp, pz, texture, 0, z, t, s, dzdx, dsdx, dtdx);
putPixelMapping<depthWrite>(this, pp, pz, texture, 1, z, t, s, dzdx, dsdx, dtdx);
putPixelMapping<depthWrite>(this, pp, pz, texture, 2, z, t, s, dzdx, dsdx, dtdx);
putPixelMapping<depthWrite>(this, pp, pz, texture, 3, z, t, s, dzdx, dsdx, dtdx);
}
if (interpZ) { if (interpZ) {
pz += 4; pz += 4;
} }
@ -437,18 +408,13 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
if (drawLogic == DRAW_FLAT) { if (drawLogic == DRAW_FLAT) {
putPixelFlat<depthWrite>(this, pp, pz, 0, z, color, dzdx); putPixelFlat<depthWrite>(this, pp, pz, 0, z, color, dzdx);
} }
if (drawLogic == DRAW_MAPPING) {
putPixelMapping<depthWrite>(this, pp, pz, texture, 0, z, t, s, dzdx, dsdx, dtdx);
}
if (interpZ) { if (interpZ) {
pz += 1; pz += 1;
} }
pp += 1; pp += 1;
n -= 1; n -= 1;
} }
} } else if (drawLogic == DRAW_SHADOW_MASK) {
break;
case DRAW_SHADOW_MASK: {
unsigned char *pm; unsigned char *pm;
int n; int n;
@ -466,9 +432,7 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
pm += 1; pm += 1;
n -= 1; n -= 1;
} }
} } else if (drawLogic == DRAW_SHADOW) {
break;
case DRAW_SHADOW: {
unsigned char *pm; unsigned char *pm;
int n; int n;
unsigned int *pz; unsigned int *pz;
@ -508,9 +472,7 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
buf += 1; buf += 1;
n -= 1; n -= 1;
} }
} } else if (drawLogic == DRAW_SMOOTH && !(interpST || interpSTZ)) {
break;
case DRAW_SMOOTH: {
unsigned int *pz; unsigned int *pz;
int buf = pp1 + x1; int buf = pp1 + x1;
unsigned int z, rgb, drgbdx; unsigned int z, rgb, drgbdx;
@ -537,9 +499,7 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
pz += 1; pz += 1;
n -= 1; n -= 1;
} }
} } else if (interpST || interpSTZ) {
break;
case DRAW_MAPPING_PERSPECTIVE: {
unsigned int *pz; unsigned int *pz;
unsigned int s, t, z, rgb, a, drgbdx; unsigned int s, t, z, rgb, a, drgbdx;
int n; int n;
@ -572,8 +532,8 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
zinv = (float)(1.0 / fz); zinv = (float)(1.0 / fz);
} }
for (int _a = 0; _a < 8; _a++) { for (int _a = 0; _a < 8; _a++) {
putPixelMappingPerspective<depthWrite>(this, buf, textureFormat, texture, pz, _a, z, t, s, tmp, rgb, a, dzdx, putPixelTextureMappingPerspective<depthWrite, interpRGB, drawLogic == DRAW_SMOOTH>(this, buf, textureFormat, texture,
dsdx, dtdx, drgbdx, dadx); pz, _a, z, t, s, tmp, rgb, a, dzdx, dsdx, dtdx, drgbdx, dadx);
} }
pz += NB_INTERP; pz += NB_INTERP;
buf += NB_INTERP; buf += NB_INTERP;
@ -593,17 +553,13 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
} }
while (n >= 0) { while (n >= 0) {
putPixelMappingPerspective<depthWrite>(this, buf, textureFormat, texture, pz, 0, z, t, s, tmp, rgb, a, dzdx, putPixelTextureMappingPerspective<depthWrite, interpRGB, drawLogic == DRAW_SMOOTH>(this, buf, textureFormat, texture,
dsdx, dtdx, drgbdx, dadx); pz, 0, z, t, s, tmp, rgb, a, dzdx, dsdx, dtdx, drgbdx, dadx);
pz += 1; pz += 1;
buf += 1; buf += 1;
n -= 1; n -= 1;
} }
} }
break;
default:
break;
}
} }
// left edge // left edge
@ -699,27 +655,26 @@ void FrameBuffer::fillTriangleSmooth(ZBufferPoint *p0, ZBufferPoint *p1, ZBuffer
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_SMOOTH, false>(p0, p1, p2); fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_SMOOTH, false>(p0, p1, p2);
} }
void FrameBuffer::fillTriangleMapping(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { void FrameBuffer::fillTriangleTextureMappingPerspectiveSmooth(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
const bool interpZ = true;
const bool interpRGB = false;
const bool interpST = true;
const bool interpSTZ = false;
if (_depthWrite)
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_MAPPING, true>(p0, p1, p2);
else
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_MAPPING, false>(p0, p1, p2);
}
void FrameBuffer::fillTriangleMappingPerspective(ZBufferPoint *p0, ZBufferPoint *p1,
ZBufferPoint *p2) {
const bool interpZ = true; const bool interpZ = true;
const bool interpRGB = true; const bool interpRGB = true;
const bool interpST = false; const bool interpST = false;
const bool interpSTZ = true; const bool interpSTZ = true;
if (_depthWrite) if (_depthWrite)
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_MAPPING_PERSPECTIVE, true>(p0, p1, p2); fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_SMOOTH, true>(p0, p1, p2);
else else
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_MAPPING_PERSPECTIVE, false>(p0, p1, p2); fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_SMOOTH, false>(p0, p1, p2);
}
void FrameBuffer::fillTriangleTextureMappingPerspectiveFlat(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
const bool interpZ = true;
const bool interpRGB = true;
const bool interpST = false;
const bool interpSTZ = true;
if (_depthWrite)
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_FLAT, true>(p0, p1, p2);
else
fillTriangle<interpRGB, interpZ, interpST, interpSTZ, DRAW_FLAT, false>(p0, p1, p2);
} }
void FrameBuffer::fillTriangleFlatShadowMask(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { void FrameBuffer::fillTriangleFlatShadowMask(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {