aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java35
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java35
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java42
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java48
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java101
-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
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java22
12 files changed, 296 insertions, 43 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
index de5c43be1..89ec7ffea 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
@@ -32,6 +32,7 @@ import com.jogamp.opengl.GLProfile;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.ui.GraphShape;
+import com.jogamp.math.Vec4f;
import com.jogamp.opengl.util.texture.TextureSequence;
/**
@@ -56,17 +57,41 @@ public abstract class TexSeqButton extends BaseButton {
public final TextureSequence getTextureSequence() { return this.texSeq; }
/**
- * Sets a renderMode {@link Region#COLORTEXTURE_LETTERBOX_RENDERING_BIT} on or off.
+ * See {@link TextureSequence#setARatioAdjustment(boolean)}.
* @return this instance for chaining
*/
- public TexSeqButton setTextureLetterbox(final boolean v) {
- if( getTextureLetterbox() != v ) {
- renderModes = Region.setRenderMode(renderModes, Region.COLORTEXTURE_LETTERBOX_RENDERING_BIT, v);
+ public TexSeqButton setARatioAdjustment(final boolean v) {
+ if( useARatioAdjustment() != v ) {
+ texSeq.setARatioAdjustment(v);
markShapeDirty();
}
return this;
}
- public boolean getTextureLetterbox() { return Region.isColorTextureLetterbox(renderModes); }
+ /**
+ * See {@link TextureSequence#useARatioAdjustment()}.
+ */
+ public boolean useARatioAdjustment() { return texSeq.useARatioAdjustment(); }
+
+ /**
+ * See {@link TextureSequence#setARatioLetterbox(boolean, Vec4f)}.
+ * @param v new value for {@link #useARatioLetterbox()}
+ * @param backColor optional background color for added letter-box space, defaults to transparent zero
+ * @return this instance for chaining
+ */
+ public TexSeqButton setARatioLetterbox(final boolean v, final Vec4f backColor) {
+ if( useAspectRatioLetterbox() != v ) {
+ texSeq.setARatioLetterbox(v, backColor);
+ markShapeDirty();
+ }
+ return this;
+ }
+ /**
+ * See {@link TextureSequence#useARatioLetterbox()}.
+ */
+ public boolean useAspectRatioLetterbox() { return texSeq.useARatioLetterbox(); }
+
+ /** See {@link TextureSequence#getARatioLetterboxBackColor()}. */
+ public Vec4f getARatioLetterboxBackColor() { return texSeq.getARatioLetterboxBackColor(); }
@Override
protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index fac65c6ee..0238ba154 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -150,29 +150,16 @@ public abstract class Region {
/**
* Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
- * If set, a color texture is used to determine the color.
+ * If set, a color texture is used to determine the color via {#link TextureSequence} passed to implementation, e.g. GLRegion.
* </p>
* <p>
* This mode-bit is a shader-key.
* </p>
- * @see #COLORTEXTURE_LETTERBOX_RENDERING_BIT
+ * @see TextureSequence#useARatioAdjustment()
+ * @see TextureSequence#useARatioLetterbox()
*/
public static final int COLORTEXTURE_RENDERING_BIT = 1 << 10;
- /**
- * Rendering-Mode bit for {@link #getRenderModes() Region}
- * <p>
- * If set, a used {@link #COLORTEXTURE_RENDERING_BIT} color texture is added letter-box space to match aspect-ratio, otherwise it will be zoomed in.
- * </p>
- * <p>
- * This mode-bit is not a shader-key.
- * </p>
- * <p>
- * Note that {@link #COLORTEXTURE_RENDERING_BIT} must also be set to even enable color texture.
- * </p>
- */
- public static final int COLORTEXTURE_LETTERBOX_RENDERING_BIT = 1 << 11;
-
/** Minimum pass2 AA-quality rendering {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
public static final int MIN_AA_QUALITY = 0;
/** Maximum pass2 AA-quality rendering {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
@@ -254,11 +241,6 @@ public abstract class Region {
return 0 != (renderModes & Region.COLORTEXTURE_RENDERING_BIT);
}
- /** Returns true if given {@code renderModes} has {@link Region#COLORTEXTURE_LETTERBOX_RENDERING_BIT} set. */
- public static boolean isColorTextureLetterbox(final int renderModes) {
- return 0 != ( renderModes & Region.COLORTEXTURE_LETTERBOX_RENDERING_BIT );
- }
-
/**
* Returns a unique technical description string for renderModes as follows:
* <pre>
@@ -271,11 +253,7 @@ public abstract class Region {
final String cChanS = hasColorChannel(renderModes) ? "-cols" : "";
final String cTexS;
if( hasColorTexture(renderModes) ) {
- if( Region.isColorTextureLetterbox(renderModes) ) {
- cTexS = "-ctex_lbox";
- } else {
- cTexS = "-ctex_zoom";
- }
+ cTexS = "-ctex";
} else {
cTexS = "";
}
@@ -420,11 +398,6 @@ public abstract class Region {
return Region.hasColorTexture(renderModes);
}
- /** Returns true if given {@code renderModes} has {@link Region#COLORTEXTURE_LETTERBOX_RENDERING_BIT} set. */
- public final boolean isColorTextureLetterbox() {
- return Region.isColorTextureLetterbox(renderModes);
- }
-
/** See {@link #setFrustum(Frustum)} */
public final Frustum getFrustum() { return frustum; }
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
index 987031b6b..2767ea7ef 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -456,6 +456,48 @@ public interface GLMediaPlayer extends TextureSequence {
public void setTextureWrapST(int[] wrapST);
/**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code true} and toggling not supported.
+ * </p>
+ */
+ @Override
+ public boolean useARatioAdjustment();
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code true} and toggling is not supported.
+ * </p>
+ */
+ @Override
+ public void setARatioAdjustment(final boolean v);
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code false} and toggling is supported via {@link #setARatioLetterbox(boolean, Vec4f)}
+ * </p>
+ */
+ @Override
+ public boolean useARatioLetterbox();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Vec4f getARatioLetterboxBackColor();
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code false}.
+ * </p>
+ */
+ @Override
+ public void setARatioLetterbox(final boolean v, Vec4f backColor);
+
+ /**
* Limit maximum supported audio channels by user.
* <p>
* Must be set before {@link #playStream(Uri, int, int, int, int)}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
index 69a990fde..4cd78b177 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
@@ -37,6 +37,7 @@ import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLProfile;
import com.jogamp.common.util.IOUtil;
+import com.jogamp.math.Vec4f;
/**
* Simple {@link TextureSequence} implementation
@@ -53,6 +54,9 @@ public class ImageSequence implements TextureSequence {
private volatile int frameIdx = 0;
private volatile boolean manualStepping = false;
private int textureFragmentShaderHashCode = 0;
+ private boolean aRatioAdjustment = true;
+ private boolean aRatioLbox = false;
+ private final Vec4f aRatioLboxBackColor = new Vec4f();
public ImageSequence(final int textureUnit, final boolean useBuildInTexLookup) {
this.textureUnit = textureUnit;
@@ -136,6 +140,50 @@ public class ImageSequence implements TextureSequence {
return texWrapST;
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code true} and toggling is supported via {@link #setARatioAdjustment(boolean)}
+ * </p>
+ */
+ @Override
+ public boolean useARatioAdjustment() { return aRatioAdjustment; }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code true}.
+ * </p>
+ */
+ @Override
+ public void setARatioAdjustment(final boolean v) { aRatioAdjustment = v; }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code false} and toggling is supported via {@link #setARatioLetterbox(boolean, Vec4f)}
+ * </p>
+ */
+ @Override
+ public boolean useARatioLetterbox() { return aRatioLbox; }
+
+ @Override
+ public Vec4f getARatioLetterboxBackColor() { return aRatioLboxBackColor; }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Defaults to {@code false}.
+ * </p>
+ */
+ @Override
+ public void setARatioLetterbox(final boolean v, final Vec4f backColor) {
+ aRatioLbox = v;
+ if( null != backColor ) {
+ aRatioLboxBackColor.set(backColor);
+ }
+ };
+
@Override
public boolean isTextureAvailable() { return frames.size() > 0; }
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 d2f30723e..a41c8f22e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
@@ -33,6 +33,8 @@ import com.jogamp.opengl.GLRunnable;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.common.av.TimeFrameI;
+import com.jogamp.graph.curve.Region;
+import com.jogamp.math.Vec4f;
import com.jogamp.math.geom.AABBox;
/**
@@ -175,6 +177,66 @@ public interface TextureSequence {
public int[] getTextureWrapST();
/**
+ * Returning {@code true} indicates texture correction for aspect-ratio in the shader.
+ * Graph's {@link Region} shader will utilize {@link #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)}
+ * for texture-coordinate bounding-box calculation.
+ * <p>
+ * Returning {@code false} indicates no correction for aspect-ratio in the shader.
+ * Graph's {@link Region} shader will utilize {@link #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)}
+ * for texture-coordinate bounding-box calculation.
+ * </p>
+ * <p>
+ * Default value is implementation specific
+ * and toggling is optional.
+ * </p>
+ * @see #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)
+ * @see #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)
+ * @see #useARatioLetterbox()
+ */
+ public boolean useARatioAdjustment();
+
+ /**
+ * Toggles {@link #useARatioLetterbox()}.
+ * <p>
+ * Default value is implementation specific
+ * and toggling is optional.
+ * </p>
+ * @see #useARatioLetterbox()
+ * @see #useARatioAdjustment()
+ */
+ public void setARatioAdjustment(final boolean v);
+
+ /**
+ * Returns whether {@link #useARatioAdjustment()} shall add letter-box space to match aspect-ratio, otherwise it will be zoomed in.
+ * <p>
+ * Default value is implementation specific
+ * and toggling is optional.
+ * </p>
+ * @see #useARatioAdjustment()
+ * @see #setARatioLetterbox(boolean, Vec4f)
+ */
+ public boolean useARatioLetterbox();
+
+ /** Returns {@link #useARatioLetterbox()} background color for added letter-box space, defaults to transparent zero. */
+ public Vec4f getARatioLetterboxBackColor();
+
+ /**
+ * Toggles {@link #useARatioLetterbox()}.
+ * <p>
+ * Default value is implementation specific
+ * and toggling is optional.
+ * </p>
+ * <p>
+ * Impacts only if {@link #useARatioAdjustment()} returns {@code true}.
+ * </p>
+ * @param v new value for {@link #useARatioLetterbox()}
+ * @param backColor optional background color for added letter-box space, defaults to transparent zero
+ * @see #useARatioLetterbox()
+ * @see #useARatioAdjustment()
+ */
+ public void setARatioLetterbox(final boolean v, Vec4f backColor);
+
+ /**
* Returns true if texture source is ready <i>and</i> a texture is available
* via {@link #getNextTexture(GL)} and {@link #getLastTexture()}.
*/
@@ -319,12 +381,50 @@ public interface TextureSequence {
public int getTextureFragmentShaderHashCode();
/**
+ * Calculates the texture coordinates bounding box w/o correcting aspect-ratio.
+ * @param tex the {@link Texture}
+ * @param box the {@Link AABBox} of the destination
+ * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH
+ * @param verbose TODO
+ * @see #useARatioAdjustment()
+ */
+ public static void setTexCoordBBoxSimple(final Texture tex, final AABBox box, final float[] colorTexBBox, final boolean verbose) {
+ final TextureCoords tc = tex.getImageTexCoords();
+ final float tcW = tc.right() - tc.left();
+ final float tcH;
+ colorTexBBox[0] = box.getMinX() / tcW;
+ colorTexBBox[2] = box.getMaxX() / tcW;
+ if( tex.getMustFlipVertically() ) {
+ tcH = tc.bottom() - tc.top();
+ colorTexBBox[1] = box.getMaxY() / tcH;
+ colorTexBBox[3] = box.getMinY() / tcH;
+ } else {
+ tcH = tc.top() - tc.bottom();
+ colorTexBBox[1] = box.getMinY() / tcH;
+ colorTexBBox[3] = box.getMaxY() / tcH;
+ }
+ colorTexBBox[4] = tcW;
+ colorTexBBox[5] = tcH;
+ if( verbose ) {
+ final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
+ final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
+ System.err.println("XXX setTexCoordBBoxSimple:");
+ System.err.println("XXX ColorTex "+tex);
+ 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);
+ }
+
+ }
+
+ /**
* Calculates the texture coordinates bounding box while correcting for aspect-ratio.
* @param tex the {@link Texture}
* @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
+ * @see #useARatioAdjustment()
*/
public static void setTexCoordBBox(final Texture tex, final AABBox box, final boolean letterBox, final float[] colorTexBBox, final boolean verbose) {
final TextureCoords tc = tex.getImageTexCoords();
@@ -334,6 +434,7 @@ public interface TextureSequence {
final float tcW = tc.right() - tc.left();
final float tcH;
float boxWidthCut=0, boxHeightCut=0, boxWidthExt=0, boxHeightExt=0;
+
if( box2ImgRatio >= 1.0f ) {
if( letterBox ) {
boxWidthCut = box.getWidth() * ( 1f - 1f / box2ImgRatio );
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}
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index ed03278b9..219cfb3e5 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -118,6 +118,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
private final int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST };
private final int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE };
+ private boolean aRatioLbox = false;
+ private final Vec4f aRatioLboxBackColor = new Vec4f();
/** User requested URI stream location. */
private Uri streamLoc;
@@ -1032,6 +1034,26 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
@Override
+ public final boolean useARatioAdjustment() { return true; }
+
+ @Override
+ public void setARatioAdjustment(final boolean v) { } // intentionally not supported
+
+ @Override
+ public final boolean useARatioLetterbox() { return aRatioLbox; }
+
+ @Override
+ public Vec4f getARatioLetterboxBackColor() { return aRatioLboxBackColor; }
+
+ @Override
+ public void setARatioLetterbox(final boolean v, final Vec4f backColor) {
+ aRatioLbox = v;
+ if( null != backColor ) {
+ aRatioLboxBackColor.set(backColor);
+ }
+ };
+
+ @Override
public final boolean isTextureAvailable() {
return null != lastFrame; // Note: lastFrame is test-texture if using initGL() pre stream ready
}