Update the recent Model3 changes for the new rgbaint_t class, nw

This commit is contained in:
therealmogminer@gmail.com 2015-06-23 21:28:07 +02:00
parent 1bef19e984
commit d0c5740466

View File

@ -2266,19 +2266,17 @@ void model3_renderer::draw_scanline_solid(INT32 scanline, const extent_t &extent
float in = extent.param[1].start; float in = extent.param[1].start;
float inz = extent.param[1].dpdx; float inz = extent.param[1].dpdx;
rgbint color; rgbaint_t color(polydata.color);
rgb_to_rgbint(&color, polydata.color);
for (int x = extent.startx; x < extent.stopx; x++) for (int x = extent.startx; x < extent.stopx; x++)
{ {
if (z <= zb[x]) if (z <= zb[x])
{ {
rgbint c = color; rgbaint_t c(color);
int ii = (int)(in);
rgbint_scale_immediate_and_clamp(&c, ii); c.scale_imm_and_clamp((int)in);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&c); fb[x] = 0xff000000 | c.to_rgba_clamp();
zb[x] = z; zb[x] = z;
} }
@ -2298,8 +2296,7 @@ void model3_renderer::draw_scanline_solid_trans(INT32 scanline, const extent_t &
float in = extent.param[1].start; float in = extent.param[1].start;
float inz = extent.param[1].dpdx; float inz = extent.param[1].dpdx;
rgbint color; rgbaint_t color(polydata.color);
rgb_to_rgbint(&color, polydata.color);
int trans = (polydata.transparency << 3) | (polydata.transparency >> 2); int trans = (polydata.transparency << 3) | (polydata.transparency >> 2);
@ -2307,21 +2304,16 @@ void model3_renderer::draw_scanline_solid_trans(INT32 scanline, const extent_t &
{ {
if (z <= zb[x]) if (z <= zb[x])
{ {
rgbint c = color; rgbaint_t c(color);
int ii = (int)(in); c.scale_imm_and_clamp((int)in);
rgbint_scale_immediate_and_clamp(&c, ii);
if (trans != 0xff) if (trans != 0xff)
{ {
rgbint fbcolor; c.blend(rgbaint_t(fb[x]), trans);
UINT32 orig = fb[x];
rgb_to_rgbint(&fbcolor, orig);
rgbint_blend(&c, &fbcolor, trans);
} }
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&c); fb[x] = 0xff000000 | c.to_rgba_clamp();
} }
in += inz; in += inz;
@ -2387,15 +2379,13 @@ void model3_renderer::draw_scanline_tex(INT32 scanline, const extent_t &extent,
if (z <= zb[x]) if (z <= zb[x])
{ {
UINT32 texel; UINT32 texel;
TEX_FETCH(); // TODO fetch rgbint instead TEX_FETCH(); // TODO fetch rgbaint_t instead
rgbint color; rgbaint_t color(texel);
rgb_to_rgbint(&color, texel);
int ii = (int)(in); color.scale_imm_and_clamp((int)in);
rgbint_scale_immediate_and_clamp(&color, ii);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&color); fb[x] = 0xff000000 | color.to_rgba_clamp();
zb[x] = z; zb[x] = z;
} }
@ -2428,25 +2418,21 @@ void model3_renderer::draw_scanline_tex_colormod(INT32 scanline, const extent_t
UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1; UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
UINT32 width = 6 + texture->width; UINT32 width = 6 + texture->width;
rgbint polycolor; rgbaint_t polycolor(polydata.color);
rgb_to_rgbint(&polycolor, polydata.color);
for (int x = extent.startx; x < extent.stopx; x++) for (int x = extent.startx; x < extent.stopx; x++)
{ {
if (z <= zb[x]) if (z <= zb[x])
{ {
UINT32 texel; UINT32 texel;
TEX_FETCH(); // TODO fetch rgbint instead TEX_FETCH(); // TODO fetch rgbaint_t instead
rgbint color; rgbaint_t color(texel);
rgb_to_rgbint(&color, texel);
rgbint_scale_channel_and_clamp(&color, &polycolor); color.scale_and_clamp(polycolor);
color.scale_imm_and_clamp((int)in);
int ii = (int)(in); fb[x] = 0xff000000 | color.to_rgba_clamp();
rgbint_scale_immediate_and_clamp(&color, ii);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&color);
zb[x] = z; zb[x] = z;
} }
@ -2479,8 +2465,7 @@ void model3_renderer::draw_scanline_tex_contour(INT32 scanline, const extent_t &
UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1; UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
UINT32 width = 6 + texture->width; UINT32 width = 6 + texture->width;
rgbint polycolor; rgbaint_t polycolor(polydata.color);
rgb_to_rgbint(&polycolor, polydata.color);
for (int x = extent.startx; x < extent.stopx; x++) for (int x = extent.startx; x < extent.stopx; x++)
{ {
@ -2492,20 +2477,13 @@ void model3_renderer::draw_scanline_tex_contour(INT32 scanline, const extent_t &
UINT32 fa = texel >> 24; UINT32 fa = texel >> 24;
if (fa >= 0xf8) if (fa >= 0xf8)
{ {
rgbint color; rgbaint_t color(texel);
rgb_to_rgbint(&color, texel);
rgbint_scale_channel_and_clamp(&color, &polycolor); color.scale_and_clamp(polycolor);
color.scale_imm_and_clamp((int)in);
color.blend(rgbaint_t(fb[x]), fa);
int ii = (int)(in); fb[x] = 0xff000000 | color.to_rgba_clamp();
rgbint_scale_immediate_and_clamp(&color, ii);
rgbint fbcolor;
UINT32 orig = fb[x];
rgb_to_rgbint(&fbcolor, orig);
rgbint_blend(&color, &fbcolor, fa);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&color);
zb[x] = z; zb[x] = z;
} }
} }
@ -2541,8 +2519,7 @@ void model3_renderer::draw_scanline_tex_trans(INT32 scanline, const extent_t &ex
UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1; UINT32 vmask = (((polydata.texture_param & TRI_PARAM_TEXTURE_MIRROR_V) ? 64 : 32) << texture->height) - 1;
UINT32 width = 6 + texture->width; UINT32 width = 6 + texture->width;
rgbint polycolor; rgbaint_t polycolor(polydata.color);
rgb_to_rgbint(&polycolor, polydata.color);
for (int x = extent.startx; x < extent.stopx; x++) for (int x = extent.startx; x < extent.stopx; x++)
{ {
@ -2551,21 +2528,13 @@ void model3_renderer::draw_scanline_tex_trans(INT32 scanline, const extent_t &ex
UINT32 texel; UINT32 texel;
TEX_FETCH(); TEX_FETCH();
rgbint color; rgbaint_t color(texel);
rgb_to_rgbint(&color, texel);
rgbint_scale_channel_and_clamp(&color, &polycolor); color.scale_and_clamp(polycolor);
color.scale_imm_and_clamp((int)in);
color.blend(rgbaint_t(fb[x]), trans);
int ii = (int)in; fb[x] = 0xff000000 | color.to_rgba_clamp();
rgbint_scale_immediate_and_clamp(&color, ii);
rgbint fbcolor;
UINT32 orig = fb[x];
rgb_to_rgbint(&fbcolor, orig);
rgbint_blend(&color, &fbcolor, trans);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&color);
} }
ooz += dooz; ooz += dooz;
@ -2610,19 +2579,12 @@ void model3_renderer::draw_scanline_tex_alpha(INT32 scanline, const extent_t &ex
UINT32 fa = texel >> 24; UINT32 fa = texel >> 24;
if (fa != 0) if (fa != 0)
{ {
rgbint color; rgbaint_t color(texel);
rgb_to_rgbint(&color, texel);
int ii = (int)in; color.scale_imm_and_clamp((int)in);
color.blend(rgbaint_t(fb[x]), fa);
rgbint_scale_immediate_and_clamp(&color, ii); fb[x] = 0xff000000 | color.to_rgba_clamp();
rgbint fbcolor;
UINT32 orig = fb[x];
rgb_to_rgbint(&fbcolor, orig);
rgbint_blend(&color, &fbcolor, fa);
fb[x] = 0xff000000 | rgbint_to_rgb_clamp(&color);
} }
} }