gradle-4.1
Kirill Vainer 8 years ago committed by GitHub
parent ef5952bcad
commit d2839fd2ab
  1. 61
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java

@ -1980,7 +1980,13 @@ public final class GLRenderer implements Renderer {
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
private void setupTextureParams(int unit, Texture tex) { private void setupTextureParams(int unit, Texture tex) {
Image image = tex.getImage(); Image image = tex.getImage();
int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1); int samples = image != null ? image.getMultiSamples() : 1;
int target = convertTextureType(tex.getType(), samples, -1);
if (samples > 1) {
bindTextureOnly(target, image, unit);
return;
}
boolean haveMips = true; boolean haveMips = true;
if (image != null) { if (image != null) {
@ -2183,41 +2189,46 @@ public final class GLRenderer implements Renderer {
int target = convertTextureType(type, img.getMultiSamples(), -1); int target = convertTextureType(type, img.getMultiSamples(), -1);
bindTextureAndUnit(target, img, unit); bindTextureAndUnit(target, img, unit);
if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) { int imageSamples = img.getMultiSamples();
// Image does not have mipmaps, but they are required.
// Generate from base level.
if (!caps.contains(Caps.FrameBuffer) && gl2 != null) { if (imageSamples <= 1) {
gl2.glTexParameteri(target, GL2.GL_GENERATE_MIPMAP, GL.GL_TRUE); if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) {
img.setMipmapsGenerated(true); // Image does not have mipmaps, but they are required.
// Generate from base level.
if (!caps.contains(Caps.FrameBuffer) && gl2 != null) {
gl2.glTexParameteri(target, GL2.GL_GENERATE_MIPMAP, GL.GL_TRUE);
img.setMipmapsGenerated(true);
} else {
// For OpenGL3 and up.
// We'll generate mipmaps via glGenerateMipmapEXT (see below)
}
} else if (img.hasMipmaps()) {
// Image already has mipmaps, set the max level based on the
// number of mipmaps we have.
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
} else { } else {
// For OpenGL3 and up. // Image does not have mipmaps and they are not required.
// We'll generate mipmaps via glGenerateMipmapEXT (see below) // Specify that that the texture has no mipmaps.
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, 0);
} }
} else if (img.hasMipmaps()) {
// Image already has mipmaps, set the max level based on the
// number of mipmaps we have.
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
} else { } else {
// Image does not have mipmaps and they are not required. // Check if graphics card doesn't support multisample textures
// Specify that that the texture has no mipmaps. if (!caps.contains(Caps.TextureMultisample)) {
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, 0); throw new RendererException("Multisample textures are not supported by the video hardware");
} }
if (img.isGeneratedMipmapsRequired() || img.hasMipmaps()) {
throw new RendererException("Multisample textures do not support mipmaps");
}
int imageSamples = img.getMultiSamples();
if (imageSamples > 1) {
if (img.getFormat().isDepthFormat()) { if (img.getFormat().isDepthFormat()) {
img.setMultiSamples(Math.min(limits.get(Limits.DepthTextureSamples), imageSamples)); img.setMultiSamples(Math.min(limits.get(Limits.DepthTextureSamples), imageSamples));
} else { } else {
img.setMultiSamples(Math.min(limits.get(Limits.ColorTextureSamples), imageSamples)); img.setMultiSamples(Math.min(limits.get(Limits.ColorTextureSamples), imageSamples));
} }
}
// Check if graphics card doesn't support multisample textures scaleToPot = false;
if (!caps.contains(Caps.TextureMultisample)) {
if (img.getMultiSamples() > 1) {
throw new RendererException("Multisample textures are not supported by the video hardware");
}
} }
// Check if graphics card doesn't support depth textures // Check if graphics card doesn't support depth textures

Loading…
Cancel
Save