diff --git a/src/swrenderer/viewport/r_drawerargs.cpp b/src/swrenderer/viewport/r_drawerargs.cpp index 65477cd55..60a0edf61 100644 --- a/src/swrenderer/viewport/r_drawerargs.cpp +++ b/src/swrenderer/viewport/r_drawerargs.cpp @@ -19,7 +19,6 @@ namespace swrenderer void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade) { mBaseColormap = base_colormap; - mTranslation = nullptr; mLight = light; mShade = shade; } diff --git a/src/swrenderer/viewport/r_spritedrawer.cpp b/src/swrenderer/viewport/r_spritedrawer.cpp index 8d5fa0751..118fd18b0 100644 --- a/src/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/swrenderer/viewport/r_spritedrawer.cpp @@ -480,11 +480,7 @@ namespace swrenderer SetLight(&identitycolormap, 0, 0); } - if (!SpriteDrawerArgs::SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags)) - { - return false; - } - return true; + return SpriteDrawerArgs::SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags); } bool SpriteDrawerArgs::SetStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade) @@ -492,20 +488,6 @@ namespace swrenderer return SetStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap, shadedlightshade); } - bool SpriteDrawerArgs::SetStyle(FRenderStyle style, float alpha, lighttable_t *translation, uint32_t color) - { - SetTranslationMap(translation); - SetLight(nullptr, 0.0f, 0); - - FDynamicColormap *basecolormap = &identitycolormap; - if (!SetStyle(style, alpha, -1, color, basecolormap)) - return false; - - if (!Colormap()) - SetTranslationMap(identitymap); - return true; - } - void SpriteDrawerArgs::FillColumn(RenderThread *thread) { thread->Drawers()->FillColumn(*this); diff --git a/src/swrenderer/viewport/r_spritedrawer.h b/src/swrenderer/viewport/r_spritedrawer.h index 8f4b93115..fc5053e6e 100644 --- a/src/swrenderer/viewport/r_spritedrawer.h +++ b/src/swrenderer/viewport/r_spritedrawer.h @@ -18,7 +18,6 @@ namespace swrenderer bool SetStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); bool SetStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); - bool SetStyle(FRenderStyle style, float alpha, lighttable_t *translation, uint32_t color); void SetDest(int x, int y); void SetCount(int count) { dc_count = count; } void SetSolidColor(int color) { dc_color = color; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6430b9448..ad9d1aa5b 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -192,14 +192,15 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) using namespace swrenderer; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; - lighttable_t *translation = NULL; auto viewport = RenderViewport::Instance(); - viewport->RenderTarget = screen; - viewport->RenderTarget->Lock(true); + lighttable_t *translation = nullptr; + FDynamicColormap *basecolormap = &identitycolormap; + int shade = 0; + if (APART(parms.colorOverlay) != 0) { // The software renderer cannot invert the source without inverting the overlay @@ -216,10 +217,15 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor(); } // Note that this overrides the translation in software, but not in hardware. - if (!viewport->RenderTarget->IsBgra()) + FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255), parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0); + + if (viewport->RenderTarget->IsBgra()) + { + basecolormap = colormap; + shade = (APART(parms.colorOverlay)*NUMCOLORMAPS / 255) << FRACBITS; + } + else { - FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255), - parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0); translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS / 255) * 256]; } } @@ -233,8 +239,10 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) SpriteDrawerArgs drawerargs; - bool visible = drawerargs.SetStyle(parms.style, parms.Alpha, translation, parms.fillcolor); - + drawerargs.SetTranslationMap(translation); + drawerargs.SetLight(basecolormap, 0.0f, shade); + bool visible = drawerargs.SetStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap); + double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight;