* Use mipmap minification modes only if mipmaps are actually available

experimental
shadowislord 10 years ago
parent 4d7dcc17bb
commit 7860ccca52
  1. 55
      jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java

@ -1757,22 +1757,37 @@ public class LwjglRenderer implements Renderer {
} }
} }
private int convertMinFilter(Texture.MinFilter filter) { private int convertMinFilter(Texture.MinFilter filter, boolean haveMips) {
switch (filter) { if (haveMips){
case Trilinear: switch (filter) {
return GL_LINEAR_MIPMAP_LINEAR; case Trilinear:
case BilinearNearestMipMap: return GL_LINEAR_MIPMAP_LINEAR;
return GL_LINEAR_MIPMAP_NEAREST; case BilinearNearestMipMap:
case NearestLinearMipMap: return GL_LINEAR_MIPMAP_NEAREST;
return GL_NEAREST_MIPMAP_LINEAR; case NearestLinearMipMap:
case NearestNearestMipMap: return GL_NEAREST_MIPMAP_LINEAR;
return GL_NEAREST_MIPMAP_NEAREST; case NearestNearestMipMap:
case BilinearNoMipMaps: return GL_NEAREST_MIPMAP_NEAREST;
return GL_LINEAR; case BilinearNoMipMaps:
case NearestNoMipMaps: return GL_LINEAR;
return GL_NEAREST; case NearestNoMipMaps:
default: return GL_NEAREST;
throw new UnsupportedOperationException("Unknown min filter: " + filter); default:
throw new UnsupportedOperationException("Unknown min filter: " + filter);
}
} else {
switch (filter) {
case Trilinear:
case BilinearNearestMipMap:
case BilinearNoMipMaps:
return GL_LINEAR;
case NearestLinearMipMap:
case NearestNearestMipMap:
case NearestNoMipMaps:
return GL_NEAREST;
default:
throw new UnsupportedOperationException("Unknown min filter: " + filter);
}
} }
} }
@ -1798,8 +1813,14 @@ public class LwjglRenderer implements Renderer {
Image image = tex.getImage(); Image image = tex.getImage();
int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1); int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1);
boolean haveMips = true;
if (image != null) {
haveMips = image.isGeneratedMipmapsRequired() || image.hasMipmaps();
}
// filter things // filter things
int minFilter = convertMinFilter(tex.getMinFilter()); int minFilter = convertMinFilter(tex.getMinFilter(), haveMips);
int magFilter = convertMagFilter(tex.getMagFilter()); int magFilter = convertMagFilter(tex.getMagFilter());
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);

Loading…
Cancel
Save