From 66809ca9f4b38763de783ea13517784f6e7be2a0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 May 2020 16:46:36 +0200 Subject: [PATCH] - fixed indexed display of 2D content. --- source/build/src/mdsprite.cpp | 3 ++- source/build/src/polymost.cpp | 9 ++++++--- source/core/rendering/gl/renderer/gl_renderer.cpp | 2 +- source/glbackend/gl_texture.cpp | 4 +++- source/glbackend/hw_draw2d.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index ed252b86a..a765bf11d 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1726,7 +1726,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) } glow = hw_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0; } - GLInterface.SetModelTexture(tex, globalpal, det, detscale, glow); + int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal); + GLInterface.SetModelTexture(tex, palid, det, detscale, glow); if (tspr->clipdist & TSPR_FLAGS_MDHACK) { diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index b5c832a47..b6c9167ec 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -426,7 +426,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 else if (drawpoly_trepeat) sampleroverride = SamplerClampX; else sampleroverride = SamplerClampXY; - bool success = GLInterface.SetTexture(globalpicnum, tileGetTexture(globalpicnum), globalpal, method, sampleroverride); + int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal); + bool success = GLInterface.SetTexture(globalpicnum, tileGetTexture(globalpicnum), palid, method, sampleroverride); if (!success) { tsiz.x = tsiz.y = 1; @@ -4551,7 +4552,8 @@ static void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype //Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); hicprecaching = 1; - GLInterface.SetTexture(dapicnum, tileGetTexture(dapicnum), dapalnum, 0, -1); + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + GLInterface.SetTexture(dapicnum, tileGetTexture(dapicnum), palid, 0, -1); hicprecaching = 0; if (datype == 0 || !hw_models) return; @@ -4565,7 +4567,8 @@ static void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype for (int i = 0; i <= surfaces; i++) { auto tex = mdloadskin((md2model_t *)models[mid], 0, dapalnum, i, nullptr); - if (tex) GLInterface.SetTexture(-1, tex, dapalnum, 0, -1); + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + if (tex) GLInterface.SetTexture(-1, tex, palid, 0, -1); } } diff --git a/source/core/rendering/gl/renderer/gl_renderer.cpp b/source/core/rendering/gl/renderer/gl_renderer.cpp index 4089b1a5d..5963fc204 100644 --- a/source/core/rendering/gl/renderer/gl_renderer.cpp +++ b/source/core/rendering/gl/renderer/gl_renderer.cpp @@ -59,7 +59,7 @@ //#include "r_data/models/models.h" #include "gl/renderer/gl_postprocessstate.h" #include "gl/system/gl_buffers.h" -#include "../glbackend/gl_hwtexture.h" +#include "gl_hwtexture.h" #include "build.h" EXTERN_CVAR(Int, screenblocks) diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index 3c633be7a..da92509f3 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -201,9 +201,11 @@ TexturePick PickTexture(int tilenum, int basepal, int palette) } #endif -bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int palette, int method, int sampleroverride, FGameTexture *det, float detscale, FGameTexture *glow) +bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid, int method, int sampleroverride, FGameTexture *det, float detscale, FGameTexture *glow) { if (tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false; + int curbasepal = GetTranslationType(paletteid) - Translation_Remap; + int palette = GetTranslationIndex(paletteid); int usepalette = fixpalette >= 0 ? fixpalette : curbasepal; int usepalswap = fixpalswap >= 0 ? fixpalswap : palette; GLInterface.SetPalette(usepalette); diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index adca3a9a4..ed87e1dc1 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -166,9 +166,10 @@ void GLInstance::Draw2D(F2DDrawer *drawer) { auto tex = cmd.mTexture; - SetFadeDisable(true); - SetShade(0, numshades); - SetNamedTexture(cmd.mTexture, cmd.mTranslationId, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); + SetFadeDisable(true); + SetShade(0, numshades); + + SetTexture(TileFiles.GetTileIndex(cmd.mTexture), cmd.mTexture, cmd.mTranslationId, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY); EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); UseColorOnly(false); } @@ -180,7 +181,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer) switch (cmd.mType) { case F2DDrawer::DrawTypeTriangles: - case F2DDrawer::DrawTypeRotateSprite: DrawElement(DT_TRIANGLES, cmd.mIndexIndex, cmd.mIndexCount, renderState); break;