From 69787fac727e7b94274eb73729e9d25107cb0d27 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Feb 2017 15:08:11 +0100 Subject: [PATCH] Fix translation issue --- src/swrenderer/viewport/r_spritedrawer.cpp | 14 ++++++++++++++ src/swrenderer/viewport/r_spritedrawer.h | 1 + src/v_draw.cpp | 19 +++---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/swrenderer/viewport/r_spritedrawer.cpp b/src/swrenderer/viewport/r_spritedrawer.cpp index cfcd3f2850..8d5fa07517 100644 --- a/src/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/swrenderer/viewport/r_spritedrawer.cpp @@ -492,6 +492,20 @@ 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 fc5053e6e0..8f4b93115d 100644 --- a/src/swrenderer/viewport/r_spritedrawer.h +++ b/src/swrenderer/viewport/r_spritedrawer.h @@ -18,6 +18,7 @@ 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 a1af3ad2c0..6d86e0a0eb 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -192,7 +192,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) using namespace swrenderer; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; - const BYTE *translation = NULL; + lighttable_t *translation = NULL; auto viewport = RenderViewport::Instance(); @@ -224,27 +224,14 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) else if (parms.remap != NULL) { if (viewport->RenderTarget->IsBgra()) - translation = (const BYTE*)parms.remap->Palette; + translation = (lighttable_t *)parms.remap->Palette; else translation = parms.remap->Remap; } SpriteDrawerArgs drawerargs; - if (translation != NULL) - { - drawerargs.SetTranslationMap((lighttable_t *)translation); - } - else - { - if (viewport->RenderTarget->IsBgra()) - drawerargs.SetTranslationMap(nullptr); - else - drawerargs.SetTranslationMap(identitymap); - } - - FDynamicColormap *basecolormap = nullptr; - bool visible = drawerargs.SetStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap); + bool visible = drawerargs.SetStyle(parms.style, parms.Alpha, translation, parms.fillcolor); double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight;