diff --git a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java index 095cc76de..ee1108878 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java @@ -443,5 +443,18 @@ public interface Renderer { * @return true if the results of the task with the given task id are available. */ public boolean isTaskResultAvailable(int taskId); + + + /** + * Gets the alpha to coverage state. + * + */ + public boolean getAlphaToCoverage(); + + /** + * Get the default anisotropic filter level for textures. + * + */ + public int getDefaultAnisotropicFilter(); } diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 6f222eb02..0e5a01d99 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -3136,4 +3136,17 @@ public final class GLRenderer implements Renderer { public boolean isTaskResultAvailable(int taskId) { return gl.glGetQueryObjectiv(taskId, GL.GL_QUERY_RESULT_AVAILABLE) == 1; } + @Override + public boolean getAlphaToCoverage() { + if (caps.contains(Caps.Multisample)) { + return gl.glIsEnabled(GLExt.GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + + } + return false; + } + + @Override + public int getDefaultAnisotropicFilter() { + return this.defaultAnisotropicFilter; + } } diff --git a/jme3-core/src/main/java/com/jme3/system/NullRenderer.java b/jme3-core/src/main/java/com/jme3/system/NullRenderer.java index 3c289ecc3..76b3fa146 100644 --- a/jme3-core/src/main/java/com/jme3/system/NullRenderer.java +++ b/jme3-core/src/main/java/com/jme3/system/NullRenderer.java @@ -212,4 +212,14 @@ public class NullRenderer implements Renderer { @Override public void setDefaultAnisotropicFilter(int level) { } + + @Override + public boolean getAlphaToCoverage() { + return false; + } + + @Override + public int getDefaultAnisotropicFilter() { + return 0; + } } diff --git a/jme3-examples/src/main/java/jme3test/renderer/TestAlphaToCoverage.java b/jme3-examples/src/main/java/jme3test/renderer/TestAlphaToCoverage.java new file mode 100644 index 000000000..1765e5478 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/renderer/TestAlphaToCoverage.java @@ -0,0 +1,54 @@ +package jme3test.renderer; +import com.jme3.app.SimpleApplication; + +import com.jme3.renderer.lwjgl.LwjglGL; +import com.jme3.renderer.opengl.GL; +import com.jme3.renderer.opengl.GLExt; +import com.jme3.renderer.opengl.GLFbo; +import com.jme3.renderer.opengl.GLRenderer; +import com.jme3.renderer.lwjgl.LwjglGLExt; +import com.jme3.renderer.lwjgl.LwjglGLFboEXT; +import com.jme3.renderer.Caps; + +import java.util.EnumSet; + +/** + * Simple application to test the getter and setters of AlphaToCoverage and + * DefaultAnisotropicFilter from the GLRenderer class. + * + * Since the app doesn't display anything relevant a stop() has been added + * This starts and closes the app on a successful run + */ +public class TestAlphaToCoverage extends SimpleApplication { + + public static void main(String[] args) { + new TestAlphaToCoverage().start(); + } + + public GL gl = new LwjglGL(); + public GLExt glext = new LwjglGLExt(); + public GLFbo glfbo = new LwjglGLFboEXT(); + private GLRenderer glRenderer= new GLRenderer(gl,glext,glfbo); + + public EnumSet caps = glRenderer.getCaps(); + + + + @Override + public void simpleInitApp() { + glRenderer.setAlphaToCoverage(false); + assert !glRenderer.getAlphaToCoverage(); + + caps.add(Caps.Multisample); + glRenderer.setAlphaToCoverage(true); + assert glRenderer.getAlphaToCoverage(); + glRenderer.setAlphaToCoverage(false); + assert !glRenderer.getAlphaToCoverage(); + + glRenderer.setDefaultAnisotropicFilter(1); + assert glRenderer.getDefaultAnisotropicFilter() == 1; + + stop(); + } + +}