java - libgdx Nearest texture filtering is forced? -
hi making simple import blender , have problem in texture filtering. texture appears filtered nearest min filter nearest min filter , linear mag filter issue questioning texture description attribute says linear. setting linear filtering doesnot change situation
i don't think libgdx has methods available turning on anisotropic filtering, can try helper class. aniostropic filtering not guaranteed supported opengl es, has check availability. haven't tested libgdx in past year, i'm not positive still works correctly.
public class anisotropy { private static boolean anisotropysupported = false; private static boolean checkcomplete = false; private static float maxanisotropysupported = 1.0f; /**applies given anisotropic level texture. returns anisotropy value applied, * based on device's maximum capability. * @param texture texture apply anisotropy to. * @param anisotropy anisotropic level apply. (will reduced if device capability less.) * @return anisotropic level applied, or -1.0 if anisotropy not supported device. */ public static float settextureanisotropy(texture texture, float anisotropy){ if (issupported()) { texture.bind(); float valueapplied = math.min(maxanisotropysupported, anisotropy); gdx.gl20.gltexparameterf(gl20.gl_texture_2d, gl20.gl_texture_max_anisotropy_ext, valueapplied); return valueapplied; } else { return -1f; } } public static boolean issupported(){ if (!checkcomplete){ gl20 gl = gdx.gl; if (gl != null){ if (gdx.graphics.supportsextension("gl_ext_texture_filter_anisotropic")){ anisotropysupported = true; floatbuffer buffer = bufferutils.newfloatbuffer(16); gdx.gl20.glgetfloatv(gl20.gl_max_texture_max_anisotropy_ext, buffer); maxanisotropysupported = buffer.get(0); } checkcomplete = true; } else throw new unsupportedoperationexception("cannot check gl state before libgdx initialized"); } return anisotropysupported; } } 
Comments
Post a Comment