Force all drawing to go through DrawerStyle

This commit is contained in:
Magnus Norddahl 2017-01-28 16:36:39 +01:00
parent 2f9453bc86
commit 4afac0f2cc
21 changed files with 145 additions and 96 deletions

View File

@ -137,7 +137,7 @@ namespace swrenderer
SWTruecolorDrawers tc_drawers;
}
SWPixelFormatDrawers *R_Drawers()
SWPixelFormatDrawers *DrawerStyle::Drawers() const
{
return active_drawers;
}
@ -235,7 +235,7 @@ namespace swrenderer
}
}
void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade)
void DrawerStyle::SetColorMapLight(FSWColormap *base_colormap, float light, int shade)
{
using namespace drawerargs;
@ -260,7 +260,7 @@ namespace swrenderer
}
}
void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade)
void DrawerStyle::SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade)
{
using namespace drawerargs;
@ -285,7 +285,7 @@ namespace swrenderer
}
}
void R_SetTranslationMap(lighttable_t *translation)
void DrawerStyle::SetTranslationMap(lighttable_t *translation)
{
using namespace drawerargs;
@ -311,7 +311,7 @@ namespace swrenderer
}
}
void R_SetSpanTexture(FTexture *tex)
void DrawerStyle::SetSpanTexture(FTexture *tex)
{
using namespace drawerargs;
@ -331,9 +331,9 @@ namespace swrenderer
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
}
void R_SetSpanColormap(FDynamicColormap *colormap, int shade)
void DrawerStyle::SetSpanColormap(FDynamicColormap *colormap, int shade)
{
R_SetDSColorMapLight(colormap, 0, shade);
SetDSColorMapLight(colormap, 0, shade);
}
void R_UpdateFuzzPos()
@ -419,7 +419,7 @@ namespace swrenderer
else if (dc_iscale < 0)
dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale));
(R_Drawers()->*colfunc)();
(Drawers()->*colfunc)();
}
span++;
}
@ -536,7 +536,7 @@ namespace swrenderer
double v = ((dc_yl + 0.5 - sprtopscreen) / spryscale) / tex->GetHeight();
dc_texturefrac = (uint32_t)(v * (1 << 30));
(R_Drawers()->*colfunc)();
(Drawers()->*colfunc)();
}
span++;
}
@ -750,11 +750,11 @@ namespace swrenderer
{
fixed_t shade = shadedlightshade;
if (shade == 0) FIXEDLIGHT2SHADE(cameraLight->fixedlightlev);
R_SetColorMapLight(basecolormap, 0, shade);
SetColorMapLight(basecolormap, 0, shade);
}
else
{
R_SetColorMapLight(basecolormap, 0, shadedlightshade);
SetColorMapLight(basecolormap, 0, shadedlightshade);
}
return true;
}
@ -781,7 +781,7 @@ namespace swrenderer
// dc_srccolor is used by the R_Fill* routines. It is premultiplied
// with the alpha.
dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff;
R_SetColorMapLight(&identitycolormap, 0, 0);
SetColorMapLight(&identitycolormap, 0, 0);
}
if (!DrawerStyle::SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags))

View File

