summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java9
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java5
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03b.java5
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java5
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java28
5 files changed, 35 insertions, 17 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 9b2e524e2..173de4db2 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -133,7 +133,6 @@ public class FontView01 {
final Scene scene = new Scene();
scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- scene.addShape(grid);
scene.setFrustumCullingEnabled(true);
final Animator animator = new Animator();
@@ -174,6 +173,7 @@ public class FontView01 {
// - Compute the animation values with DPI
scene.waitUntilDisplayed();
+ grid.validate(reqGLP); // pre-validate to move & scale before display
final AABBox sceneBox = scene.getBounds();
System.err.println("SceneBox "+sceneBox);
final float sxy = sceneBox.getWidth() < sceneBox.getHeight() ? sceneBox.getWidth() : sceneBox.getHeight();
@@ -182,12 +182,11 @@ public class FontView01 {
final float sgxy = sxy / gxy;
grid.scale(sgxy, sgxy, 1f);
grid.moveTo(sceneBox.getMinX(), sceneBox.getMinY(), 0f);
+ scene.addShape(grid); // late add at correct position and size
System.err.println("Grid "+grid);
System.err.println("Grid "+grid.getLayout());
System.err.println("Grid[0] "+grid.getShapes().get(0));
- try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
- if( !options.stayOpen ) {
- window.destroy();
- }
+ scene.screenshot(true, options.renderModes, FontView01.class.getSimpleName());
+ // stay open ..
}
}
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 d49be6bf0..4bfe718d7 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -393,10 +393,7 @@ public class UISceneDemo03 {
final float has_dur_s = ((Clock.currentNanos() / 1000) - t0_us) / 1e6f; // [us]
System.err.printf("Text travel-duration %.3f s, %d chars%n", has_dur_s, originalTexts[txt_idx].length());
if( scene.getScreenshotCount() < 1 + originalTexts.length ) {
- window.invoke(true, (drawable) -> {
- scene.screenshot(drawable.getGL(), options.renderModes, UISceneDemo03.class.getSimpleName());
- return true;
- });
+ scene.screenshot(true, options.renderModes, UISceneDemo03.class.getSimpleName());
}
try { Thread.sleep(2000); } catch (final InterruptedException e1) { }
if( autoSpeed > 0 ) {
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03b.java
index 46201df1e..a3fcbb1af 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03b.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03b.java
@@ -483,10 +483,7 @@ public class UISceneDemo03b {
final float has_dur_s = ((Clock.currentNanos() / 1000) - t0_us) / 1e6f; // [us]
System.err.printf("Text travel-duration %.3f s, %d chars%n", has_dur_s, originalTexts[txt_idx].length());
if( scene.getScreenshotCount() < 1 + originalTexts.length ) {
- window.invoke(true, (drawable) -> {
- scene.screenshot(drawable.getGL(), options.renderModes, UISceneDemo03b.class.getSimpleName());
- return true;
- });
+ scene.screenshot(true, options.renderModes, UISceneDemo03b.class.getSimpleName());
}
try { Thread.sleep(2000); } catch (final InterruptedException e1) { }
if( autoSpeed > 0 ) {
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index 4d132814c..0be93f06c 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -604,10 +604,7 @@ public class UISceneDemo20 implements GLEventListener {
button.addMouseListener(new Shape.MouseGestureAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
- cDrawable.invoke(true, (drawable) -> {
- scene.screenshot(drawable.getGL(), renderModes, UISceneDemo20.class.getSimpleName());
- return true;
- });
+ scene.screenshot(true, renderModes, UISceneDemo20.class.getSimpleName());
} } );
button.addMouseListener(dragZoomRotateListener);
buttonsLeft.addShape(button);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index 7d4e10574..ded1cfa61 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -1069,7 +1069,16 @@ public final class Scene implements Container, GLEventListener {
/**
* Write current read drawable (screen) to a PNG file.
+ *
+ * Best to be {@link GLAutoDrawable#invoke(boolean, GLRunnable) invoked on the display call},
+ * see {@link #screenshot(boolean, int, String)}.
+ *
+ * @param gl current GL object
+ * @param renderModes Graph renderModes
+ * @param prefix filename prefix
+ *
* @see #getScreenshotCount()
+ * @see #screenshot(boolean, int, String)
*/
public void screenshot(final GL gl, final int renderModes, final String prefix) {
final RegionRenderer renderer = getRenderer();
@@ -1085,6 +1094,25 @@ public final class Scene implements Container, GLEventListener {
}
private int shotCount = 0;
+ /**
+ * Write current read drawable (screen) to a PNG file on {@link GLAutoDrawable#invoke(boolean, GLRunnable) on the display call}.
+ *
+ * @param wait if true block until execution of screenshot {@link GLRunnable} is finished, otherwise return immediately w/o waiting
+ * @param renderModes Graph renderModes
+ * @param prefix filename prefix
+ *
+ * @see #getScreenshotCount()
+ * @see #screenshot(GL, int, String)
+ */
+ public void screenshot(final boolean wait, final int renderModes, final String prefix) {
+ if( null != cDrawable ) {
+ cDrawable.invoke(wait, (drawable) -> {
+ screenshot(drawable.getGL(), renderModes, prefix);
+ return true;
+ });
+ }
+ }
+
/** Return the number of {@link #screenshot(GL, int, String)}s being taken. */
public int getScreenshotCount() { return shotCount; }