From 2534e80a1915422042c2c2a0338f1d33d41857a5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 16 Oct 2016 16:14:54 +0200 Subject: [PATCH] Fix vid_hw2d 0 rendering glitch --- src/r_draw.cpp | 29 +++++++++++++++++++---------- src/v_draw.cpp | 25 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 03515c8a1..6b68cf81b 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2689,16 +2689,19 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, alpha = clamp (alpha, 0, OPAQUE); } - dc_translation = NULL; - if (translation != 0) + if (translation != -1) { - FRemapTable *table = TranslationToTable(translation); - if (table != NULL && !table->Inactive) + dc_translation = NULL; + if (translation != 0) { - if (r_swtruecolor) - dc_translation = (BYTE*)table->Palette; - else - dc_translation = table->Remap; + FRemapTable *table = TranslationToTable(translation); + if (table != NULL && !table->Inactive) + { + if (r_swtruecolor) + dc_translation = (BYTE*)table->Palette; + else + dc_translation = table->Remap; + } } } basecolormapsave = basecolormap; @@ -2801,10 +2804,11 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) void R_SetTranslationMap(lighttable_t *translation) { - dc_fcolormap = nullptr; - dc_colormap = translation; if (r_swtruecolor) { + dc_fcolormap = nullptr; + dc_colormap = nullptr; + dc_translation = translation; dc_shade_constants.light_red = 256; dc_shade_constants.light_green = 256; dc_shade_constants.light_blue = 256; @@ -2817,6 +2821,11 @@ void R_SetTranslationMap(lighttable_t *translation) dc_shade_constants.simple_shade = true; dc_light = 0; } + else + { + dc_fcolormap = nullptr; + dc_colormap = translation; + } } void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a89a0865d..921896296 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -169,13 +169,19 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor(); } // Note that this overrides DTA_Translation in software, but not in hardware. - FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255,255,255), - parms.colorOverlay & MAKEARGB(0,255,255,255), 0); - translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS/255)*256]; + if (!r_swtruecolor) + { + FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255), + parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0); + translation = &colormap->Maps[(APART(parms.colorOverlay)*NUMCOLORMAPS / 255) * 256]; + } } else if (parms.remap != NULL) { - translation = parms.remap->Remap; + if (r_swtruecolor) + translation = (const BYTE*)parms.remap->Palette; + else + translation = parms.remap->Remap; } if (translation != NULL) @@ -184,11 +190,18 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) } else { - R_SetTranslationMap(identitymap); + if (r_swtruecolor) + R_SetTranslationMap(nullptr); + else + R_SetTranslationMap(identitymap); } fixedcolormap = dc_fcolormap; - ESPSResult mode = R_SetPatchStyle (parms.style, parms.Alpha, 0, parms.fillcolor); + ESPSResult mode; + if (r_swtruecolor) + mode = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); + else + mode = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer();