Remove a few more drawerargs

This commit is contained in:
Magnus Norddahl 2017-01-28 08:17:31 +01:00
parent 9eebe3e940
commit dbf9cd5de5
5 changed files with 23 additions and 40 deletions

View file

@ -130,7 +130,6 @@ namespace swrenderer
const uint8_t *ds_source; const uint8_t *ds_source;
bool ds_source_mipmapped; bool ds_source_mipmapped;
int ds_color; int ds_color;
bool drawer_needs_pal_input;
} }
namespace namespace
@ -242,19 +241,18 @@ namespace swrenderer
{ {
using namespace drawerargs; using namespace drawerargs;
dc_fcolormap = base_colormap;
if (r_swtruecolor) if (r_swtruecolor)
{ {
dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; dc_shade_constants.light_red = base_colormap->Color.r * 256 / 255;
dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; dc_shade_constants.light_green = base_colormap->Color.g * 256 / 255;
dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; dc_shade_constants.light_blue = base_colormap->Color.b * 256 / 255;
dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; dc_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255;
dc_shade_constants.fade_red = dc_fcolormap->Fade.r; dc_shade_constants.fade_red = base_colormap->Fade.r;
dc_shade_constants.fade_green = dc_fcolormap->Fade.g; dc_shade_constants.fade_green = base_colormap->Fade.g;
dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; dc_shade_constants.fade_blue = base_colormap->Fade.b;
dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; dc_shade_constants.fade_alpha = base_colormap->Fade.a;
dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256; dc_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256;
dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0); dc_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
dc_colormap = base_colormap->Maps; dc_colormap = base_colormap->Maps;
dc_light = LIGHTSCALE(light, shade); dc_light = LIGHTSCALE(light, shade);
} }
@ -687,7 +685,7 @@ namespace swrenderer
} }
} }
bool DrawerStyle::SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap) bool DrawerStyle::SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -755,11 +753,13 @@ namespace swrenderer
basecolormap = &ShadeFakeColormap[16 - alpha]; basecolormap = &ShadeFakeColormap[16 - alpha];
if (cameraLight->fixedlightlev >= 0 && cameraLight->fixedcolormap == NULL) if (cameraLight->fixedlightlev >= 0 && cameraLight->fixedcolormap == NULL)
{ {
R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev)); fixed_t shade = shadedlightshade;
if (shade == 0) FIXEDLIGHT2SHADE(cameraLight->fixedlightlev);
R_SetColorMapLight(basecolormap, 0, shade);
} }
else else
{ {
R_SetColorMapLight(basecolormap, 0, 0); R_SetColorMapLight(basecolormap, 0, shadedlightshade);
} }
return true; return true;
} }
@ -796,9 +796,9 @@ namespace swrenderer
return true; return true;
} }
bool DrawerStyle::SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap) bool DrawerStyle::SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade)
{ {
return SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap); return SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap, shadedlightshade);
} }
DrawerFunc DrawerStyle::GetTransMaskDrawer() DrawerFunc DrawerStyle::GetTransMaskDrawer()

View file

@ -37,7 +37,6 @@ namespace swrenderer
{ {
extern int dc_pitch; extern int dc_pitch;
extern lighttable_t *dc_colormap; extern lighttable_t *dc_colormap;
extern FSWColormap *dc_fcolormap;
extern ShadeConstants dc_shade_constants; extern ShadeConstants dc_shade_constants;
extern fixed_t dc_light; extern fixed_t dc_light;
extern int dc_x; extern int dc_x;
@ -67,8 +66,6 @@ namespace swrenderer
extern TriLight *dc_lights; extern TriLight *dc_lights;
extern int dc_num_lights; extern int dc_num_lights;
extern bool drawer_needs_pal_input;
extern uint32_t dc_wall_texturefrac[4]; extern uint32_t dc_wall_texturefrac[4];
extern uint32_t dc_wall_iscale[4]; extern uint32_t dc_wall_iscale[4];
extern uint8_t *dc_wall_colormap[4]; extern uint8_t *dc_wall_colormap[4];
@ -192,8 +189,8 @@ namespace swrenderer
spanfunc = &SWPixelFormatDrawers::DrawSpan; spanfunc = &SWPixelFormatDrawers::DrawSpan;
} }
bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap); bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap); bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
void SetSpanStyle(bool masked, bool additive, fixed_t alpha); void SetSpanStyle(bool masked, bool additive, fixed_t alpha);
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); 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);
@ -211,5 +208,7 @@ namespace swrenderer
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
static fixed_t GetAlpha(int type, fixed_t alpha); static fixed_t GetAlpha(int type, fixed_t alpha);
bool drawer_needs_pal_input = false;
}; };
} }

View file

@ -592,15 +592,7 @@ namespace swrenderer
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(Light.BaseColormap); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(Light.BaseColormap);
DrawerStyle drawerstyle; DrawerStyle drawerstyle;
bool visible = drawerstyle.SetPatchStyle(RenderStyle, Alpha, Translation, FillColor, basecolormap); bool visible = drawerstyle.SetPatchStyle(RenderStyle, Alpha, Translation, FillColor, basecolormap, Light.ColormapNum << FRACBITS);
if (RenderStyle == LegacyRenderStyles[STYLE_Shaded])
{ // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but
// it is the brightest one. We need to get back to the proper light level for
// this sprite.
R_SetColorMapLight(drawerargs::dc_fcolormap, 0, Light.ColormapNum << FRACBITS);
}
if (!visible) if (!visible)
return; return;

View file

@ -251,14 +251,7 @@ namespace swrenderer
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->Light.BaseColormap); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->Light.BaseColormap);
DrawerStyle drawerstyle; DrawerStyle drawerstyle;
bool visible = drawerstyle.SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap); bool visible = drawerstyle.SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap, vis->Light.ColormapNum << FRACBITS);
if (vis->RenderStyle == LegacyRenderStyles[STYLE_Shaded])
{ // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but
// it is the brightest one. We need to get back to the proper light level for
// this sprite.
R_SetColorMapLight(drawerargs::dc_fcolormap, 0, vis->Light.ColormapNum << FRACBITS);
}
if (visible) if (visible)
{ {

View file

@ -197,7 +197,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
R_SetTranslationMap(identitymap); R_SetTranslationMap(identitymap);
} }
CameraLight::Instance()->fixedcolormap = dc_fcolormap;
bool visible; bool visible;
FDynamicColormap *basecolormap = nullptr; FDynamicColormap *basecolormap = nullptr;
DrawerStyle drawerstyle; DrawerStyle drawerstyle;