diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index a79775b3cd..9f36438cc5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1123,6 +1123,15 @@ reset() { _num_active_texture_stages = 0; + // Check availability of anisotropic texture filtering. + if (has_extension("GL_EXT_texture_filter_anisotropic")) { + GLfloat max_anisotropy; + GLP(GetFloatv)(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); + _max_anisotropy = (float)max_anisotropy; + } else { + _max_anisotropy = 1.0; + } + report_my_gl_errors(); _supports_stencil_wrap = has_extension("GL_EXT_stencil_wrap"); @@ -6702,6 +6711,15 @@ specify_texture(Texture *tex) { GLP(TexParameteri)(target, GL_TEXTURE_MAG_FILTER, get_texture_filter_type(magfilter, tex->get_format(), true)); + // Set anisotropic filtering. + float anisotropy = tex->get_anisotropic_degree(); + if (anisotropy > _max_anisotropy) { + anisotropy = _max_anisotropy; + } + if (anisotropy > 1.0) { + GLP(TexParameterf)(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); + } + if (tex->get_format() == Texture::F_depth_stencil) { GLP(TexParameteri)(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); if (_supports_shadow_filter) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 90f4cda120..0807ed7887 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -401,6 +401,7 @@ protected: GLuint _current_ibuffer_index; GLuint _current_fbo; int _num_active_texture_stages; + float _max_anisotropy; int _error_count;