aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-03 02:30:07 +0200
committerSven Gothel <[email protected]>2023-09-03 02:30:07 +0200
commitc059585e246ed707ba490f9d2bae3a8b90e949a7 (patch)
tree61349e65c273e16a0f0a0a31998f28a968c81d36
parentef63d2e288fe47762d9cf743d11cd01f8d255349 (diff)
GraphUI Scene: Pass sampleCount in ctor variant and refine API doc, clip to [1..8]; Add clarity in Region; Demos CommandlineOptions adds actual graphAASamples set and utilized
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java15
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java2
-rw-r--r--src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java23
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java45
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java3
13 files changed, 84 insertions, 31 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index dcc1102ed..7af28ca23 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -144,7 +144,7 @@ public class FontView01 {
});
animator.add(window);
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setFrustumCullingEnabled(true);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java
index 6c424d42c..d515896b8 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIGraphDemoU01a.java
@@ -184,7 +184,7 @@ public class UIGraphDemoU01a {
/** World origin (bottom left) offset. */
private final Vec3f worldOrigin = new Vec3f();
/** Sample count for Graph-VBAA */
- private final int[] sampleCount = { 4 };
+ private final int[] sampleCount = { options.graphAASamples };
/** Graph region renderer */
private final RegionRenderer renderer;
/** The Graph region for text */
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
index e0ffb9663..ddc1b72f6 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
@@ -75,7 +75,7 @@ public class UISceneDemo00 {
final Shape shape = new Button(options.renderModes, font, "+", 0.10f, 0.10f/2.5f); // normalized: 1 is 100% surface size (width and/or height)
System.err.println("Shape bounds "+shape.getBounds(reqGLP));
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.addShape(shape);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
index 8bdb3eb47..5aa5869cd 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -83,7 +83,7 @@ public class UISceneDemo01 {
System.err.println("Shape bounds "+shape.getBounds(reqGLP));
System.err.println("Shape "+shape);
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.addShape(shape);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
index 4a564ef42..37ecac50c 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
@@ -91,7 +91,7 @@ public class UISceneDemo01b {
System.err.println("Shape bounds "+shape.getBounds(reqGLP));
System.err.println("Shape "+shape);
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setPMVMatrixSetup(new MyPMVMatrixSetup());
scene.addShape(shape);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
index 449d6bd96..a670b02f8 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
@@ -58,6 +58,7 @@ import com.jogamp.opengl.util.PMVMatrix;
* </p>
* <p>
* Pass '-keep' to main-function to keep running.
+ * Pass '-auto' to main-function to keep running and change speed for each animation cycle
* </p>
*/
public class UISceneDemo02 {
@@ -65,10 +66,8 @@ public class UISceneDemo02 {
static float req_total_dur_s = 6f; // [s]
public static void main(final String[] args) throws IOException {
- boolean wait_to_start = false;
int autoSpeed = 0;
- boolean keepRunning = false;
if( 0 != args.length ) {
final int[] idx = { 0 };
for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
@@ -77,9 +76,7 @@ public class UISceneDemo02 {
} else if(args[idx[0]].equals("-aspeed")) {
autoSpeed = 1;
req_total_dur_s = 1f;
- keepRunning = true;
- } else if(args[idx[0]].equals("-wait")) {
- wait_to_start = true;
+ options.keepRunning = true;
}
}
}
@@ -99,7 +96,7 @@ public class UISceneDemo02 {
final Label movingGlyph = new Label(options.renderModes, font, "");
movingGlyph.setColor(0.1f, 0.1f, 0.1f, 1);
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.addShape(destText);
scene.addShape(movingGlyph);
@@ -142,7 +139,7 @@ public class UISceneDemo02 {
final AABBox sceneBox = scene.getBounds();
System.err.println("SceneBox "+sceneBox);
- if( wait_to_start ) {
+ if( options.wait_to_start ) {
MiscUtils.waitForKey("Start");
}
@@ -293,8 +290,8 @@ public class UISceneDemo02 {
autoSpeed = 1;
}
}
- } while ( keepRunning && window.isNativeValid() );
- if( !keepRunning ) {
+ } while ( options.keepRunning && window.isNativeValid() );
+ if( !options.keepRunning ) {
window.destroy();
}
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
index 744ab1ea6..810fcdb87 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -182,7 +182,7 @@ public class UISceneDemo03 {
System.err.println("Font: " + font.getFullFamilyName());
final Font fontStatus = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMono.ttf", FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f }, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setPMVMatrixSetup( new MyPMVMatrixSetup(Scene.DEFAULT_SCENE_DIST) );
scene.setDebugBorderBox(options.debugBoxThickness);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
index 58e382c43..2459cbbf6 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo10.java
@@ -122,7 +122,7 @@ public class UISceneDemo10 {
System.err.println("m0 "+shape);
// Scene for Shape ...
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
shape.onMove(new Shape.Listener() {
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
index 474860532..79e8c8271 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
@@ -96,7 +96,7 @@ public class UISceneDemo11 {
System.err.println("Group-A0 Layout "+groupA0.getLayout());
groupA0.forAll( (shape) -> { System.err.println("Shape... "+shape); return false; });
- final Scene scene = new Scene();
+ final Scene scene = new Scene(options.graphAASamples);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.addShape(groupA0);
scene.setFrustumCullingEnabled(true);
diff --git a/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java b/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
index 0e0488ff1..21ea23a10 100644
--- a/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
+++ b/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
@@ -35,6 +35,8 @@ public class CommandlineOptions {
public String glProfileName = GLProfile.GL2ES2;
public int renderModes = Region.NORM_RENDERING_BIT;
public int sceneMSAASamples = 0;
+ /** Sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT} */
+ public int graphAASamples = 0;
public float debugBoxThickness = 0f;
public boolean exclusiveContext = false;
public boolean wait_to_start = false;
@@ -46,10 +48,19 @@ public class CommandlineOptions {
GLProfile.initSingleton(); // ensure JOGL is completely initialized
}
+ /**
+ * Commandline options
+ * @param width viewport width in pixels
+ * @param height viewport height in pixels
+ * @param renderModes {@link Region#getRenderModes()}, if {@link Region#isGraphAA(int)} {@link #graphAASamples} is set to {@code 4}.
+ */
public CommandlineOptions(final int width, final int height, final int renderModes) {
this.surface_width = width;
this.surface_height = height;
this.renderModes = renderModes;
+ if( Region.isGraphAA(renderModes) ) {
+ this.graphAASamples = 4;
+ }
}
public void parse(final String[] args) {
final int[] idx = { 0 };
@@ -92,6 +103,7 @@ public class CommandlineOptions {
glProfileName = null;
} else if(args[idx[0]].equals("-gnone")) {
sceneMSAASamples = 0;
+ graphAASamples = 0;
renderModes = Region.NORM_RENDERING_BIT;
} else if(args[idx[0]].equals("-color")) {
renderModes |= Region.COLORCHANNEL_RENDERING_BIT;
@@ -99,15 +111,20 @@ public class CommandlineOptions {
renderModes &= ~Region.COLORCHANNEL_RENDERING_BIT;
} else if(args[idx[0]].equals("-smsaa")) {
++idx[0];
+ graphAASamples = 0;
sceneMSAASamples = MiscUtils.atoi(args[idx[0]], 4);
- renderModes &= ~(Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT );
+ renderModes &= ~Region.AA_RENDERING_MASK;
} else if(args[idx[0]].equals("-gmsaa")) {
+ ++idx[0];
sceneMSAASamples = 0;
- renderModes &= ~(Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT );
+ graphAASamples = MiscUtils.atoi(args[idx[0]], 4);
+ renderModes &= ~Region.AA_RENDERING_MASK;
renderModes |= Region.MSAA_RENDERING_BIT;
} else if(args[idx[0]].equals("-gvbaa")) {
+ ++idx[0];
sceneMSAASamples = 0;
- renderModes &= ~(Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT );
+ graphAASamples = MiscUtils.atoi(args[idx[0]], 4);
+ renderModes &= ~Region.AA_RENDERING_MASK;
renderModes |= Region.VBAA_RENDERING_BIT;
} else if (args[idx[0]].equals("-dbgbox")) {
++idx[0];
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index 39bf12140..acde820f7 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -52,6 +52,7 @@ import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.ui.Shape.Visitor2;
+import com.jogamp.graph.ui.Scene.PMVMatrixSetup;
import com.jogamp.graph.ui.Shape.Visitor1;
import com.jogamp.newt.event.GestureHandler;
import com.jogamp.newt.event.InputEvent;
@@ -106,6 +107,12 @@ public final class Scene implements Container, GLEventListener {
/** Default projection z-far value is 7000. */
public static final float DEFAULT_ZFAR = 7000.0f;
+ /** Minimum 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_SAMPLE_COUNT = 1;
+
+ /** Maximum 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_SAMPLE_COUNT = 8;
+
@SuppressWarnings("unused")
private static final boolean DEBUG = false;
@@ -138,23 +145,38 @@ public final class Scene implements Container, GLEventListener {
}
/**
- * Create a new scene with an internally created RegionRenderer
- * and using default values {@link #DEFAULT_SCENE_DIST}, {@link #DEFAULT_ANGLE}, {@link #DEFAULT_ZNEAR} and {@link #DEFAULT_ZFAR}.
+ * Create a new scene with an internally created {@link RegionRenderer}, a graph AA sample-count 4 and using {@link DefaultPMVMatrixSetup#DefaultPMVMatrixSetup()}.
+ * @see #Scene(RegionRenderer, int)
+ * @see #setSampleCount(int)
*/
public Scene() {
- this(createRenderer());
+ this(createRenderer(), 4);
}
/**
- * Create a new scene taking ownership of the given RegionRenderer
- * and using default values {@link #DEFAULT_SCENE_DIST}, {@link #DEFAULT_ANGLE}, {@link #DEFAULT_ZNEAR} and {@link #DEFAULT_ZFAR}.
+ * Create a new scene with an internally created {@link RegionRenderer}, using {@link DefaultPMVMatrixSetup#DefaultPMVMatrixSetup()}.
+ * @param sampleCount sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT},
+ * clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * @see #Scene(RegionRenderer, int)
+ * @see #setSampleCount(int)
*/
- public Scene(final RegionRenderer renderer) {
+ public Scene(final int sampleCount) {
+ this(createRenderer(), sampleCount);
+ }
+
+ /**
+ * Create a new scene taking ownership of the given RegionRenderer, using {@link DefaultPMVMatrixSetup#DefaultPMVMatrixSetup()}.
+ * @param renderer {@link RegionRenderer} to be owned
+ * @param sampleCount sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT},
+ * clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * @see #setSampleCount(int)
+ */
+ public Scene(final RegionRenderer renderer, final int sampleCount) {
if( null == renderer ) {
throw new IllegalArgumentException("Null RegionRenderer");
}
this.renderer = renderer;
- this.sampleCount[0] = 4;
+ this.sampleCount[0] = Math.min(MAX_SAMPLE_COUNT, Math.max(sampleCount, MIN_SAMPLE_COUNT)); // clip
this.screenshot = new GLReadBufferUtil(false, false);
}
@@ -282,9 +304,16 @@ public final class Scene implements Container, GLEventListener {
return null;
}
+ /** Returns sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT} */
public int getSampleCount() { return sampleCount[0]; }
+
+ /**
+ * Sets sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}
+ * @param v sample count, clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * @return clipped and set value
+ */
public int setSampleCount(final int v) {
- sampleCount[0] = Math.min(8, Math.max(v, 0)); // clip
+ sampleCount[0] = Math.min(MAX_SAMPLE_COUNT, Math.max(v, MIN_SAMPLE_COUNT)); // clip
markAllShapesDirty();
return sampleCount[0];
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 345b45eab..07592430e 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -93,6 +93,9 @@ public abstract class Region {
*/
public static final int VBAA_RENDERING_BIT = 1 << 1;
+ /** Rendering bit-mask including {@link #MSAA_RENDERING_BIT} and {@link #VBAA_RENDERING_BIT}. */
+ public static final int AA_RENDERING_MASK = MSAA_RENDERING_BIT | VBAA_RENDERING_BIT;
+
/**
* Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
@@ -142,16 +145,24 @@ public abstract class Region {
protected final AABBox box = new AABBox();
protected Frustum frustum = null;
+ /** 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);
}
+ /** Returns true if given {@code renderModes} has {@link Region#MSAA_RENDERING_BIT} set. */
public static boolean isMSAA(final int renderModes) {
return 0 != (renderModes & Region.MSAA_RENDERING_BIT);
}
+ /** Returns true if given {@code renderModes} has any of {@link Region#AA_RENDERING_MASK} set. */
+ public static boolean isGraphAA(final int renderModes) {
+ return 0 != ( renderModes & Region.AA_RENDERING_MASK );
+ }
+
+ /** Returns true if given {@code renderModes} has any of {@link Region#AA_RENDERING_MASK} set. */
public static boolean isTwoPass(final int renderModes) {
- return 0 != ( renderModes & ( Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT) );
+ return 0 != ( renderModes & Region.AA_RENDERING_MASK );
}
/**
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
index 36cb41654..684e0c78a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
@@ -63,8 +63,7 @@ public class FontViewListener01 implements GLEventListener {
this.startGlyphID = startGlyphID;
this.font = font;
- scene = new Scene();
- scene.setSampleCount(graphSampleCount);
+ scene = new Scene(graphSampleCount);
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
scene.setFrustumCullingEnabled(true);
}