diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index 233ae4396..ff963c068 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -189,10 +189,8 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int auto sampler = (method & DAMETH_CLAMPED) ? (sampleroverride != -1 ? sampleroverride : SamplerClampXY) : SamplerRepeat; if (TextureType == TT_INDEXED) { - renderState.Flags |= RF_UsePalette; sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat; } - else renderState.Flags &= ~RF_UsePalette; UseDetailMapping(false); UseGlowMapping(false); UseBrightmaps(false); @@ -326,7 +324,6 @@ bool GLInstance::SetNamedTexture(FTexture* tex, int palette, int sampler) auto mtex = LoadTexture(tex, palette>= 0? TT_TRUECOLOR : TT_HICREPLACE, palette); if (!mtex) return false; - renderState.Flags &= ~RF_UsePalette; BindTexture(0, mtex, sampler); GLInterface.SetAlphaThreshold(tex->isTranslucent()? 0.f : 0.5f); return true; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index da80b54fb..f92a5d09c 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -284,6 +284,12 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) void GLInstance::BindTexture(int texunit, FHardwareTexture *tex, int sampler) { if (!tex) return; + if (texunit == 0 && tex->isIndexed()) + { + renderState.Flags |= RF_UsePalette; + } + else renderState.Flags &= ~RF_UsePalette; + if (texunit != 0) glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, tex->GetTextureHandle()); mSamplers->Bind(texunit, sampler == NoSampler? tex->GetSampler() : sampler, 0);