aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java12
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java8
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java62
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java65
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java38
5 files changed, 112 insertions, 73 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 2ffa68be6..46406cf96 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -176,8 +176,9 @@ public abstract class GLRegion extends Region {
* objects for use in rendering if {@link #isShapeDirty()}.
* <p>Allocates the ogl related data and initializes it the 1st time.<p>
* <p>Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.</p>
+ * @param curRenderModes TODO
*/
- protected abstract void updateImpl(final GL2ES2 gl);
+ protected abstract void updateImpl(final GL2ES2 gl, int curRenderModes);
protected abstract void destroyImpl(final GL2ES2 gl);
@@ -248,17 +249,18 @@ public abstract class GLRegion extends Region {
* </p>
* @param matrix current {@link PMVMatrix}.
* @param renderer the {@link RegionRenderer} to be used
- * @param sampleCount desired multisampling sample count for msaa-rendering.
+ * @param sampleCount desired multisampling sample count for vbaa- or msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @see RegionRenderer#enable(GL2ES2, boolean)
*/
public final void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
+ final int curRenderModes = getRenderModes();
if( isShapeDirty() ) {
- updateImpl(gl);
+ updateImpl(gl, curRenderModes);
}
- drawImpl(gl, renderer, sampleCount);
+ drawImpl(gl, renderer, curRenderModes, sampleCount);
clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
}
- protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount);
+ protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, int curRenderModes, final int[/*1*/] sampleCount);
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index e2674fbe0..3c14b1bab 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -521,7 +521,9 @@ public final class RegionRenderer {
final ShaderModeSelector1 sel1 = pass1 ? ShaderModeSelector1.selectPass1(renderModes) :
ShaderModeSelector1.selectPass2(renderModes, quality, sampleCount);
final boolean isTwoPass = Region.isTwoPass( renderModes );
- final boolean isPass1ColorTexSeq = pass1 && null != colorTexSeq;
+ final boolean hasColorChannel = Region.hasColorChannel( renderModes );
+ final boolean hasColorTexture = Region.hasColorTexture( renderModes ) && null != colorTexSeq;
+ final boolean isPass1ColorTexSeq = pass1 && hasColorTexture;
final int colorTexSeqHash;
final String texLookupFuncName;
if( isPass1ColorTexSeq ) {
@@ -601,11 +603,11 @@ public final class RegionRenderer {
// GLSL append from here on
posFp = -1;
- if( Region.hasColorChannel( renderModes ) ) {
+ if( hasColorChannel ) {
posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_CHANNEL);
posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_CHANNEL);
}
- if( Region.hasColorTexture( renderModes ) ) {
+ if( isPass1ColorTexSeq ) {
rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_TEXTURE);
posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_TEXTURE);
}
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);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 21f454655..55f31a161 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -133,14 +133,18 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
*
* @param gl
* @param renderer
- * @param renderModes
+ * @param curRenderModes
* @param pass1
* @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 ) {
@@ -152,13 +156,15 @@ public final class VBORegion2PVBAAES2 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);
}
@@ -172,7 +178,7 @@ public final class VBORegion2PVBAAES2 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
rs.updateUniformLoc(gl, updateLocLocal, gcu_FboTexSize, sampleCount > 1); // maybe optimized away for sampleCount <= 1
}
@@ -387,7 +393,10 @@ public final class VBORegion2PVBAAES2 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);
@@ -395,11 +404,11 @@ public final class VBORegion2PVBAAES2 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();
@@ -443,7 +452,7 @@ public final class VBORegion2PVBAAES2 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("VBORegion2PVBAAES2.drawImpl: Empty%n");
@@ -458,8 +467,9 @@ public final class VBORegion2PVBAAES2 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);
@@ -561,7 +571,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
}
if( sampleCount[0] <= 0 ) {
// Last way out!
- renderRegion(gl);
+ renderRegion(gl, curRenderModes);
return;
}
}
@@ -623,13 +633,13 @@ public final class VBORegion2PVBAAES2 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, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
} else if( isStateDirty() ) {
- useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
- renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, fboWidth, fboHeight, vpWidth, vpHeight, sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]);
+ renderRegion2FBO(gl, rs, curRenderModes, targetFboWidth, targetFboHeight, fboWidth, fboHeight, vpWidth, vpHeight, sampleCount[0]);
}
- useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]);
+ useShaderProgram(gl, renderer, curRenderModes, false, getQuality(), sampleCount[0]);
renderFBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount[0]);
}
}
@@ -662,7 +672,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs,
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int curRenderModes,
final int targetFboWidth, final int targetFboHeight, final int newFboWidth, final int newFboHeight,
final int vpWidth, final int vpHeight, final int sampleCount) {
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
@@ -723,22 +733,25 @@ public final class VBORegion2PVBAAES2 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();
@@ -754,7 +767,7 @@ public final class VBORegion2PVBAAES2 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);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 0077186e6..9e29821fa 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -224,17 +224,20 @@ public final class VBORegionSPES2 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
gca_VerticesAttr.seal(gl, true);
gca_VerticesAttr.enableBuffer(gl, false);
gca_CurveParamsAttr.seal(gl, true);
gca_CurveParamsAttr.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();
@@ -270,12 +273,15 @@ public final class VBORegionSPES2 extends GLRegion {
*
* @param gl
* @param renderer
- * @param renderModes
+ * @param curRenderModes
* @param quality
*/
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final int quality) {
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int quality) {
+ 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, true, quality, 0, colorTexSeq);
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, quality, 0, colorTexSeq);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocLocal = !sp.equals(spPass1);
spPass1 = sp;
@@ -285,12 +291,12 @@ public final class VBORegionSPES2 extends GLRegion {
if( updateLocLocal ) {
rs.updateAttributeLoc(gl, true, gca_VerticesAttr, throwOnError);
rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, throwOnError);
- if( null != gca_ColorsAttr ) {
+ if( hasColorChannel && null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, true, gca_ColorsAttr, throwOnError);
}
}
- rsLocal.update(gl, rs, updateLocLocal, renderModes, true, throwOnError);
- if( null != gcu_ColorTexUnit ) {
+ rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, throwOnError);
+ if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, throwOnError);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, throwOnError);
}
@@ -298,9 +304,11 @@ public final class VBORegionSPES2 extends GLRegion {
@Override
- protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
- final int renderModes = getRenderModes();
- useShaderProgram(gl, renderer, renderModes, getQuality());
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) {
+ final boolean hasColorChannel = Region.hasColorChannel( curRenderModes );
+ final boolean hasColorTexture = Region.hasColorTexture( curRenderModes );
+
+ useShaderProgram(gl, renderer, curRenderModes, getQuality());
if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
@@ -310,7 +318,7 @@ public final class VBORegionSPES2 extends GLRegion {
}
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
@@ -319,7 +327,7 @@ public final class VBORegionSPES2 extends GLRegion {
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
}
- 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();
@@ -337,7 +345,7 @@ public final class VBORegionSPES2 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);