diff --git a/include/ACGL/OpenGL/Objects/Texture.hh b/include/ACGL/OpenGL/Objects/Texture.hh index cf4853a234aa09e9cbece571c0ee389709e67dd5..e5c9186e02e51ef8182ee6b32f578c6768b939ea 100644 --- a/include/ACGL/OpenGL/Objects/Texture.hh +++ b/include/ACGL/OpenGL/Objects/Texture.hh @@ -112,6 +112,27 @@ public: openGLRareError(); } + //! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum + void setAnisotropicFilter( GLfloat _sampleCount ) + { +#ifdef ACGL_USE_GLEW + if (GLEW_EXT_texture_filter_anisotropic) { + GLfloat maxAnisotropicSamples; + glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropicSamples ); + _sampleCount = std::max( 1.0f, _sampleCount ); + _sampleCount = std::min( maxAnisotropicSamples, _sampleCount ); + glBindTexture(mTarget, mContext); + glTexParameterf( mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, _sampleCount); + openGLRareError(); + } else +#endif + { + // anisotropic filtering will just increase the image quality, so this is just + // a warning and no error + ACGL::Utils::warning() << "Anisotropic filtering is not supported, ignored" << std::endl; + } + } + //! Set texture data for 1D, 2D or 3D textures inline void setImageData(const GLvoid* _pData = NULL) {