Fix translation issue

This commit is contained in:
Magnus Norddahl 2017-02-13 15:08:11 +01:00
parent a2edca6032
commit 69787fac72
3 changed files with 18 additions and 16 deletions

View File

@ -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);

View File

@ -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; }

View File

@ -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;