diff --git a/source/build/src/texcache.cpp b/source/build/src/texcache.cpp index f1514292b..962c3ba4f 100644 --- a/source/build/src/texcache.cpp +++ b/source/build/src/texcache.cpp @@ -34,10 +34,7 @@ static pthtyp *texcache_tryart(int32_t const dapicnum, int32_t const dapalnum, i // load from art for (pth=texcache.list[j]; pth; pth=pth->next) - if (pth->picnum == dapicnum && - (pth->flags & PTH_INDEXED) && - (pth->flags & (PTH_HIGHTILE)) == 0 && - polymost_want_npotytex(dameth, tilesiz[dapicnum].y) == !!(pth->flags & PTH_NPOTWALL)) + if (pth->picnum == dapicnum && ((pth->flags & (PTH_INDEXED|PTH_HIGHTILE)) == PTH_INDEXED)) { if (pth->flags & PTH_INVALIDATED) { diff --git a/source/glbackend/gl_hwtexture.h b/source/glbackend/gl_hwtexture.h index afb804794..363663f33 100644 --- a/source/glbackend/gl_hwtexture.h +++ b/source/glbackend/gl_hwtexture.h @@ -33,6 +33,7 @@ public: unsigned int GetTextureHandle(); int GetSampler() { return mSampler; } void SetSampler(int sampler) { mSampler = sampler; } + bool isIndexed() const { return glTextureBytes == 1; } friend class FGameTexture; }; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index aa1b446cd..cb710eaa8 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -209,14 +209,21 @@ FHardwareTexture* GLInstance::NewTexture() return new FHardwareTexture; } +FHardwareTexture* texv; + void GLInstance::BindTexture(int texunit, FHardwareTexture *tex, int sampler) { if (!tex) return; if (texunit != 0) glActiveTexture(GL_TEXTURE0 + texunit); glBindTexture(GL_TEXTURE_2D, tex->GetTextureHandle()); + if (tex->isIndexed() && sampler > NoSampler && sampler < Sampler2D) + { + sampler = sampler == SamplerRepeat ? SamplerNoFilter : Sampler2DNoFilter; + } mSamplers->Bind(texunit, sampler == NoSampler? tex->GetSampler() : sampler, 0); if (texunit != 0) glActiveTexture(GL_TEXTURE0); LastBoundTextures[texunit] = tex->GetTextureHandle(); + texv = tex; } void GLInstance::UnbindTexture(int texunit)