aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/Region.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-30 01:28:59 +0200
committerSven Gothel <[email protected]>2023-09-30 01:28:59 +0200
commit297c48f4fefd1ab59800524ea5f0dd56684d6786 (patch)
tree02c1b8f65de349c9af3bc2a5b94e04e90d75c684 /src/jogl/classes/com/jogamp/graph/curve/Region.java
parent2e46eb1bf06ef07801062122716aa99a6c871646 (diff)
Bug 1465 - Graph / GraphUI: Render a Region's ColorTexture in proper aspect-ratio, letter-boxed or zoomed (config) + Bug 1466 Fix color mixing
Bug 1465: Region currently simply bloats a given texture to its region AABBox, which renders textures with the wrong aspect ratio. Add facility to program the texture-coordinates to either letter-box or scaled-up (and cut) true aspect-ratio. Default shall be zoom (scale-up and cut), but user shall be able to set a flag in the Region for letter-box. Have the shader clip texture coordinates properly, best w/o branching to soothe performance. See functions.glsl +++ Bug 1466: Current color mix: texture * color_channel * color_static is useless in GraphUI. color_static shall modulate the texture, which works. But in case of color_channel (attribute/varying) we want it to be mixed so it can become the more dominant color for e.g. a border. Desired is: color = vec4( mix( tex.rgb * gcu_ColorStatic.rgb, gcv_Color.rgb, gcv_Color.a ), mix( tex.a * gcu_ColorStatic.a, 1, gcv_Color.a) );
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/Region.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 93b05aefa..5f78283ed 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -127,9 +127,21 @@ public abstract class Region {
* <p>
* If set, a color texture is used to determine the color.
* </p>
+ * @see #COLORTEXTURE_LETTERBOX_RENDERING_BIT
*/
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>
+ * 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;
+
/** Default maximum {@link #getQuality() quality}, {@value}. */
public static final int MAX_QUALITY = 1;
@@ -147,6 +159,9 @@ public abstract class Region {
protected final AABBox box = new AABBox();
protected Frustum frustum = null;
+ public static final boolean isRenderModeSet(final int renderModes, final int mask) { return mask == ( renderModes & mask ); }
+ public static final int setRenderMode(int renderModes, final int mask, final boolean v) { if( v ) { renderModes |= mask; } else { renderModes &= ~mask; }; return renderModes; }
+
/** Returns true if given {@code renderModes} has {@link Region#VBAA_RENDERING_BIT} set. */
public static boolean isVBAA(final int renderModes) {
return 0 != (renderModes & Region.VBAA_RENDERING_BIT);
@@ -194,6 +209,11 @@ 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>
@@ -204,7 +224,16 @@ public abstract class Region {
public static String getRenderModeString(final int renderModes) {
final String curveS = hasVariableWeight(renderModes) ? "-curve" : "";
final String cChanS = hasColorChannel(renderModes) ? "-cols" : "";
- final String cTexS = hasColorTexture(renderModes) ? "-ctex" : "";
+ final String cTexS;
+ if( hasColorTexture(renderModes) ) {
+ if( Region.isColorTextureLetterbox(renderModes) ) {
+ cTexS = "-ctex_lbox";
+ } else {
+ cTexS = "-ctex_zoom";
+ }
+ } else {
+ cTexS = "";
+ }
if( Region.isVBAA(renderModes) ) {
return "vbaa"+curveS+cChanS+cTexS;
} else if( Region.isMSAA(renderModes) ) {
@@ -299,6 +328,8 @@ public abstract class Region {
box.reset();
}
+ public final boolean isRenderModeSet(final int mask) { return mask == ( renderModes & mask ); }
+
/**
* Returns true if capable of two pass rendering - VBAA, otherwise false.
* @see #getRenderModes()
@@ -340,11 +371,16 @@ public abstract class Region {
* i.e. the bit {@link #COLORTEXTURE_RENDERING_BIT} is set,
* otherwise false.
* @see #getRenderModes()
+ * @see #isColorTextureLetterbox()
*/
public final boolean hasColorTexture() {
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; }