Renderer: add setDefaultAnisotropicFilter

cleanup_build_scripts
Kirill Vainer 9 years ago
parent eecca5fa0f
commit 33b67a381c
  1. 16
      jme3-core/src/main/java/com/jme3/renderer/Renderer.java
  2. 20
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
  3. 3
      jme3-core/src/main/java/com/jme3/system/NullRenderer.java
  4. 2
      jme3-core/src/main/java/com/jme3/texture/image/LastTextureState.java

@ -310,7 +310,21 @@ public interface Renderer {
* @see NativeObject#deleteObject(java.lang.Object)
*/
public void cleanup();
/**
* Set the default anisotropic filter level for textures.
*
* If the
* {@link Texture#setAnisotropicFilter(int) texture anisotropic filter} is
* set to 0, then the default level is used. Otherwise if the texture level
* is 1 or greater, then the texture's value overrides the default value.
*
* @param level The default anisotropic filter level to use. Default: 1.
*
* @throws IllegalArgumentException If level is less than 1.
*/
public void setDefaultAnisotropicFilter(int level);
/**
* Sets the alpha to coverage state.
* <p>

@ -90,6 +90,7 @@ public final class GLRenderer implements Renderer {
private final Statistics statistics = new Statistics();
private int vpX, vpY, vpW, vpH;
private int clipX, clipY, clipW, clipH;
private int defaultAnisotropicFilter = 1;
private boolean linearizeSrgbImages;
private HashSet<String> extensions;
@ -600,6 +601,14 @@ public final class GLRenderer implements Renderer {
}
}
@Override
public void setDefaultAnisotropicFilter(int level) {
if (level < 1) {
throw new IllegalArgumentException("level cannot be less than 1");
}
this.defaultAnisotropicFilter = level;
}
public void setAlphaToCoverage(boolean value) {
if (caps.contains(Caps.Multisample)) {
if (value) {
@ -1878,13 +1887,18 @@ public final class GLRenderer implements Renderer {
gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, convertMinFilter(tex.getMinFilter(), haveMips));
curState.minFilter = tex.getMinFilter();
}
int desiredAnisoFilter = tex.getAnisotropicFilter() == 0
? defaultAnisotropicFilter
: tex.getAnisotropicFilter();
if (caps.contains(Caps.TextureFilterAnisotropic)
&& curState.anisoFilter != tex.getAnisotropicFilter()) {
&& curState.anisoFilter != desiredAnisoFilter) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameterf(target,
GLExt.GL_TEXTURE_MAX_ANISOTROPY_EXT,
tex.getAnisotropicFilter());
curState.anisoFilter = tex.getAnisotropicFilter();
desiredAnisoFilter);
curState.anisoFilter = desiredAnisoFilter;
}
switch (tex.getType()) {

@ -175,4 +175,7 @@ public class NullRenderer implements Renderer {
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
}
@Override
public void setDefaultAnisotropicFilter(int level) {
}
}

@ -58,7 +58,7 @@ public final class LastTextureState {
rWrap = null;
magFilter = null;
minFilter = null;
anisoFilter = 0;
anisoFilter = 1;
// The default in OpenGL is OFF, so we avoid setting this per texture
// if its not used.

Loading…
Cancel
Save