aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-23 19:28:21 +0200
committerSven Gothel <[email protected]>2012-10-23 19:28:21 +0200
commite027d4a2f9b3d7f23e9a9eec81c0cb011e861269 (patch)
tree679d62942593204d2d0dc4594c7cfda8fc6f7db9 /src/test/com
parent133d7b82d47b2918af042944158e9b09e2663855 (diff)
FixedFuncPipeline: Require GLSL 1.20 (GL 2.1) due to GL driver bugs in OSX (gl_PointCoords n/a otherwise); Add FFP Emul point test in TestPointNEWT/PointDemoES1.
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java45
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java19
3 files changed, 79 insertions, 3 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java
index 37994914e..0ac75d424 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java
@@ -109,6 +109,24 @@ public class TestPointsNEWT extends UITestCase {
}
@Test
+ public void test03FFP__ES2() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ PointsDemoES1 demo = new PointsDemoES1();
+ demo.setForceFFPEmu(true, false, false, false);
+ runTestGL(caps, demo, false);
+ }
+
+ @Test
+ public void test04FFP__GL2ES2() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2ES2)) { System.err.println("GL2ES2 n/a"); return; }
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2));
+ PointsDemoES1 demo = new PointsDemoES1();
+ demo.setForceFFPEmu(true, false, false, false);
+ runTestGL(caps, demo, false);
+ }
+
+ @Test
public void test11GLSL_GL2() throws InterruptedException {
if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
index bfc2e94fe..097784f67 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java
@@ -33,15 +33,25 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
+import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.gl2es1.GLUgl2es1;
public class PointsDemoES1 extends PointsDemo {
final static GLU glu = new GLUgl2es1();
+ private boolean debugFFPEmu = false;
+ private boolean verboseFFPEmu = false;
+ private boolean traceFFPEmu = false;
+ private boolean forceFFPEmu = false;
+ private boolean debug = false ;
+ private boolean trace = false ;
GLArrayDataServer vertices ;
float[] pointSizes ;
private int swapInterval = 0;
@@ -56,10 +66,43 @@ public class PointsDemoES1 extends PointsDemo {
this.swapInterval = 1;
}
+ public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) {
+ this.forceFFPEmu = forceFFPEmu;
+ this.verboseFFPEmu = verboseFFPEmu;
+ this.debugFFPEmu = debugFFPEmu;
+ this.traceFFPEmu = traceFFPEmu;
+ }
+
public void setSmoothPoints(boolean v) { smooth = v; }
public void init(GLAutoDrawable glad) {
- GL2ES1 gl = glad.getGL().getGL2ES1();
+ GL _gl = glad.getGL();
+
+ if(debugFFPEmu) {
+ // Debug ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) );
+ debug = false;
+ }
+ if(traceFFPEmu) {
+ // Trace ..
+ _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) );
+ trace = false;
+ }
+ GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu);
+
+ if(debug) {
+ try {
+ // Debug ..
+ gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) );
+ } catch (Exception e) {e.printStackTrace();}
+ }
+ if(trace) {
+ try {
+ // Trace ..
+ gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) );
+ } catch (Exception e) {e.printStackTrace();}
+ }
+
System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
index 8c6d7e180..27457e23c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java
@@ -58,6 +58,20 @@ public class PointsDemoES2 extends PointsDemo {
/** ( pointSize, pointSmooth, attn. pointMinSize, attn. pointMaxSize ) , ( attenuation coefficients 1f 0f 0f, attenuation fade theshold 1f ) */
private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 4096.0f, 1.0f, 0.0f, 0.0f, 1.0f });
+ static final String es2_prelude_vp = "#version 100\n\nprecision highp float;\nprecision highp int;\n";
+ static final String es2_prelude_fp = "#version 100\n\nprecision mediump float;\nprecision mediump int;\n/*precision lowp sampler2D;*/\n";
+ static final String gl2_prelude = "#version 120\n"; // GL 2.1 (Nvidia driver claims it's required to use gl_Points, OSX claim's it for gl_PointCoord -> driver bug - both were introduced w/ 1.10)
+
+ private void customizeShader(GL2ES2 gl, ShaderCode vp, ShaderCode fp) {
+ if(gl.isGLES2()) {
+ vp.insertShaderSource(0, 0, es2_prelude_vp);
+ fp.insertShaderSource(0, 0, es2_prelude_fp);
+ } else {
+ vp.insertShaderSource(0, 0, gl2_prelude);
+ fp.insertShaderSource(0, 0, gl2_prelude);
+ }
+ }
+
public PointsDemoES2(int swapInterval) {
this.swapInterval = swapInterval;
}
@@ -91,9 +105,10 @@ public class PointsDemoES2 extends PointsDemo {
st = new ShaderState();
st.setVerbose(true);
final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader",
- "shader/bin", "PointsShader", false);
+ "shader/bin", "PointsShader", true);
final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader",
- "shader/bin", "PointsShader", false);
+ "shader/bin", "PointsShader", true);
+ customizeShader(gl, vp0, fp0);
final ShaderProgram sp0 = new ShaderProgram();
sp0.add(gl, vp0, System.err);
sp0.add(gl, fp0, System.err);