@ -159,8 +159,6 @@ namespace swrenderer
typedef void(SWPixelFormatDrawers::*DrawerFunc)();
SWPixelFormatDrawers *R_Drawers();
void R_InitColumnDrawers();
void R_InitShadeMaps();
void R_InitFuzzTable(int fuzzoff);
@ -168,14 +166,6 @@ namespace swrenderer
void R_UpdateFuzzPos();
// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color)
void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade);
void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade);
void R_SetTranslationMap(lighttable_t *translation);
void R_SetSpanTexture(FTexture *tex);
void R_SetSpanColormap(FDynamicColormap *colormap, int shade);
class DrawerStyle
{
public:
@ -194,6 +184,14 @@ namespace swrenderer
void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false);
// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color)
void SetColorMapLight(FSWColormap *base_colormap, float light, int shade);
void SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade);
void SetTranslationMap(lighttable_t *translation);
void SetSpanTexture(FTexture *tex);
void SetSpanColormap(FDynamicColormap *colormap, int shade);
DrawerFunc GetTransMaskDrawer();
DrawerFunc colfunc;
@ -202,6 +200,38 @@ namespace swrenderer
DrawerFunc transcolfunc;
DrawerFunc spanfunc;
void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
{
Drawers()->DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
}
void DrawFogBoundaryLine(int y, int x1, int x2)
{
Drawers()->DrawFogBoundaryLine(y, x1, x2);
}
void DrawColoredSpan(int y, int x1, int x2)
{
Drawers()->DrawColoredSpan(y, x1, x2);
}
void DrawSingleSkyColumn(uint32_t solid_top, uint32_t solid_bottom, bool fadeSky)
{
Drawers()->DrawSingleSkyColumn(solid_top, solid_bottom, fadeSky);
}
void DrawDoubleSkyColumn(uint32_t solid_top, uint32_t solid_bottom, bool fadeSky)
{
Drawers()->DrawDoubleSkyColumn(solid_top, solid_bottom, fadeSky);
}
void FillColumn()
{
Drawers()->FillColumn();
}
SWPixelFormatDrawers *Drawers() const;
private:
void DrawMaskedColumnBgra(int x, fixed_t iscale, FTexture *tex, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked);

View File

@ -64,7 +64,7 @@ namespace swrenderer
fillshort(spanend + t2, b2 - t2, x);
}
R_SetColorMapLight(basecolormap, (float)light, wallshade);
drawerstyle.SetColorMapLight(basecolormap, (float)light, wallshade);
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
@ -91,7 +91,7 @@ namespace swrenderer
fillshort(spanend + t2, b2 - t2, x);
}
rcolormap = lcolormap;
R_SetColorMapLight(basecolormap, (float)light, wallshade);
drawerstyle.SetColorMapLight(basecolormap, (float)light, wallshade);
fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
}
else
@ -102,13 +102,13 @@ namespace swrenderer
while (t2 < stop)
{
int y = t2++;
R_Drawers()->DrawFogBoundaryLine(y, xr, spanend[y]);
drawerstyle.DrawFogBoundaryLine(y, xr, spanend[y]);
}
stop = MAX(b1, t2);
while (b2 > stop)
{
int y = --b2;
R_Drawers()->DrawFogBoundaryLine(y, xr, spanend[y]);
drawerstyle.DrawFogBoundaryLine(y, xr, spanend[y]);
}
}
else
@ -142,7 +142,7 @@ namespace swrenderer
{
for (; y < y2; ++y)
{
R_Drawers()->DrawFogBoundaryLine(y, x1, spanend[y]);
drawerstyle.DrawFogBoundaryLine(y, x1, spanend[y]);
}
}
}

View File

@ -13,6 +13,8 @@
#pragma once
#include "swrenderer/drawers/r_draw.h"
namespace swrenderer
{
class RenderFogBoundary
@ -24,5 +26,6 @@ namespace swrenderer
void RenderSection(int y, int y2, int x1);
short spanend[MAXHEIGHT];
DrawerStyle drawerstyle;
};
}

View File

@ -932,11 +932,13 @@ namespace swrenderer
double yscale;
fixed_t xoffset = rw_offset;
DrawerStyle drawerstyle;
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != nullptr)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
// clip wall to the floor and ceiling
auto ceilingclip = RenderOpaquePass::Instance()->ceilingclip;
@ -1044,7 +1046,6 @@ namespace swrenderer
rw_offset = -rw_offset;
}
DrawerStyle drawerstyle;
RenderWallPart renderWallpart;
renderWallpart.Render(drawerstyle, frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallbottom.ScreenY, rw_midtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}
@ -1082,7 +1083,6 @@ namespace swrenderer
rw_offset = -rw_offset;
}
DrawerStyle drawerstyle;
RenderWallPart renderWallpart;
renderWallpart.Render(drawerstyle, frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallupper.ScreenY, rw_toptexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}
@ -1123,7 +1123,6 @@ namespace swrenderer
rw_offset = -rw_offset;
}
DrawerStyle drawerstyle;
RenderWallPart renderWallpart;
renderWallpart.Render(drawerstyle, frontsector, curline, WallC, rw_pic, x1, x2, walllower.ScreenY, wallbottom.ScreenY, rw_bottomtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}

