Attempt to fixing 1074 (#1093)

* Attempt to fixing 1074

* Added method implementations in GlRenderer

* Added test.

* Added test to jme-examples

* Some changes to resolve merge conficts

* Fixes

* Indent-fixes

* Documented the class and added stop()

* Fixed a minor error

* Fixed build gradles

* Removed line ending
accellbaker
Karan Nehra 6 years ago committed by Stephen Gold
parent cde108c2c0
commit 9dff704a82
  1. 13
      jme3-core/src/main/java/com/jme3/renderer/Renderer.java
  2. 13
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
  3. 10
      jme3-core/src/main/java/com/jme3/system/NullRenderer.java
  4. 54
      jme3-examples/src/main/java/jme3test/renderer/TestAlphaToCoverage.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();
}

@ -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;
}
}

@ -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;
}
}

@ -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> 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();
}
}
Loading…
Cancel
Save