diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e6e802e5cc..7d091ebb60 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -168,7 +168,7 @@ void gl_LoadExtensions() gl.vendorstring = (char*)glGetString(GL_VENDOR); gl.lightmethod = LM_SOFTWARE; - if (gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) + if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) { gl.flags |= RFL_SAMPLER_OBJECTS; } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index ee51bb2b9f..6a579b0d53 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -346,7 +346,8 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla delete[] buffer; } if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); - if (lastSampler != clampmode || lastTranslation != translation) + if (translation != lastTranslation) lastSampler = 254; + if (lastSampler != clampmode) lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); lastTranslation = translation; return hwtex; diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp index db0193c697..cee2fd894f 100644 --- a/src/gl/textures/gl_samplers.cpp +++ b/src/gl/textures/gl_samplers.cpp @@ -86,7 +86,6 @@ void FSamplerManager::UnbindAll() { for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) { - mLastBound[i] = 0; glBindSampler(i, 0); } } @@ -97,12 +96,8 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) if (gl.flags & RFL_SAMPLER_OBJECTS) { unsigned int samp = mSamplers[num]; - //if (samp != mLastBound[texunit]) - { - glBindSampler(texunit, samp); - mLastBound[texunit] = samp; - return 255; - } + glBindSampler(texunit, samp); + return 255; } else { @@ -112,7 +107,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_NONE: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -123,7 +118,7 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_X: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -134,7 +129,18 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) case CLAMP_Y: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (lastval > CLAMP_XY_NOMIP) + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_XY: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval >= CLAMP_XY_NOMIP) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); @@ -143,15 +149,11 @@ BYTE FSamplerManager::Bind(int texunit, int num, int lastval) break; case CLAMP_XY_NOMIP: - case CLAMP_XY: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - if (lastval > CLAMP_XY_NOMIP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); - } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); break; case CLAMP_NOFILTER: diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h index daba65d454..b74d49a337 100644 --- a/src/gl/textures/gl_samplers.h +++ b/src/gl/textures/gl_samplers.h @@ -8,7 +8,6 @@ class FSamplerManager // We need 6 different samplers: 4 for the different clamping modes, // one for 2D-textures and one for voxel textures unsigned int mSamplers[7]; - unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES]; void UnbindAll();