View File

@ -141,9 +141,9 @@ namespace swrenderer
rw_scalestep = ds->iscalestep;
if (cameraLight->fixedlightlev >= 0)
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != nullptr)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
// find positioning
texheight = tex->GetScaledHeightDouble();
@ -272,7 +272,7 @@ namespace swrenderer
{
if (cameraLight->fixedcolormap == nullptr && cameraLight->fixedlightlev < 0)
{
R_SetColorMapLight(basecolormap, rw_light, wallshade);
drawerstyle.SetColorMapLight(basecolormap, rw_light, wallshade);
}
fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY);
@ -444,9 +444,9 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != nullptr)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
WallC.sz1 = ds->sz1;
WallC.sz2 = ds->sz2;

View File

@ -250,7 +250,7 @@ namespace swrenderer
dc_iscale = sampler.uv_step;
dc_texturefrac = sampler.uv_pos;
dc_textureheight = sampler.height;
(R_Drawers()->*draw1column)();
(drawerstyle.Drawers()->*draw1column)();
uint64_t step64 = sampler.uv_step;
uint64_t pos64 = sampler.uv_pos;
@ -269,7 +269,7 @@ namespace swrenderer
dc_count = count;
dc_iscale = sampler.uv_step;
dc_texturefrac = sampler.uv_pos;
(R_Drawers()->*draw1column)();
(drawerstyle.Drawers()->*draw1column)();
uint64_t step64 = sampler.uv_step;
uint64_t pos64 = sampler.uv_pos;
@ -295,7 +295,7 @@ namespace swrenderer
dc_count = count;
dc_iscale = sampler.uv_step;
dc_texturefrac = uv_pos;
(R_Drawers()->*draw1column)();
(drawerstyle.Drawers()->*draw1column)();
left -= count;
uv_pos += sampler.uv_step * count;
@ -341,9 +341,9 @@ namespace swrenderer
}
if (cameraLight->fixedcolormap)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
else
R_SetColorMapLight(basecolormap, 0, 0);
drawerstyle.SetColorMapLight(basecolormap, 0, 0);
float dx = WallC.tright.X - WallC.tleft.X;
float dy = WallC.tright.Y - WallC.tleft.Y;
@ -362,7 +362,7 @@ namespace swrenderer
continue;
if (!fixed)
R_SetColorMapLight(basecolormap, light, wallshade);
drawerstyle.SetColorMapLight(basecolormap, light, wallshade);
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));

View File

@ -44,7 +44,7 @@
namespace swrenderer
{
void RenderFlatPlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap)
void RenderFlatPlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FTexture *texture)
{
using namespace drawerargs;
@ -53,6 +53,8 @@ namespace swrenderer
return;
}
drawerstyle.SetSpanTexture(texture);
double planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians();
double xstep, ystep, leftxfrac, leftyfrac, rightxfrac, rightyfrac;
double x;
@ -111,12 +113,12 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
{
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
plane_shade = false;
}
else if (cameraLight->fixedcolormap)
{
R_SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
plane_shade = false;
}
else
@ -184,7 +186,7 @@ namespace swrenderer
if (plane_shade)
{
// Determine lighting based on the span's distance from the viewer.
R_SetDSColorMapLight(basecolormap, (float)(GlobVis * fabs(CenterY - y)), planeshade);
drawerstyle.SetDSColorMapLight(basecolormap, (float)(GlobVis * fabs(CenterY - y)), planeshade);
}
if (r_dynlights)
@ -255,7 +257,7 @@ namespace swrenderer
ds_x1 = x1;
ds_x2 = x2;
(R_Drawers()->*drawerstyle.spanfunc)();
(drawerstyle.Drawers()->*drawerstyle.spanfunc)();
}
void RenderFlatPlane::StepColumn()
@ -317,6 +319,6 @@ namespace swrenderer
void RenderColoredPlane::RenderLine(int y, int x1, int x2)
{
R_Drawers()->DrawColoredSpan(y, x1, x2);
drawerstyle.DrawColoredSpan(y, x1, x2);
}
}

