aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-15 04:47:34 +0100
committerSven Göthel <[email protected]>2024-01-15 04:47:34 +0100
commitd7cb4a77b71cb3703ff7ac0667c5a97f29a5bdb4 (patch)
tree17cb67b7867f0da11a2717492d691a5e96f52636 /src/jogl/classes/com/jogamp/graph/curve
parent9b8d1825cfb76454e42b196a93dc54d189a8a9a6 (diff)
Graph/GraphUI AA-Quality (shader): Region: Add DEFAULT_AA_QUALITY and clipping funs for aaQuality/sampleCount; TextRegionUtil: Pass quality parameter in draw-functions
Region.DEFAULT_AA_QUALITY defaults to MAX_AA_QUALITY still - TODO: AA shader is subject to change .. Region.draw(..) clips the quality param (save) TextRegionUtil: Pass quality parameter in draw-functions - Allowing to select the AA shader GraphUI Scene and some demos add the AA-quality param to the status line or screenshot-filename. - See Region.getRenderModeString(..) +++ TestTextRendererNEWT20 and TestTextRendererNEWT21 now iterate through all fonts, AA-quality shader and sample-sizes. Most demos and some more tests take AA-quality into acount, demos via CommandlineOptions.graphAAQuality
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java21
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java2
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java31
3 files changed, 34 insertions, 20 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index d49d68982..389af2a8b 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -173,15 +173,21 @@ public abstract class Region {
*/
public static final int COLORTEXTURE_LETTERBOX_RENDERING_BIT = 1 << 11;
- /** Minimum pass2 AA-quality rendering {@value} (default) for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
+ /** 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} (default) for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
+ /** Maximum pass2 AA-quality rendering {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
public static final int MAX_AA_QUALITY = 1;
+ /** Default pass2 AA-quality rendering {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT}. */
+ public static final int DEFAULT_AA_QUALITY = MAX_AA_QUALITY;
+ /** Returns clipped AA quality value to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] */
+ public static final int clipAAQuality(final int v) { return Math.min(Region.MAX_AA_QUALITY, Math.max(v, Region.MIN_AA_QUALITY)); }
/** Minimum pass2 AA sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */
public static final int MIN_AA_SAMPLE_COUNT = 1;
/** Maximum pass2 AA sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */
public static final int MAX_AA_SAMPLE_COUNT = 8;
+ /** Returns clipped AA sample-count to [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}] */
+ public static final int clipAASampleCount(final int v) { return Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(v, Region.MIN_AA_SAMPLE_COUNT)); }
public static final int DEFAULT_TWO_PASS_TEXTURE_UNIT = 0;
@@ -283,15 +289,20 @@ public abstract class Region {
/**
* Return a unique technical description string for renderModes and sample counts as follows:
* <pre>
- * {@link #getRenderModeString(int)}-s{sampleCount}-fsaa{CapsNumSamples}
+ * {@link #getRenderModeString(int)}-q{AA-quality}-s{sampleCount}-fsaa{CapsNumSamples}
* </pre>
*
* @param renderModes the used Graph renderModes, see {@link GLRegion#create(GLProfile, int, TextureSequence) create(..)}
+ * @param graphAAQuality Graph AA quality, see {@link #DEFAULT_AA_QUALITY}, set to negative value to mark undefined
* @param graphSampleCount Graph sample count for {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}
* @param fsaaSampleCount full-screen AA (fsaa) sample count, retrieved e.g. via {@link GLCapabilitiesImmutable#getNumSamples()}
*/
- public static String getRenderModeString(final int renderModes, final int graphSampleCount, final int fsaaSampleCount) {
- return String.format((Locale)null, "%s-s%02d-fsaa%d", Region.getRenderModeString(renderModes), graphSampleCount, fsaaSampleCount);
+ public static String getRenderModeString(final int renderModes, final int graphAAQuality, final int graphSampleCount, final int fsaaSampleCount) {
+ if( Region.MIN_AA_QUALITY > graphAAQuality ) {
+ return String.format((Locale)null, "%s-qu-s%02d-fsaa%d", Region.getRenderModeString(renderModes), graphSampleCount, fsaaSampleCount);
+ } else {
+ return String.format((Locale)null, "%s-q%01d-s%02d-fsaa%d", Region.getRenderModeString(renderModes), graphAAQuality, graphSampleCount, fsaaSampleCount);
+ }
}
protected Region(final int regionRenderModes, final boolean use_int32_idx) {
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 718f543c2..dfc7d3921 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -539,7 +539,7 @@ public abstract class GLRegion extends Region {
if( isShapeDirty() ) {
updateImpl(gl, renderer, curRenderModes);
}
- drawImpl(gl, renderer, curRenderModes, pass2Quality, sampleCount);
+ drawImpl(gl, renderer, curRenderModes, Region.clipAAQuality(pass2Quality), sampleCount);
clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
lastRenderModes = curRenderModes;
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
index 225f42830..633bc38af 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -168,7 +168,7 @@ public class TextRegionUtil {
* @return the given int[2] storage for chaining
* @see Region#setBufferCapacity(int, int)
* @see Region#growBuffer(int, int)
- * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int[], AffineTransform, AffineTransform)
+ * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)
*/
public static int[] countStringRegion(final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) {
final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() {
@@ -203,6 +203,7 @@ public class TextRegionUtil {
* @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used
* and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white.
* Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}.
+ * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}]
* @param sampleCount desired multisampling sample count for msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @return the bounding box of the given string from the produced and rendered GLRegion
@@ -210,7 +211,7 @@ public class TextRegionUtil {
*/
public AABBox drawString3D(final GL2ES2 gl,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
+ final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) {
if( !renderer.isInitialized() ) {
throw new GLException("TextRendererImpl01: not initialized!");
}
@@ -231,20 +232,20 @@ public class TextRegionUtil {
} else {
renderer.setColorStatic(1, 1, 1, 1);
}
- region.draw(gl, renderer, Region.MAX_AA_QUALITY, sampleCount);
+ region.draw(gl, renderer, aaQuality, sampleCount);
return res;
}
/**
- * Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, Vec4f, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ * Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
* <p>
* The region's buffer size is pre-calculated via {@link GLRegion#create(com.jogamp.opengl.GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence, Font, CharSequence)}
* </p>
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
- return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
+ final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) {
+ return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, aaQuality, sampleCount, new AffineTransform(), new AffineTransform());
}
/**
@@ -261,7 +262,7 @@ public class TextRegionUtil {
* <p>
* In case of a multisampling region renderer, i.e. {@link Region#VBAA_RENDERING_BIT}, recreating the {@link GLRegion}
* is a huge performance impact.
- * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int[], AffineTransform, AffineTransform)}
+ * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)}
* instead.
* </p>
* @param gl the current GL state
@@ -271,6 +272,7 @@ public class TextRegionUtil {
* @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used
* and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white.
* Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}.
+ * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}]
* @param sampleCount desired multisampling sample count for msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @param tmp1 temp {@link AffineTransform} to be reused
@@ -280,7 +282,7 @@ public class TextRegionUtil {
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final Vec4f rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
+ final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
@@ -293,20 +295,20 @@ public class TextRegionUtil {
} else {
renderer.setColorStatic(1, 1, 1, 1);
}
- region.draw(gl, renderer, Region.MAX_AA_QUALITY, sampleCount);
+ region.draw(gl, renderer, aaQuality, sampleCount);
region.destroy(gl);
return res;
}
/**
- * Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ * Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
* <p>
* The region buffer's size is grown by pre-calculating required size via {@link #countStringRegion(Font, CharSequence, int[])}.
* </p>
*/
public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
- final Font font, final CharSequence str, final Vec4f rgbaColor, final int[/*1*/] sampleCount) {
- return drawString3D(gl, region, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
+ final Font font, final CharSequence str, final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) {
+ return drawString3D(gl, region, renderer, font, str, rgbaColor, aaQuality, sampleCount, new AffineTransform(), new AffineTransform());
}
/**
@@ -331,6 +333,7 @@ public class TextRegionUtil {
* @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used
* and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white.
* Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}.
+ * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}]
* @param sampleCount desired multisampling sample count for msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @param tmp1 temp {@link AffineTransform} to be reused
@@ -340,7 +343,7 @@ public class TextRegionUtil {
*/
public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
final Font font, final CharSequence str, final Vec4f rgbaColor,
- final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
+ final int aaQuality, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
@@ -352,7 +355,7 @@ public class TextRegionUtil {
} else {
renderer.setColorStatic(1, 1, 1, 1);
}
- region.draw(gl, renderer, Region.MAX_AA_QUALITY, sampleCount);
+ region.draw(gl, renderer, aaQuality, sampleCount);
return res;
}