aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-01 15:37:03 +0100
committerSven Göthel <[email protected]>2024-02-01 15:37:03 +0100
commit9ff736464e0d2762c424bab66bc6d03ccc6e6d11 (patch)
tree14e1a383a86bca406608841c7e3acf5d44cbee11 /src/jogl/classes/jogamp/graph/curve
parentca846bc67e6a074a182e97f29b3c34b90a12cac3 (diff)
Bug 805: Graph/GraphUI TextureSequence Scale: Move Region.COLORTEXTURE_LETTERBOX_RENDERING_BIT to TextureSequence and add enabling/disabling of aratio adjustment + letter-box back-color
TextureSequence color-texture params fetched from Graph VBORegion* and fed into shader. This allows more flexibility in aspect-ratio adjustment as well as setting a clipping background color for the added letter-box space.
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java15
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java15
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java16
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java1
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl8
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl1
6 files changed, 49 insertions, 7 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index a6ba0e810..4644ff883 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -67,6 +67,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[] colorTexClearCol;
+ private final GLUniformData gcu_ColorTexClearCol; // vec4 gcu_ColorTexClearCol
private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
@@ -107,10 +109,14 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
colorTexBBox = new float[6];
gcu_ColorTexBBox = new GLUniformData(UniformNames.gcu_ColorTexBBox, 2, FloatBuffer.wrap(colorTexBBox));
+ colorTexClearCol = new float[4];
+ gcu_ColorTexClearCol = new GLUniformData(UniformNames.gcu_ColorTexClearCol, 4, FloatBuffer.wrap(colorTexClearCol));
} else {
gcu_ColorTexUnit = null;
colorTexBBox = null;
gcu_ColorTexBBox = null;
+ colorTexClearCol = null;
+ gcu_ColorTexClearCol = null;
}
clipFrustum = new float[4*6];
gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
@@ -157,7 +163,12 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
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);
+ if( colorTexSeq.useARatioAdjustment() ) {
+ TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, colorTexSeq.useARatioLetterbox(), colorTexBBox, false);
+ } else {
+ TextureSequence.setTexCoordBBoxSimple(colorTexSeq.getLastTexture().getTexture(), box, colorTexBBox, false);
+ }
+ colorTexSeq.getARatioLetterboxBackColor().toArray(colorTexClearCol);
}
// Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
@@ -215,6 +226,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexClearCol, true);
}
} else {
updateLocLocal = !sp.equals(spPass2);
@@ -516,6 +528,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
+ gl.glUniform(gcu_ColorTexClearCol); // Always update, since program maybe used by multiple regions
gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
tex.disable(gl); // nop on core
} else {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 4585c4cab..333150899 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -72,6 +72,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[] colorTexClearCol;
+ private final GLUniformData gcu_ColorTexClearCol; // vec4 gcu_ColorTexClearCol
private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
@@ -111,10 +113,14 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
colorTexBBox = new float[6];
gcu_ColorTexBBox = new GLUniformData(UniformNames.gcu_ColorTexBBox, 2, FloatBuffer.wrap(colorTexBBox));
+ colorTexClearCol = new float[4];
+ gcu_ColorTexClearCol = new GLUniformData(UniformNames.gcu_ColorTexClearCol, 4, FloatBuffer.wrap(colorTexClearCol));
} else {
gcu_ColorTexUnit = null;
colorTexBBox = null;
gcu_ColorTexBBox = null;
+ colorTexClearCol = null;
+ gcu_ColorTexClearCol = null;
}
clipFrustum = new float[4*6];
gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
@@ -187,6 +193,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexClearCol, true);
}
} else {
updateLocLocal = !sp.equals(spPass2);
@@ -230,7 +237,12 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
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);
+ if( colorTexSeq.useARatioAdjustment() ) {
+ TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, colorTexSeq.useARatioLetterbox(), colorTexBBox, false);
+ } else {
+ TextureSequence.setTexCoordBBoxSimple(colorTexSeq.getLastTexture().getTexture(), box, colorTexBBox, false);
+ }
+ colorTexSeq.getARatioLetterboxBackColor().toArray(colorTexClearCol);
}
// Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
@@ -539,6 +551,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
+ gl.glUniform(gcu_ColorTexClearCol); // Always update, since program maybe used by multiple regions
gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
tex.disable(gl); // nop on core
} else {
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 39ce54240..a406bfb82 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.Vec4f;
import com.jogamp.math.geom.Frustum;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.Texture;
@@ -52,6 +53,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[] colorTexClearCol;
+ private final GLUniformData gcu_ColorTexClearCol; // vec4 gcu_ColorTexClearCol
private final float[/* 4*6 */] clipFrustum; // 6 frustum planes, each [n.x, n.y. n.z, d]
private final GLUniformData gcu_ClipFrustum; // uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F
private ShaderProgram spPass1 = null;
@@ -69,10 +72,14 @@ public final class VBORegionSPES2 extends GLRegion {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
colorTexBBox = new float[6];
gcu_ColorTexBBox = new GLUniformData(UniformNames.gcu_ColorTexBBox, 2, FloatBuffer.wrap(colorTexBBox));
+ colorTexClearCol = new float[4];
+ gcu_ColorTexClearCol = new GLUniformData(UniformNames.gcu_ColorTexClearCol, 4, FloatBuffer.wrap(colorTexClearCol));
} else {
gcu_ColorTexUnit = null;
colorTexBBox = null;
gcu_ColorTexBBox = null;
+ colorTexClearCol = null;
+ gcu_ColorTexClearCol = null;
}
clipFrustum = new float[4*6];
gcu_ClipFrustum = new GLUniformData(UniformNames.gcu_ClipFrustum, 4, FloatBuffer.wrap(clipFrustum));
@@ -95,7 +102,12 @@ public final class VBORegionSPES2 extends GLRegion {
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);
+ if( colorTexSeq.useARatioAdjustment() ) {
+ TextureSequence.setTexCoordBBox(colorTexSeq.getLastTexture().getTexture(), box, colorTexSeq.useARatioLetterbox(), colorTexBBox, false);
+ } else {
+ TextureSequence.setTexCoordBBoxSimple(colorTexSeq.getLastTexture().getTexture(), box, colorTexBBox, false);
+ }
+ colorTexSeq.getARatioLetterboxBackColor().toArray(colorTexClearCol);
}
indicesBuffer.seal(gl, true);
indicesBuffer.enableBuffer(gl, false);
@@ -147,6 +159,7 @@ public final class VBORegionSPES2 extends GLRegion {
if( hasColorTexture && null != gcu_ColorTexUnit ) {
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, throwOnError);
rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, throwOnError);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexClearCol, throwOnError);
}
}
@@ -187,6 +200,7 @@ public final class VBORegionSPES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
+ gl.glUniform(gcu_ColorTexClearCol); // Always update, since program maybe used by multiple regions
gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
// gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), gl_idx_type, 0);
tex.disable(gl); // nop on core
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 7a20fc2da..f7bb18a6b 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java
@@ -6,6 +6,7 @@ public class UniformNames {
public static final String gcu_Weight = "gcu_Weight";
public static final String gcu_ColorTexUnit = "gcu_ColorTexUnit";
public static final String gcu_ColorTexBBox = "gcu_ColorTexBBox";
+ public static final String gcu_ColorTexClearCol = "gcu_ColorTexClearCol";
public static final String gcu_ClipFrustum = "gcu_ClipFrustum";
public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix02"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
index 032ca9228..80e776587 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve_simple.glsl
@@ -12,12 +12,12 @@
if( gcv_CurveParam.x == 0.0 && gcv_CurveParam.y == 0.0 ) {
// pass-1: Lines
#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
- vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), vec4(0), gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
+ vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), gcu_ColorTexClearCol, gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
mgl_FragColor = vec4( mix( t.rgb * gcu_ColorStatic.rgb, gcv_Color.rgb, gcv_Color.a ),
mix( t.a * gcu_ColorStatic.a, 1, gcv_Color.a) );
#elif defined(USE_COLOR_TEXTURE)
- mgl_FragColor = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), vec4(0), gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2])
+ mgl_FragColor = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), gcu_ColorTexClearCol, gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2])
* gcu_ColorStatic;
#elif defined(USE_COLOR_CHANNEL)
mgl_FragColor = gcv_Color * gcu_ColorStatic;
@@ -36,12 +36,12 @@
float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_CurveParam.y), 0.0, 1.0);
#if defined(USE_COLOR_TEXTURE) && defined(USE_COLOR_CHANNEL)
- vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), vec4(0), gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
+ vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), gcu_ColorTexClearCol, gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
mgl_FragColor = vec4( mix( t.rgb * gcu_ColorStatic.rgb, gcv_Color.rgb, gcv_Color.a ),
a * mix( t.a * gcu_ColorStatic.a, 1, gcv_Color.a) );
#elif defined(USE_COLOR_TEXTURE)
- vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), vec4(0), gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
+ vec4 t = clip_coord(gcuTexture2D(gcu_ColorTexUnit, gcv_ColorTexCoord.st), gcu_ColorTexClearCol, gcv_ColorTexCoord, vec2(0), gcu_ColorTexBBox[2]);
mgl_FragColor = vec4(t.rgb * gcu_ColorStatic.rgb, t.a * gcu_ColorStatic.a * a);
#elif defined(USE_COLOR_CHANNEL)
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
index 18c563fbb..41eb97f00 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl
@@ -9,6 +9,7 @@ uniform float gcu_Weight;
#ifdef USE_COLOR_TEXTURE
uniform vec2 gcu_ColorTexBBox[3]; // box-min[2], box-max[2] and tex-size[2]
+ uniform vec4 gcu_ColorTexClearCol; // clear color for gcu_ColorTexBBox clipping
#endif
#ifdef USE_FRUSTUM_CLIPPING
uniform vec4 gcu_ClipFrustum[6]; // L, R, B, T, N, F each {n.x, n.y, n.z, d}