From 0017e5f6e7e8410d566dcefd9f42ffd0d4fc61e7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 13 Apr 2023 06:29:16 +0200 Subject: GraphUI Scene.screenshot(): Add convenient variant to be executed on-display call. FontView stays open and issues a screenshot. --- src/graphui/classes/com/jogamp/graph/ui/Scene.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/graphui') 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; } -- cgit v1.2.3