diff options
Diffstat (limited to 'src/jogl')
7 files changed, 111 insertions, 34 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 2cd40c6e4..af8a54177 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -366,6 +366,7 @@ public abstract class GLRegion extends Region { // gca_VerticesAttr.putf(coords, 0, 3);
// gca_CurveParamsAttr.putf(texParams, 0, 3);
// gca_VerticesAttr.put3f(coords.x(), coords.y(), coords.z());
+ // System.err.println("GLRegion V: "+coords);
put3f((FloatBuffer)vpc_ileave.getBuffer(), coords);
put3f((FloatBuffer)vpc_ileave.getBuffer(), texParams);
if( hasColorChannel() ) {
@@ -384,6 +385,7 @@ public abstract class GLRegion extends Region { if( cc && null == rgba ) {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
+ // System.err.println("GLRegion V: "+coords1+", "+coords2+", "+coords3);
put3f((FloatBuffer)vpc_ileave.getBuffer(), coords1);
put3f((FloatBuffer)vpc_ileave.getBuffer(), texParams1);
if( cc ) {
@@ -531,7 +533,7 @@ public abstract class GLRegion extends Region { markStateDirty();
}
if( isShapeDirty() ) {
- updateImpl(gl, curRenderModes);
+ updateImpl(gl, renderer, curRenderModes);
}
drawImpl(gl, renderer, curRenderModes, sampleCount);
clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
@@ -544,9 +546,8 @@ 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, int curRenderModes);
+ protected abstract void updateImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes);
- protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, int curRenderModes, final int[/*1*/] sampleCount);
+ protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final 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 0927c41cb..06c10586c 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -48,6 +48,7 @@ import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.curve.Region; import com.jogamp.math.Recti; import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; import com.jogamp.math.util.PMVMatrix4f; /** @@ -302,6 +303,9 @@ public final class RegionRenderer { public final void setColorStatic(final float r, final float g, final float b, final float a){ rs.setColorStatic(r, g, b, a); } + public final void setClipBBox(final AABBox clipBBox) { rs.setClipBBox(clipBBox); } + public final AABBox getClipBBox() { return rs.getClipBBox(); } + public final boolean isHintMaskSet(final int mask) { return rs.isHintMaskSet(mask); } public final void setHintMask(final int mask) { rs.setHintMask(mask); } @@ -398,9 +402,9 @@ public final class RegionRenderer { private static final String SHADER_SRC_SUB = ""; private static final String SHADER_BIN_SUB = "bin"; - private static final String GLSL_USE_COLOR_CHANNEL = "#define USE_COLOR_CHANNEL 1\n"; private static final String GLSL_USE_COLOR_TEXTURE = "#define USE_COLOR_TEXTURE 1\n"; + private static final String GLSL_USE_AABBOX_CLIPPING = "#define USE_AABBOX_CLIPPING 1\n"; private static final String GLSL_DEF_SAMPLE_COUNT = "#define SAMPLE_COUNT "; private static final String GLSL_CONST_SAMPLE_COUNT = "const float sample_count = "; private static final String GLSL_MAIN_BEGIN = "void main (void)\n{\n"; @@ -530,6 +534,7 @@ public final class RegionRenderer { final boolean pass1, final int quality, final int sampleCount, final TextureSequence colorTexSeq) { final ShaderModeSelector1 sel1 = pass1 ? ShaderModeSelector1.selectPass1(renderModes) : ShaderModeSelector1.selectPass2(renderModes, quality, sampleCount); + final boolean hasAABBoxClipping = null != getClipBBox(); final boolean isTwoPass = Region.isTwoPass( renderModes ); final boolean hasColorChannel = Region.hasColorChannel( renderModes ); final boolean hasColorTexture = Region.hasColorTexture( renderModes ) && null != colorTexSeq; @@ -543,8 +548,16 @@ public final class RegionRenderer { texLookupFuncName = null; colorTexSeqHash = 0; } - final int shaderKey = ( (colorTexSeqHash << 5) - colorTexSeqHash ) + - ( sel1.ordinal() | ( HIGH_MASK & renderModes ) | ( isTwoPass ? TWO_PASS_BIT : 0 ) ); + final int shaderKey; + { + // 31 * x == (x << 5) - x + int hash = 31 + colorTexSeqHash; + hash = ((hash << 5) - hash) + sel1.ordinal(); + hash = ((hash << 5) - hash) + ( HIGH_MASK & renderModes ); + hash = ((hash << 5) - hash) + ( hasAABBoxClipping ? 1 : 0 ); + hash = ((hash << 5) - hash) + ( isTwoPass ? TWO_PASS_BIT : 0 ); + shaderKey = hash; + } /** if(DEBUG) { @@ -617,6 +630,11 @@ public final class RegionRenderer { posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_DISCARD); } + if( hasAABBoxClipping ) { + posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_AABBOX_CLIPPING); + posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_AABBOX_CLIPPING); + } + if( hasColorChannel ) { posVp = rsVp.insertShaderSource(0, posVp, GLSL_USE_COLOR_CHANNEL); posFp = rsFp.insertShaderSource(0, posFp, GLSL_USE_COLOR_CHANNEL); @@ -631,7 +649,9 @@ public final class RegionRenderer { } try { - posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "functions.glsl"); + if( isPass1ColorTexSeq || hasAABBoxClipping ) { + posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "functions.glsl"); + } posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "uniforms.glsl"); posFp = rsFp.insertShaderSource(0, posFp, AttributeNames.class, "varyings.glsl"); } catch (final IOException ioe) { diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index b1bbdde91..32483c1fc 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -39,6 +39,7 @@ import jogamp.graph.curve.opengl.shader.UniformNames; import com.jogamp.graph.curve.Region; import com.jogamp.math.Vec4f; +import com.jogamp.math.geom.AABBox; import com.jogamp.math.util.PMVMatrix4f; import com.jogamp.opengl.util.GLArrayDataWrapper; import com.jogamp.opengl.util.glsl.ShaderProgram; @@ -91,15 +92,16 @@ public class RenderState { return (RenderState) gl.getContext().getAttachedObject(thisKey); } + private final int id; private final PMVMatrix4f pmvMatrix; private final float[] weight; private final FloatBuffer weightBuffer; private final float[] colorStatic; private final FloatBuffer colorStaticBuffer; - private ShaderProgram sp; + private AABBox clipBBox; private int hintBitfield; + private ShaderProgram sp; - private final int id; private static synchronized int getNextID() { return nextID++; } @@ -189,13 +191,14 @@ public class RenderState { */ /* pp */ RenderState(final PMVMatrix4f sharedPMVMatrix) { this.id = getNextID(); - this.sp = null; this.pmvMatrix = null != sharedPMVMatrix ? sharedPMVMatrix : new PMVMatrix4f(); this.weight = new float[1]; this.weightBuffer = FloatBuffer.wrap(weight); this.colorStatic = new float[] { 1, 1, 1, 1 }; this.colorStaticBuffer = FloatBuffer.wrap(colorStatic); + this.clipBBox = null; this.hintBitfield = 0; + this.sp = null; } public final int id() { return id; } @@ -259,6 +262,8 @@ public class RenderState { colorStatic[3] = a; } + public final void setClipBBox(final AABBox clipBBox) { this.clipBBox = clipBBox; } + public final AABBox getClipBBox() { return this.clipBBox; } /** * diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 2951eec90..8376f0fa5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -308,7 +308,7 @@ public interface TextureSequence { /** * Calculates the texture coordinates bounding box while correcting for aspect-ratio. * @param tex the {@link Texture} - * @param box the {@Link AABBpx} of the destination + * @param box the {@Link AABBox} of the destination * @param letterBox true to produce letter-box space to match aspect-ratio, otherwise will zoom in * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH * @param verbose TODO @@ -408,7 +408,7 @@ public interface TextureSequence { System.err.println("XXX setTexCoordBBox:"); System.err.println("XXX ColorTex imgRatio "+imgRatio+", texRatio "+texRatio+", texPixelRatio[w "+texWidthRatio+", h "+texHeightRatio+"], "+tex); System.err.println("XXX ColorTexBBox lbox "+letterBox+", cut "+boxWidthCut+"/"+boxHeightCut+", ext "+boxWidthExt+"/"+boxHeightExt); - System.err.println("XXX ColorTexBBox min "+colorTexBBox[0]+"/"+colorTexBBox[1]+", max "+colorTexBBox[2]+" x "+colorTexBBox[3]+ + System.err.println("XXX ColorTexBBox min "+colorTexBBox[0]+"/"+colorTexBBox[1]+", max "+colorTexBBox[2]+"/"+colorTexBBox[3]+ ", dim "+colorTexBBoxW+" x "+colorTexBBoxH+ ", tc-dim "+tcW+" x "+tcH+", tc "+tc+", box2ImgRatio "+box2ImgRatio+", box2TexRatio "+box2TexRatio); System.err.println("XXX Box ratio "+boxRatio+", "+box); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 040e0328c..7abcf8818 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -62,6 +62,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion { private final GLUniformData gcu_ColorTexUnit; private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2] + private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ + private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3] private ShaderProgram spPass1 = null; // Pass-2: @@ -103,6 +105,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion { colorTexBBox = null; gcu_ColorTexBBox = null; } + clipBBox = new float[6]; + gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox)); gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, new SyncMatrices4f16( new Matrix4f[] { matP, matMv } )); // Pass 2: @@ -136,8 +140,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } @Override - protected void updateImpl(final GL2ES2 gl, final int curRenderModes) { - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); // seal buffers @@ -186,6 +190,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion { final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq; final RenderState rs = renderer.getRenderState(); + final boolean hasAABBoxClipping = null != rs.getClipBBox(); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, quality, sampleCount, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal; @@ -203,6 +209,9 @@ public final class VBORegion2PMSAAES2 extends GLRegion { if( hasColorChannel && null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true); } + if( hasAABBoxClipping ) { + rs.updateUniformLoc(gl, true, gcu_ClipBBox, true); + } } rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true); if( isTwoPass ) { @@ -248,16 +257,16 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } return; // inf } + final RenderState rs = renderer.getRenderState(); final int vpWidth = renderer.getWidth(); final int vpHeight = renderer.getHeight(); if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0) { useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]); - renderRegion(gl, curRenderModes); + renderRegion(gl, rs, curRenderModes); } else { if(0 > maxTexSize[0]) { gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0); } - final RenderState rs = renderer.getRenderState(); final float winWidth, winHeight; final float ratioObjWinWidth, ratioObjWinHeight; @@ -449,17 +458,26 @@ public final class VBORegion2PMSAAES2 extends GLRegion { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } - renderRegion(gl, curRenderModes); + renderRegion(gl, rs, curRenderModes); fbo.unbind(gl); fboDirty = false; } - private void renderRegion(final GL2ES2 gl, final int curRenderModes) { - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + private void renderRegion(final GL2ES2 gl, final RenderState rs, final int curRenderModes) { + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); gl.glUniform(gcu_PMVMatrix02); + { + final AABBox cb = rs.getClipBBox(); + if( null != cb ) { + clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ(); + clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ(); + gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions + } + } + vpc_ileave.enableBuffer(gl, true); indicesBuffer.bindBuffer(gl, true); // keeps VBO binding if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index a26e5d70a..82426a73c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -95,7 +95,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion { private final GLUniformData gcu_ColorTexUnit; private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2] - + private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ + private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3] private ShaderProgram spPass1 = null; // Pass-2: @@ -137,6 +138,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion { final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq; final RenderState rs = renderer.getRenderState(); + final boolean hasAABBoxClipping = null != rs.getClipBBox(); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, quality, sampleCount, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal; @@ -154,6 +157,9 @@ public final class VBORegion2PVBAAES2 extends GLRegion { if( hasColorChannel && null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true); } + if( hasAABBoxClipping ) { + rs.updateUniformLoc(gl, true, gcu_ClipBBox, true); + } } rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, true); if( isTwoPass ) { @@ -200,6 +206,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion { colorTexBBox = null; gcu_ColorTexBBox = null; } + clipBBox = new float[6]; + gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox)); gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, new SyncMatrices4f16( new Matrix4f[] { matP, matMv } )); // Pass 2: @@ -234,9 +242,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected void updateImpl(final GL2ES2 gl, final int curRenderModes) { - @SuppressWarnings("unused") - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); // seal buffers @@ -284,16 +291,16 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } return; // inf } + final RenderState rs = renderer.getRenderState(); final int vpWidth = renderer.getWidth(); final int vpHeight = renderer.getHeight(); if(vpWidth <=0 || vpHeight <= 0 || null==sampleCount || sampleCount[0] <= 0) { useShaderProgram(gl, renderer, curRenderModes, true, getQuality(), sampleCount[0]); - renderRegion(gl, curRenderModes); + renderRegion(gl, rs, curRenderModes); } else { if(0 > maxTexSize[0]) { gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0); } - final RenderState rs = renderer.getRenderState(); final float winWidth, winHeight; final float ratioObjWinWidth, ratioObjWinHeight; @@ -388,7 +395,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } if( sampleCount[0] <= 0 ) { // Last way out! - renderRegion(gl, curRenderModes); + renderRegion(gl, rs, curRenderModes); return; } } @@ -555,17 +562,25 @@ public final class VBORegion2PVBAAES2 extends GLRegion { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } - renderRegion(gl, curRenderModes); + renderRegion(gl, rs, curRenderModes); fbo.unbind(gl); fboDirty = false; } - private void renderRegion(final GL2ES2 gl, final int curRenderModes) { - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + private void renderRegion(final GL2ES2 gl, final RenderState rs, final int curRenderModes) { + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); gl.glUniform(gcu_PMVMatrix02); + { + final AABBox cb = rs.getClipBBox(); + if( null != cb ) { + clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ(); + clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ(); + gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions + } + } vpc_ileave.enableBuffer(gl, true); indicesBuffer.bindBuffer(gl, true); // keeps VBO binding diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 2514f4a1e..281757da4 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -40,6 +40,7 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.math.geom.AABBox; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; @@ -51,6 +52,8 @@ public final class VBORegionSPES2 extends GLRegion { private final GLUniformData gcu_ColorTexUnit; private final float[] colorTexBBox; // minX/minY, maxX/maxY, texW/texH private final GLUniformData gcu_ColorTexBBox; // vec2 gcu_ColorTexBBox[3] -> boxMin[2], boxMax[2] and texSize[2] + private final float[] clipBBox; // minX/minY/minZ, maxX/maxY/maxZ + private final GLUniformData gcu_ClipBBox; // uniform vec3 gcu_ClipBBox[2]; // box-min[3], box-max[3] private ShaderProgram spPass1 = null; public VBORegionSPES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, @@ -71,6 +74,8 @@ public final class VBORegionSPES2 extends GLRegion { colorTexBBox = null; gcu_ColorTexBBox = null; } + clipBBox = new float[6]; + gcu_ClipBBox = new GLUniformData(UniformNames.gcu_ClipBBox, 3, FloatBuffer.wrap(clipBBox)); } @Override @@ -82,15 +87,15 @@ public final class VBORegionSPES2 extends GLRegion { protected final void clearImpl(final GL2ES2 gl) { } @Override - protected void updateImpl(final GL2ES2 gl, final int curRenderModes) { - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); // seal buffers vpc_ileave.seal(gl, true); vpc_ileave.enableBuffer(gl, false); if( hasColorTexture && null != gcu_ColorTexUnit && colorTexSeq.isTextureAvailable() ) { - TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, isColorTextureLetterbox(), colorTexBBox, false); + TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, isColorTextureLetterbox(), colorTexBBox, true); } indicesBuffer.seal(gl, true); indicesBuffer.enableBuffer(gl, false); @@ -117,6 +122,8 @@ public final class VBORegionSPES2 extends GLRegion { final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq; final RenderState rs = renderer.getRenderState(); + final boolean hasAABBoxClipping = null != rs.getClipBBox(); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, quality, 0, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal = !sp.equals(spPass1); @@ -132,6 +139,9 @@ public final class VBORegionSPES2 extends GLRegion { if( hasColorChannel && null != gca_ColorsAttr ) { rs.updateAttributeLoc(gl, true, gca_ColorsAttr, throwOnError); } + if( hasAABBoxClipping ) { + rs.updateUniformLoc(gl, true, gcu_ClipBBox, throwOnError); + } } rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, throwOnError); if( hasColorTexture && null != gcu_ColorTexUnit ) { @@ -143,10 +153,18 @@ public final class VBORegionSPES2 extends GLRegion { @Override protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int[/*1*/] sampleCount) { - final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); + // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); useShaderProgram(gl, renderer, curRenderModes, getQuality()); + { + final AABBox cb = renderer.getClipBBox(); + if( null != cb ) { + clipBBox[0] = cb.getMinX(); clipBBox[1] = cb.getMinY(); clipBBox[2] = cb.getMinZ(); + clipBBox[3] = cb.getMaxX(); clipBBox[4] = cb.getMaxY(); clipBBox[5] = cb.getMaxZ(); + gl.glUniform(gcu_ClipBBox); // Always update, since program maybe used by multiple regions + } + } if( 0 >= indicesBuffer.getElemCount() ) { if(DEBUG_INSTANCE) { |