View File

@ -23,7 +23,7 @@ namespace swrenderer
class RenderFlatPlane : PlaneRenderer
{
public:
void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap);
void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FTexture *texture);
static void SetupSlope();
@ -54,5 +54,7 @@ namespace swrenderer
private:
void RenderLine(int y, int x1, int x2) override;
DrawerStyle drawerstyle;
};
}

View File

@ -151,13 +151,13 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedcolormap)
{
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
}
else
{
fakefixed = true;
cameraLight->fixedcolormap = &NormalLight;
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
}
DrawSky(pl);
@ -228,9 +228,9 @@ namespace swrenderer
bool fadeSky = (r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY));
if (!backskytex)
R_Drawers()->DrawSingleSkyColumn(solid_top, solid_bottom, fadeSky);
drawerstyle.DrawSingleSkyColumn(solid_top, solid_bottom, fadeSky);
else
R_Drawers()->DrawDoubleSkyColumn(solid_top, solid_bottom, fadeSky);
drawerstyle.DrawDoubleSkyColumn(solid_top, solid_bottom, fadeSky);
}
void RenderSkyPlane::DrawSkyColumn(int start_x, int y1, int y2, int columns)

View File

@ -14,6 +14,7 @@
#pragma once
#include "r_visibleplane.h"
#include "swrenderer/drawers/r_draw.h"
namespace swrenderer
{
@ -36,5 +37,7 @@ namespace swrenderer
fixed_t backcyl = 0;
double skymid = 0.0;
angle_t skyangle = 0;
DrawerStyle drawerstyle;
};
}

View File

@ -48,7 +48,7 @@
namespace swrenderer
{
void RenderSlopePlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap)
void RenderSlopePlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FTexture *texture)
{
using namespace drawerargs;
@ -72,6 +72,8 @@ namespace swrenderer
return;
}
drawerstyle.SetSpanTexture(texture);
lxscale = _xscale * ifloatpow2[ds_xbits];
lyscale = _yscale * ifloatpow2[ds_ybits];
xscale = 64.f / lxscale;
@ -153,17 +155,17 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
{
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
plane_shade = false;
}
else if (cameraLight->fixedcolormap)
{
R_SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
plane_shade = false;
}
else
{
R_SetDSColorMapLight(basecolormap, 0, 0);
drawerstyle.SetDSColorMapLight(basecolormap, 0, 0);
plane_shade = true;
planeshade = LIGHT2SHADE(pl->lightlevel);
}
@ -183,6 +185,6 @@ namespace swrenderer
void RenderSlopePlane::RenderLine(int y, int x1, int x2)
{
R_Drawers()->DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
drawerstyle.DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
}
}

View File

@ -14,13 +14,14 @@
#pragma once
#include "r_planerenderer.h"
#include "swrenderer/drawers/r_draw.h"
namespace swrenderer
{
class RenderSlopePlane : PlaneRenderer
{
public:
void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap);
void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FTexture *texture);
private:
void RenderLine(int y, int x1, int x2) override;
@ -32,5 +33,6 @@ namespace swrenderer
fixed_t pviewx, pviewy;
fixed_t xscale, yscale;
FDynamicColormap *basecolormap;
DrawerStyle drawerstyle;
};
}

View File

