diff options
author | Sven Gothel <[email protected]> | 2011-04-26 07:53:27 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-26 07:53:27 +0200 |
commit | 360b86f4b5d0e440863c1749fe990e39fbabc51c (patch) | |
tree | 6be44962f9cf59740597e1dd745bd2204b150ac1 /src/test/com/jogamp | |
parent | f47230cb4649df13260ac56c5dae6c01dad7c1e7 (diff) |
ShaderState: Add 'ownUniform()/ownAttribute()'; rename glFunction -> function; switch program enh. ; Graph lifecycle
Add 'ownUniform()/ownAttribute()' allowing to reset all bound uniforms/attributes,
not just active ones plus handling the lifecycle of the owned attributes (destroy).
This simplifies the lifecycle of all shader attributes.
Rename glFunction -> function .. well, the GL attribute marks them GL related already
Switch program enhancement. If switching to new program (unlinked), issue glBindAttributeLocation ..
Graph lifecycle cleanup using the above ..
Diffstat (limited to 'src/test/com/jogamp')
7 files changed, 101 insertions, 100 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index 8a16113f5..3daa97ab3 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -126,7 +126,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { autoDrawable = null; GL2ES2 gl = drawable.getGL().getGL2ES2(); screenshot.dispose(gl); - renderer.dispose(gl); + renderer.destroy(gl); } public void zoom(int v){ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java index 9ad036d96..e9e5bc105 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java @@ -104,7 +104,7 @@ public class UIGLListener01 extends UIListenerBase01 { public void dispose(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); + glyphString.destroy(gl, getRegionRenderer().getRenderState()); super.dispose(drawable); - glyphString.destroy(gl); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index c74d11f0d..98a7d4531 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -130,8 +130,8 @@ public abstract class UIListenerBase01 implements GLEventListener { autoDrawable = null; GL2ES2 gl = drawable.getGL().getGL2ES2(); screenshot.dispose(gl); - rRenderer.dispose(gl); - tRenderer.dispose(gl); + rRenderer.destroy(gl); + tRenderer.destroy(gl); } public void zoom(int v){ 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 ebe24cb00..e75bd7bdd 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 @@ -110,8 +110,8 @@ public class GLSLMiscHelper { Assert.assertEquals(data, st.getAttribute(data.getName())); if(st.shaderProgram().linked()) { Assert.assertEquals(data.getLocation(), st.getAttribLocation(data.getName())); - Assert.assertEquals(data.getLocation(), st.glGetAttribLocation(gl, data)); - Assert.assertEquals(data.getLocation(), st.glGetAttribLocation(gl, data.getName())); + Assert.assertEquals(data.getLocation(), st.getAttribLocation(gl, data)); + Assert.assertEquals(data.getLocation(), st.getAttribLocation(gl, data.getName())); Assert.assertEquals(data.getLocation(), gl.glGetAttribLocation(st.shaderProgram().program(), data.getName())); } } @@ -178,7 +178,7 @@ public class GLSLMiscHelper { // Allocate Vertex Array0 GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL(st, "mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); if(0<=location) { - st.glBindAttribLocation(gl, location, vertices0); + st.bindAttribLocation(gl, location, vertices0); } Assert.assertTrue(vertices0.isVBO()); Assert.assertTrue(vertices0.isVertexAttribute()); @@ -221,7 +221,7 @@ public class GLSLMiscHelper { public static GLArrayDataServer createRSColors0(GL2ES2 gl, ShaderState st, int location) { GLArrayDataServer colors0 = GLArrayDataServer.createGLSL(st, "mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); if(0<=location) { - st.glBindAttribLocation(gl, location, colors0); + st.bindAttribLocation(gl, location, colors0); } colors0.putf(1); colors0.putf(0); colors0.putf(0); colors0.putf(1); colors0.putf(0); colors0.putf(0); colors0.putf(1); colors0.putf(1); 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 f357113d3..9bce30285 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 @@ -91,12 +91,14 @@ public class TestGLSLShaderState01NEWT extends UITestCase { System.err.println("vertices0: " + vertices0); vertices0.enableBuffer(gl, false); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); + st.ownAttribute(vertices0, true); // Allocate Color Array0 GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, colors0_loc); System.err.println("colors0: " + colors0); colors0.enableBuffer(gl, false); Assert.assertEquals(colors0_loc, colors0.getLocation()); + st.ownAttribute(colors0, true); Assert.assertTrue(sp.link(gl, System.err)); Assert.assertTrue(sp.linked()); @@ -109,31 +111,34 @@ public class TestGLSLShaderState01NEWT extends UITestCase { GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors0); Assert.assertEquals(null, ShaderState.getShaderState(gl)); - st.glUseProgram(gl, true); + 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 + // setup gcu_PMVMatrix PMVMatrix pmvMatrix = new PMVMatrix(); - GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.ownUniform(pmvMatrixUniform); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix")); + Assert.assertEquals(pmvMatrixUniform, st.getUniform("gcu_PMVMatrix")); // Allocate Vertex Array1 GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); System.err.println("vertices1: " + vertices1); vertices1.enableBuffer(gl, false); GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices1); + st.ownAttribute(vertices1, true); // Allocate Color Array1 GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); System.err.println("colors1: " + colors1); colors1.enableBuffer(gl, false); GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors1); + st.ownAttribute(colors0, true); // misc GL setup gl.glClearColor(0, 0, 0, 1); @@ -147,7 +152,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // display #1 vertices0 / colors0 (post-disable) @@ -160,12 +165,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest); // cleanup - vertices1.destroy(gl); - vertices0.destroy(gl); - colors0.destroy(gl); - colors1.destroy(gl); - st.glUseProgram(gl, false); - sp.release(gl, true); + st.destroy(gl); GLSLMiscHelper.destroyWindow(winctx); } @@ -203,19 +203,22 @@ public class TestGLSLShaderState01NEWT extends UITestCase { Assert.assertTrue(sp.link(gl, System.err)); st.attachShaderProgram(gl, sp); - st.glUseProgram(gl, true); + st.useProgram(gl, true); - // setup mgl_PMVMatrix + // setup gcu_PMVMatrix PMVMatrix pmvMatrix = new PMVMatrix(); - GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); - st.glUniform(gl, pmvMatrixUniform); + GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, toggleEnable ? false : true); // Allocate Color Array0 GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + st.ownAttribute(colors0, true); colors0.enableBuffer(gl, toggleEnable ? false : true); // misc GL setup @@ -229,7 +232,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); long t0 = System.currentTimeMillis(); int frames; @@ -253,10 +256,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { System.err.println("testShaderState00PerformanceSingle toggleEnable "+toggleEnable+": "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f"); // cleanup - st.glUseProgram(gl, false); - sp.release(gl, true); - vertices0.destroy(gl); - colors0.destroy(gl); + st.destroy(gl); GLSLMiscHelper.destroyWindow(winctx); } @@ -286,27 +286,32 @@ public class TestGLSLShaderState01NEWT extends UITestCase { Assert.assertTrue(sp.link(gl, System.err)); st.attachShaderProgram(gl, sp); - st.glUseProgram(gl, true); + st.useProgram(gl, true); - // setup mgl_PMVMatrix + // setup gcu_PMVMatrix PMVMatrix pmvMatrix = new PMVMatrix(); - GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); - st.glUniform(gl, pmvMatrixUniform); + GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 - GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, false); // Allocate Vertex Array1 - GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + st.ownAttribute(vertices1, true); vertices1.enableBuffer(gl, false); // Allocate Color Array0 GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + st.ownAttribute(colors0, true); colors0.enableBuffer(gl, false); // Allocate Color Array1 GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + st.ownAttribute(colors1, true); colors1.enableBuffer(gl, false); // misc GL setup @@ -320,7 +325,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); // validation .. GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0); @@ -346,12 +351,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase { System.err.println("testShaderState01PerformanceDouble: "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f"); // cleanup - st.glUseProgram(gl, false); - sp.release(gl, true); - vertices1.destroy(gl); - vertices0.destroy(gl); - colors0.destroy(gl); - colors1.destroy(gl); + st.destroy(gl); GLSLMiscHelper.destroyWindow(winctx); } 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 10e506693..7e8fb7c3d 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 @@ -57,10 +57,18 @@ public class TestGLSLShaderState02NEWT extends UITestCase { static long durationPerTest = 10; // ms static final int vertices0_loc = 0; // FIXME: AMD needs this to be location 0 ? hu ? - static final int colors0_loc = 2; + static final int colors0_loc = 5; @Test - public void testShaderState01Validation() throws InterruptedException { + public void testShaderState01ValidationSP1Linked() throws InterruptedException { + testShaderState01Validation(true); + } + @Test + public void testShaderState01ValidationSP1Unlinked() throws InterruptedException { + testShaderState01Validation(false); + } + + private void testShaderState01Validation(boolean linkSP1) throws InterruptedException { // preset .. GLSLMiscHelper.WindowContext winctx = GLSLMiscHelper.createWindow(GLProfile.getGL2ES2(), true); GLDrawable drawable = winctx.context.getGLDrawable(); @@ -88,9 +96,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertTrue(!sp1.inUse()); Assert.assertTrue(!sp1.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertTrue(sp1.link(gl, System.err)); - Assert.assertTrue(sp1.linked()); - Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + if(linkSP1) { + Assert.assertTrue(sp1.link(gl, System.err)); + Assert.assertTrue(sp1.linked()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + } ShaderProgram sp0 = new ShaderProgram(); sp0.add(rsVp0); @@ -108,12 +118,14 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // Allocate Vertex Array0 GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, vertices0_loc); + st.ownAttribute(vertices0, true); System.err.println("vertices0: " + vertices0); vertices0.enableBuffer(gl, false); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); // Allocate Color Array0 GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, colors0_loc); + st.ownAttribute(colors0, true); System.err.println("colors0: " + colors0); colors0.enableBuffer(gl, false); Assert.assertEquals(colors0_loc, colors0.getLocation()); @@ -123,35 +135,38 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); Assert.assertEquals(vertices0_loc, vertices0.getLocation()); - Assert.assertEquals(vertices0_loc, st.glGetAttribLocation(gl, vertices0.getName())); + Assert.assertEquals(vertices0_loc, st.getAttribLocation(gl, vertices0.getName())); Assert.assertEquals(vertices0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), vertices0.getName())); Assert.assertEquals(colors0_loc, colors0.getLocation()); - Assert.assertEquals(colors0_loc, st.glGetAttribLocation(gl, colors0.getName())); + 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.glUseProgram(gl, true); + 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 + // setup gcu_PMVMatrix PMVMatrix pmvMatrix = new PMVMatrix(); - GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix")); + Assert.assertEquals(pmvMatrixUniform, st.getUniform("gcu_PMVMatrix")); // Allocate Vertex Array1 GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + st.ownAttribute(vertices1, true); System.err.println("vertices1: " + vertices1); vertices1.enableBuffer(gl, false); // Allocate Color Array1 GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + st.ownAttribute(colors1, true); System.err.println("colors1: " + colors1); colors1.enableBuffer(gl, false); @@ -167,7 +182,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase { pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // display #1 vertices0 / colors0 (post-disable) @@ -180,14 +195,19 @@ public class TestGLSLShaderState02NEWT extends UITestCase { GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest); // SP1 - // both are currently not attached to ShaderState, hence we have to reset their location as well - vertices0.setLocation(-1); - colors0.setLocation(-1); - vertices1.setLocation(-1); - colors1.setLocation(-1); - st.attachShaderProgram(gl, sp1); + if(!linkSP1) { + // all attribute locations shall be same now, due to impl. glBindAttributeLocation + Assert.assertEquals(vertices0_loc, vertices0.getLocation()); + Assert.assertEquals(vertices0_loc, st.getAttribLocation(gl, vertices0.getName())); + Assert.assertEquals(vertices0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), vertices0.getName())); + + Assert.assertEquals(colors0_loc, colors0.getLocation()); + Assert.assertEquals(colors0_loc, st.getAttribLocation(gl, colors0.getName())); + Assert.assertEquals(colors0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), colors0.getName())); + } + // display #1 vertices0 / colors0 (post-disable) GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 10, durationPerTest); @@ -198,12 +218,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase { GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 30, durationPerTest); // cleanup - vertices1.destroy(gl); - vertices0.destroy(gl); - colors0.destroy(gl); - colors1.destroy(gl); - st.glUseProgram(gl, false); - sp0.release(gl, true); + st.destroy(gl); GLSLMiscHelper.destroyWindow(winctx); } @@ -243,27 +258,32 @@ public class TestGLSLShaderState02NEWT extends UITestCase { Assert.assertTrue(sp0.link(gl, System.err)); st.attachShaderProgram(gl, sp0); - st.glUseProgram(gl, true); + st.useProgram(gl, true); - // setup mgl_PMVMatrix + // setup gcu_PMVMatrix PMVMatrix pmvMatrix = new PMVMatrix(); - GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); - st.glUniform(gl, pmvMatrixUniform); + GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array0 - GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1); + st.ownAttribute(vertices0, true); vertices0.enableBuffer(gl, false); // Allocate Vertex Array1 - GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st); + st.ownAttribute(vertices1, true); vertices1.enableBuffer(gl, false); // Allocate Color Array0 GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1); + st.ownAttribute(colors0, true); colors0.enableBuffer(gl, false); // Allocate Color Array1 GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st); + st.ownAttribute(colors1, true); colors1.enableBuffer(gl, false); // misc GL setup @@ -277,9 +297,13 @@ public class TestGLSLShaderState02NEWT extends UITestCase { pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); - st.glUniform(gl, pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); // 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); + 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); @@ -288,36 +312,19 @@ public class TestGLSLShaderState02NEWT extends UITestCase { // warmup .. for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) { // SP0 - vertices0.setLocation(-1); - colors0.setLocation(-1); - vertices1.setLocation(-1); - colors1.setLocation(-1); st.attachShaderProgram(gl, sp0); GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true); // SP1 - vertices0.setLocation(-1); - colors0.setLocation(-1); - vertices1.setLocation(-1); - colors1.setLocation(-1); st.attachShaderProgram(gl, sp1); GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true); } // measure .. for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=4) { // SP0 - vertices0.setLocation(-1); - colors0.setLocation(-1); - vertices1.setLocation(-1); - colors1.setLocation(-1); st.attachShaderProgram(gl, sp0); GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true); - GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true); - + GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true); // SP1 - vertices0.setLocation(-1); - colors0.setLocation(-1); - vertices1.setLocation(-1); - colors1.setLocation(-1); st.attachShaderProgram(gl, sp1); GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true); GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true); @@ -331,13 +338,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase { System.err.println("testShaderState01PerformanceDouble: "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f"); // cleanup - st.glUseProgram(gl, false); - sp0.release(gl, true); - vertices1.destroy(gl); - vertices0.destroy(gl); - colors0.destroy(gl); - colors1.destroy(gl); - + st.destroy(gl); GLSLMiscHelper.destroyWindow(winctx); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java index 086c0d111..ed9fbd455 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java @@ -118,7 +118,7 @@ public class TestGLSLSimple01NEWT extends UITestCase { window.addGLEventListener(new RedSquare0()); Animator animator = new Animator(window); - animator.setUpdateFPSFrames(1, System.err); + animator.setUpdateFPSFrames(1, null); animator.start(); Assert.assertEquals(true, animator.isAnimating()); while(animator.isAnimating() && animator.getTotalFPSDuration()<durationPerTest) { |