From dbf9cd5de514428557deff5bf80eca68a02afa52 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 28 Jan 2017 08:17:31 +0100 Subject: [PATCH] Remove a few more drawerargs --- src/swrenderer/drawers/r_draw.cpp | 34 ++++++++++++------------ src/swrenderer/drawers/r_draw.h | 9 +++---- src/swrenderer/things/r_playersprite.cpp | 10 +------ src/swrenderer/things/r_sprite.cpp | 9 +------ src/v_draw.cpp | 1 - 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/swrenderer/drawers/r_draw.cpp b/src/swrenderer/drawers/r_draw.cpp index 88a477df91..885c3fc36f 100644 --- a/src/swrenderer/drawers/r_draw.cpp +++ b/src/swrenderer/drawers/r_draw.cpp @@ -130,7 +130,6 @@ namespace swrenderer const uint8_t *ds_source; bool ds_source_mipmapped; int ds_color; - bool drawer_needs_pal_input; } namespace @@ -242,19 +241,18 @@ namespace swrenderer { using namespace drawerargs; - dc_fcolormap = base_colormap; if (r_swtruecolor) { - dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255; - dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255; - dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255; - dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255; - dc_shade_constants.fade_red = dc_fcolormap->Fade.r; - dc_shade_constants.fade_green = dc_fcolormap->Fade.g; - dc_shade_constants.fade_blue = dc_fcolormap->Fade.b; - dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a; - dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->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.light_red = base_colormap->Color.r * 256 / 255; + dc_shade_constants.light_green = base_colormap->Color.g * 256 / 255; + dc_shade_constants.light_blue = base_colormap->Color.b * 256 / 255; + dc_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255; + dc_shade_constants.fade_red = base_colormap->Fade.r; + dc_shade_constants.fade_green = base_colormap->Fade.g; + dc_shade_constants.fade_blue = base_colormap->Fade.b; + dc_shade_constants.fade_alpha = base_colormap->Fade.a; + dc_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256; + 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_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; @@ -755,11 +753,13 @@ namespace swrenderer basecolormap = &ShadeFakeColormap[16 - alpha]; 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 { - R_SetColorMapLight(basecolormap, 0, 0); + R_SetColorMapLight(basecolormap, 0, shadedlightshade); } return true; } @@ -796,9 +796,9 @@ namespace swrenderer 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() diff --git a/src/swrenderer/drawers/r_draw.h b/src/swrenderer/drawers/r_draw.h index f4dd0378eb..20e77d3460 100644 --- a/src/swrenderer/drawers/r_draw.h +++ b/src/swrenderer/drawers/r_draw.h @@ -37,7 +37,6 @@ namespace swrenderer { extern int dc_pitch; extern lighttable_t *dc_colormap; - extern FSWColormap *dc_fcolormap; extern ShadeConstants dc_shade_constants; extern fixed_t dc_light; extern int dc_x; @@ -67,8 +66,6 @@ namespace swrenderer extern TriLight *dc_lights; extern int dc_num_lights; - extern bool drawer_needs_pal_input; - extern uint32_t dc_wall_texturefrac[4]; extern uint32_t dc_wall_iscale[4]; extern uint8_t *dc_wall_colormap[4]; @@ -192,8 +189,8 @@ namespace swrenderer spanfunc = &SWPixelFormatDrawers::DrawSpan; } - bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap); - bool SetPatchStyle(FRenderStyle style, float 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, fixed_t shadedlightshade = 0); 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); @@ -211,5 +208,7 @@ namespace swrenderer bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); static fixed_t GetAlpha(int type, fixed_t alpha); + + bool drawer_needs_pal_input = false; }; } diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 2380c7a452..3e7f745646 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -592,15 +592,7 @@ namespace swrenderer FDynamicColormap *basecolormap = static_cast(Light.BaseColormap); DrawerStyle drawerstyle; - bool visible = drawerstyle.SetPatchStyle(RenderStyle, Alpha, Translation, FillColor, basecolormap); - - 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); - } - + bool visible = drawerstyle.SetPatchStyle(RenderStyle, Alpha, Translation, FillColor, basecolormap, Light.ColormapNum << FRACBITS); if (!visible) return; diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 575cb8369d..ac2cedb2a5 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -251,14 +251,7 @@ namespace swrenderer FDynamicColormap *basecolormap = static_cast(vis->Light.BaseColormap); DrawerStyle drawerstyle; - bool visible = drawerstyle.SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap); - - 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); - } + bool visible = drawerstyle.SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap, vis->Light.ColormapNum << FRACBITS); if (visible) { diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6e4f417287..a3d206726b 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -197,7 +197,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) R_SetTranslationMap(identitymap); } - CameraLight::Instance()->fixedcolormap = dc_fcolormap; bool visible; FDynamicColormap *basecolormap = nullptr; DrawerStyle drawerstyle;