diff options
Diffstat (limited to 'src/test/com')
3 files changed, 63 insertions, 56 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java index c83af4362..ae08b640c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java @@ -40,7 +40,8 @@ public class GLSLMiscHelper { public static final int frames_perftest = 10000; // frames public static final int frames_warmup = 500; // frames - public static void validateGLArrayDataServerState(GL2ES2 gl, ShaderState st, GLArrayDataServer data) { + public static void validateGLArrayDataServerState(GL2ES2 gl, GLArrayDataServer data) { + final ShaderState st = ShaderState.getShaderState(gl); int[] qi = new int[1]; if(null != st) { Assert.assertEquals(data, st.getAttribute(data.getName())); @@ -65,7 +66,7 @@ public class GLSLMiscHelper { } } - public static void displayVCArrays(GLDrawable drawable, GL2ES2 gl, ShaderState st, boolean preEnable, GLArrayDataServer vertices, GLArrayDataServer colors, boolean postDisable, int num, long postDelay) throws InterruptedException { + public static void displayVCArrays(GLDrawable drawable, GL2ES2 gl, boolean preEnable, GLArrayDataServer vertices, GLArrayDataServer colors, boolean postDisable, int num, long postDelay) throws InterruptedException { System.err.println("screen #"+num); if(preEnable) { vertices.enableBuffer(gl, true); @@ -80,8 +81,8 @@ public class GLSLMiscHelper { Assert.assertTrue(vertices.enabled()); Assert.assertTrue(colors.enabled()); - validateGLArrayDataServerState(gl, st, vertices); - validateGLArrayDataServerState(gl, st, colors); + validateGLArrayDataServerState(gl, vertices); + validateGLArrayDataServerState(gl, colors); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); @@ -110,7 +111,9 @@ public class GLSLMiscHelper { drawable.swapBuffers(); } - public static GLArrayDataServer createRSVertices0(GL2ES2 gl, ShaderState st, int location) { + public static GLArrayDataServer createRSVertices0(GL2ES2 gl, int location) { + final ShaderState st = ShaderState.getShaderState(gl); + // Allocate Vertex Array0 GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); if(0<=location) { @@ -130,11 +133,11 @@ public class GLSLMiscHelper { Assert.assertEquals(4, vertices0.getElementCount()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices0.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); - validateGLArrayDataServerState(gl, st, vertices0); + validateGLArrayDataServerState(gl, vertices0); return vertices0; } - public static GLArrayDataServer createRSVertices1(GL2ES2 gl, ShaderState st) { + public static GLArrayDataServer createRSVertices1(GL2ES2 gl) { GLArrayDataServer vertices1 = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); Assert.assertTrue(vertices1.isVBO()); Assert.assertTrue(vertices1.isVertexAttribute()); @@ -150,11 +153,12 @@ public class GLSLMiscHelper { Assert.assertEquals(4, vertices1.getElementCount()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices1.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); - validateGLArrayDataServerState(gl, st, vertices1); + validateGLArrayDataServerState(gl, vertices1); return vertices1; } - public static GLArrayDataServer createRSColors0(GL2ES2 gl, ShaderState st, int location) { + public static GLArrayDataServer createRSColors0(GL2ES2 gl, int location) { + final ShaderState st = ShaderState.getShaderState(gl); GLArrayDataServer colors0 = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); if(0<=location) { st.bindAttribLocation(gl, location, colors0); @@ -170,11 +174,11 @@ public class GLSLMiscHelper { Assert.assertTrue(colors0.sealed()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(colors0.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); - validateGLArrayDataServerState(gl, st, colors0); + validateGLArrayDataServerState(gl, colors0); return colors0; } - public static GLArrayDataServer createRSColors1(GL2ES2 gl, ShaderState st) { + public static GLArrayDataServer createRSColors1(GL2ES2 gl) { // Allocate Color Array1 GLArrayDataServer colors1 = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); colors1.putf(1); colors1.putf(0); colors1.putf(1); colors1.putf(1); @@ -188,7 +192,7 @@ public class GLSLMiscHelper { Assert.assertTrue(colors1.sealed()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(colors1.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER)); - validateGLArrayDataServerState(gl, st, colors1); + validateGLArrayDataServerState(gl, colors1); return colors1; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index b8551527e..4b7617d63 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -88,15 +88,19 @@ public class TestGLSLShaderState01NEWT extends UITestCase { st.attachShaderProgram(gl, sp); + Assert.assertEquals(null, ShaderState.getShaderState(gl)); + st.setShaderState(gl); // pre-use attach + Assert.assertEquals(st, ShaderState.getShaderState(gl)); + // Allocate Vertex Array0 - final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, vertices0_loc); + final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, vertices0_loc); System.err.println("vertices0: " + vertices0); vertices0.enableBuffer(gl, false); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); st.ownAttribute(vertices0, true); // Allocate Color Array0 - final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, colors0_loc); + final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, colors0_loc); System.err.println("colors0: " + colors0); colors0.enableBuffer(gl, false); Assert.assertEquals(colors0_loc, colors0.getLocation()); @@ -107,16 +111,14 @@ public class TestGLSLShaderState01NEWT extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); - GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices0); + GLSLMiscHelper.validateGLArrayDataServerState(gl, vertices0); Assert.assertEquals(colors0_loc, colors0.getLocation()); - GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors0); + GLSLMiscHelper.validateGLArrayDataServerState(gl, colors0); - Assert.assertEquals(null, ShaderState.getShaderState(gl)); st.useProgram(gl, true); Assert.assertTrue(sp.inUse()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertEquals(st, ShaderState.getShaderState(gl)); // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); @@ -129,17 +131,17 @@ public class TestGLSLShaderState01NEWT extends UITestCase { Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix")); // Allocate Vertex Array1 - final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl); System.err.println("vertices1: " + vertices1); vertices1.enableBuffer(gl, false); - GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices1); + GLSLMiscHelper.validateGLArrayDataServerState(gl, vertices1); st.ownAttribute(vertices1, true); // Allocate Color Array1 - final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl); System.err.println("colors1: " + colors1); colors1.enableBuffer(gl, false); - GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors1); + GLSLMiscHelper.validateGLArrayDataServerState(gl, colors1); st.ownAttribute(colors0, true); // misc GL setup @@ -159,13 +161,13 @@ public class TestGLSLShaderState01NEWT extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // display #1 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, durationPerTest); // display #2 #1 vertices1 / colors1 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, durationPerTest); // display #3 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 3, durationPerTest); // cleanup st.destroy(gl); @@ -217,12 +219,12 @@ public class TestGLSLShaderState01NEWT extends UITestCase { st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 - final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1); st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, toggleEnable ? false : true); // Allocate Color Array0 - final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1); st.ownAttribute(colors0, true); colors0.enableBuffer(gl, toggleEnable ? false : true); @@ -243,7 +245,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { gl.setSwapInterval(0); // validation .. - GLSLMiscHelper.displayVCArrays(drawable, gl, st, toggleEnable, vertices0, colors0, toggleEnable, 1, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable, 1, 0); // warmup .. for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) { @@ -306,22 +308,22 @@ public class TestGLSLShaderState01NEWT extends UITestCase { st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 - final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1); st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, false); // Allocate Vertex Array1 - final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl); st.ownAttribute(vertices1, true); vertices1.enableBuffer(gl, false); // Allocate Color Array0 - final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1); st.ownAttribute(colors0, true); colors0.enableBuffer(gl, false); // Allocate Color Array1 - final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl); st.ownAttribute(colors1, true); colors1.enableBuffer(gl, false); @@ -342,8 +344,8 @@ public class TestGLSLShaderState01NEWT extends UITestCase { gl.setSwapInterval(0); // validation .. - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0); - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0); // warmup .. for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index f71b7bea7..854bc2aa6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -114,16 +114,19 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); st.attachShaderProgram(gl, sp0); + Assert.assertEquals(null, ShaderState.getShaderState(gl)); + st.setShaderState(gl); // pre-use attach + Assert.assertEquals(st, ShaderState.getShaderState(gl)); // Allocate Vertex Array0 - final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, vertices0_loc); + final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, vertices0_loc); st.ownAttribute(vertices0, true); System.err.println("vertices0: " + vertices0); vertices0.enableBuffer(gl, false); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); // Allocate Color Array0 - final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, colors0_loc); + final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, colors0_loc); st.ownAttribute(colors0, true); System.err.println("colors0: " + colors0); colors0.enableBuffer(gl, false); @@ -141,11 +144,9 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertEquals(colors0_loc, st.getAttribLocation(gl, colors0.getName())); Assert.assertEquals(colors0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), colors0.getName())); - Assert.assertEquals(null, ShaderState.getShaderState(gl)); st.useProgram(gl, true); Assert.assertTrue(sp0.inUse()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertEquals(st, ShaderState.getShaderState(gl)); // setup mgl_PMVMatrix final PMVMatrix pmvMatrix = new PMVMatrix(); @@ -158,13 +159,13 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix")); // Allocate Vertex Array1 - final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl); st.ownAttribute(vertices1, true); System.err.println("vertices1: " + vertices1); vertices1.enableBuffer(gl, false); // Allocate Color Array1 - final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl); st.ownAttribute(colors1, true); System.err.println("colors1: " + colors1); colors1.enableBuffer(gl, false); @@ -186,16 +187,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // display #1 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, durationPerTest); // display #2 vertices1 / colors1 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, durationPerTest); // display #3 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 3, durationPerTest); // display #4 vertices1 / colors1 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 4, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 4, durationPerTest); // SP1 st.attachShaderProgram(gl, sp1); @@ -212,16 +213,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase { } // display #1 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 10, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 10, durationPerTest); // display #2 vertices1 / colors1 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 20, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 20, durationPerTest); // display #3 vertices0 / colors0 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 30, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 30, durationPerTest); // display #4 vertices1 / colors1 (post-disable) - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 40, durationPerTest); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 40, durationPerTest); // cleanup st.destroy(gl); @@ -275,22 +276,22 @@ public class TestGLSLShaderState02NEWT extends UITestCase { st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 - final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, -1); st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, false); // Allocate Vertex Array1 - final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl); st.ownAttribute(vertices1, true); vertices1.enableBuffer(gl, false); // Allocate Color Array0 - final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, -1); st.ownAttribute(colors0, true); colors0.enableBuffer(gl, false); // Allocate Color Array1 - final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl); st.ownAttribute(colors1, true); colors1.enableBuffer(gl, false); @@ -312,11 +313,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // validation .. st.attachShaderProgram(gl, sp0); - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0); - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0); st.attachShaderProgram(gl, sp1); - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0); - GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices0, colors0, true, 1, 0); + GLSLMiscHelper.displayVCArrays(drawable, gl, true, vertices1, colors1, true, 2, 0); // warmup .. for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) { |