@ -114,19 +114,18 @@ namespace swrenderer
{ // Don't waste time on a masked texture if it isn't really masked.
masked = false;
}
R_SetSpanTexture(tex);
double xscale = xform.xScale * tex->Scale.X;
double yscale = xform.yScale * tex->Scale.Y;
if (!height.isSlope() && !tilt)
{
RenderFlatPlane renderer;
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap, tex);
}
else
{
RenderSlopePlane renderer;
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap, tex);
}
}
NetUpdate();

View File

@ -252,15 +252,8 @@ namespace swrenderer
}
light = lightleft + (x1 - savecoord.sx1) * lightstep;
cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != NULL)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0);
else
calclighting = true;
// Draw it
bool sprflipvert;
@ -281,6 +274,16 @@ namespace swrenderer
int x = x1;
DrawerStyle drawerstyle;
if (cameraLight->fixedlightlev >= 0)
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != NULL)
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0);
else
calclighting = true;
bool visible = drawerstyle.SetPatchStyle(decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, basecolormap);
// R_SetPatchStyle can modify basecolormap.
@ -295,7 +298,7 @@ namespace swrenderer
{
if (calclighting)
{ // calculate lighting
R_SetColorMapLight(usecolormap, light, wallshade);
drawerstyle.SetColorMapLight(usecolormap, light, wallshade);
}
DrawColumn(drawerstyle, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep;

View File

@ -586,11 +586,11 @@ namespace swrenderer
return;
}
R_SetColorMapLight(Light.BaseColormap, 0, Light.ColormapNum << FRACBITS);
DrawerStyle drawerstyle;
drawerstyle.SetColorMapLight(Light.BaseColormap, 0, Light.ColormapNum << FRACBITS);
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(Light.BaseColormap);
DrawerStyle drawerstyle;
bool visible = drawerstyle.SetPatchStyle(RenderStyle, Alpha, Translation, FillColor, basecolormap, Light.ColormapNum << FRACBITS);
if (!visible)
return;

View File

@ -243,12 +243,11 @@ namespace swrenderer
return;
}
fixed_t centeryfrac = FLOAT2FIXED(CenterY);
R_SetColorMapLight(vis->Light.BaseColormap, 0, vis->Light.ColormapNum << FRACBITS);
DrawerStyle drawerstyle;
drawerstyle.SetColorMapLight(vis->Light.BaseColormap, 0, vis->Light.ColormapNum << FRACBITS);
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->Light.BaseColormap);
DrawerStyle drawerstyle;
bool visible = drawerstyle.SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap, vis->Light.ColormapNum << FRACBITS);
if (visible)

View File

@ -184,9 +184,9 @@ namespace swrenderer
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(sprite->Light.BaseColormap);
R_SetColorMapLight(sprite->Light.BaseColormap, 0, sprite->Light.ColormapNum << FRACBITS);
DrawerStyle drawerstyle;
drawerstyle.SetColorMapLight(sprite->Light.BaseColormap, 0, sprite->Light.ColormapNum << FRACBITS);
bool visible = drawerstyle.SetPatchStyle(sprite->RenderStyle, sprite->Alpha, sprite->Translation, sprite->FillColor, basecolormap);
if (!visible)
return;
@ -285,7 +285,7 @@ namespace swrenderer
voxel_pos.Y += dirY.X * x + dirY.Y * y;
voxel_pos.Z += dirZ * z;
FillBox(voxel_pos, sprite_xscale, sprite_yscale, color, cliptop, clipbottom, false, false);
FillBox(drawerstyle, voxel_pos, sprite_xscale, sprite_yscale, color, cliptop, clipbottom, false, false);
}
}
}
@ -308,7 +308,7 @@ namespace swrenderer
return (kvxslab_t*)(((uint8_t*)slab) + 3 + slab->zleng);
}
void RenderVoxel::FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch)
void RenderVoxel::FillBox(DrawerStyle &drawerstyle, DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch)
{
double viewX, viewY, viewZ;
if (viewspace)
@ -354,7 +354,7 @@ namespace swrenderer
dc_dest = dc_destorg + (dc_pitch * columnY1 + x) * pixelsize;
dc_color = color;
dc_count = columnY2 - columnY1;
R_Drawers()->FillColumn();
drawerstyle.FillColumn();
}
}
}

