aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index bc87b3faa..c7a5a4bda 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -273,7 +273,10 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
@Override
- protected void updateImpl(final GL2ES2 gl) {
+ protected void updateImpl(final GL2ES2 gl, final int curRenderModes) {
+ final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
+ final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
+
// seal buffers
indicesBuffer.seal(gl, true);
indicesBuffer.enableBuffer(gl, false);
@@ -281,11 +284,11 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
gca_CurveParamsAttr.enableBuffer(gl, false);
gca_VerticesAttr.seal(gl, true);
gca_VerticesAttr.enableBuffer(gl, false);
- if( null != gca_ColorsAttr ) {
+ if( hasColorChannel && null != gca_ColorsAttr ) {
gca_ColorsAttr.seal(gl, true);
gca_ColorsAttr.enableBuffer(gl, false);
}
- if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
+ if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
final TextureSequence.TextureFrame frame = colorTexSeq.getLastTexture();
final Texture tex = frame.getTexture();
final TextureCoords tc = tex.getImageTexCoords();
@@ -333,9 +336,13 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
* @param quality
* @param sampleCount
*/
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int quality, final int sampleCount) {
+ final boolean isTwoPass = Region.isTwoPass( curRenderModes );
+ final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
+ final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq;
+
final RenderState rs = renderer.getRenderState();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, quality, sampleCount, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal;
if( pass1 ) {
@@ -347,13 +354,15 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
if( updateLocLocal ) {
rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true);
rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true);
- if( null != gca_ColorsAttr ) {
+ if( hasColorChannel && null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
}
}
- rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true);
- rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
- if( null != gcu_ColorTexUnit ) {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true);
+ if( isTwoPass ) {
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
+ }
+ if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
}
@@ -367,7 +376,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true);
rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true);
}
- rsLocal.update(gl, rs, updateLocLocal, renderModes, false, true);
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, false, true);
rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
}
}
@@ -382,7 +391,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) {
if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegion2PMSAAES2.drawImpl: Empty%n");
@@ -397,8 +406,9 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
final int vpWidth = renderer.getWidth();
final int vpHeight = renderer.getHeight();
- if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0){
- renderRegion(gl);
+ if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0) {
+ useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ renderRegion(gl, curRenderModes);
} else {
if(0 > maxTexSize[0]) {
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0);
@@ -487,13 +497,13 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
gca_FboVerticesAttr.seal(true);
FloatUtil.makeOrtho(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);
+ useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
} else if( isStateDirty() ) {
- useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
+ useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
}
- useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, false, getQuality(), sampleCount[0]);
renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]);
}
}
@@ -528,7 +538,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight,
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int curRenderModes,
+ final int targetFboWidth, final int targetFboHeight,
final int vpWidth, final int vpHeight, final int[] sampleCount) {
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
throw new IllegalArgumentException("fboSize must be greater than 0: "+targetFboWidth+"x"+targetFboHeight);
@@ -592,21 +603,24 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
- renderRegion(gl);
+ renderRegion(gl, curRenderModes);
fbo.unbind(gl);
fboDirty = false;
}
- private void renderRegion(final GL2ES2 gl) {
+ private void renderRegion(final GL2ES2 gl, final int curRenderModes) {
+ final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
+ final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
+
gl.glUniform(gcu_PMVMatrix02);
gca_VerticesAttr.enableBuffer(gl, true);
gca_CurveParamsAttr.enableBuffer(gl, true);
- if( null != gca_ColorsAttr ) {
+ if( hasColorChannel && null != gca_ColorsAttr ) {
gca_ColorsAttr.enableBuffer(gl, true);
}
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
- if( null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
+ if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) {
final TextureSequence.TextureFrame frame = colorTexSeq.getNextTexture(gl);
gl.glActiveTexture(GL.GL_TEXTURE0 + colorTexSeq.getTextureUnit());
final Texture tex = frame.getTexture();
@@ -622,7 +636,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
}
indicesBuffer.bindBuffer(gl, false);
- if( null != gca_ColorsAttr ) {
+ if( hasColorChannel && null != gca_ColorsAttr ) {
gca_ColorsAttr.enableBuffer(gl, false);
}
gca_CurveParamsAttr.enableBuffer(gl, false);