- fixed voxel rendering in indexed color mode.

This commit is contained in:
Christoph Oelckers 2020-01-03 18:30:00 +01:00
parent f743b22661
commit 6ba04e7a09
2 changed files with 6 additions and 3 deletions

View file

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

View file

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