View File

@ -31,6 +31,8 @@ struct FVoxel;
namespace swrenderer
{
class DrawerStyle;
// [RH] A c-buffer. Used for keeping track of offscreen voxel spans.
struct FCoverageBuffer
{
@ -81,7 +83,7 @@ namespace swrenderer
enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 };
static void FillBox(DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch);
static void FillBox(DrawerStyle &drawerstyle, DVector3 origin, double extentX, double extentY, int color, short *cliptop, short *clipbottom, bool viewspace, bool pixelstretch);
static kvxslab_t *GetSlabStart(const FVoxelMipLevel &mip, int x, int y);
static kvxslab_t *GetSlabEnd(const FVoxelMipLevel &mip, int x, int y);

View File

@ -178,6 +178,8 @@ namespace swrenderer
rereadcolormap = false;
}
DrawerStyle drawerstyle;
int shade = LIGHT2SHADE(spr->sector->lightlevel + R_ActualExtraLight(spr->foggy));
double GlobVis = LightVisibility::Instance()->WallGlobVis();
float lightleft = float(GlobVis / spr->wallc.sz1);
@ -185,11 +187,11 @@ namespace swrenderer
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0)
R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
drawerstyle.SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
else if (cameraLight->fixedcolormap != NULL)
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
drawerstyle.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT))
R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0);
drawerstyle.SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0);
else
calclighting = true;
@ -212,7 +214,6 @@ namespace swrenderer
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(spr->Light.BaseColormap);
DrawerStyle drawerstyle;
bool visible = drawerstyle.SetPatchStyle(spr->RenderStyle, spr->Alpha, spr->Translation, spr->FillColor, basecolormap);
// R_SetPatchStyle can modify basecolormap.
@ -233,7 +234,7 @@ namespace swrenderer
{
if (calclighting)
{ // calculate lighting
R_SetColorMapLight(usecolormap, light, shade);
drawerstyle.SetColorMapLight(usecolormap, light, shade);
}
if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
DrawColumn(drawerstyle, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);

View File

@ -185,21 +185,22 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
translation = parms.remap->Remap;
}
DrawerStyle drawerstyle;
if (translation != NULL)
{
R_SetTranslationMap((lighttable_t *)translation);
drawerstyle.SetTranslationMap((lighttable_t *)translation);
}
else
{
if (r_swtruecolor)
R_SetTranslationMap(nullptr);
drawerstyle.SetTranslationMap(nullptr);
else
R_SetTranslationMap(identitymap);
drawerstyle.SetTranslationMap(identitymap);
}
bool visible;
FDynamicColormap *basecolormap = nullptr;
DrawerStyle drawerstyle;
if (r_swtruecolor)
visible = drawerstyle.SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap);
else
@ -1388,11 +1389,12 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
sinrot = sin(rotation.Radians());
// Setup constant texture mapping parameters.
R_SetSpanTexture(tex);
DrawerStyle drawerstyle;
drawerstyle.SetSpanTexture(tex);
if (colormap)
R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1));
drawerstyle.SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1));
else
R_SetSpanColormap(&identitycolormap, 0);
drawerstyle.SetSpanColormap(&identitycolormap, 0);
if (ds_xbits != 0)
{
scalex = double(1u << (32 - ds_xbits)) / scalex;
@ -1491,7 +1493,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
ds_xfrac = xs_RoundToInt(tex.X * scalex);
ds_yfrac = xs_RoundToInt(tex.Y * scaley);
R_Drawers()->DrawSpan();
(drawerstyle.Drawers()->*drawerstyle.spanfunc)();
#endif
}
x += xinc;