From 7860ccca5288e8ef51f5e0cb3f09c988795d22c6 Mon Sep 17 00:00:00 2001 From: shadowislord Date: Tue, 4 Nov 2014 16:40:09 -0500 Subject: [PATCH] * Use mipmap minification modes only if mipmaps are actually available --- .../jme3/renderer/lwjgl/LwjglRenderer.java | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java index f3ef9055c..c23919ded 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java +++ b/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) { - switch (filter) { - case Trilinear: - return GL_LINEAR_MIPMAP_LINEAR; - case BilinearNearestMipMap: - return GL_LINEAR_MIPMAP_NEAREST; - case NearestLinearMipMap: - return GL_NEAREST_MIPMAP_LINEAR; - case NearestNearestMipMap: - return GL_NEAREST_MIPMAP_NEAREST; - case BilinearNoMipMaps: - return GL_LINEAR; - case NearestNoMipMaps: - return GL_NEAREST; - default: - throw new UnsupportedOperationException("Unknown min filter: " + filter); + private int convertMinFilter(Texture.MinFilter filter, boolean haveMips) { + if (haveMips){ + switch (filter) { + case Trilinear: + return GL_LINEAR_MIPMAP_LINEAR; + case BilinearNearestMipMap: + return GL_LINEAR_MIPMAP_NEAREST; + case NearestLinearMipMap: + return GL_NEAREST_MIPMAP_LINEAR; + case NearestNearestMipMap: + return GL_NEAREST_MIPMAP_NEAREST; + case BilinearNoMipMaps: + return GL_LINEAR; + case NearestNoMipMaps: + return GL_NEAREST; + 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(); int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1); + boolean haveMips = true; + + if (image != null) { + haveMips = image.isGeneratedMipmapsRequired() || image.hasMipmaps(); + } + // filter things - int minFilter = convertMinFilter(tex.getMinFilter()); + int minFilter = convertMinFilter(tex.getMinFilter(), haveMips); int magFilter = convertMagFilter(tex.getMagFilter()); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);