aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java32
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java35
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java26
3 files changed, 72 insertions, 21 deletions
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) {