diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 0703b9341..05086a66f 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1845,7 +1845,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) int prevClamp = GLInterface.GetClamp(); GLInterface.SetClamp(0); - GLInterface.UsePaletteIndexing(false); for (surfi=0; surfihead.numsurfs; surfi++) { @@ -2012,7 +2011,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) GLInterface.SetTinting(0, 0); GLInterface.SetClamp(prevClamp); - GLInterface.UsePaletteIndexing(true); GLInterface.SetPolymostShader(); globalnoeffect=0; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index d62269c59..78cba270d 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -926,10 +926,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 if (videoGetRenderMode() == REND_POLYMOST) { - //POGOTODO: I could move this into bindPth - if (!(pth->flags & PTH_INDEXED)) - GLInterface.UsePaletteIndexing(false); - // The entire logic here is just one lousy hack. int mSampler = NoSampler; if (pth->glpic->GetSampler() != SamplerRepeat) @@ -1250,12 +1246,6 @@ do return; } - if (!(pth->flags & PTH_INDEXED)) - { - // restore palette usage if we were just rendering a non-indexed color texture - GLInterface.UsePaletteIndexing(true); - } - if (skyzbufferhack && skyzbufferhack_pass == 0) { vec3d_t const bxtex = xtex, bytex = ytex, botex = otex; @@ -6005,9 +5995,6 @@ void polymost_fillpolygon(int32_t npoints) if (pth) { polymost_bindPth(pth, -1); - - if (!(pth->flags & PTH_INDEXED)) - GLInterface.UsePaletteIndexing(false); } polymost_updatePalette(); @@ -6026,12 +6013,6 @@ void polymost_fillpolygon(int32_t npoints) } tessectrap((float *)rx1,(float *)ry1,xb1,npoints); - - if (pth && !(pth->flags & PTH_INDEXED)) - { - // restore palette usage if we were just rendering a non-indexed color texture - GLInterface.UsePaletteIndexing(true); - } } static int32_t gen_font_glyph_tex(void) @@ -6121,8 +6102,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba GLInterface.BindTexture(0, polymosttext); - GLInterface.UsePaletteIndexing(false); - polymostSet2dView(); // disables blending, texturing, and depth testing GLInterface.EnableAlphaTest(false); @@ -6219,8 +6198,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba if (!nofog) GLInterface.SetFogEnabled(true); - GLInterface.UsePaletteIndexing(true); - return 0; } diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 7d0e6bec5..a98d68a17 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1333,7 +1333,11 @@ void sdlayer_setvideomode_opengl(void) GLInterface.Deinit(); GLInterface.Init(); GLInterface.InitGLState(4, glmultisample); +#if 1 + GLInterface.mSamplers->SetTextureFilterMode(0, 1); +#else GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); +#endif } diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 64b3a2f8b..fa87eef21 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1136,8 +1136,6 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) GLInterface.BindTexture(0, m->texid[globalpal]); - GLInterface.UsePaletteIndexing(false); - auto data = GLInterface.AllocVertices(m->qcnt * 4); auto vt = data.second; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 7a65ddddd..6cc11ec8d 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -180,7 +180,11 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) { // Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. - if (activeShader == polymostShader) renderState.Apply(polymostShader); + if (activeShader == polymostShader) + { + renderState.UsePalette = texv && texv->isIndexed(); + renderState.Apply(polymostShader); + } glBegin(primtypes[type]); auto p = &Buffer[start]; for (size_t i = 0; i < count; i++, p++) @@ -209,21 +213,16 @@ 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; + if (texunit == 0) texv = tex; } void GLInstance::UnbindTexture(int texunit) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index cad7ba045..1055057df 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -199,6 +199,7 @@ class GLInstance int maxTextureSize; PaletteManager palmanager; int lastPalswapIndex = -1; + FHardwareTexture* texv; VSMatrix matrices[NUMMATRICES]; @@ -323,11 +324,6 @@ public: renderState.UseColorOnly = useColorOnly; } - void UsePaletteIndexing(bool usePaletteIndexing) - { - renderState.UsePalette = usePaletteIndexing; - } - void UseDetailMapping(bool useDetailMapping) { renderState.UseDetailMapping = useDetailMapping;