diff options
author | Sven Gothel <[email protected]> | 2014-04-02 04:41:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-04-02 04:41:48 +0200 |
commit | e8a5a1cbb988670ca206ab1ac633e19a91bfa478 (patch) | |
tree | 5b9f17a06ad350150375a2a0e38daa3d6dd11251 /src/jogl/classes/jogamp/graph/curve | |
parent | 6f5686696b1e9085a759774056c7be9887a9e34f (diff) |
Bug 801: WIP 2/2 - Add color attribute; Switch Shader instead of branching in shader; Update attributes and uniforms manually, drop ShaderState;
- Due to shader-switching,
'renderModes' are now local to Region, e.g. UIShape etc
- Remove RegionRenderer.renderModes
- VBORegion2P*:
- Use simple 2x float matrix for orthogonal P+Mv
- Cleanup shader
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve')
11 files changed, 115 insertions, 297 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 4649a2714..172bd52c8 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -30,21 +30,21 @@ package jogamp.graph.curve.opengl; import java.nio.FloatBuffer; import javax.media.opengl.GL2ES2; -// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER ! import javax.media.opengl.GL; import javax.media.opengl.GLUniformData; import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; +import com.jogamp.common.nio.Buffers; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderProgram; public class VBORegion2PMSAAES2 extends GLRegion { @@ -63,11 +63,9 @@ public class VBORegion2PMSAAES2 extends GLRegion { private GLArrayDataServer gca_FboTexCoordsAttr; private GLArrayDataServer indicesFbo; private final GLUniformData gcu_FboTexUnit; - private GLUniformData gcu_FboTexSize; - private final PMVMatrix fboPMVMatrix; + private final GLUniformData gcu_FboTexSize; + private final float[] pmvMatrix02 = new float[2*16]; // P + Mv private final GLUniformData gcu_PMVMatrix02; - private boolean gcu_FboTexSize_dirty = true; - private boolean gcu_PMVMatrix02_dirty = true; private ShaderProgram spPass2 = null; private FBObject fbo; @@ -80,33 +78,27 @@ public class VBORegion2PMSAAES2 extends GLRegion { public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) { final RenderState rs = renderer.getRenderState(); - final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount); + renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocation; if( pass1 ) { updateLocation = !sp.equals(spPass1); spPass1 = sp; rs.update(gl, updateLocation, renderModes, true); - if( updateLocation ) { - gcu_PMVMatrix02.setLocation(gl, sp.program()); - } + rs.updateUniformLoc(gl, updateLocation, gcu_PMVMatrix02); rs.updateAttributeLoc(gl, updateLocation, gca_VerticesAttr); rs.updateAttributeLoc(gl, updateLocation, gca_CurveParamsAttr); if( null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr); } - System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0+", "+rs); } else { updateLocation = !sp.equals(spPass2); spPass2 = sp; rs.update(gl, updateLocation, renderModes, false); rs.updateAttributeLoc(gl, updateLocation, gca_FboVerticesAttr); rs.updateAttributeLoc(gl, updateLocation, gca_FboTexCoordsAttr); - rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexSize); - if( updateLocation ) { - gcu_FboTexSize.setLocation(gl, sp.program()); - } - System.err.println("XXX changedSP.p2 "+updateLocation+" / "+updateLocation0+", "+rs); + rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexUnit); + rs.updateUniformLoc(gl, updateLocation, gcu_FboTexSize); } } @@ -130,30 +122,33 @@ public class VBORegion2PMSAAES2 extends GLRegion { gca_ColorsAttr = null; } + FloatUtil.makeIdentityf(pmvMatrix02, 0); + FloatUtil.makeIdentityf(pmvMatrix02, 16); + gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02)); + // Pass 2: - fboPMVMatrix = new PMVMatrix(); - gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix01, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, textureUnit); + gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, Buffers.newDirectFloatBuffer(2)); indicesFbo = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3); indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3); indicesFbo.seal(true); - gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 2, GL2ES2.GL_FLOAT, - false, 4, GL.GL_STATIC_DRAW); + gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_TEXCOORDS_ATTR_NAME, 2, GL2ES2.GL_FLOAT, + false, 4, GL.GL_STATIC_DRAW); gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.seal(true); - gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, - false, 4, GL.GL_STATIC_DRAW); + gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, + false, 4, GL.GL_STATIC_DRAW); } @Override - protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected final void clearImpl(final GL2ES2 gl) { if( null != indicesBuffer ) { indicesBuffer.seal(gl, false); indicesBuffer.rewind(); @@ -166,11 +161,15 @@ public class VBORegion2PMSAAES2 extends GLRegion { gca_CurveParamsAttr.seal(gl, false); gca_CurveParamsAttr.rewind(); } + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.seal(gl, false); + gca_ColorsAttr.rewind(); + } fboDirty = true; } @Override - protected final void pushVertex(float[] coords, float[] texParams, float[] color) { + protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); gca_VerticesAttr.putf(coords[2]); @@ -178,6 +177,17 @@ public class VBORegion2PMSAAES2 extends GLRegion { gca_CurveParamsAttr.putf(texParams[0]); gca_CurveParamsAttr.putf(texParams[1]); gca_CurveParamsAttr.putf(texParams[2]); + + if( null != gca_ColorsAttr ) { + if( null != rgba ) { + gca_ColorsAttr.putf(rgba[0]); + gca_ColorsAttr.putf(rgba[1]); + gca_ColorsAttr.putf(rgba[2]); + gca_ColorsAttr.putf(rgba[3]); + } else { + throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); + } + } } @Override @@ -186,7 +196,7 @@ public class VBORegion2PMSAAES2 extends GLRegion { } @Override - protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void updateImpl(final GL2ES2 gl) { // seal buffers indicesBuffer.seal(gl, true); indicesBuffer.enableBuffer(gl, false); @@ -194,6 +204,10 @@ public class VBORegion2PMSAAES2 extends GLRegion { gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.seal(gl, true); gca_VerticesAttr.enableBuffer(gl, false); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.seal(gl, true); + gca_ColorsAttr.enableBuffer(gl, false); + } // update all bbox related data gca_FboVerticesAttr.seal(gl, false); @@ -204,18 +218,12 @@ public class VBORegion2PMSAAES2 extends GLRegion { fb.put( 8, box.getMinZ()); fb.put(11, box.getMinZ()); } - // Pending .. (follow fboDirty) - // gca_FboVerticesAttr.seal(gl, true); - // gca_FboVerticesAttr.enableBuffer(gl, false); - // fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - // fboPMVMatrix.glLoadIdentity(); - // fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1); + // Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty // push data 2 GPU .. indicesFbo.seal(gl, true); indicesFbo.enableBuffer(gl, false); - // trigger renderRegion2FBO ! fboDirty = true; // the buffers were disabled, since due to real/fbo switching and other vbo usage } @@ -324,16 +332,17 @@ public class VBORegion2PMSAAES2 extends GLRegion { fb.put(3, minX); fb.put( 4, maxY); fb.put(6, maxX); fb.put( 7, maxY); fb.put(9, maxX); fb.put(10, minY); + fb.position(12); } gca_FboVerticesAttr.seal(true); - fboPMVMatrix.glLoadIdentity(); - fboPMVMatrix.glOrthof(minX, maxX, minY, maxY, -1, 1); - gcu_PMVMatrix02_dirty = true; + FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1); + useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]); renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount); } else { gca_FboTexCoordsAttr.setVBOWritten(false); } // System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3)); + useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]); renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]); } } @@ -341,14 +350,7 @@ public class VBORegion2PMSAAES2 extends GLRegion { private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, final int sampleCount) { gl.glViewport(0, 0, width, height); - if( gcu_FboTexSize_dirty ) { - gl.glUniform(gcu_FboTexSize); - gcu_FboTexSize_dirty = false; - } - if( gcu_PMVMatrix02_dirty ) { - gl.glUniform(gcu_PMVMatrix02); - gcu_PMVMatrix02_dirty = false; - } + gl.glUniform(gcu_FboTexSize); gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue()); @@ -376,6 +378,11 @@ public class VBORegion2PMSAAES2 extends GLRegion { if(null == fbo) { fboWidth = targetFboWidth; fboHeight = targetFboHeight; + final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer(); + { + fboTexSize.put(0, fboWidth); + fboTexSize.put(1, fboHeight); + } fbo = new FBObject(); fbo.reset(gl, fboWidth, fboHeight, sampleCount[0], false); sampleCount[0] = fbo.getNumSamples(); @@ -402,6 +409,11 @@ public class VBORegion2PMSAAES2 extends GLRegion { } fboWidth = targetFboWidth; fboHeight = targetFboHeight; + final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer(); + { + fboTexSize.put(0, fboWidth); + fboTexSize.put(1, fboHeight); + } } fbo.bind(gl); @@ -415,19 +427,26 @@ public class VBORegion2PMSAAES2 extends GLRegion { } private void renderRegion(final GL2ES2 gl) { + gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.enableBuffer(gl, true); + } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); indicesBuffer.bindBuffer(gl, false); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.enableBuffer(gl, false); + } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); } @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Destroy: " + this); } @@ -443,6 +462,10 @@ public class VBORegion2PMSAAES2 extends GLRegion { gca_CurveParamsAttr.destroy(gl); gca_CurveParamsAttr = null; } + if(null != gca_ColorsAttr) { + gca_ColorsAttr.destroy(gl); + gca_ColorsAttr = null; + } if(null != indicesBuffer) { indicesBuffer.destroy(gl); indicesBuffer = null; @@ -459,5 +482,7 @@ public class VBORegion2PMSAAES2 extends GLRegion { indicesFbo.destroy(gl); indicesFbo = null; } + spPass1 = null; + spPass2 = null; } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index afaae3679..a701a4b19 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -45,9 +45,9 @@ import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderProgram; public class VBORegion2PVBAAES2 extends GLRegion { @@ -97,10 +97,8 @@ public class VBORegion2PVBAAES2 extends GLRegion { private GLArrayDataServer indicesFbo; private final GLUniformData gcu_FboTexUnit; private final GLUniformData gcu_FboTexSize; - private final PMVMatrix fboPMVMatrix; + private final float[] pmvMatrix02 = new float[2*16]; // P + Mv private final GLUniformData gcu_PMVMatrix02; - private boolean gcu_FboTexSize_dirty = true; - private boolean gcu_PMVMatrix02_dirty = true; private ShaderProgram spPass2 = null; private FBObject fbo; @@ -114,7 +112,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) { final RenderState rs = renderer.getRenderState(); - final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount); + renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocation; if( pass1 ) { @@ -127,7 +125,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { if( null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr); } - System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0+", "+rs); } else { updateLocation = !sp.equals(spPass2); spPass2 = sp; @@ -136,7 +133,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { rs.updateAttributeLoc(gl, updateLocation, gca_FboTexCoordsAttr); rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexUnit); rs.updateUniformLoc(gl, updateLocation, gcu_FboTexSize); - System.err.println("XXX changedSP.p2 "+updateLocation+" / "+updateLocation0+", "+rs); } } @@ -159,9 +155,11 @@ public class VBORegion2PVBAAES2 extends GLRegion { gca_ColorsAttr = null; } + FloatUtil.makeIdentityf(pmvMatrix02, 0); + FloatUtil.makeIdentityf(pmvMatrix02, 16); + gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02)); + // Pass 2: - fboPMVMatrix = new PMVMatrix(); - gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, textureUnit); gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, Buffers.newDirectFloatBuffer(2)); @@ -183,7 +181,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected final void clearImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Clear: " + this); // Thread.dumpStack(); @@ -208,7 +206,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected final void pushVertex(final float[] coords, final float[] texParams, float[] rgba) { + protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); gca_VerticesAttr.putf(coords[2]); @@ -235,7 +233,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void updateImpl(final GL2ES2 gl) { if(null == indicesFbo) { if(Region.DEBUG_INSTANCE) { System.err.println("VBORegion2PVBAAES2 Create: " + this); @@ -262,12 +260,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { fb.put( 8, box.getMinZ()); fb.put(11, box.getMinZ()); } - // Pending .. (follow fboDirty) - // gca_FboVerticesAttr.seal(gl, true); - // gca_FboVerticesAttr.enableBuffer(gl, false); - // fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - // fboPMVMatrix.glLoadIdentity(); - // fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1); + // Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty // push data 2 GPU .. indicesFbo.seal(gl, true); @@ -455,11 +448,10 @@ public class VBORegion2PVBAAES2 extends GLRegion { fb.put(3, minX); fb.put( 4, maxY); fb.put(6, maxX); fb.put( 7, maxY); fb.put(9, maxX); fb.put(10, minY); + fb.position(12); } gca_FboVerticesAttr.seal(true); - fboPMVMatrix.glLoadIdentity(); - fboPMVMatrix.glOrthof(minX, maxX, minY, maxY, -1, 1); - gcu_PMVMatrix02_dirty = true; + FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1); useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]); renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]); } @@ -472,10 +464,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { final int vpWidth, final int vpHeight, final int sampleCount) { gl.glViewport(0, 0, vpWidth, vpHeight); - if( gcu_FboTexSize_dirty ) { - gl.glUniform(gcu_FboTexSize); - gcu_FboTexSize_dirty = false; - } + gl.glUniform(gcu_FboTexSize); gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue()); @@ -508,7 +497,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { { fboTexSize.put(0, fboWidth); fboTexSize.put(1, fboHeight); - gcu_FboTexSize_dirty=true; } fbo = new FBObject(); fbo.reset(gl, fboWidth, fboHeight); @@ -532,7 +520,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { { fboTexSize.put(0, fboWidth); fboTexSize.put(1, fboHeight); - gcu_FboTexSize_dirty=true; } } else { fbo.bind(gl); @@ -540,19 +527,16 @@ public class VBORegion2PVBAAES2 extends GLRegion { //render texture gl.glViewport(0, 0, fboWidth, fboHeight); - - if( gcu_PMVMatrix02_dirty ) { - gl.glUniform(gcu_PMVMatrix02); - gcu_PMVMatrix02_dirty = false; - } - gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); + renderRegion(gl); + fbo.unbind(gl); fboDirty = false; } private void renderRegion(final GL2ES2 gl) { + gl.glUniform(gcu_PMVMatrix02); gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); if( null != gca_ColorsAttr ) { @@ -571,7 +555,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Destroy: " + this); // Thread.dumpStack(); @@ -610,5 +594,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { indicesFbo.destroy(gl); indicesFbo = null; } + spPass1 = null; + spPass2 = null; } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 659f64847..8268394dd 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -43,6 +43,7 @@ public class VBORegionSPES2 extends GLRegion { private GLArrayDataServer gca_CurveParamsAttr = null; private GLArrayDataServer gca_ColorsAttr; private GLArrayDataServer indicesBuffer = null; + private ShaderProgram spPass1 = null; public VBORegionSPES2(final int renderModes) { super(renderModes); @@ -64,7 +65,7 @@ public class VBORegionSPES2 extends GLRegion { } @Override - protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected final void clearImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Clear: " + this); } @@ -87,7 +88,7 @@ public class VBORegionSPES2 extends GLRegion { } @Override - protected final void pushVertex(float[] coords, float[] texParams, float[] rgba) { + protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); gca_VerticesAttr.putf(coords[2]); @@ -114,7 +115,7 @@ public class VBORegionSPES2 extends GLRegion { } @Override - protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void updateImpl(final GL2ES2 gl) { // seal buffers indicesBuffer.seal(gl, true); indicesBuffer.enableBuffer(gl, false); @@ -133,8 +134,6 @@ public class VBORegionSPES2 extends GLRegion { } } - private ShaderProgram spPass1 = null; - public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final int quality) { final RenderState rs = renderer.getRenderState(); final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, true, quality, 0); @@ -149,10 +148,9 @@ public class VBORegionSPES2 extends GLRegion { if( null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr); } - System.err.println("XXX changedSP "+updateLocation+", "+rs); - System.err.println("XXX gca_VerticesAttr "+gca_VerticesAttr); - System.err.println("XXX gca_CurveParamsAttr "+gca_CurveParamsAttr); - System.err.println("XXX gca_ColorsAttr "+gca_ColorsAttr); + if( DEBUG ) { + System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0); + } } @@ -169,17 +167,23 @@ public class VBORegionSPES2 extends GLRegion { } gca_VerticesAttr.enableBuffer(gl, true); gca_CurveParamsAttr.enableBuffer(gl, true); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.enableBuffer(gl, true); + } indicesBuffer.bindBuffer(gl, true); // keeps VBO binding gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); indicesBuffer.bindBuffer(gl, false); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.enableBuffer(gl, false); + } gca_CurveParamsAttr.enableBuffer(gl, false); gca_VerticesAttr.enableBuffer(gl, false); } @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + protected void destroyImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Destroy: " + this); } @@ -199,5 +203,6 @@ public class VBORegionSPES2 extends GLRegion { indicesBuffer.destroy(gl); indicesBuffer = null; } + spPass1 = null; } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java index df5ba35f2..f37025516 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java @@ -5,7 +5,7 @@ public class UniformNames { public static final String gcu_ColorStatic = "gcu_ColorStatic"; public static final String gcu_Weight = "gcu_Weight"; - public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix01"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi + public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix02"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi public static final String gcu_FboTexUnit = "gcu_FboTexUnit"; public static final String gcu_FboTexSize = "gcu_FboTexSize"; } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp deleted file mode 100644 index 6e60fc044..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp +++ /dev/null @@ -1,23 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/o weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - -// #include curverenderer01-pass1-curve-lineAA.glsl -#include curverenderer01-pass1-curve-weight.glsl - -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp deleted file mode 100644 index 18f06fff0..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp +++ /dev/null @@ -1,23 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/o weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - -// #include curverenderer01-pass1-curve-lineAA.glsl -#include curverenderer01-pass1-curve-simple.glsl - -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp deleted file mode 100644 index 0a4f7b331..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp +++ /dev/null @@ -1,35 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/ weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; - #define texture2D texture -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - if( 0.0 < gcu_FboTexSize.z ) { - // Pass-2: Dump Texture - vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st); - #if 0 - if( 0.0 == t.a ) { - discard; // discard freezes NV tegra2 compiler - } - #endif - - mgl_FragColor = t; - } else { - -#include curverenderer01-pass1-curve-weight.glsl - - } -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp deleted file mode 100644 index c5cbb99b0..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp +++ /dev/null @@ -1,36 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/o weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; - #define texture2D texture -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - if( 0.0 < gcu_FboTexSize.z ) { - // Pass-2: Dump Texture - vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st); - #if 0 - if( 0.0 == t.a ) { - discard; // discard freezes NV tegra2 compiler - } - #endif - - mgl_FragColor = t; - } else { - -#include curverenderer01-pass1-curve-simple.glsl - - } -} - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp deleted file mode 100644 index e3bcd20ae..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp +++ /dev/null @@ -1,44 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/ weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; - #define texture2D texture -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY)) - -void main (void) -{ - if( 0.0 < gcu_FboTexSize.z ) { - -// Quality: allsamples > [flipquad,rgss, quincunx] > poles -#include curverenderer01-pass2-vbaa_allsamples_equal.glsl - -// #include curverenderer01-pass2-vbaa_flipquad3.glsl -// #include curverenderer01-pass2-vbaa_flipquad2.glsl -// #include curverenderer01-pass2-vbaa_flipquad.glsl -// #include curverenderer01-pass2-vbaa_rgss.glsl -// #include curverenderer01-pass2-vbaa_quincunx.glsl - -// #include curverenderer01-pass2-vbaa_poles_equalweight.glsl -// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl -// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl -// #include curverenderer01-pass2-vbaa_allsamples_prop01.glsl -// #include curverenderer01-pass2-vbaa_fxaa3.glsl - - } else { - -#include curverenderer01-pass1-curve-weight.glsl - - } -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp deleted file mode 100644 index 52c719e46..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp +++ /dev/null @@ -1,47 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/o weight -// - -#if __VERSION__ >= 130 - #define varying in - out vec4 mgl_FragColor; - #define texture2D texture -#else - #define mgl_FragColor gl_FragColor -#endif - -#include uniforms.glsl -#include varyings.glsl - -#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY)) - -void main (void) -{ - if( 0.0 < gcu_FboTexSize.z ) { - -// Quality: allsamples > [flipquad,rgss, quincunx] > poles - - if( 0.0 >= gcu_FboTexSize.w ) { -#include curverenderer01-pass2-vbaa_flipquad3.glsl - } else { -#include curverenderer01-pass2-vbaa_allsamples_equal.glsl - } -// #include curverenderer01-pass2-vbaa_flipquad2.glsl -// #include curverenderer01-pass2-vbaa_flipquad.glsl -// #include curverenderer01-pass2-vbaa_rgss.glsl -// #include curverenderer01-pass2-vbaa_quincunx.glsl - -// #include curverenderer01-pass2-vbaa_poles_equalweight.glsl -// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl -// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl -// #include curverenderer01-pass2-vbaa_allsamples_prop01.glsl -// #include curverenderer01-pass2-vbaa_fxaa3.glsl - - } else { - -#include curverenderer01-pass1-curve-simple.glsl - - } -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl new file mode 100644 index 000000000..1872af67f --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl @@ -0,0 +1,10 @@ + // Pass-2: Dump Texture + vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st); + #if 0 + if( 0.0 == t.a ) { + discard; // discard freezes NV tegra2 compiler + } + #endif + + mgl_FragColor = t; + |