From 3131eaaf5272ca3f0011e334eb08c6ba68702a6c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 10 Mar 2023 03:11:24 +0100 Subject: GraphUI: Promote API to JOGL via graphui.jar or within any jogl-all*.jar (WIP) Root package is 'com.jogamp.graph.ui.gl', i.e. a sub-package of Graph denoting UI and OpenGL usage. Implementation will stay small, hence relative files size costs are minimal. Source and build is in parallel to nativewindow, jogl and newt and has a dependency to all of them. The NEWT dependencies are merely the input listener .. --- .../opengl/test/android/NEWTGraphUI1pActivity.java | 3 +- .../opengl/test/android/NEWTGraphUI2pActivity.java | 3 +- .../junit/graph/demos/GPUUISceneGLListener0A.java | 968 -------------------- .../graph/demos/GPUUISceneNewtCanvasAWTDemo.java | 220 ----- .../test/junit/graph/demos/GPUUISceneNewtDemo.java | 197 ----- .../junit/graph/demos/GPUUISceneTextAnim01.java | 350 -------- .../test/junit/graph/demos/UIShapeDemo01.java | 568 ------------ .../test/junit/graph/demos/UITypeDemo01.java | 616 ------------- .../junit/graph/demos/button-pressed-145x53.png | Bin 8603 -> 0 bytes .../junit/graph/demos/button-released-145x53.png | Bin 9429 -> 0 bytes .../test/junit/graph/demos/ui/CrossHair.java | 108 --- .../graph/demos/ui/GLEventListenerButton.java | 151 ---- .../test/junit/graph/demos/ui/ImageSeqButton.java | 63 -- .../opengl/test/junit/graph/demos/ui/Label.java | 130 --- .../opengl/test/junit/graph/demos/ui/Label0.java | 81 -- .../test/junit/graph/demos/ui/LabelButton.java | 179 ---- .../junit/graph/demos/ui/MediaPlayerButton.java | 133 --- .../test/junit/graph/demos/ui/Rectangle.java | 113 --- .../test/junit/graph/demos/ui/RoundButton.java | 131 --- .../junit/graph/demos/ui/SceneUIController.java | 626 ------------- .../junit/graph/demos/ui/TextureSeqButton.java | 79 -- .../opengl/test/junit/graph/demos/ui/UIShape.java | 782 ----------------- .../graph/testshapes/Glyph01UbuntuLight_o.java | 316 ------- .../graph/testshapes/Glyph02UbuntuLight_ae.java | 652 -------------- .../graph/testshapes/Glyph03FreeMonoRegular_M.java | 804 ----------------- .../junit/graph/testshapes/Glyph04FreeSans_0.java | 150 ---- .../testshapes/Glyph05FreeSerifBoldItalic_ae.java | 287 ------ .../graph/ui/demos/GPUUISceneGLListener0A.java | 969 +++++++++++++++++++++ .../ui/demos/GPUUISceneNewtCanvasAWTDemo.java | 220 +++++ .../junit/graph/ui/demos/GPUUISceneNewtDemo.java | 197 +++++ .../junit/graph/ui/demos/GPUUISceneTextAnim01.java | 351 ++++++++ .../test/junit/graph/ui/demos/UIShapeDemo01.java | 569 ++++++++++++ .../test/junit/graph/ui/demos/UITypeDemo01.java | 617 +++++++++++++ .../junit/graph/ui/demos/button-pressed-145x53.png | Bin 0 -> 8603 bytes .../graph/ui/demos/button-released-145x53.png | Bin 0 -> 9429 bytes .../graph/ui/testshapes/Glyph01UbuntuLight_o.java | 316 +++++++ .../graph/ui/testshapes/Glyph02UbuntuLight_ae.java | 652 ++++++++++++++ .../ui/testshapes/Glyph03FreeMonoRegular_M.java | 804 +++++++++++++++++ .../graph/ui/testshapes/Glyph04FreeSans_0.java | 150 ++++ .../testshapes/Glyph05FreeSerifBoldItalic_ae.java | 287 ++++++ 40 files changed, 5134 insertions(+), 7708 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtCanvasAWTDemo.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneTextAnim01.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/button-pressed-145x53.png delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/button-released-145x53.png delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Rectangle.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph01UbuntuLight_o.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph02UbuntuLight_ae.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph03FreeMonoRegular_M.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph04FreeSans_0.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph05FreeSerifBoldItalic_ae.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneGLListener0A.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneNewtCanvasAWTDemo.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneNewtDemo.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneTextAnim01.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UIShapeDemo01.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UITypeDemo01.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-pressed-145x53.png create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-released-145x53.png create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph01UbuntuLight_o.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph02UbuntuLight_ae.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph04FreeSans_0.java create mode 100644 src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph05FreeSerifBoldItalic_ae.java (limited to 'src/test/com') diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index f84c7672b..a272490bf 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -29,14 +29,13 @@ package com.jogamp.opengl.test.android; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.test.junit.graph.ui.demos.GPUUISceneGLListener0A; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; - -import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; import com.jogamp.opengl.util.Animator; import android.os.Bundle; diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index af079f1ac..0acc87690 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.android; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.test.junit.graph.ui.demos.GPUUISceneGLListener0A; import jogamp.newt.driver.android.NewtBaseActivity; @@ -36,8 +37,6 @@ import com.jogamp.graph.curve.Region; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; - -import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; import com.jogamp.opengl.util.Animator; import android.os.Bundle; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java deleted file mode 100644 index 311099169..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ /dev/null @@ -1,968 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLPipelineFactory; -import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.common.net.Uri; -import com.jogamp.common.util.IOUtil; -import com.jogamp.common.util.InterruptSource; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.font.FontScale; -import com.jogamp.graph.geom.SVertex; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.Window; -import com.jogamp.newt.event.InputEvent; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.PinchToZoomGesture; -import com.jogamp.newt.event.GestureHandler.GestureEvent; -import com.jogamp.newt.event.MouseEvent.PointerClass; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.test.junit.graph.FontSet01; -import com.jogamp.opengl.test.junit.graph.demos.ui.GLEventListenerButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.Label; -import com.jogamp.opengl.test.junit.graph.demos.ui.LabelButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.MediaPlayerButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.RoundButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController; -import com.jogamp.opengl.test.junit.graph.demos.ui.ImageSeqButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.av.GLMediaPlayer; -import com.jogamp.opengl.util.av.GLMediaPlayerFactory; -import com.jogamp.opengl.util.texture.ImageSequence; -import com.jogamp.opengl.util.texture.TextureIO; - -public class GPUUISceneGLListener0A implements GLEventListener { - - private boolean debug = false; - private boolean trace = false; - - private final float noAADPIThreshold; - private final SceneUIController sceneUICntrl; - - /** -1 == AUTO, TBD @ init(..) */ - private int renderModes; - - private final Font font; - private final Font fontFPS; - - private final float sceneDist = 3000f; - private final float zNear = 0.1f, zFar = 7000f; - - private final float relTop = 80f/100f; - private final float relMiddle = 22f/100f; - private final float relLeft = 11f/100f; - - /** Proportional Button Size to Window Height, per-vertical-pixels [PVP] */ - private final float buttonYSizePVP = 0.084f; - private final float buttonXSizePVP = 0.084f; // 0.105f; - private final float fontSizePt = 10f; - /** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */ - private final float fontSizeFixedPVP = 0.04f; - /** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */ - private final float fontSizeFpsPVP = 0.03f; - private float dpiV = 96; - - /** - * Default DPI threshold value to disable {@link Region#VBAA_RENDERING_BIT VBAA}: {@value} dpi - * @see #GPUUISceneGLListener0A(float) - * @see #GPUUISceneGLListener0A(float, boolean, boolean) - */ - public static final float DefaultNoAADPIThreshold = 200f; - - private int currentText = 0; - - private String actionText = null; - private Label[] labels = null; - private String[] strings = null; - private final List buttons = new ArrayList(); - private int buttonsLeftCount = 0; - private Label truePtSizeLabel = null; - private Label jogampLabel = null; - private Label fpsLabel = null; - - private GLAutoDrawable cDrawable; - - private final GLReadBufferUtil screenshot; - - private final String jogamp = "JogAmp - Jogl Graph Module Demo"; - private final String truePtSize = fontSizePt+" pt font size label - true scale!"; - - private final String longText = "JOGL: Java™ Binding for the OpenGL® API.\n\n"+ - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec \n"+ - "Ut purus odio, rhoncus sit amet commodo eget, ullamcorper vel\n"+ - "quam iaculis urna cursus ornare. Nullam ut felis a ante ultrices\n"+ - "In hac habitasse platea dictumst. Vivamus et mi a quam lacinia\n"+ - "Morbi quis bibendum nibh. Donec lectus orci, sagittis in consequat\n"+ - "Donec ut dolor et nulla tristique varius. In nulla magna, fermentum\n"+ - "in lorem. Maecenas in ipsum ac justo scelerisque sollicitudin.\n"+ - "\n"+ - "Lyford’s in Texas & L’Anse-aux-Griffons in Québec;\n"+ - "Kwikpak on the Yukon delta, Kvæven in Norway, Kyulu in Kenya, not Rwanda.…\n"+ - "Ytterbium in the periodic table. Are Toussaint L’Ouverture, Wölfflin, Wolfe,\n"+ - "\n"+ - "The quick brown fox jumps over the lazy dog\n"; - - /** - * @param renderModes - */ - public GPUUISceneGLListener0A(final int renderModes) { - this(null, renderModes, false, false); - } - - /** - * @param renderModes - * @param debug - * @param trace - */ - public GPUUISceneGLListener0A(final String fontfilename, final int renderModes, final boolean debug, final boolean trace) { - this(fontfilename, 0f, renderModes, debug, trace); - } - - /** - * @param noAADPIThreshold see {@link #DefaultNoAADPIThreshold} - * @param debug - * @param trace - */ - public GPUUISceneGLListener0A(final String fontfilename, final float noAADPIThreshold, final boolean debug, final boolean trace) { - this(fontfilename, noAADPIThreshold, 0, debug, trace); - } - - private GPUUISceneGLListener0A(final String fontfilename, final float noAADPIThreshold, final int renderModes, final boolean debug, final boolean trace) { - this.noAADPIThreshold = noAADPIThreshold; - this.debug = debug; - this.trace = trace; - - this.renderModes = renderModes; - - try { - if( null == fontfilename ) { - font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf", - FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); - } else { - font = FontFactory.get( new File( fontfilename ) ); - } - System.err.println("Font "+font.getFullFamilyName()); - - fontFPS = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMonoBold.ttf", - FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); - System.err.println("Font FPS "+fontFPS.getFullFamilyName()); - - } catch (final IOException ioe) { - throw new RuntimeException(ioe); - } - { - final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); - // renderer = RegionRenderer.create(rs, null, null); - - sceneUICntrl = new SceneUIController(renderer, sceneDist, zNear, zFar); - // sceneUIController.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? - } - screenshot = new GLReadBufferUtil(false, false); - } - - private void rotateButtons(float[] angdeg) { - angdeg = VectorUtil.scaleVec3(angdeg, angdeg, FloatUtil.PI / 180.0f); - for(int i=0; i "+buttonXSize+" x "+buttonYSize); - final float xStartLeft = 0f; // aligned to left edge w/ space via reshape - final float yStartTop = 0f; // aligned to top edge w/ space via reshape - final float diffX = 1.2f * buttonXSize; - final float diffY = 1.5f * buttonYSize; - - LabelButton button = new LabelButton(SVertex.factory(), renderModes, font, "Next Text", buttonXSize, buttonYSize); - button.setName(BUTTON_NEXTTEXT); - button.translate(xStartLeft,yStartTop-diffY*buttons.size(), 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - if( null != labels[currentText] ) { - labels[currentText].setEnabled(false); - } - currentText = (currentText+1)%labels.length; - if( null != labels[currentText] ) { - labels[currentText].setEnabled(true); - } - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - button = new LabelButton(SVertex.factory(), renderModes, font, "Show FPS", buttonXSize, buttonYSize); - button.setName(BUTTON_FPS); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.setToggleable(true); - button.setToggle(fpsLabel.isEnabled()); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final GLAnimatorControl a = cDrawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - fpsLabel.setEnabled(!fpsLabel.isEnabled()); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - button = new LabelButton(SVertex.factory(), renderModes, font, "V-Sync", buttonXSize, buttonYSize); - button.setName(BUTTON_VSYNC); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.setToggleable(true); - button.setToggle(gl.getSwapInterval()>0); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - cDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - gl.setSwapInterval(gl.getSwapInterval()<=0?1:0); - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - return true; - } - }); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - button = new LabelButton(SVertex.factory(), renderModes, font, "< Tilt >", buttonXSize, buttonYSize); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { - rotateButtons(new float[] { 0f, -5f, 0f}); // left-half pressed - } else { - rotateButtons(new float[] { 0f, 5f, 0f}); // right-half pressed - } - } - @Override - public void mouseWheelMoved(final MouseEvent e) { - rotateButtons(new float[] { 0f, e.getRotation()[1], 0f}); - } } ); - buttons.add(button); - - if( pass2Mode ) { // second column to the left - button = new LabelButton(SVertex.factory(), renderModes, font, "< Samples >", buttonXSize, buttonYSize); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - int sampleCount = sceneUICntrl.getSampleCount(); - if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { - // left-half pressed - sampleCount--; - } else { - // right-half pressed - sampleCount++; - } - sampleCount = sceneUICntrl.setSampleCount(sampleCount); // validated / clipped - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - button = new LabelButton(SVertex.factory(), renderModes, font, "< Quality >", buttonXSize, buttonYSize); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - int quality = shapeEvent.shape.getQuality(); - - if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { - // left-half pressed - if( quality > 0 ) { - quality--; - } - } else { - // right-half pressed - if( quality < Region.MAX_QUALITY ) { - quality++; - } - } - sceneUICntrl.setAllShapesQuality(quality); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - } - - button = new LabelButton(SVertex.factory(), renderModes, font, "Quit", buttonXSize, buttonYSize); - button.setName(BUTTON_QUIT); - button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); - button.setColor(0.7f, 0.0f, 0.0f, 1.0f); - button.setLabelColor(1.2f, 1.2f, 1.2f); - button.setPressedColorMod(1.1f, 0.0f, 0.0f, 1.0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - new InterruptSource.Thread() { - @Override - public void run() { - if( null != cDrawable ) { - final GLAnimatorControl actrl = cDrawable.getAnimator(); - if( null != actrl ) { - actrl.stop(); - } - cDrawable.destroy(); - } - } }.start(); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - // second column to the left - { - final int j = 1; // column - int k = 0; // row - button = new LabelButton(SVertex.factory(), renderModes, font, "Y Flip", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - rotateButtons(new float[] { 0f, 180f, 0f}); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - - k++; - button = new LabelButton(SVertex.factory(), renderModes, font, "X Flip", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - rotateButtons(new float[] { 180f, 0f, 0f}); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - k++; - - button = new LabelButton(SVertex.factory(), renderModes, font, "+", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - // rel position to center - final float dx = shapeEvent.objPos[0] - shapeEvent.shape.getBounds().getCenter()[0] ; - final float dy = shapeEvent.objPos[1] - shapeEvent.shape.getBounds().getCenter()[1] ; - // per-cent position to center (remove dependency on dimension) - final float awdx = Math.abs(dx)/shapeEvent.shape.getBounds().getWidth(); - final float awdy = Math.abs(dy)/shapeEvent.shape.getBounds().getHeight(); - float tx = 0, ty = 0; - if ( awdx > awdy ) { - tx = dx < 0 ? -5 : 5; - } else { - ty = dy < 0 ? -5 : 5; - } - translateButtons(tx, ty, 0f); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - k++; - - button = new LabelButton(SVertex.factory(), renderModes, font, "< Space >", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - final float dx, dy; - if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { - dx=-0.01f; dy=-0.005f; - } else { - dx=0.01f; dy=0.005f; - } - setButtonsSpacing(dx, dy); - } - @Override - public void mouseWheelMoved(final MouseEvent e) { - setButtonsSpacing(e.getRotation()[0]/100f, e.getRotation()[1]/200f); - } } ); - buttons.add(button); - k++; - - button = new LabelButton(SVertex.factory(), renderModes, font, "< Corner >", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - final float dc; - if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { - dc=-0.1f; - } else { - dc=0.1f; - } - setButtonsCorner(dc); - } - @Override - public void mouseWheelMoved(final MouseEvent e) { - setButtonsCorner(e.getRotation()[1]/20f); - } } ); - buttons.add(button); - k++; - - button = new LabelButton(SVertex.factory(), renderModes, font, "Reset", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - resetButtons(); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - k++; - - button = new LabelButton(SVertex.factory(), renderModes, font, "Snapshot", buttonXSize, buttonYSize); - button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); - button.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - cDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - printScreen(drawable.getGL()); - return true; - } - }); - } } ); - button.addMouseListener(dragZoomRotateListener); - buttons.add(button); - k++; - } - - buttonsLeftCount = buttons.size(); - - final float button2XSize = 2f*buttonXSize; - final float button2YSize = 2f*buttonYSize; - final float xStartRight = -button2XSize - 8f; // aligned to right edge via reshape - final int texUnitMediaPlayer, texUnitImageButton, texUnitGLELButton; - { - // works - but not required .. - texUnitMediaPlayer=1; - texUnitImageButton=2; - texUnitGLELButton=3; - } - - if( true ) { - final GLMediaPlayer mPlayer = GLMediaPlayerFactory.createDefault(); - mPlayer.setTextureUnit(texUnitMediaPlayer); - final MediaPlayerButton mPlayerButton = new MediaPlayerButton(sceneUICntrl.getVertexFactory(), renderModes, - button2XSize, button2YSize, mPlayer); - mPlayerButton.setName(BUTTON_MOVIE); - mPlayerButton.setVerbose(true); - mPlayerButton.addDefaultEventListener(); - mPlayerButton.translate(xStartRight, yStartTop - diffY*1, 0f); - mPlayerButton.setToggleable(true); - mPlayerButton.setToggle(false); // toggle == false -> mute audio - mPlayerButton.setToggleOffColorMod(0f, 1f, 0f, 1.0f); - mPlayerButton.addMouseListener(dragZoomRotateListener); - mPlayerButton.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - mPlayer.setAudioVolume( mPlayerButton.isToggleOn() ? 1f : 0f ); - } } ); - buttons.add(mPlayerButton); - try { - final Uri streamLoc = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); - mPlayer.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT); - } catch (final URISyntaxException e1) { - e1.printStackTrace(); - } - } - if( true ) { - final ImageSequence imgSeq = new ImageSequence(texUnitImageButton, true); - final ImageSeqButton imgButton = new ImageSeqButton(sceneUICntrl.getVertexFactory(), renderModes, - button2XSize, button2YSize, imgSeq); - try { - imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-released-145x53.png", TextureIO.PNG); - imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-pressed-145x53.png", TextureIO.PNG); - } catch (final IOException e2) { - e2.printStackTrace(); - } - imgSeq.setManualStepping(true); - imgButton.translate(xStartRight, yStartTop - diffY*2.5f, 0f); - imgButton.addMouseListener(dragZoomRotateListener); - imgButton.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mousePressed(final MouseEvent e) { - imgButton.setCurrentIdx(1); - System.err.println("XXX: "+imgButton); - } - @Override - public void mouseReleased(final MouseEvent e) { - imgButton.setCurrentIdx(0); - } } ); - buttons.add(imgButton); - } - if( true ) { - // Issues w/ OSX and NewtCanvasAWT when rendering / animating - // Probably related to CALayer - FBO - FBO* (of this button) - final GLEventListener glel; - { - final GearsES2 gears = new GearsES2(0); - gears.setVerbose(false); - gears.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } ); - glel = gears; - } - final GLEventListenerButton glelButton = new GLEventListenerButton(sceneUICntrl.getVertexFactory(), renderModes, - button2XSize, button2YSize, - texUnitGLELButton, glel, false /* useAlpha */, - (int)(button2XSize), (int)(button2YSize)); - glelButton.setName(BUTTON_GLEL); - glelButton.setToggleable(true); - glelButton.setToggle(false); // toggle == true -> animation - glelButton.setAnimate(false); - glelButton.translate(xStartRight, yStartTop - diffY*4f, 0f); - glelButton.addMouseListener(dragZoomRotateListener); - glelButton.addMouseListener(new UIShape.MouseGestureAdapter() { - @Override - public void mouseClicked(final MouseEvent e) { - glelButton.setAnimate( glelButton.isToggleOn() ); - } } ); - buttons.add(glelButton); - } - } - - private void initTexts() { - strings = new String[4]; - int i = 0; - - strings[i++] = "- Mouse Scroll Over Object\n"+ - " - General\n"+ - " - Z Translation\n"+ - " - Ctrl: Y-Rotation (Shift: X-Rotation)\n"+ - " - Tilt, Space and Corner\n"+ - " - Their respective action via wheel\n"+ - " (shift = other value)\n"+ - "\n"+ - "- Mouse Drag On Object\n"+ - " - Click on Object and drag mouse\n"+ - " - Current postion in status line at bottom\n"+ - "\n"+ - "- Tilt Button Rotate Whole Button Group"; - - strings[i++] = "abcdefghijklmn\nopqrstuvwxyz\n"+ - "ABCDEFGHIJKL\n"+ - "MNOPQRSTUVWXYZ\n"+ - "0123456789.:,;(*!?/\\\")$%^&-+@~#<>{}[]"; - - strings[i++] = "The quick brown fox jumps over the lazy dog"; - - strings[i++] = longText; - - labels = new Label[i]; - - currentText = strings.length - 1; - } - - - private static final boolean enableOthers = true; - private static final boolean reshape_ui = false; // incomplete: button positioning - - - private void setupUI(final GLAutoDrawable drawable) { - final float pixelSizeFixed = fontSizeFixedPVP * drawable.getSurfaceHeight(); - jogampLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSizeFixed, jogamp); - jogampLabel.addMouseListener(dragZoomRotateListener); - sceneUICntrl.addShape(jogampLabel); - jogampLabel.setEnabled(enableOthers); - - final float pixelSize10Pt = FontScale.toPixels(fontSizePt, dpiV); - System.err.println("10Pt PixelSize: Display "+dpiV+" dpi, fontSize "+fontSizePt+" ppi -> "+pixelSize10Pt+" pixel-size"); - truePtSizeLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSize10Pt, truePtSize); - sceneUICntrl.addShape(truePtSizeLabel); - truePtSizeLabel.setEnabled(enableOthers); - truePtSizeLabel.translate(0, - 1.5f * jogampLabel.getLineHeight(), 0f); - truePtSizeLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); - - /** - * - * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 - * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 - */ - final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); - fpsLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, fontFPS, pixelSizeFPS, "Nothing there yet"); - fpsLabel.addMouseListener(dragZoomRotateListener); - sceneUICntrl.addShape(fpsLabel); - fpsLabel.setEnabled(enableOthers); - fpsLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); - fpsLabel.translate(0f, pixelSizeFPS * (fontFPS.getMetrics().getLineGap() - fontFPS.getMetrics().getDescent()), 0f); - - initButtons(drawable.getGL().getGL2ES2(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); - for(int i=0; i "+pixelSize10Pt+" pixel-size"); - truePtSizeLabel.setPixelSize(pixelSize10Pt); - - /** - * - * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 - * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 - */ - final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); - fpsLabel.setPixelSize(pixelSizeFPS); - - final float buttonXSize = buttonXSizePVP * drawable.getSurfaceWidth(); - // final float buttonYSize = buttonYSizePVP * height; - final float buttonYSize = buttonXSize / 2.5f; - final float button2XSize = 2f*buttonXSize; - final float button2YSize = 2f*buttonYSize; - - for(int i=0; i= noAADPIThreshold; - final String noAAs = noAA ? " >= " : " < "; - System.err.println("AUTO RenderMode: dpi "+dpiV+noAAs+noAADPIThreshold+" -> noAA "+noAA); - renderModes = noAA ? 0 : Region.VBAA_RENDERING_BIT; - } - if(drawable instanceof GLWindow) { - System.err.println("GPUUISceneGLListener0A: init (1)"); - final GLWindow glw = (GLWindow) drawable; - sceneUICntrl.attachInputListenerTo(glw); - } else { - System.err.println("GPUUISceneGLListener0A: init (0)"); - } - cDrawable = drawable; - GL2ES2 gl = drawable.getGL().getGL2ES2(); - if(debug) { - gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2(); - } - if(trace) { - gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2(); - } - System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString()); - System.err.println("VSync Swap Interval: "+gl.getSwapInterval()); - System.err.println("Chosen: "+drawable.getChosenGLCapabilities()); - MSAATool.dump(drawable); - - gl.setSwapInterval(1); - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_BLEND); - - initTexts(); - - sceneUICntrl.init(drawable); - - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - - setupUI(drawable); - } - - @Override - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { - System.err.println("GPUUISceneGLListener0A: reshape"); - - // - // Layout all shapes: Relational move regarding window coordinates - // - final float dw = width - lastWidth; - final float dh = height - lastHeight; - - final float dz = 0f; - final float dyTop = dh * relTop; - final float dxLeft = dw * relLeft; - final float dxRight = dw; - - if( reshape_ui ) { - reshapeUI(drawable); - } - for(int i=0; i 0 ) { - caps.setSampleBuffers(true); - caps.setNumSamples(SceneMSAASamples); - } - System.out.println("Requested: " + caps); - - final int rmode; - if( GraphVBAAMode ) { - rmode = Region.VBAA_RENDERING_BIT; - } else if( GraphMSAAMode ) { - rmode = Region.MSAA_RENDERING_BIT; - } else { - rmode = 0; - } - - final GLWindow window = GLWindow.create(caps); - window.setPosition(x, y); - window.setSize(width, height); - window.setTitle("GraphUI Newt/AWT Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); - window.setSurfaceScale(reqSurfacePixelScale); - final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); - - final GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(fontfilename, GraphAutoMode, DEBUG, TRACE) : - new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); - - window.addGLEventListener(sceneGLListener); - sceneGLListener.attachInputListenerTo(window); - - final Animator animator = new Animator(); - animator.setUpdateFPSFrames(60, System.err); - animator.add(window); - - window.addWindowListener(new WindowAdapter() { - @Override - public void windowDestroyed(final WindowEvent e) { - animator.stop(); - } - }); - - final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(window); - final Frame frame = new Frame("GraphUI Newt/AWT Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); - - setComponentSize(newtCanvasAWT, new Dimension(width, height)); - frame.add(newtCanvasAWT); - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - frame.pack(); - frame.setVisible(true); - } - }); - animator.start(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java deleted file mode 100644 index b4fd16796..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos; - -import com.jogamp.nativewindow.ScalableSurface; -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.common.util.VersionUtil; -import com.jogamp.graph.curve.Region; -import com.jogamp.newt.Display; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; - -public class GPUUISceneNewtDemo { - static final boolean DEBUG = false; - static final boolean TRACE = false; - - static void sleep(final long ms) { - try { - Thread.sleep(ms); - } catch (final InterruptedException ie) {} - } - - public static void main(final String[] args) { - int SceneMSAASamples = 0; - boolean GraphVBAAMode = false; - boolean GraphMSAAMode = false; - float GraphAutoMode = GPUUISceneGLListener0A.DefaultNoAADPIThreshold; - - final float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; - - String fontfilename = null; - - int width = 1280, height = 720; - - boolean forceES2 = false; - boolean forceES3 = false; - boolean forceGL3 = false; - boolean forceGLDef = false; - - if( 0 != args.length ) { - for(int i=0; i 0 ) { - caps.setSampleBuffers(true); - caps.setNumSamples(SceneMSAASamples); - } - System.out.println("Requested: " + caps); - - final int rmode; - if( GraphVBAAMode ) { - rmode = Region.VBAA_RENDERING_BIT; - } else if( GraphMSAAMode ) { - rmode = Region.MSAA_RENDERING_BIT; - } else { - rmode = 0; - } - - final GLWindow window = GLWindow.create(screen, caps); - if( 0 == SceneMSAASamples ) { - window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(true)); - } - window.setSize(width, height); - window.setTitle("GraphUI Newt Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); - window.setSurfaceScale(reqSurfacePixelScale); - // final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); - - final GPUUISceneGLListener0A scene = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(fontfilename, GraphAutoMode, DEBUG, TRACE) : - new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); - - window.addGLEventListener(scene); - scene.attachInputListenerTo(window); - - final Animator animator = new Animator(); - animator.setUpdateFPSFrames(5*60, null); - animator.add(window); - - window.addWindowListener(new WindowAdapter() { - @Override - public void windowDestroyed(final WindowEvent e) { - animator.stop(); - } - }); - - window.setVisible(true); - animator.start(); - - // sleep(3000); - // final UIShape movie = scene.getWidget(GPUUISceneGLListener0A.BUTTON_MOVIE); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneTextAnim01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneTextAnim01.java deleted file mode 100644 index e9bbfc0fb..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneTextAnim01.java +++ /dev/null @@ -1,350 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Locale; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.font.FontScale; -import com.jogamp.graph.geom.SVertex; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.Window; -import com.jogamp.newt.event.GestureHandler.GestureEvent; -import com.jogamp.newt.event.InputEvent; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseEvent.PointerClass; -import com.jogamp.newt.event.PinchToZoomGesture; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLPipelineFactory; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.test.junit.graph.FontSet01; -import com.jogamp.opengl.test.junit.graph.demos.ui.Label; -import com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.opengl.util.GLReadBufferUtil; - -public class GPUUISceneTextAnim01 implements GLEventListener { - - private boolean debug = false; - private boolean trace = false; - - private final float noAADPIThreshold; - private final SceneUIController sceneUICntrl; - - /** -1 == AUTO, TBD @ init(..) */ - private int renderModes; - - private final Font font; - private final Font fontFPS; - - private final float sceneDist = 3000f; - private final float zNear = 0.1f, zFar = 7000f; - - // private final float relTop = 80f/100f; - private final float relMiddle = 22f/100f; - // private final float relLeft = 11f/100f; - - private final float fontSizePt = 10f; - /** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */ - private final float fontSizeFixedPVP = 0.04f; - /** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */ - private final float fontSizeFpsPVP = 0.03f; - private float dpiV = 96; - - /** - * Default DPI threshold value to disable {@link Region#VBAA_RENDERING_BIT VBAA}: {@value} dpi - * @see #GPUUISceneGLListener0A(float) - * @see #GPUUISceneGLListener0A(float, boolean, boolean) - */ - public static final float DefaultNoAADPIThreshold = 200f; - - private String actionText = null; - private Label jogampLabel = null; - private Label fpsLabel = null; - - // private GLAutoDrawable cDrawable; - - private final GLReadBufferUtil screenshot; - - private final String jogamp = "JogAmp - Jogl Graph Module Demo"; - - // private final String longText = "JOGL: Java™ Binding for the OpenGL® API."; - - public GPUUISceneTextAnim01(final String fontfilename, final float noAADPIThreshold, final int renderModes, final boolean debug, final boolean trace) { - this.noAADPIThreshold = noAADPIThreshold; - this.debug = debug; - this.trace = trace; - - this.renderModes = renderModes; - - try { - if( null == fontfilename ) { - font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf", - FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); - } else { - font = FontFactory.get( new File( fontfilename ) ); - } - System.err.println("Font "+font.getFullFamilyName()); - - fontFPS = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMonoBold.ttf", - FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); - System.err.println("Font FPS "+fontFPS.getFullFamilyName()); - - } catch (final IOException ioe) { - throw new RuntimeException(ioe); - } - - { - final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); - // renderer = RegionRenderer.create(rs, null, null); - - sceneUICntrl = new SceneUIController(renderer, sceneDist, zNear, zFar); - // sceneUIController.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? - } - screenshot = new GLReadBufferUtil(false, false); - } - - private void setupUI(final GLAutoDrawable drawable) { - final float pixelSizeFixed = fontSizeFixedPVP * drawable.getSurfaceHeight(); - jogampLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSizeFixed, jogamp); - jogampLabel.addMouseListener(dragZoomRotateListener); - sceneUICntrl.addShape(jogampLabel); - jogampLabel.setEnabled(true); - - final float pixelSize10Pt = FontScale.toPixels(fontSizePt, dpiV); - System.err.println("10Pt PixelSize: Display "+dpiV+" dpi, fontSize "+fontSizePt+" ppi -> "+pixelSize10Pt+" pixel-size"); - - /** - * - * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 - * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 - */ - final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); - fpsLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, fontFPS, pixelSizeFPS, "Nothing there yet"); - fpsLabel.addMouseListener(dragZoomRotateListener); - sceneUICntrl.addShape(fpsLabel); - fpsLabel.setEnabled(true); - fpsLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); - fpsLabel.translate(0f, pixelSizeFPS * (fontFPS.getMetrics().getLineGap() - fontFPS.getMetrics().getDescent()), 0f); - } - - @Override - public void init(final GLAutoDrawable drawable) { - final Object upObj = drawable.getUpstreamWidget(); - if( upObj instanceof Window ) { - final Window upWin = (Window)upObj; - final MonitorDevice monitor = upWin.getMainMonitor(); - final float[] monitorDPI = MonitorDevice.perMMToPerInch( monitor.getPixelsPerMM(new float[2]) ); - final float[] sDPI = MonitorDevice.perMMToPerInch( upWin.getPixelsPerMM(new float[2]) ); - dpiV = sDPI[1]; - System.err.println("Monitor detected: "+monitor); - System.err.println("Monitor dpi: "+monitorDPI[0]+" x "+monitorDPI[1]); - System.err.println("Surface scale: native "+Arrays.toString(upWin.getMaximumSurfaceScale(new float[2]))+", current "+Arrays.toString(upWin.getCurrentSurfaceScale(new float[2]))); - System.err.println("Surface dpi "+sDPI[0]+" x "+sDPI[1]); - } else { - System.err.println("Using default DPI of "+dpiV); - } - if( 0 == renderModes && !FloatUtil.isZero(noAADPIThreshold, FloatUtil.EPSILON)) { - final boolean noAA = dpiV >= noAADPIThreshold; - final String noAAs = noAA ? " >= " : " < "; - System.err.println("AUTO RenderMode: dpi "+dpiV+noAAs+noAADPIThreshold+" -> noAA "+noAA); - renderModes = noAA ? 0 : Region.VBAA_RENDERING_BIT; - } - if(drawable instanceof GLWindow) { - System.err.println("GPUUISceneGLListener0A: init (1)"); - final GLWindow glw = (GLWindow) drawable; - sceneUICntrl.attachInputListenerTo(glw); - } else { - System.err.println("GPUUISceneGLListener0A: init (0)"); - } - // cDrawable = drawable; - GL2ES2 gl = drawable.getGL().getGL2ES2(); - if(debug) { - gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2(); - } - if(trace) { - gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2(); - } - System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString()); - System.err.println("VSync Swap Interval: "+gl.getSwapInterval()); - System.err.println("Chosen: "+drawable.getChosenGLCapabilities()); - MSAATool.dump(drawable); - - gl.setSwapInterval(1); - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_BLEND); - - sceneUICntrl.init(drawable); - - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - - setupUI(drawable); - } - - @Override - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { - System.err.println("GPUUISceneGLListener0A: reshape"); - - // - // Layout all shapes: Relational move regarding window coordinates - // - final float dz = 0f; - - final float dxMiddleAbs = width * relMiddle; - final float dyTopLabelAbs = drawable.getSurfaceHeight() - 2f*jogampLabel.getLineHeight(); - jogampLabel.setTranslate(dxMiddleAbs, dyTopLabelAbs, dz); - fpsLabel.translate(0f, 0f, 0f); - - sceneUICntrl.reshape(drawable, x, y, width, height); - - lastWidth = width; - lastHeight = height; - } - float lastWidth = 0f, lastHeight = 0f; - - @Override - public void dispose(final GLAutoDrawable drawable) { - System.err.println("GPUUISceneGLListener0A: dispose"); - - sceneUICntrl.dispose(drawable); // disposes all registered UIShapes - - final GL2ES2 gl = drawable.getGL().getGL2ES2(); - screenshot.dispose(gl); - } - - private int shotCount = 0; - - public void printScreen(final GL gl) { - final RegionRenderer renderer = sceneUICntrl.getRenderer(); - final String modeS = Region.getRenderModeString(jogampLabel.getRenderModes()); - final String filename = String.format((Locale)null, "GraphUIDemo-shot%03d-%03dx%03d-S_%s_%02d.png", - shotCount++, renderer.getWidth(), renderer.getHeight(), - modeS, sceneUICntrl.getSampleCount()); - gl.glFinish(); // just make sure rendering finished .. - if(screenshot.readPixels(gl, false)) { - screenshot.write(new File(filename)); - System.err.println("Wrote: "+filename); - } - } - - @Override - public void display(final GLAutoDrawable drawable) { - if( fpsLabel.isEnabled() ) { - final String text; - if( null == actionText ) { - text = sceneUICntrl.getStatusText(drawable, renderModes, fpsLabel.getQuality(), dpiV); - } else if( null != drawable.getAnimator() ) { - text = SceneUIController.getStatusText(drawable.getAnimator())+", "+actionText; - } else { - text = actionText; - } - if( fpsLabel.setText(text) ) { // marks dirty only if text differs. - System.err.println(text); - } - } - sceneUICntrl.display(drawable); - } - - public void attachInputListenerTo(final GLWindow window) { - sceneUICntrl.attachInputListenerTo(window); - } - - public void detachInputListenerFrom(final GLWindow window) { - sceneUICntrl.detachInputListenerFrom(window); - } - - /** - * We can share this instance w/ all UI elements, - * since only mouse action / gesture is complete for a single one (press, drag, released and click). - */ - private final UIShape.MouseGestureAdapter dragZoomRotateListener = new UIShape.MouseGestureAdapter() { - @Override - public void mouseReleased(final MouseEvent e) { - actionText = null; - } - - @Override - public void mouseDragged(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - if( e.getPointerCount() == 1 ) { - final float[] tx = shapeEvent.shape.getTranslate(); - actionText = String.format((Locale)null, "Pos %6.2f / %6.2f / %6.2f", tx[0], tx[1], tx[2]); - } - } - - @Override - public void mouseWheelMoved(final MouseEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - final boolean isOnscreen = PointerClass.Onscreen == e.getPointerType(0).getPointerClass(); - if( 0 == ( ~InputEvent.BUTTONALL_MASK & e.getModifiers() ) && !isOnscreen ) { - // offscreen vertical mouse wheel zoom - final float tz = 100f*e.getRotation()[1]; // vertical: wheel - System.err.println("Rotate.Zoom.W: "+tz); - shapeEvent.shape.translate(0f, 0f, tz); - } else if( isOnscreen || e.isControlDown() ) { - final float[] rot = VectorUtil.scaleVec3(e.getRotation(), e.getRotation(), FloatUtil.PI / 180.0f); - if( isOnscreen ) { - System.err.println("XXX: "+e); - // swap axis for onscreen rotation matching natural feel - final float tmp = rot[0]; rot[0] = rot[1]; rot[1] = tmp; - VectorUtil.scaleVec3(rot, rot, 2f); - } - shapeEvent.shape.getRotation().rotateByEuler( rot ); - } - } - @Override - public void gestureDetected(final GestureEvent e) { - final UIShape.UIShapeEvent shapeEvent = (UIShape.UIShapeEvent) e.getAttachment(); - if( e instanceof PinchToZoomGesture.ZoomEvent ) { - final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) e; - final float tz = ze.getDelta() * ze.getScale(); - System.err.println("Rotate.Zoom.G: "+tz); - shapeEvent.shape.translate(0f, 0f, tz); - } - } }; -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java deleted file mode 100644 index 656345694..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java +++ /dev/null @@ -1,568 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos; - -import java.io.File; -import java.io.IOException; - -import com.jogamp.opengl.FPSCounter; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLException; -import com.jogamp.opengl.GLPipelineFactory; -import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.test.junit.graph.demos.ui.CrossHair; -import com.jogamp.opengl.test.junit.graph.demos.ui.LabelButton; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.common.util.InterruptSource; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.curve.opengl.TextRegionUtil; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.geom.SVertex; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.newt.Window; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; - -/** - * Basic UIShape and Type Rendering demo. - * - * Action Keys: - * - 1/2: zoom in/out - * - 4/5: increase/decrease shape/text spacing - * - 6/7: increase/decrease corner size - * - 0/9: rotate - * - v: toggle v-sync - * - s: screenshot - */ -public class UIShapeDemo01 implements GLEventListener { - static final boolean DEBUG = false; - static final boolean TRACE = false; - - public static void main(final String[] args) throws IOException { - Font font = null; - if( 0 != args.length ) { - for(int i=0; i obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]); - } - } - glWinX = drawable.getSurfaceWidth(); - glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) { - if( once ) { - System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]); - } - } - full_width_o = objCoord1[0] - objCoord0[0]; - } - final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); - final float full_width_s = full_width_o / txt_box_em.getWidth(); - final float txt_scale = full_width_s/2f; - pmv.glPushMatrix(); - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); - final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new float[] { 0, 0, 0, 1 }, sampleCount, tempT1, tempT2); - if( once ) { - final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); - System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); - System.err.println("XXX: txt_box_em "+txt_box_em); - System.err.println("XXX: txt_box_e2 "+txt_box_em2); - System.err.println("XXX: txt_box_rg "+txt_box_r); - once = false; - } - pmv.glPopMatrix(); - } - renderer.enable(gl, false); - } - static boolean once = true; - - @Override - public void dispose(final GLAutoDrawable drawable) { - final GL2ES2 gl = drawable.getGL().getGL2ES2(); - button.destroy(gl, getRegionRenderer()); - crossHair.destroy(gl, getRegionRenderer()); - - autoDrawable = null; - screenshot.dispose(gl); - rRenderer.destroy(gl); - } - - /** Attach the input listener to the window */ - public void attachInputListenerTo(final GLWindow window) { - if ( null == keyAction ) { - keyAction = new KeyAction(); - window.addKeyListener(keyAction); - } - if ( null == mouseAction ) { - mouseAction = new MouseAction(); - window.addMouseListener(mouseAction); - } - } - - public void detachFrom(final GLWindow window) { - if ( null == keyAction ) { - return; - } - if ( null == mouseAction ) { - return; - } - window.removeGLEventListener(this); - window.removeKeyListener(keyAction); - window.removeMouseListener(mouseAction); - } - - public void printScreen(final GLAutoDrawable drawable, final String dir, final String tech, final String objName, final boolean exportAlpha) throws GLException, IOException { - final String sw = String.format("-%03dx%03d-Z%04d-T%04d-%s", drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), (int)Math.abs(zTran), 0, objName); - - final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), false)) { - screenshot.write(new File(filename)); - } - } - - int screenshot_num = 0; - - public void setIgnoreInput(final boolean v) { - ignoreInput = v; - } - public boolean getIgnoreInput() { - return ignoreInput; - } - - public class MouseAction implements MouseListener{ - - @Override - public void mouseClicked(final MouseEvent e) { - - } - - @Override - public void mouseEntered(final MouseEvent e) { - } - - @Override - public void mouseExited(final MouseEvent e) { - } - - @Override - public void mousePressed(final MouseEvent e) { - autoDrawable.invoke(false, new GLRunnable() { // avoid data-race - @Override - public boolean run(final GLAutoDrawable drawable) { - System.err.println("\n\nMouse: "+e); - - final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); - - // flip to GL window coordinates, origin bottom-left - final int[] viewport = renderer.getViewport(new int[4]); - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - - { - pmv.glPushMatrix(); - button.setTransform(pmv); - - final float[] objPos = new float[3]; - System.err.println("\n\nButton: "+button); - button.winToObjCoord(renderer, glWinX, glWinY, objPos); - System.err.println("Button: Click: Win "+glWinX+"/"+glWinY+" -> Obj "+objPos[0]+"/"+objPos[1]+"/"+objPos[1]); - - final int[] surfaceSize = new int[2]; - button.getSurfaceSize(renderer, surfaceSize); - System.err.println("Button: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - - pmv.glPopMatrix(); - } - { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); - - final float[] objPosC = crossHair.getBounds().getCenter(); - final int[] objWinPos = new int[2]; - System.err.println("\n\nCrossHair: "+crossHair); - if( crossHair.objToWinCoord(renderer, objPosC, objWinPos) ) { - System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]); - } - - final float[] objPos2 = new float[3]; - crossHair.winToObjCoord(renderer, objWinPos[0], objWinPos[1], objPos2); - System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]); - - final float[] winObjPos = new float[3]; - if( crossHair.winToObjCoord(renderer, glWinX, glWinY, winObjPos) ) { - // final float[] translate = crossHair.getTranslate(); - // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; - final float dx = winObjPos[0] - objPosC[0]; - final float dy = winObjPos[1] - objPosC[1]; - // final float dz = winObjPos[2] - objPosT[2]; - if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) { - System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); - crossHair.translate(dx, dy, 0f); - } else { - System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); - } - } - - final int[] surfaceSize = new int[2]; - crossHair.getSurfaceSize(renderer, surfaceSize); - System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - - pmv.glPopMatrix(); - } - return true; - } } ); - - } - - @Override - public void mouseReleased(final MouseEvent e) { - } - - @Override - public void mouseMoved(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseDragged(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseWheelMoved(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - } - - public class KeyAction implements KeyListener { - @Override - public void keyPressed(final KeyEvent arg0) { - if(ignoreInput) { - return; - } - - if(arg0.getKeyCode() == KeyEvent.VK_1){ - button.translate(0f, 0f, -zTran/10f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_2){ - button.translate(0f, 0f, zTran/10f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_UP){ - button.translate(0f, button.getHeight()/10f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){ - button.translate(0f, -button.getHeight()/10f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){ - button.translate(-button.getWidth()/10f, 0f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){ - button.translate(button.getWidth()/10f, 0f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_4){ - button.setSpacing(button.getSpacingX()-0.01f, button.getSpacingY()-0.005f); - System.err.println("Button Spacing: " + button.getSpacingX()); - } - else if(arg0.getKeyCode() == KeyEvent.VK_5){ - button.setSpacing(button.getSpacingX()+0.01f, button.getSpacingY()+0.005f); - System.err.println("Button Spacing: " + button.getSpacingX()); - } - else if(arg0.getKeyCode() == KeyEvent.VK_6){ - button.setCorner(button.getCorner()-0.01f); - System.err.println("Button Corner: " + button.getCorner()); - } - else if(arg0.getKeyCode() == KeyEvent.VK_7){ - button.setCorner(button.getCorner()+0.01f); - System.err.println("Button Corner: " + button.getCorner()); - } - else if(arg0.getKeyCode() == KeyEvent.VK_0){ - // rotate(1); - } - else if(arg0.getKeyCode() == KeyEvent.VK_9){ - // rotate(-1); - } - else if(arg0.getKeyCode() == KeyEvent.VK_V) { - if(null != autoDrawable) { - autoDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - final int _i = gl.getSwapInterval(); - final int i; - switch(_i) { - case 0: i = 1; break; - case 1: i = -1; break; - case -1: i = 0; break; - default: i = 1; break; - } - gl.setSwapInterval(i); - - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - if(drawable instanceof FPSCounter) { - ((FPSCounter)drawable).resetFPSCounter(); - } - System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval()); - return true; - } - }); - } - } - else if(arg0.getKeyCode() == KeyEvent.VK_S){ - if(null != autoDrawable) { - autoDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - try { - final String type = Region.getRenderModeString(renderModes); - printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false); - screenshot_num++; - } catch (final GLException e) { - e.printStackTrace(); - } catch (final IOException e) { - e.printStackTrace(); - } - return true; - } - }); - } - } - } - @Override - public void keyReleased(final KeyEvent arg0) {} - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java deleted file mode 100644 index 212a0aff0..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java +++ /dev/null @@ -1,616 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos; - -import java.io.File; -import java.io.IOException; - -import com.jogamp.opengl.FPSCounter; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLException; -import com.jogamp.opengl.GLPipelineFactory; -import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.test.junit.graph.demos.ui.CrossHair; -import com.jogamp.opengl.test.junit.graph.demos.ui.Rectangle; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.opengl.test.junit.graph.testshapes.Glyph03FreeMonoRegular_M; -import com.jogamp.opengl.test.junit.graph.testshapes.Glyph04FreeSans_0; -import com.jogamp.opengl.test.junit.graph.testshapes.Glyph05FreeSerifBoldItalic_ae; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.common.util.InterruptSource; -import com.jogamp.graph.curve.Region; -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.curve.opengl.TextRegionUtil; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.font.FontSet; -import com.jogamp.graph.font.Font.Glyph; -import com.jogamp.graph.geom.SVertex; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.newt.Window; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.PMVMatrix; - -/** - * Basic UIShape and Type Rendering demo. - * - * Action Keys: - * - 1/2: zoom in/out - * - 4/5: increase/decrease shape/text spacing - * - 6/7: increase/decrease corner size - * - 0/9: rotate - * - v: toggle v-sync - * - s: screenshot - */ -public class UITypeDemo01 implements GLEventListener { - static final boolean DEBUG = false; - static final boolean TRACE = false; - - public static void main(final String[] args) throws IOException { - Font font = null; - String text = "Hello Origin."; - int glyph_id = Glyph.ID_UNKNOWN; - if( 0 != args.length ) { - for(int i=0; i obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]); - } - } - glWinX = drawable.getSurfaceWidth(); - glWinY = drawable.getSurfaceHeight(); - if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) { - if( once ) { - System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]); - } - } - full_width_o = objCoord1[0] - objCoord0[0]; - full_height_o = objCoord1[1] - objCoord0[1]; - } - pmv.glPushMatrix(); - - final Font.Glyph glyph; - if( Glyph.ID_UNKNOWN < glyph_id ) { - glyph = font.getGlyph(glyph_id); - if( once ) { - System.err.println("glyph_id "+glyph_id+": "+glyph); - } - } else { - glyph = null; - } - if( null != glyph && glyph.getID() != Glyph.ID_UNKNOWN ) { - final AABBox txt_box_em = glyph.getBBox(); - final float full_width_s = full_width_o / txt_box_em.getWidth(); - final float full_height_s = full_height_o / txt_box_em.getHeight(); - final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); - if( null != glyph.getShape() ) { - final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); - region.addOutlineShape(glyph.getShape(), null, region.hasColorChannel() ? fg_color : null); - region.draw(gl, renderer, sampleCount); - region.destroy(gl); - } - if( once ) { - final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); - System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); - System.err.println("XXX: full_height: "+full_height_o+" / "+txt_box_em.getHeight()+" -> "+full_height_s); - System.err.println("XXX: txt_scale: "+txt_scale); - System.err.println("XXX: txt_box_em "+txt_box_em); - System.err.println("XXX: txt_box_e2 "+txt_box_em2); - } - } else if( Glyph.ID_UNKNOWN == glyph_id ) { - final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); - final float full_width_s = full_width_o / txt_box_em.getWidth(); - final float full_height_s = full_height_o / txt_box_em.getHeight(); - final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; - pmv.glScalef(txt_scale, txt_scale, 1f); - pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); - final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount, tempT1, tempT2); - if( once ) { - final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); - System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); - System.err.println("XXX: full_height: "+full_height_o+" / "+txt_box_em.getHeight()+" -> "+full_height_s); - System.err.println("XXX: txt_scale: "+txt_scale); - System.err.println("XXX: txt_box_em "+txt_box_em); - System.err.println("XXX: txt_box_e2 "+txt_box_em2); - System.err.println("XXX: txt_box_rg "+txt_box_r); - } - } - pmv.glPopMatrix(); - if( once ) { - try { - printScreen(drawable); - } catch (GLException | IOException e) { - e.printStackTrace(); - } - } - once = false; - } - renderer.enable(gl, false); - } - private boolean once = true; - - @Override - public void dispose(final GLAutoDrawable drawable) { - final GL2ES2 gl = drawable.getGL().getGL2ES2(); - crossHair.destroy(gl, getRegionRenderer()); - testObj.destroy(gl, getRegionRenderer()); - - autoDrawable = null; - screenshot.dispose(gl); - rRenderer.destroy(gl); - } - - /** Attach the input listener to the window */ - public void attachInputListenerTo(final GLWindow window) { - if ( null == keyAction ) { - keyAction = new KeyAction(); - window.addKeyListener(keyAction); - } - if ( null == mouseAction ) { - mouseAction = new MouseAction(); - window.addMouseListener(mouseAction); - } - } - - public void detachFrom(final GLWindow window) { - if ( null == keyAction ) { - return; - } - if ( null == mouseAction ) { - return; - } - window.removeGLEventListener(this); - window.removeKeyListener(keyAction); - window.removeMouseListener(mouseAction); - } - - public void printScreen(final GLAutoDrawable drawable) throws GLException, IOException { - final String dir = "./"; - final String tech="demo-"+Region.getRenderModeString(renderModes); - final String objName = "snap"+screenshot_num; - { - final String sw = String.format("-%03dx%03d-Z%04d-T%04d-%s", drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), (int)Math.abs(zTran), 0, objName); - - final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), false)) { - screenshot.write(new File(filename)); - } - } - screenshot_num++; - } - int screenshot_num = 0; - - public void setIgnoreInput(final boolean v) { - ignoreInput = v; - } - public boolean getIgnoreInput() { - return ignoreInput; - } - - public class MouseAction implements MouseListener{ - - @Override - public void mouseClicked(final MouseEvent e) { - - } - - @Override - public void mouseEntered(final MouseEvent e) { - } - - @Override - public void mouseExited(final MouseEvent e) { - } - - @Override - public void mousePressed(final MouseEvent e) { - autoDrawable.invoke(false, new GLRunnable() { // avoid data-race - @Override - public boolean run(final GLAutoDrawable drawable) { - System.err.println("\n\nMouse: "+e); - - final RegionRenderer renderer = getRegionRenderer(); - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(xTran, yTran, zTran); - - // flip to GL window coordinates, origin bottom-left - final int[] viewport = renderer.getViewport(new int[4]); - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - - { - pmv.glPushMatrix(); - crossHair.setTransform(pmv); - - final float[] objPosC = crossHair.getBounds().getCenter(); - final int[] objWinPos = new int[2]; - System.err.println("\n\nCrossHair: "+crossHair); - if( crossHair.objToWinCoord(renderer, objPosC, objWinPos) ) { - System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]); - } - - final float[] objPos2 = new float[3]; - crossHair.winToObjCoord(renderer, objWinPos[0], objWinPos[1], objPos2); - System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]); - - final float[] winObjPos = new float[3]; - if( crossHair.winToObjCoord(renderer, glWinX, glWinY, winObjPos) ) { - // final float[] translate = crossHair.getTranslate(); - // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; - final float dx = winObjPos[0] - objPosC[0]; - final float dy = winObjPos[1] - objPosC[1]; - // final float dz = winObjPos[2] - objPosT[2]; - if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) { - System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); - crossHair.translate(dx, dy, 0f); - } else { - System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); - } - } - - final int[] surfaceSize = new int[2]; - crossHair.getSurfaceSize(renderer, surfaceSize); - System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); - - pmv.glPopMatrix(); - } - return true; - } } ); - - } - - @Override - public void mouseReleased(final MouseEvent e) { - } - - @Override - public void mouseMoved(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseDragged(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseWheelMoved(final MouseEvent e) { - // TODO Auto-generated method stub - - } - - } - - public class KeyAction implements KeyListener { - @Override - public void keyPressed(final KeyEvent arg0) { - if(ignoreInput) { - return; - } - - if(arg0.getKeyCode() == KeyEvent.VK_1){ - crossHair.translate(0f, 0f, -zTran/10f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_2){ - crossHair.translate(0f, 0f, zTran/10f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_UP){ - crossHair.translate(0f, crossHair.getHeight()/10f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){ - crossHair.translate(0f, -crossHair.getHeight()/10f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){ - crossHair.translate(-crossHair.getWidth()/10f, 0f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){ - crossHair.translate(crossHair.getWidth()/10f, 0f, 0f); - } - else if(arg0.getKeyCode() == KeyEvent.VK_0){ - // rotate(1); - } - else if(arg0.getKeyCode() == KeyEvent.VK_9){ - // rotate(-1); - } - else if(arg0.getKeyCode() == KeyEvent.VK_V) { - if(null != autoDrawable) { - autoDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - final int _i = gl.getSwapInterval(); - final int i; - switch(_i) { - case 0: i = 1; break; - case 1: i = -1; break; - case -1: i = 0; break; - default: i = 1; break; - } - gl.setSwapInterval(i); - - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - if(drawable instanceof FPSCounter) { - ((FPSCounter)drawable).resetFPSCounter(); - } - System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval()); - return true; - } - }); - } - } - else if(arg0.getKeyCode() == KeyEvent.VK_S){ - if(null != autoDrawable) { - autoDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - try { - printScreen(drawable); - } catch (final GLException e) { - e.printStackTrace(); - } catch (final IOException e) { - e.printStackTrace(); - } - return true; - } - }); - } - } - } - @Override - public void keyReleased(final KeyEvent arg0) {} - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/button-pressed-145x53.png b/src/test/com/jogamp/opengl/test/junit/graph/demos/button-pressed-145x53.png deleted file mode 100644 index 1eba3a09e..000000000 Binary files a/src/test/com/jogamp/opengl/test/junit/graph/demos/button-pressed-145x53.png and /dev/null differ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/button-released-145x53.png b/src/test/com/jogamp/opengl/test/junit/graph/demos/button-released-145x53.png deleted file mode 100644 index fe223c6d3..000000000 Binary files a/src/test/com/jogamp/opengl/test/junit/graph/demos/button-released-145x53.png and /dev/null differ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java deleted file mode 100644 index 0c8595c70..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; - -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent Crosshair - */ -public class CrossHair extends UIShape { - private float width, height, lineWidth; - - public CrossHair(final Factory factory, final int renderModes, final float width, final float height, final float linewidth) { - super(factory, renderModes); - this.width = width; - this.height = height; - this.lineWidth = linewidth; - } - - public final float getWidth() { return width; } - public final float getHeight() { return height; } - public final float getLineWidth() { return lineWidth; } - - public void setDimension(final float width, final float height, final float lineWidth) { - this.width = width; - this.height = height; - this.lineWidth = lineWidth; - markShapeDirty(); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - final float lwh = lineWidth/2f; - - final float tw = getWidth(); - final float th = getHeight(); - final float twh = tw/2f; - final float thh = th/2f; - - final float ctrX = 0f, ctrY = 0f; - final float ctrZ = 0f; - - // middle vertical (CCW!) - shape.moveTo(ctrX-lwh, ctrY-thh, ctrZ); - shape.lineTo(ctrX+lwh, ctrY-thh, ctrZ); - shape.lineTo(ctrX+lwh, ctrY+thh, ctrZ); - shape.lineTo(ctrX-lwh, ctrY+thh, ctrZ); - shape.closePath(); - - // middle horizontal (CCW!) - shape.moveTo(ctrX-twh, ctrY-lwh, ctrZ); - shape.lineTo(ctrX+twh, ctrY-lwh, ctrZ); - shape.lineTo(ctrX+twh, ctrY+lwh, ctrZ); - shape.lineTo(ctrX-twh, ctrY+lwh, ctrZ); - shape.closePath(); - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java deleted file mode 100644 index 9e6c131ed..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright 2014 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLCapabilitiesImmutable; -import com.jogamp.opengl.GLContext; -import com.jogamp.opengl.GLDrawable; -import com.jogamp.opengl.GLDrawableFactory; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLOffscreenAutoDrawable; - -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.FBObject; -import com.jogamp.opengl.util.texture.ImageSequence; -import com.jogamp.opengl.util.texture.Texture; - -/** - * GPU based resolution independent Button impl, - * rendering {@link GLEventListener} content via FBO as an {@link ImageSequence}. - */ -public class GLEventListenerButton extends TextureSeqButton { - private final GLEventListener glel; - private final boolean useAlpha; - private volatile int fboWidth = 200; - private volatile int fboHeight = 200; - private volatile GLOffscreenAutoDrawable.FBO fboGLAD = null; - private boolean animateGLEL = false; - - public GLEventListenerButton(final Factory factory, final int renderModes, - final float width, final float height, final int textureUnit, - final GLEventListener glel, final boolean useAlpha, final int fboWidth, final int fboHeight) { - super(factory, renderModes, width, height, new ImageSequence(textureUnit, true)); - this.glel = glel; - this.useAlpha = useAlpha; - - setColor(0.95f, 0.95f, 0.95f, 1.0f); - setPressedColorMod(1f, 1f, 1f, 0.9f); - setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); - setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); - - this.fboWidth = fboWidth; - this.fboHeight = fboHeight; - } - - public final void setAnimate(final boolean v) { animateGLEL = v; } - public final boolean getAnimate() { return animateGLEL; } - - public final void setFBOSize(final int fboWidth, final int fboHeight) { - this.fboWidth = fboWidth; - this.fboHeight = fboHeight; - } - - public final GLOffscreenAutoDrawable.FBO getFBOAutoDrawable() { return fboGLAD; } - - @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - final int[/*2*/] surfaceSize = new int[2]; - final boolean got_sz = getSurfaceSize(renderer, surfaceSize); - - if( null == fboGLAD ) { - final ImageSequence imgSeq = (ImageSequence)texSeq; - - final GLContext ctx = gl.getContext(); - final GLDrawable drawable = ctx.getGLDrawable(); - final GLCapabilitiesImmutable reqCaps = drawable.getRequestedGLCapabilities(); - final GLCapabilities caps = (GLCapabilities) reqCaps.cloneMutable(); - caps.setFBO(true); - caps.setDoubleBuffered(false); - if( !useAlpha ) { - caps.setAlphaBits(0); - } - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - - fboGLAD = (GLOffscreenAutoDrawable.FBO) factory.createOffscreenAutoDrawable( - drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(), - caps, null, fboWidth, fboHeight); - fboWidth = 0; - fboHeight = 0; - fboGLAD.setSharedContext(ctx); - fboGLAD.setTextureUnit(imgSeq.getTextureUnit()); - fboGLAD.addGLEventListener(glel); - fboGLAD.display(); // 1st init! - - final FBObject.TextureAttachment texA01 = fboGLAD.getColorbuffer(GL.GL_FRONT).getTextureAttachment(); - final Texture tex = new Texture(texA01.getName(), imgSeq.getTextureTarget(), - fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), - false /* mustFlipVertically */); - imgSeq.addFrame(gl, tex); - markStateDirty(); - } else if( 0 != fboWidth*fboHeight ) { - fboGLAD.setSurfaceSize(fboWidth, fboHeight); - fboWidth = 0; - fboHeight = 0; - markStateDirty(); - } else if( got_sz && ( fboGLAD.getSurfaceWidth() != surfaceSize[0] || fboGLAD.getSurfaceHeight() != surfaceSize[1] ) ) { - // System.err.println("XXX FBO setSurfaceSize "+fboGLAD.getSurfaceWidth()+" x "+fboGLAD.getSurfaceHeight()+" -> "+surfaceSize[0]+" x "+surfaceSize[1]); - final ImageSequence imgSeq = (ImageSequence)texSeq; - - fboGLAD.setSurfaceSize(surfaceSize[0], surfaceSize[1]); - fboGLAD.display(); // re-init! - - imgSeq.destroy(gl); - final FBObject.TextureAttachment texA01 = fboGLAD.getColorbuffer(GL.GL_FRONT).getTextureAttachment(); - final Texture tex = new Texture(texA01.getName(), imgSeq.getTextureTarget(), - fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), - false /* mustFlipVertically */); - imgSeq.addFrame(gl, tex); - fboWidth = 0; - fboHeight = 0; - markStateDirty(); - } else if( animateGLEL ) { - fboGLAD.display(); - } - - super.drawShape(gl, renderer, sampleCount); - - if( animateGLEL ) { - markStateDirty(); // keep on going - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java deleted file mode 100644 index 8556007d3..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/ImageSeqButton.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2014 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; - -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.util.texture.ImageSequence; - -/** - * GPU based resolution independent {@link ImageSequence} Button impl - */ -public class ImageSeqButton extends TextureSeqButton { - - public ImageSeqButton(final Factory factory, final int renderModes, - final float width, final float height, final ImageSequence texSeq) { - super(factory, renderModes, width, height, texSeq); - setColor(0.95f, 0.95f, 0.95f, 1.0f); - setPressedColorMod(1f, 1f, 1f, 0.9f); - setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); - setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); - } - - public final void setCurrentIdx(final int idx) { - ((ImageSequence)texSeq).setCurrentIdx(idx); - markStateDirty(); - } - - @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - super.drawShape(gl, renderer, sampleCount); - if( !((ImageSequence)texSeq).getManualStepping() ) { - markStateDirty(); // keep on going - } - }; -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java deleted file mode 100644 index d64b9a731..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.graph.geom.plane.AffineTransform; - -public class Label extends UIShape { - protected Font font; - protected float pixelSize; - protected String text; - - public Label(final Factory factory, final int renderModes, final Font font, final float pixelSize, final String text) { - super(factory, renderModes); - this.font = font; - this.pixelSize = pixelSize; - this.text = text; - } - - public String getText() { - return text; - } - - /** - * Returns true if text has been updated, false if unchanged. - * @param text the text to be set. - */ - public boolean setText(final String text) { - if( !this.text.equals(text) ) { - this.text = text; - markShapeDirty(); - return true; - } else { - return false; - } - } - - public Font getFont() { - return font; - } - - /** - * Returns true if font has been updated, false if unchanged. - * @param font the font to be set. - */ - public boolean setFont(final Font font) { - if( !this.font.equals(font) ) { - this.font = font; - markShapeDirty(); - return true; - } else { - return false; - } - } - - public float getPixelSize() { - return pixelSize; - } - - public float getLineHeight() { - return pixelSize * font.getLineHeight(); - } - - public void setPixelSize(final float pixelSize) { - this.pixelSize = pixelSize; - markShapeDirty(); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - private final OutlineShape.Visitor shapeVisitor = new OutlineShape.Visitor() { - @Override - public void visit(final OutlineShape shape, final AffineTransform t) { - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, t, rgbaColor); - } - }; - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - tempT1.setToScale(pixelSize, pixelSize); - final AABBox fbox = font.processString(shapeVisitor, tempT1, text, tempT2, tempT3); - final float[] ctr = box.getCenter(); - setRotationOrigin( ctr[0], ctr[1], ctr[2]); - box.resize(fbox); - } - - @Override - public String getSubString() { - final int m = Math.min(text.length(), 8); - return super.getSubString()+", psize " + pixelSize + ", '" + text.substring(0, m)+"'"; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java deleted file mode 100644 index 7d8f34261..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.TextRegionUtil; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.opengl.math.geom.AABBox; - -public class Label0 { - protected Font font; - protected String text; - protected final float[] rgbaColor; - - public Label0(final Font font, final String text, final float[] rgbaColor) { - this.font = font; - this.text = text; - this.rgbaColor = rgbaColor; - } - - public final String getText() { return text; } - - public final float[] getColor() { return rgbaColor; } - - public final void setColor(final float r, final float g, final float b, final float a) { - this.rgbaColor[0] = r; - this.rgbaColor[1] = g; - this.rgbaColor[2] = b; - this.rgbaColor[3] = a; - } - - public final void setText(final String text) { - this.text = text; - } - - public final Font getFont() { return font; } - - public final void setFont(final Font font) { - this.font = font; - } - - public final AABBox addShapeToRegion(final float scale, final Region region, final AffineTransform tLeft, - final AffineTransform tmp1, final AffineTransform tmp2, final AffineTransform tmp3) - { - tmp1.setTransform(tLeft); - tmp1.scale(scale, scale, tmp2); - return TextRegionUtil.addStringToRegion(region, font, tmp1, text, rgbaColor, tmp2, tmp3); - } - - @Override - public final String toString(){ - final int m = Math.min(text.length(), 8); - return "Label0 ['" + text.substring(0, m) + "']"; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java deleted file mode 100644 index 8a357c8a6..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; - -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.font.Font; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.math.geom.AABBox; - -/** - * GPU based resolution independent Button impl - */ -public class LabelButton extends RoundButton { - /** {@value} */ - public static final float DEFAULT_SPACING_X = 0.12f; - /** {@value} */ - public static final float DEFAULT_SPACING_Y = 0.42f; - - private static final float DEFAULT_2PASS_LABEL_ZOFFSET = -0.005f; // -0.05f; - - private final Label0 label; - private float spacingX = DEFAULT_SPACING_X; - private float spacingY = DEFAULT_SPACING_Y; - - public LabelButton(final Factory factory, final int renderModes, - final Font labelFont, final String labelText, - final float width, final float height) { - super(factory, renderModes | Region.COLORCHANNEL_RENDERING_BIT, width, height); - this.label = new Label0(labelFont, labelText, new float[] { 1.33f, 1.33f, 1.33f, 1.0f }); // 0.75 * 1.33 = 1.0 - setColor(0.75f, 0.75f, 0.75f, 1.0f); - setPressedColorMod(0.9f, 0.9f, 0.9f, 0.7f); - setToggleOffColorMod(0.65f, 0.65f, 0.65f, 1.0f); - setToggleOnColorMod(0.85f, 0.85f, 0.85f, 1.0f); - } - - public Font getFont() { return label.font; } - - @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - if( false ) { - // Setup poly offset for z-fighting - gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); - gl.glPolygonOffset(0f, 1f); - super.drawShape(gl, renderer, sampleCount); - gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); - } else { - super.drawShape(gl, renderer, sampleCount); - } - } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - if(corner == 0.0f) { - createSharpOutline(shape, DEFAULT_2PASS_LABEL_ZOFFSET); - } else { - createCurvedOutline(shape, DEFAULT_2PASS_LABEL_ZOFFSET); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); - - // Precompute text-box size .. guessing pixelSize - final float lw = width * ( 1f - spacingX ) ; - final float lh = height * ( 1f - spacingY ) ; - final AABBox lbox0_em = label.font.getGlyphBounds(label.text, tempT1, tempT2); - final float lsx = lw / lbox0_em.getWidth(); - final float lsy = lh / lbox0_em.getHeight(); - final float lScale = lsx < lsy ? lsx : lsy; - - // Setting left-corner transform using text-box in font em-size [0..1] - final AABBox lbox1_s = new AABBox(lbox0_em).scale2(lScale, new float[3]); - // Center text .. (share same center w/ button) - final float[] lctr = lbox1_s.getCenter(); - final float[] ctr = box.getCenter(); - final float[] ltx = new float[] { ctr[0] - lctr[0], ctr[1] - lctr[1], 0f }; - - if( DRAW_DEBUG_BOX ) { - System.err.println("RIButton: dim "+width+" x "+height+", spacing "+spacingX+", "+spacingY); - System.err.println("RIButton: net-text "+lw+" x "+lh); - System.err.println("RIButton: shape "+box); - System.err.println("RIButton: text_em "+lbox0_em+" em, "+label.text); - System.err.println("RIButton: lscale "+lsx+" x "+lsy+" -> "+lScale); - System.err.printf ("RIButton: text_s %s%n", lbox1_s); - System.err.printf ("RIButton: tleft %f / %f, %f / %f%n", ltx[0], ltx[1], ltx[0] * lScale, ltx[1] * lScale); - } - - final AABBox lbox2 = label.addShapeToRegion(lScale, region, tempT1.setToTranslation(ltx[0], ltx[1]), tempT2, tempT3, tempT4); - if( DRAW_DEBUG_BOX ) { - System.err.printf("RIButton.X: lbox2 %s%n", lbox2); - } - - setRotationOrigin( ctr[0], ctr[1], ctr[2]); - - if( DRAW_DEBUG_BOX ) { - System.err.println("XXX.UIShape.RIButton: Added Shape: "+shape+", "+box); - } - } - - public final float getSpacingX() { return spacingX; } - public final float getSpacingY() { return spacingY; } - - /** - * In percent of text label - * @param spacingX spacing in percent on X, default is {@link #DEFAULT_SPACING_X} - * @param spacingY spacing in percent on Y, default is {@link #DEFAULT_SPACING_Y} - */ - public final void setSpacing(final float spacingX, final float spacingY) { - if ( spacingX < 0.0f ) { - this.spacingX = 0.0f; - } else if ( spacingX > 1.0f ) { - this.spacingX = 1.0f; - } else { - this.spacingX = spacingX; - } - if ( spacingY < 0.0f ) { - this.spacingY = 0.0f; - } else if ( spacingY > 1.0f ) { - this.spacingY = 1.0f; - } else { - this.spacingY = spacingY; - } - markShapeDirty(); - } - - public final float[] getLabelColor() { - return label.getColor(); - } - - public final void setLabelColor(final float r, final float g, final float b) { - label.setColor(r, g, b, 1.0f); - markShapeDirty(); - } - - public final void setLabelText(final Font labelFont, final String labelText) { - if( !label.getText().equals(labelText) || !label.getFont().equals(labelFont) ) { - label.setFont(labelFont); - label.setText(labelText); - markShapeDirty(); - } - } - - @Override - public String getSubString() { - return super.getSubString()+", "+ label + ", " + "spacing: " + spacingX+"/"+spacingY; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java deleted file mode 100644 index 44e2c6034..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/MediaPlayerButton.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright 2014 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.common.util.InterruptSource; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.util.av.GLMediaPlayer; -import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; -import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; -import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; - -/** - * GPU based resolution independent {@link GLMediaPlayer} Button impl - */ -public class MediaPlayerButton extends TextureSeqButton { - private boolean verbose = false; - - /** - * @param factory - * @param renderModes - * @param width - * @param height - * @param mPlayer - * @param mPlayerListener - */ - public MediaPlayerButton(final Factory factory, final int renderModes, - final float width, final float height, - final GLMediaPlayer mPlayer) { - super(factory, renderModes, width, height, mPlayer); - setColor(0.8f, 0.8f, 0.8f, 1.0f); - setPressedColorMod(1.1f, 1.1f, 1.1f, 0.7f); - setToggleOffColorMod(0.8f, 0.8f, 0.8f, 1.0f); - setToggleOnColorMod(1.0f, 1.0f, 1.0f, 1.0f); - setEnabled(false); // data and shader n/a yet - } - - public void setVerbose(final boolean v) { verbose = v; } - - /** - * Add the default {@link GLMediaEventListener} to {@link #getGLMediaPlayer() this class's GLMediaPlayer}. - */ - public void addDefaultEventListener() { - getGLMediaPlayer().addEventListener(defGLMediaEventListener); - } - - public final GLMediaPlayer getGLMediaPlayer() { return (GLMediaPlayer)texSeq; } - - private final GLMediaEventListener defGLMediaEventListener = new GLMediaEventListener() { - @Override - public void newFrameAvailable(final GLMediaPlayer ts, final TextureFrame newFrame, final long when) { - // texButton.markStateDirty(); - } - - @Override - public void attributesChanged(final GLMediaPlayer mp, final int event_mask, final long when) { - final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq; - if( verbose ) { - System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("MovieCube State: "+mp); - } - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { - MediaPlayerButton.this.setEnabled(true); // data and shader is available .. - } - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { - // FIXME: mPlayer.resetGLState(); - } - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - new InterruptSource.Thread() { - public void run() { - // loop for-ever .. - mPlayer.seek(0); - mPlayer.play(); - } }.start(); - } else if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) { - final StreamException se = mPlayer.getStreamException(); - if( null != se ) { - se.printStackTrace(); - } - } - } }; - - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - ((GLMediaPlayer)texSeq).destroy(gl); - } - - @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq; - if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) { - try { - mPlayer.initGL(gl); - mPlayer.setAudioVolume( 0f ); - mPlayer.play(); - markStateDirty(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - super.drawShape(gl, renderer, sampleCount); - markStateDirty(); // keep on going - }; - -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Rectangle.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Rectangle.java deleted file mode 100644 index aa9400050..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Rectangle.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; - -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent Rectangle - */ -public class Rectangle extends UIShape { - private float width, height, lineWidth; - - public Rectangle(final Factory factory, final int renderModes, final float width, final float height, final float linewidth) { - super(factory, renderModes); - this.width = width; - this.height = height; - this.lineWidth = linewidth; - } - - public final float getWidth() { return width; } - public final float getHeight() { return height; } - public final float getLineWidth() { return lineWidth; } - - public void setDimension(final float width, final float height, final float lineWidth) { - this.width = width; - this.height = height; - this.lineWidth = lineWidth; - markShapeDirty(); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - final float lwh = lineWidth/2f; - - final float tw = getWidth(); - final float th = getHeight(); - - final float twh = tw/2f; - final float twh_o = twh+lwh; - final float twh_i = twh-lwh; - final float thh = th/2f; - final float thh_o = thh+lwh; - final float thh_i = thh-lwh; - - final float ctrX = 0f, ctrY = 0f; - final float ctrZ = 0f; - - // outer (CCW!) - shape.moveTo(ctrX-twh_o, ctrY-thh_o, ctrZ); - shape.lineTo(ctrX+twh_o, ctrY-thh_o, ctrZ); - shape.lineTo(ctrX+twh_o, ctrY+thh_o, ctrZ); - shape.lineTo(ctrX-twh_o, ctrY+thh_o, ctrZ); - shape.closePath(); - - // inner (CCW!) - shape.moveTo(ctrX-twh_i, ctrY-thh_i, ctrZ); - shape.lineTo(ctrX+twh_i, ctrY-thh_i, ctrZ); - shape.lineTo(ctrX+twh_i, ctrY+thh_i, ctrZ); - shape.lineTo(ctrX-twh_i, ctrY+thh_i, ctrZ); - shape.closePath(); - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java deleted file mode 100644 index 1f238763d..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.graph.geom.plane.AffineTransform; - -public abstract class RoundButton extends UIShape { - - /** {@value} */ - public static final float DEFAULT_CORNER = 1f; - protected float width; - protected float height; - protected float corner = DEFAULT_CORNER; - - protected RoundButton(final Factory factory, final int renderModes, final float width, final float height) { - super(factory, renderModes); - this.width = width; - this.height = height; - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - public final float getWidth() { return width; } - - public final float getHeight() { return height; } - - public final float getCorner() { return corner; } - - public void setSize(final float width, final float height) { - this.width = width; - this.height = height; - markShapeDirty(); - } - - protected void createSharpOutline(final OutlineShape shape, final float zOffset) { - final float tw = getWidth(); - final float th = getHeight(); - - final float minX = 0; - final float minY = 0; - final float minZ = zOffset; - - shape.addVertex(minX, minY, minZ, true); - shape.addVertex(minX+tw, minY, minZ, true); - shape.addVertex(minX+tw, minY + th, minZ, true); - shape.addVertex(minX, minY + th, minZ, true); - shape.closeLastOutline(true); - } - - protected void createCurvedOutline(final OutlineShape shape, final float zOffset) { - final float tw = getWidth(); - final float th = getHeight(); - final float dC = 0.5f*corner*Math.min(tw, th); - - final float minX = 0; - final float minY = 0; - final float minZ = zOffset; - - shape.addVertex(minX, minY + dC, minZ, true); - shape.addVertex(minX, minY, minZ, false); - - shape.addVertex(minX + dC, minY, minZ, true); - - shape.addVertex(minX + tw - dC, minY, minZ, true); - shape.addVertex(minX + tw, minY, minZ, false); - shape.addVertex(minX + tw, minY + dC, minZ, true); - shape.addVertex(minX + tw, minY + th- dC, minZ, true); - shape.addVertex(minX + tw, minY + th, minZ, false); - shape.addVertex(minX + tw - dC, minY + th, minZ, true); - shape.addVertex(minX + dC, minY + th, minZ, true); - shape.addVertex(minX, minY + th, minZ, false); - shape.addVertex(minX, minY + th - dC, minZ, true); - - shape.closeLastOutline(true); - } - - /** Set corner size, default is {@link #DEFAULT_CORNER} */ - public void setCorner(final float corner) { - if(corner > 1.0f){ - this.corner = 1.0f; - } - else if(corner < 0.01f){ - this.corner = 0.0f; - } - else{ - this.corner = corner; - } - markShapeDirty(); - } - - @Override - public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight() + ", corner " + corner; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java deleted file mode 100644 index 196447a23..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java +++ /dev/null @@ -1,626 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; - -import com.jogamp.opengl.FPSCounter; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLCapabilitiesImmutable; -import com.jogamp.opengl.GLEventListener; -import com.jogamp.opengl.GLRunnable; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.newt.event.GestureHandler; -import com.jogamp.newt.event.InputEvent; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.PinchToZoomGesture; -import com.jogamp.newt.event.GestureHandler.GestureEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Ray; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; - -public class SceneUIController implements GLEventListener{ - private final ArrayList shapes = new ArrayList(); - - private final float sceneDist, zNear, zFar; - - private RegionRenderer renderer; - - private final int[] sampleCount = new int[1]; - - /** Describing the bounding box in model-coordinates of the near-plane parallel at distance one. */ - private final AABBox nearPlane1Box = new AABBox(); - private final int[] viewport = new int[] { 0, 0, 0, 0 }; - private final float[] sceneScale = new float[3]; - private final float[] scenePlaneOrigin = new float[3]; - - - private volatile UIShape activeShape = null; - - private SBCMouseListener sbcMouseListener = null; - private SBCGestureListener sbcGestureListener = null; - private PinchToZoomGesture pinchToZoomGesture = null; - - private GLAutoDrawable cDrawable = null; - - public SceneUIController(final float sceneDist, final float zNear, final float zFar) { - this(null, sceneDist, zNear, zFar); - } - - public SceneUIController(final RegionRenderer renderer, final float sceneDist, final float zNear, final float zFar) { - this.renderer = renderer; - this.sceneDist = sceneDist; - this.zFar = zFar; - this.zNear = zNear; - this.sampleCount[0] = 4; - } - - /** Returns the associated RegionRenderer */ - public RegionRenderer getRenderer() { return renderer; } - /** Sets the associated RegionRenderer, may set to null to avoid its destruction when {@link #dispose(GLAutoDrawable)} this instance. */ - public void setRenderer(final RegionRenderer renderer) { - this.renderer = renderer; - } - /** Returns the associated RegionRenderer's RenderState, may be null. */ - public RenderState getRenderState() { - if( null != renderer ) { - return renderer.getRenderState(); - } - return null; - } - public final Vertex.Factory getVertexFactory() { - if( null != renderer ) { - return renderer.getRenderState().getVertexFactory(); - } - return null; - } - - public void attachInputListenerTo(final GLWindow window) { - if(null == sbcMouseListener) { - sbcMouseListener = new SBCMouseListener(); - window.addMouseListener(sbcMouseListener); - sbcGestureListener = new SBCGestureListener(); - window.addGestureListener(sbcGestureListener); - pinchToZoomGesture = new PinchToZoomGesture(window.getNativeSurface(), false); - window.addGestureHandler(pinchToZoomGesture); - } - } - - public void detachInputListenerFrom(final GLWindow window) { - if(null != sbcMouseListener) { - window.removeMouseListener(sbcMouseListener); - sbcMouseListener = null; - window.removeGestureListener(sbcGestureListener); - sbcGestureListener = null; - window.removeGestureHandler(pinchToZoomGesture); - pinchToZoomGesture = null; - } - } - - public ArrayList getShapes() { - return shapes; - } - public void addShape(final UIShape b) { - shapes.add(b); - } - public void removeShape(final UIShape b) { - shapes.remove(b); - } - public final UIShape getShapeByIdx(final int id) { - if( 0 > id ) { - return null; - } - return shapes.get(id); - } - public UIShape getShapeByName(final int name) { - for(final UIShape b : shapes) { - if(b.getName() == name ) { - return b; - } - } - return null; - } - - public int getSampleCount() { return sampleCount[0]; } - public int setSampleCount(final int v) { - sampleCount[0] = Math.min(8, Math.max(v, 1)); // clip - markAllShapesDirty(); - return sampleCount[0]; - } - - public void setAllShapesQuality(final int q) { - for(int i=0; i shapeZAscComparator = new Comparator() { - @Override - public int compare(final UIShape s1, final UIShape s2) { - final float s1Z = s1.getBounds().getMinZ()+s1.getTranslate()[2]; - final float s2Z = s2.getBounds().getMinZ()+s2.getTranslate()[2]; - if( FloatUtil.isEqual(s1Z, s2Z, FloatUtil.EPSILON) ) { - return 0; - } else if( s1Z < s2Z ){ - return -1; - } else { - return 1; - } - } }; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void display(final GLAutoDrawable drawable) { - final GL2ES2 gl = drawable.getGL().getGL2ES2(); - - gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - - final Object[] shapesS = shapes.toArray(); - Arrays.sort(shapesS, (Comparator)shapeZAscComparator); - - renderer.enable(gl, true); - - //final int shapeCount = shapes.size(); - final int shapeCount = shapesS.length; - for(int i=0; i=0; i--) { - final UIShape uiShape = (UIShape)shapesS[i]; - - if( uiShape.isEnabled() ) { - pmv.glPushMatrix(); - uiShape.setTransform(pmv); - final boolean ok = pmv.gluUnProjectRay(glWinX, glWinY, winZ0, winZ1, viewport, 0, ray); - pmv.glPopMatrix(); - if( ok ) { - final AABBox sbox = uiShape.getBounds(); - if( sbox.intersectsRay(ray) ) { - // System.err.printf("Pick.0: shape %d, [%d, %d, %f/%f] -> %s%n", i, glWinX, glWinY, winZ0, winZ1, ray); - if( null == sbox.getRayIntersection(objPos, ray, FloatUtil.EPSILON, true, dpyTmp1V3, dpyTmp2V3, dpyTmp3V3) ) { - throw new InternalError("Ray "+ray+", box "+sbox); - } - // System.err.printf("Pick.1: shape %d @ [%f, %f, %f], within %s%n", i, objPos[0], objPos[1], objPos[2], uiShape.getBounds()); - return uiShape; - } - } - } - } - return null; - } - private final float[] dpyTmp1V3 = new float[3]; - private final float[] dpyTmp2V3 = new float[3]; - private final float[] dpyTmp3V3 = new float[3]; - - /** - * Calling {@link UIShape#winToObjCoord(RegionRenderer, int, int, float[])}, retrieving its object position. - * @param activeShape - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - * @param objPos resulting object position - * @param runnable action - */ - public void windowToShapeCoords(final UIShape activeShape, final int glWinX, final int glWinY, final float[] objPos, final Runnable runnable) { - if( null == cDrawable || null == activeShape ) { - return; - } - cDrawable.invoke(false, new GLRunnable() { - @Override - public boolean run(final GLAutoDrawable drawable) { - final boolean ok; - { - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glPushMatrix(); - activeShape.setTransform(pmv); - ok = activeShape.winToObjCoord(renderer, glWinX, glWinY, objPos); - pmv.glPopMatrix(); - } - if( ok ) { - runnable.run(); - } - return true; - } } ); - } - - /** - * Disposes all {@link #addShape(UIShape) added} {@link UIShape}s. - *

- * Implementation also issues {@link RegionRenderer#destroy(GL2ES2)} if set - * and {@link #detachInputListenerFrom(GLWindow)} in case the drawable is of type {@link GLWindow}. - *

- *

- * {@inheritDoc} - *

- */ - @Override - public void dispose(final GLAutoDrawable drawable) { - System.err.println("SceneUIController: dispose"); - if( drawable instanceof GLWindow ) { - final GLWindow glw = (GLWindow) drawable; - detachInputListenerFrom(glw); - } - final GL2ES2 gl = drawable.getGL().getGL2ES2(); - for(int i=0; i [%f, %f, %f]%n", 0f, 0f, orthoDist, winZ[0], obj00Coord[0], obj00Coord[1], obj00Coord[2]); - - mapWin2ObjectCoords(pmv, viewport, zNear, zFar, width, height, orthoDist, winZ, obj11Coord); - System.err.printf("Reshape: mapped.11: [%f, %f, %f], winZ %f -> [%f, %f, %f]%n", (float)width, (float)height, orthoDist, winZ[0], obj11Coord[0], obj11Coord[1], obj11Coord[2]); - - nearPlane1Box.setSize( obj00Coord[0], // lx - obj00Coord[1], // ly - obj00Coord[2], // lz - obj11Coord[0], // hx - obj11Coord[1], // hy - obj11Coord[2] );// hz - System.err.printf("Reshape: dist1Box: %s%n", nearPlane1Box); - } - scenePlaneOrigin[0] = nearPlane1Box.getMinX() * sceneDist; - scenePlaneOrigin[1] = nearPlane1Box.getMinY() * sceneDist; - scenePlaneOrigin[2] = nearPlane1Box.getMinZ() * sceneDist; - sceneScale[0] = ( nearPlane1Box.getWidth() * sceneDist ) / width; - sceneScale[1] = ( nearPlane1Box.getHeight() * sceneDist ) / height; - sceneScale[2] = 1f; - System.err.printf("Scene Origin [%f, %f, %f]%n", scenePlaneOrigin[0], scenePlaneOrigin[1], scenePlaneOrigin[2]); - System.err.printf("Scene Scale %f * [%f x %f] / [%d x %d] = [%f, %f, %f]%n", - sceneDist, nearPlane1Box.getWidth(), nearPlane1Box.getHeight(), - width, height, - sceneScale[0], sceneScale[1], sceneScale[2]); - - pmv.glTranslatef(scenePlaneOrigin[0], scenePlaneOrigin[1], scenePlaneOrigin[2]); - pmv.glScalef(sceneScale[0], sceneScale[1], sceneScale[2]); - } - - public final UIShape getActiveShape() { - return activeShape; - } - - public void release() { - setActiveShape(null); - } - private void setActiveShape(final UIShape shape) { - activeShape = shape; - } - - private final class SBCGestureListener implements GestureHandler.GestureListener { - @Override - public void gestureDetected(final GestureEvent gh) { - if( null != activeShape ) { - // gesture .. delegate to active shape! - final InputEvent orig = gh.getTrigger(); - if( orig instanceof MouseEvent ) { - final MouseEvent e = (MouseEvent) orig; - // flip to GL window coordinates - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - final float[] objPos = new float[3]; - final UIShape shape = activeShape; - windowToShapeCoords(shape, glWinX, glWinY, objPos, new Runnable() { - @Override - public void run() { - shape.dispatchGestureEvent(gh, glWinX, glWinY, objPos); - } } ); - } - } - } - } - - /** - * Dispatch mouse event, either directly sending to activeShape or picking one - * @param e original Newt {@link MouseEvent} - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - */ - final void dispatchMouseEvent(final MouseEvent e, final int glWinX, final int glWinY) { - if( null == activeShape ) { - dispatchMouseEventPickShape(e, glWinX, glWinY, true); - } else { - dispatchMouseEventForShape(activeShape, e, glWinX, glWinY); - } - } - /** - * Pick the shape using the event coordinates - * @param e original Newt {@link MouseEvent} - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - * @param setActive - */ - final void dispatchMouseEventPickShape(final MouseEvent e, final int glWinX, final int glWinY, final boolean setActive) { - final float[] objPos = new float[3]; - final UIShape[] shape = { null }; - pickShape(glWinX, glWinY, objPos, shape, new Runnable() { - @Override - public void run() { - if( setActive ) { - setActiveShape(shape[0]); - } - shape[0].dispatchMouseEvent(e, glWinX, glWinY, objPos); - } } ); - } - /** - * Dispatch event to shape - * @param shape target active shape of event - * @param e original Newt {@link MouseEvent} - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - */ - final void dispatchMouseEventForShape(final UIShape shape, final MouseEvent e, final int glWinX, final int glWinY) { - final float[] objPos = new float[3]; - windowToShapeCoords(shape, glWinX, glWinY, objPos, new Runnable() { - @Override - public void run() { - shape.dispatchMouseEvent(e, glWinX, glWinY, objPos); - } } ); - } - - private class SBCMouseListener implements MouseListener { - int lx=-1, ly=-1, lId=-1; - - void clear() { - lx = -1; ly = -1; lId = -1; - } - - @Override - public void mousePressed(final MouseEvent e) { - if( -1 == lId || e.getPointerId(0) == lId ) { - lx = e.getX(); - ly = e.getY(); - lId = e.getPointerId(0); - } - // flip to GL window coordinates, origin bottom-left - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - dispatchMouseEvent(e, glWinX, glWinY); - } - - @Override - public void mouseReleased(final MouseEvent e) { - // flip to GL window coordinates, origin bottom-left - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - dispatchMouseEvent(e, glWinX, glWinY); - if( 1 == e.getPointerCount() ) { - // Release active shape: last pointer has been lifted! - release(); - clear(); - } - } - - @Override - public void mouseClicked(final MouseEvent e) { - // flip to GL window coordinates - final int glWinX = e.getX(); - final int glWinY = viewport[3] - e.getY() - 1; - // activeId should have been released by mouseRelease() already! - dispatchMouseEventPickShape(e, glWinX, glWinY, false); - // Release active shape: last pointer has been lifted! - release(); - clear(); - } - - @Override - public void mouseDragged(final MouseEvent e) { - // drag activeShape, if no gesture-activity, only on 1st pointer - if( null != activeShape && !pinchToZoomGesture.isWithinGesture() && e.getPointerId(0) == lId ) { - lx = e.getX(); - ly = e.getY(); - - // dragged .. delegate to active shape! - // flip to GL window coordinates, origin bottom-left - final int glWinX = lx; - final int glWinY = viewport[3] - ly - 1; - dispatchMouseEventForShape(activeShape, e, glWinX, glWinY); - } - } - - @Override - public void mouseWheelMoved(final MouseEvent e) { - // flip to GL window coordinates - final int glWinX = lx; - final int glWinY = viewport[3] - ly - 1; - dispatchMouseEventPickShape(e, glWinX, glWinY, true); - } - - @Override - public void mouseMoved(final MouseEvent e) { - if( -1 == lId || e.getPointerId(0) == lId ) { - lx = e.getX(); - ly = e.getY(); - lId = e.getPointerId(0); - } - } - @Override - public void mouseEntered(final MouseEvent e) { } - @Override - public void mouseExited(final MouseEvent e) { - release(); - clear(); - } - } - - /** - * Return a formatted status string containing avg fps and avg frame duration. - * @param glad GLAutoDrawable instance for FPSCounter, its chosen GLCapabilities and its GL's swap-interval - * @param renderModes render modes for {@link Region#getRenderModeString(int)} - * @param quality the Graph-Curve quality setting - * @param dpi the monitor's DPI (vertical preferred) - * @return formatted status string - */ - public String getStatusText(final GLAutoDrawable glad, final int renderModes, final int quality, final float dpi) { - final FPSCounter fpsCounter = glad.getAnimator(); - final float lfps, tfps, td; - if( null != fpsCounter ) { - lfps = fpsCounter.getLastFPS(); - tfps = fpsCounter.getTotalFPS(); - td = (float)fpsCounter.getLastFPSPeriod() / (float)fpsCounter.getUpdateFPSFrames(); - } else { - lfps = 0f; - tfps = 0f; - td = 0f; - } - final String modeS = Region.getRenderModeString(renderModes); - final GLCapabilitiesImmutable caps = glad.getChosenGLCapabilities(); - return String.format("%03.1f/%03.1f fps, %.1f ms/f, v-sync %d, dpi %.1f, %s-samples %d, q %d, msaa %d, blend %b, alpha %d", - lfps, tfps, td, glad.getGL().getSwapInterval(), dpi, modeS, getSampleCount(), quality, - caps.getNumSamples(), - getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), - caps.getAlphaBits()); - } - - /** - * Return a formatted status string containing avg fps and avg frame duration. - * @param fpsCounter the counter, must not be null - * @return formatted status string - */ - public static String getStatusText(final FPSCounter fpsCounter) { - final float lfps = fpsCounter.getLastFPS(); - final float tfps = fpsCounter.getTotalFPS(); - final float td = (float)fpsCounter.getLastFPSPeriod() / (float)fpsCounter.getUpdateFPSFrames(); - return String.format("%03.1f/%03.1f fps, %.1f ms/f", lfps, tfps, td); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java deleted file mode 100644 index 226dfc1cd..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLProfile; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.GLRegion; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.util.texture.TextureSequence; - -/** - * GPU based resolution independent {@link TextureSequence} Button impl - */ -public class TextureSeqButton extends RoundButton { - protected final TextureSequence texSeq; - - public TextureSeqButton(final Factory factory, final int renderModes, - final float width, final float height, final TextureSequence texSeq) { - super(factory, renderModes | Region.COLORTEXTURE_RENDERING_BIT, width, height); - this.texSeq = texSeq; - } - - @Override - protected GLRegion createGLRegion(final GLProfile glp) { - return GLRegion.create(glp, getRenderModes(), texSeq); - } - - public final TextureSequence getTextureSequence() { return this.texSeq; } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - if(corner == 0.0f) { - createSharpOutline(shape, 0f); - } else { - createCurvedOutline(shape, 0f); - } - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); - - final float[] ctr = box.getCenter(); - setRotationOrigin( ctr[0], ctr[1], ctr[2]); - - if( DRAW_DEBUG_BOX ) { - System.err.println("XXX.UIShape.TextureSeqButton: Added Shape: "+shape+", "+box); - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java deleted file mode 100644 index 1ef54304f..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java +++ /dev/null @@ -1,782 +0,0 @@ -/** - * Copyright 2010-2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.demos.ui; - -import java.util.ArrayList; - -import com.jogamp.nativewindow.NativeWindowException; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLProfile; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.Region; -import com.jogamp.graph.curve.opengl.GLRegion; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.graph.geom.plane.AffineTransform; -import com.jogamp.newt.event.GestureHandler.GestureEvent; -import com.jogamp.newt.event.GestureHandler.GestureListener; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.NEWTEvent; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.Quaternion; -import com.jogamp.opengl.math.VectorUtil; -import com.jogamp.opengl.math.geom.AABBox; -import com.jogamp.opengl.util.PMVMatrix; - -public abstract class UIShape { - public static final boolean DRAW_DEBUG_BOX = false; - private static final boolean DEBUG = false; - - protected static final int DIRTY_SHAPE = 1 << 0 ; - protected static final int DIRTY_STATE = 1 << 1 ; - - private final Factory vertexFactory; - private final int renderModes; - protected final AABBox box; - - protected final AffineTransform tempT1 = new AffineTransform(); - protected final AffineTransform tempT2 = new AffineTransform(); - protected final AffineTransform tempT3 = new AffineTransform(); - protected final AffineTransform tempT4 = new AffineTransform(); - - protected final float[] translate = new float[] { 0f, 0f, 0f }; - protected final Quaternion rotation = new Quaternion(); - protected final float[] rotOrigin = new float[] { 0f, 0f, 0f }; - protected final float[] scale = new float[] { 1f, 1f, 1f }; - - protected GLRegion region = null; - protected int regionQuality = Region.MAX_QUALITY; - - protected int dirty = DIRTY_SHAPE | DIRTY_STATE; - protected float shapesSharpness = OutlineShape.DEFAULT_SHARPNESS; - - /** Default base-color w/o color channel, will be modulated w/ pressed- and toggle color */ - protected final float[] rgbaColor = {0.75f, 0.75f, 0.75f, 1.0f}; - /** Default pressed color-factor w/o color channel, modulated base-color. 0.75 * 1.2 = 0.9 */ - protected final float[] pressedRGBAModulate = {1.2f, 1.2f, 1.2f, 0.7f}; - /** Default toggle color-factor w/o color channel, modulated base-color. 0.75 * 1.13 ~ 0.85 */ - protected final float[] toggleOnRGBAModulate = {1.13f, 1.13f, 1.13f, 1.0f}; - /** Default toggle color-factor w/o color channel, modulated base-color. 0.75 * 0.86 ~ 0.65 */ - protected final float[] toggleOffRGBAModulate = {0.86f, 0.86f, 0.86f, 1.0f}; - - private int name = -1; - - private boolean down = false; - private boolean toggle = false; - private boolean toggleable = false; - private boolean draggable = true; - private boolean enabled = true; - private ArrayList mouseListeners = new ArrayList(); - - public UIShape(final Factory factory, final int renderModes) { - this.vertexFactory = factory; - this.renderModes = renderModes; - this.box = new AABBox(); - } - - /** Set a symbolic name for this shape for identification. Default is -1 for noname. */ - public void setName(final int name) { this.name = name; } - /** Return the optional symbolic name for this shape. */ - public int getName() { return this.name; } - - public final Vertex.Factory getVertexFactory() { return vertexFactory; } - - /** Returns true if this shape is enabled and hence visible, otherwise false. */ - public boolean isEnabled() { return enabled; } - /** Enable or disable this shape, i.e. its visibility. */ - public void setEnabled(final boolean v) { enabled = v; } - - /** - * Clears all data and reset all states as if this instance was newly created - * @param gl TODO - * @param renderer TODO\ - */ - public void clear(final GL2ES2 gl, final RegionRenderer renderer) { - clearImpl(gl, renderer); - translate[0] = 0f; - translate[1] = 0f; - translate[2] = 0f; - rotation.setIdentity(); - rotOrigin[0] = 0f; - rotOrigin[1] = 0f; - rotOrigin[2] = 0f; - scale[0] = 1f; - scale[1] = 1f; - scale[2] = 1f; - box.reset(); - markShapeDirty(); - } - - /** - * Destroys all data - * @param gl - * @param renderer - */ - public void destroy(final GL2ES2 gl, final RegionRenderer renderer) { - destroyImpl(gl, renderer); - translate[0] = 0f; - translate[1] = 0f; - translate[2] = 0f; - rotation.setIdentity(); - rotOrigin[0] = 0f; - rotOrigin[1] = 0f; - rotOrigin[2] = 0f; - scale[0] = 1f; - scale[1] = 1f; - scale[2] = 1f; - box.reset(); - markShapeDirty(); - } - - public void setTranslate(final float tx, final float ty, final float tz) { - translate[0] = tx; - translate[1] = ty; - translate[2] = tz; - // System.err.println("UIShape.setTranslate: "+tx+"/"+ty+"/"+tz+": "+toString()); - } - public void translate(final float tx, final float ty, final float tz) { - translate[0] += tx; - translate[1] += ty; - translate[2] += tz; - // System.err.println("UIShape.translate: "+tx+"/"+ty+"/"+tz+": "+toString()); - } - public final float[] getTranslate() { return translate; } - public final Quaternion getRotation() { return rotation; } - public final float[] getRotationOrigin() { return rotOrigin; } - public void setRotationOrigin(final float rx, final float ry, final float rz) { - rotOrigin[0] = rx; - rotOrigin[1] = ry; - rotOrigin[2] = rz; - } - public void setScale(final float sx, final float sy, final float sz) { - scale[0] = sx; - scale[1] = sy; - scale[2] = sz; - } - public void scale(final float sx, final float sy, final float sz) { - scale[0] *= sx; - scale[1] *= sy; - scale[2] *= sz; - } - public final float[] getScale() { return scale; } - - public final void markShapeDirty() { - dirty |= DIRTY_SHAPE; - } - public final boolean isShapeDirty() { - return 0 != ( dirty & DIRTY_SHAPE ) ; - } - public final void markStateDirty() { - dirty |= DIRTY_STATE; - } - public final boolean isStateDirty() { - return 0 != ( dirty & DIRTY_STATE ) ; - } - - public final AABBox getBounds() { return box; } - - public final int getRenderModes() { return renderModes; } - - public GLRegion getRegion(final GL2ES2 gl, final RegionRenderer renderer) { - validate(gl, renderer); - return region; - } - - /** - * Renders {@link OutlineShape} using local {@link GLRegion} which might be cached or updated. - *

- * No matrix operations (translate, scale, ..) are performed. - *

- * @param gl - * @param renderer - * @param sampleCount - */ - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - final float r, g, b, a; - final boolean isPressed = isPressed(), isToggleOn = isToggleOn(); - final boolean modBaseColor = !Region.hasColorChannel( renderModes ) && !Region.hasColorTexture( renderModes ); - if( modBaseColor ) { - if( isPressed ) { - r = rgbaColor[0]*pressedRGBAModulate[0]; - g = rgbaColor[1]*pressedRGBAModulate[1]; - b = rgbaColor[2]*pressedRGBAModulate[2]; - a = rgbaColor[3]*pressedRGBAModulate[3]; - } else if( isToggleable() ) { - if( isToggleOn ) { - r = rgbaColor[0]*toggleOnRGBAModulate[0]; - g = rgbaColor[1]*toggleOnRGBAModulate[1]; - b = rgbaColor[2]*toggleOnRGBAModulate[2]; - a = rgbaColor[3]*toggleOnRGBAModulate[3]; - } else { - r = rgbaColor[0]*toggleOffRGBAModulate[0]; - g = rgbaColor[1]*toggleOffRGBAModulate[1]; - b = rgbaColor[2]*toggleOffRGBAModulate[2]; - a = rgbaColor[3]*toggleOffRGBAModulate[3]; - } - } else { - r = rgbaColor[0]; - g = rgbaColor[1]; - b = rgbaColor[2]; - a = rgbaColor[3]; - } - } else { - if( isPressed ) { - r = pressedRGBAModulate[0]; - g = pressedRGBAModulate[1]; - b = pressedRGBAModulate[2]; - a = pressedRGBAModulate[3]; - } else if( isToggleable() ) { - if( isToggleOn ) { - r = toggleOnRGBAModulate[0]; - g = toggleOnRGBAModulate[1]; - b = toggleOnRGBAModulate[2]; - a = toggleOnRGBAModulate[3]; - } else { - r = toggleOffRGBAModulate[0]; - g = toggleOffRGBAModulate[1]; - b = toggleOffRGBAModulate[2]; - a = toggleOffRGBAModulate[3]; - } - } else { - r = rgbaColor[0]; - g = rgbaColor[1]; - b = rgbaColor[2]; - a = rgbaColor[3]; - } - } - renderer.getRenderState().setColorStatic(r, g, b, a); - getRegion(gl, renderer).draw(gl, renderer, sampleCount); - } - - protected GLRegion createGLRegion(final GLProfile glp) { - return GLRegion.create(glp, renderModes, null); - } - - /** - * Validates the shape's underlying {@link GLRegion}. - * - * @param gl - * @param renderer - */ - public final void validate(final GL2ES2 gl, final RegionRenderer renderer) { - if( isShapeDirty() || null == region ) { - box.reset(); - if( null == region ) { - region = createGLRegion(gl.getGLProfile()); - } else { - region.clear(gl); - } - addShapeToRegion(gl, renderer); - if( DRAW_DEBUG_BOX ) { - region.clear(gl); - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - shape.setSharpness(shapesSharpness); - shape.setIsQuadraticNurbs(); - region.addOutlineShape(shape, null, rgbaColor); - } - region.setQuality(regionQuality); - dirty &= ~(DIRTY_SHAPE|DIRTY_STATE); - } else if( isStateDirty() ) { - region.markStateDirty(); - dirty &= ~DIRTY_STATE; - } - } - - /** - * Setup the pre-selected {@link GLMatrixFunc#GL_MODELVIEW} {@link PMVMatrix} for this object. - * @param pmv the matrix - */ - public void setTransform(final PMVMatrix pmv) { - final float[] uiTranslate = getTranslate(); - pmv.glTranslatef(uiTranslate[0], uiTranslate[1], uiTranslate[2]); - - final Quaternion quat = getRotation(); - final boolean rotate = !quat.isIdentity(); - final float[] uiScale = getScale(); - final boolean scale = !VectorUtil.isVec3Equal(uiScale, 0, VectorUtil.VEC3_ONE, 0, FloatUtil.EPSILON); - if( rotate || scale ) { - final float[] rotOrigin = getRotationOrigin(); - final boolean pivot = !VectorUtil.isVec3Zero(rotOrigin, 0, FloatUtil.EPSILON); - if( pivot ) { - pmv.glTranslatef(rotOrigin[0], rotOrigin[1], rotOrigin[2]); - } - if( scale ) { - pmv.glScalef(uiScale[0], uiScale[1], uiScale[2]); - } - if( rotate ) { - pmv.glRotate(quat); - } - if( pivot ) { - pmv.glTranslatef(-rotOrigin[0], -rotOrigin[1], -rotOrigin[2]); - } - } - } - - /** - * Retrieve window surface size of this shape - *

- * The {@link RegionRenderer#getMatrix()} has to be setup properly for this object, - * i.e. reshape for {@link GLMatrixFunc#GL_PROJECTION} and {@link #setTransform(PMVMatrix)} for {@link GLMatrixFunc#GL_MODELVIEW}. - *

- * @param renderer source of viewport and {@link PMVMatrix} - * @param surfaceSize target surface size - * @return true for successful gluProject(..) operation, otherwise false - */ - public boolean getSurfaceSize(final RegionRenderer renderer, final int[/*2*/] surfaceSize) { - boolean res = false; - final int[/*4*/] viewport = renderer.getViewport(new int[4]); - // System.err.println("UIShape::getSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]); - final float[] winCoordHigh = new float[3]; - final float[] winCoordLow = new float[3]; - final float[] high = getBounds().getHigh(); - final float[] low = getBounds().getLow(); - final PMVMatrix pmv = renderer.getMatrix(); - - if( pmv.gluProject(high[0], high[1], high[2], viewport, 0, winCoordHigh, 0) ) { - // System.err.printf("UIShape::surfaceSize.H: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), high[0], high[1], high[2], winCoordHigh[0], winCoordHigh[1], winCoordHigh[2]); - if( pmv.gluProject(low[0], low[1], low[2], viewport, 0, winCoordLow, 0) ) { - // System.err.printf("UIShape::surfaceSize.L: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), low[0], low[1], low[2], winCoordLow[0], winCoordLow[1], winCoordLow[2]); - surfaceSize[0] = (int)(winCoordHigh[0] - winCoordLow[0]); - surfaceSize[1] = (int)(winCoordHigh[1] - winCoordLow[1]); - // System.err.printf("UIShape::surfaceSize.S: shape %d: %f x %f -> %d x %d%n", getName(), winCoordHigh[0] - winCoordLow[0], winCoordHigh[1] - winCoordLow[1], surfaceSize[0], surfaceSize[1]); - res = true; - } - } - return res; - } - - /** - * Map given object coordinate relative to this shape to window coordinates - *

- * The {@link RegionRenderer#getMatrix()} has to be setup properly for this object, - * i.e. reshape for {@link GLMatrixFunc#GL_PROJECTION} and {@link #setTransform(PMVMatrix)} for {@link GLMatrixFunc#GL_MODELVIEW}. - *

- * @param renderer source of viewport and {@link PMVMatrix} - * @param objPos object position relative to this shape's center - * @param glWinPos target window position of objPos relative to this shape - * @return true for successful gluProject(..) operation, otherwise false - */ - public boolean objToWinCoord(final RegionRenderer renderer, final float[/*3*/] objPos, final int[/*2*/] glWinPos) { - boolean res = false; - final int[/*4*/] viewport = renderer.getViewport(new int[4]); - // System.err.println("UIShape::objToWinCoordgetSurfaceSize.VP "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]); - final float[] winCoord = new float[3]; - final PMVMatrix pmv = renderer.getMatrix(); - - if( pmv.gluProject(objPos[0], objPos[1], objPos[2], viewport, 0, winCoord, 0) ) { - // System.err.printf("UIShape::objToWinCoord.0: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), objPos[0], objPos[1], objPos[2], winCoord[0], winCoord[1], winCoord[2]); - glWinPos[0] = (int)(winCoord[0]); - glWinPos[1] = (int)(winCoord[1]); - // System.err.printf("UIShape::objToWinCoord.X: shape %d: %f / %f -> %d / %d%n", getName(), winCoord[0], winCoord[1], glWinPos[0], glWinPos[1]); - res = true; - } - return res; - } - - /** - * Map given gl-window-coordinates to object coordinates relative to this shape and its z-coordinate. - *

- * The {@link RegionRenderer#getMatrix()} has to be setup properly for this object, - * i.e. reshape for {@link GLMatrixFunc#GL_PROJECTION} and {@link #setTransform(PMVMatrix)} for {@link GLMatrixFunc#GL_MODELVIEW}. - *

- * @param renderer source of viewport and {@link PMVMatrix} - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - * @param objPos target object position of glWinX/glWinY relative to this shape - * @return @return true for successful gluProject(..) and gluUnProject(..) operations, otherwise false - */ - public boolean winToObjCoord(final RegionRenderer renderer, final int glWinX, final int glWinY, final float[/*3*/] objPos) { - boolean res = false; - final float[] ctr = getBounds().getCenter(); - final int[] viewport = renderer.getViewport(new int[4]); - final float[] tmp = new float[3]; - final PMVMatrix pmv = renderer.getMatrix(); - - if( pmv.gluProject(ctr[0], ctr[1], ctr[2], viewport, 0, tmp, 0) ) { - // System.err.printf("UIShape::winToObjCoord.0: shape %d: obj [%f, %f, %f] -> win [%f, %f, %f]%n", getName(), ctr[0], ctr[1], ctr[2], tmp[0], tmp[1], tmp[2]); - if( pmv.gluUnProject(glWinX, glWinY, tmp[2], viewport, 0, objPos, 0) ) { - // System.err.printf("UIShape::winToObjCoord.1: shape %d: win [%d, %d, %f] -> obj [%f, %f, %f]%n", getName(), glWinX, glWinY, tmp[2], objPos[0], objPos[1], objPos[2]); - res = true; - } - } - return res; - } - - public float[] getColor() { - return rgbaColor; - } - - public final int getQuality() { return regionQuality; } - public final void setQuality(final int q) { - this.regionQuality = q; - if( null != region ) { - region.setQuality(q); - } - } - public final void setSharpness(final float sharpness) { - this.shapesSharpness = sharpness; - markShapeDirty(); - } - public final float getSharpness() { - return shapesSharpness; - } - - /** - * Set base color. - *

- * Default base-color w/o color channel, will be modulated w/ pressed- and toggle color - *

- */ - public final void setColor(final float r, final float g, final float b, final float a) { - this.rgbaColor[0] = r; - this.rgbaColor[1] = g; - this.rgbaColor[2] = b; - this.rgbaColor[3] = a; - } - - /** - * Set pressed color. - *

- * Default pressed color-factor w/o color channel, modulated base-color. 0.75 * 1.2 = 0.9 - *

- */ - public final void setPressedColorMod(final float r, final float g, final float b, final float a) { - this.pressedRGBAModulate[0] = r; - this.pressedRGBAModulate[1] = g; - this.pressedRGBAModulate[2] = b; - this.pressedRGBAModulate[3] = a; - } - - /** - * Set toggle-on color. - *

- * Default toggle-on color-factor w/o color channel, modulated base-color. 0.75 * 1.13 ~ 0.85 - *

- */ - public final void setToggleOnColorMod(final float r, final float g, final float b, final float a) { - this.toggleOnRGBAModulate[0] = r; - this.toggleOnRGBAModulate[1] = g; - this.toggleOnRGBAModulate[2] = b; - this.toggleOnRGBAModulate[3] = a; - } - - /** - * Set toggle-off color. - *

- * Default toggle-off color-factor w/o color channel, modulated base-color. 0.75 * 0.86 ~ 0.65 - *

- */ - public final void setToggleOffColorMod(final float r, final float g, final float b, final float a) { - this.toggleOffRGBAModulate[0] = r; - this.toggleOffRGBAModulate[1] = g; - this.toggleOffRGBAModulate[2] = b; - this.toggleOffRGBAModulate[3] = a; - } - - @Override - public final String toString() { - return getClass().getSimpleName()+"["+getSubString()+"]"; - } - - public String getSubString() { - return "enabled "+enabled+", toggle[able "+toggleable+", state "+toggle+"], "+translate[0]+" / "+translate[1]+", box "+box; - } - - // - // Input - // - - public void setPressed(final boolean b) { - this.down = b; - markStateDirty(); - } - public boolean isPressed() { - return this.down; - } - - public void setToggleable(final boolean toggleable) { - this.toggleable = toggleable; - } - /** - * Returns true if this shape is toggable, - * i.e. rendered w/ {@link #setToggleOnColorMod(float, float, float, float)} or {@link #setToggleOffColorMod(float, float, float, float)}. - */ - public boolean isToggleable() { - return toggleable; - } - public void setToggle(final boolean v) { - toggle = v; - markStateDirty(); - } - public void toggle() { - if( isToggleable() ) { - toggle = !toggle; - } - markStateDirty(); - } - public boolean isToggleOn() { return toggle; } - - /** - * Set whether this shape is draggable, - * i.e. translated by 1-pointer-click and drag. - *

- * Default is draggable on. - *

- */ - public void setDraggable(final boolean draggable) { - this.draggable = draggable; - } - public boolean isDraggable() { - return draggable; - } - - public final void addMouseListener(final MouseGestureListener l) { - if(l == null) { - return; - } - @SuppressWarnings("unchecked") - final ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - clonedListeners.add(l); - mouseListeners = clonedListeners; - } - - public final void removeMouseListener(final MouseGestureListener l) { - if (l == null) { - return; - } - @SuppressWarnings("unchecked") - final ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - clonedListeners.remove(l); - mouseListeners = clonedListeners; - } - - /** - * Combining {@link MouseListener} and {@link GestureListener} - */ - public static interface MouseGestureListener extends MouseListener, GestureListener { - } - - /** - * Convenient adapter combining dummy implementation for {@link MouseListener} and {@link GestureListener} - */ - public static abstract class MouseGestureAdapter extends MouseAdapter implements MouseGestureListener { - @Override - public void gestureDetected(final GestureEvent gh) { - } - } - - /** - * {@link UIShape} event details for propagated {@link NEWTEvent}s - * containing reference of {@link #shape the intended shape} as well as - * the {@link #objPos rotated relative position}. - * The latter is normalized to lower-left zero origin, allowing easier usage. - */ - public static class UIShapeEvent { - /** The associated {@link UIShape} for this event */ - public final UIShape shape; - /** The relative object coordinate of glWinX/glWinY to the associated {@link UIShape}. */ - public final float[] objPos; - /** The GL window coordinates, origin bottom-left */ - public final int[] winPos; - /** The drag delta of the relative object coordinate of glWinX/glWinY to the associated {@link UIShape}. */ - public final float[] objDrag = { 0f, 0f }; - /** The drag delta of GL window coordinates, origin bottom-left */ - public final int[] winDrag = { 0, 0 }; - - /** - * Ctor - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - * @param shape associated shape - * @param objPos relative object coordinate of glWinX/glWinY to the associated shape. - */ - UIShapeEvent(final int glWinX, final int glWinY, final UIShape shape, final float[] objPos) { - this.winPos = new int[] { glWinX, glWinY }; - this.shape = shape; - this.objPos = objPos; - } - - @Override - public String toString() { - return "EventDetails[winPos ["+winPos[0]+", "+winPos[1]+"], objPos ["+objPos[0]+", "+objPos[1]+", "+objPos[2]+"], "+shape+"]"; - } - } - - /** - * @param e original Newt {@link GestureEvent} - * @param glWinX x-position in OpenGL model space - * @param glWinY y-position in OpenGL model space - */ - public final void dispatchGestureEvent(final GestureEvent e, final int glWinX, final int glWinY, final float[] objPos) { - e.setAttachment(new UIShapeEvent(glWinX, glWinY, this, objPos)); - for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { - mouseListeners.get(i).gestureDetected(e); - } - } - - boolean dragFirst = false; - float[] objDraggedFirst = { 0f, 0f }; // b/c its relative to UIShape and we stick to it - int[] winDraggedLast = { 0, 0 }; // b/c its absolute window pos - - /** - * Dispatch given NEWT mouse event to this shape - * @param e original Newt {@link MouseEvent} - * @param glWinX in GL window coordinates, origin bottom-left - * @param glWinY in GL window coordinates, origin bottom-left - * @param objPos object position of mouse event within this shape - */ - public final void dispatchMouseEvent(final MouseEvent e, final int glWinX, final int glWinY, final float[] objPos) { - final UIShape.UIShapeEvent shapeEvent = new UIShapeEvent(glWinX, glWinY, this, objPos); - e.setAttachment(shapeEvent); - - final short eventType = e.getEventType(); - if( 1 == e.getPointerCount() ) { - switch( eventType ) { - case MouseEvent.EVENT_MOUSE_CLICKED: - toggle(); - break; - case MouseEvent.EVENT_MOUSE_PRESSED: - setPressed(true); - break; - case MouseEvent.EVENT_MOUSE_RELEASED: - setPressed(false); - break; - } - } - switch( eventType ) { - case MouseEvent.EVENT_MOUSE_PRESSED: - dragFirst = true; - break; - case MouseEvent.EVENT_MOUSE_RELEASED: - dragFirst = false; - break; - case MouseEvent.EVENT_MOUSE_DRAGGED: { - // 1 pointer drag - if(dragFirst) { - objDraggedFirst[0] = objPos[0]; - objDraggedFirst[1] = objPos[1]; - winDraggedLast[0] = glWinX; - winDraggedLast[1] = glWinY; - dragFirst=false; - return; - } - shapeEvent.objDrag[0] = objPos[0] - objDraggedFirst[0]; - shapeEvent.objDrag[1] = objPos[1] - objDraggedFirst[1]; - shapeEvent.winDrag[0] = glWinX - winDraggedLast[0]; - shapeEvent.winDrag[1] = glWinY - winDraggedLast[1]; - winDraggedLast[0] = glWinX; - winDraggedLast[1] = glWinY; - if( draggable && e.getPointerCount() == 1 ) { - translate(shapeEvent.objDrag[0], shapeEvent.objDrag[1], 0f); - } - if( DEBUG ) { - System.err.printf("Dragged: win %4d/%4d + %2d/%2d; obj %.3f/%.3f + %.3f/%.3f%n", - shapeEvent.winPos[0], shapeEvent.winPos[1], - shapeEvent.winDrag[0], shapeEvent.winDrag[1], - shapeEvent.objPos[0], shapeEvent.objPos[1], - shapeEvent.objDrag[0], shapeEvent.objDrag[1]); - } - } - break; - } - - for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { - final MouseGestureListener l = mouseListeners.get(i); - switch( eventType ) { - case MouseEvent.EVENT_MOUSE_CLICKED: - l.mouseClicked(e); - break; - case MouseEvent.EVENT_MOUSE_ENTERED: - l.mouseEntered(e); - break; - case MouseEvent.EVENT_MOUSE_EXITED: - l.mouseExited(e); - break; - case MouseEvent.EVENT_MOUSE_PRESSED: - l.mousePressed(e); - break; - case MouseEvent.EVENT_MOUSE_RELEASED: - l.mouseReleased(e); - break; - case MouseEvent.EVENT_MOUSE_MOVED: - l.mouseMoved(e); - break; - case MouseEvent.EVENT_MOUSE_DRAGGED: - l.mouseDragged(e); - break; - case MouseEvent.EVENT_MOUSE_WHEEL_MOVED: - l.mouseWheelMoved(e); - break; - default: - throw new NativeWindowException("Unexpected mouse event type " + e.getEventType()); - } - } - } - - // - // - // - - protected abstract void clearImpl(GL2ES2 gl, RegionRenderer renderer); - protected abstract void destroyImpl(GL2ES2 gl, RegionRenderer renderer); - protected abstract void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer); - - // - // - // - - protected OutlineShape createDebugOutline(final OutlineShape shape, final AABBox box) { - final float d = 0.025f; - final float tw = box.getWidth() + d*2f; - final float th = box.getHeight() + d*2f; - - final float minX = box.getMinX() - d; - final float minY = box.getMinY() - d; - final float z = 0; // box.getMinZ() + 0.025f; - - // CCW! - shape.moveTo(minX, minY, z); - shape.lineTo(minX+tw, minY, z); - shape.lineTo(minX+tw, minY + th, z); - shape.lineTo(minX, minY + th, z); - shape.closePath(); - - // shape.addVertex(minX, minY, z, true); - // shape.addVertex(minX+tw, minY, z, true); - // shape.addVertex(minX+tw, minY + th, z, true); - // shape.addVertex(minX, minY + th, z, true); - // shape.closeLastOutline(true); - - return shape; - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph01UbuntuLight_o.java b/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph01UbuntuLight_o.java deleted file mode 100644 index f1ef69800..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph01UbuntuLight_o.java +++ /dev/null @@ -1,316 +0,0 @@ -/** - * Copyright 2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.testshapes; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.graph.geom.plane.Winding; - -/** - * GPU based resolution independent test object - * - Ubuntu-Light, lower case 'o' - * - TTF Shape for Glyph 82 - */ -public class Glyph01UbuntuLight_o extends UIShape { - - public Glyph01UbuntuLight_o(final Factory factory, final int renderModes) { - super(factory, renderModes); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @SuppressWarnings("unused") - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - // Ubuntu-Light, lower case 'o' - // Start TTF Shape for Glyph 82 - if( false ) { - // Original Outer shape: Winding.CW - // Moved into OutlineShape reverse -> Winding.CCW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.527000f, 0.258000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.527000f, 0.197000f, false); - shape.addVertex(0, 0.510000f, 0.147000f, true); - // 002: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.492000f, 0.097000f, false); - shape.addVertex(0, 0.461000f, 0.062000f, true); - // 003: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.429000f, 0.027000f, false); - shape.addVertex(0, 0.386000f, 0.008000f, true); - // 004: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.343000f, -0.012000f, false); - shape.addVertex(0, 0.291000f, -0.012000f, true); - // 005: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.239000f, -0.012000f, false); - shape.addVertex(0, 0.196000f, 0.007000f, true); - // 007: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.153000f, 0.027000f, false); - shape.addVertex(0, 0.122000f, 0.062000f, true); - // 008: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.090000f, 0.097000f, false); - shape.addVertex(0, 0.073000f, 0.147000f, true); - // 009: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.055000f, 0.197000f, false); - shape.addVertex(0, 0.055000f, 0.258000f, true); - // 010: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.055000f, 0.319000f, false); - shape.addVertex(0, 0.072000f, 0.369000f, true); - // 012: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.090000f, 0.419000f, false); - shape.addVertex(0, 0.121000f, 0.454000f, true); - // 013: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.153000f, 0.490000f, false); - shape.addVertex(0, 0.196000f, 0.509000f, true); - // 014: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.239000f, 0.529000f, false); - shape.addVertex(0, 0.291000f, 0.529000f, true); - // 015: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.343000f, 0.529000f, false); - shape.addVertex(0, 0.386000f, 0.510000f, true); - // 017: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.429000f, 0.490000f, false); - shape.addVertex(0, 0.460000f, 0.455000f, true); - // 018: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.492000f, 0.419000f, false); - shape.addVertex(0, 0.509000f, 0.369000f, true); - // 019: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.527000f, 0.319000f, false); - shape.addVertex(0, 0.527000f, 0.258000f, true); - System.err.println("Glyph01UbuntuLight_o.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - // Outer shape: Winding.CW - // Moved into OutlineShape same-order -> Winding.CW -> ERROR (so we fix it in the end, see below) - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0.527000f, 0.258000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.527000f, 0.197000f, false); - shape.addVertex(0.510000f, 0.147000f, true); - // 002: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.492000f, 0.097000f, false); - shape.addVertex(0.461000f, 0.062000f, true); - // 003: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.429000f, 0.027000f, false); - shape.addVertex(0.386000f, 0.008000f, true); - // 004: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.343000f, -0.012000f, false); - shape.addVertex(0.291000f, -0.012000f, true); - // 005: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.239000f, -0.012000f, false); - shape.addVertex(0.196000f, 0.007000f, true); - // 007: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.153000f, 0.027000f, false); - shape.addVertex(0.122000f, 0.062000f, true); - // 008: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.090000f, 0.097000f, false); - shape.addVertex(0.073000f, 0.147000f, true); - // 009: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.055000f, 0.197000f, false); - shape.addVertex(0.055000f, 0.258000f, true); - // 010: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.055000f, 0.319000f, false); - shape.addVertex(0.072000f, 0.369000f, true); - // 012: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.090000f, 0.419000f, false); - shape.addVertex(0.121000f, 0.454000f, true); - // 013: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.153000f, 0.490000f, false); - shape.addVertex(0.196000f, 0.509000f, true); - // 014: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.239000f, 0.529000f, false); - shape.addVertex(0.291000f, 0.529000f, true); - // 015: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.343000f, 0.529000f, false); - shape.addVertex(0.386000f, 0.510000f, true); - // 017: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.429000f, 0.490000f, false); - shape.addVertex(0.460000f, 0.455000f, true); - // 018: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.492000f, 0.419000f, false); - shape.addVertex(0.509000f, 0.369000f, true); - // 019: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.527000f, 0.319000f, false); - shape.addVertex(0.527000f, 0.258000f, true); - System.err.println("Glyph01UbuntuLight_o.shape01b.1.winding_area: "+shape.getWindingOfLastOutline()); - shape.setWindingOfLastOutline(Winding.CCW); - System.err.println("Glyph01UbuntuLight_o.shape01b.2.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - - if( true ) { - // Original Inner shape: Winding.CCW - // Moved into OutlineShape reverse -> Winding.CW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.458000f, 0.258000f, true); - // 020: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.458000f, 0.355000f, false); - shape.addVertex(0, 0.413000f, 0.412000f, true); - // 022: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.368000f, 0.470000f, false); - shape.addVertex(0, 0.291000f, 0.470000f, true); - // 023: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.214000f, 0.470000f, false); - shape.addVertex(0, 0.169000f, 0.413000f, true); - // 025: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.124000f, 0.355000f, false); - shape.addVertex(0, 0.124000f, 0.258000f, true); - // 026: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.124000f, 0.161000f, false); - shape.addVertex(0, 0.169000f, 0.104000f, true); - // 028: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.214000f, 0.047000f, false); - shape.addVertex(0, 0.291000f, 0.047000f, true); - // 029: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.368000f, 0.047000f, false); - shape.addVertex(0, 0.413000f, 0.104000f, true); - // 031: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.458000f, 0.161000f, false); - shape.addVertex(0, 0.458000f, 0.258000f, true); - System.err.println("Glyph01UbuntuLight_o.shape02a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - // Inner shape: Winding.CCW - // Moved into OutlineShape same-order -> Winding.CCW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - - shape.addVertex(0.458000f, 0.258000f, true); - // 020: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.458000f, 0.355000f, false); - shape.addVertex(0.413000f, 0.412000f, true); - // 022: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.368000f, 0.470000f, false); - shape.addVertex(0.291000f, 0.470000f, true); - // 023: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.214000f, 0.470000f, false); - shape.addVertex(0.169000f, 0.413000f, true); - // 025: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.124000f, 0.355000f, false); - shape.addVertex(0.124000f, 0.258000f, true); - // 026: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.124000f, 0.161000f, false); - shape.addVertex(0.169000f, 0.104000f, true); - // 028: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.214000f, 0.047000f, false); - shape.addVertex(0.291000f, 0.047000f, true); - // 029: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.368000f, 0.047000f, false); - shape.addVertex(0.413000f, 0.104000f, true); - // 031: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.458000f, 0.161000f, false); - shape.addVertex(0.458000f, 0.258000f, true); - - System.err.println("Glyph01UbuntuLight_o.shape02b.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - // End Shape for Glyph 82 - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph02UbuntuLight_ae.java b/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph02UbuntuLight_ae.java deleted file mode 100644 index 0b024f970..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph02UbuntuLight_ae.java +++ /dev/null @@ -1,652 +0,0 @@ -/** - * Copyright 2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.testshapes; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent test object - * - Ubuntu-Light, lower case 'æ' - * - TTF Shape for Glyph 193 - */ -public class Glyph02UbuntuLight_ae extends UIShape { - - public Glyph02UbuntuLight_ae(final Factory factory, final int renderModes) { - super(factory, renderModes); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @SuppressWarnings("unused") - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - // Ubuntu-Light, lower case 'æ' - - // Start TTF Shape for Glyph 193 - if( true ) { - // Original Inner e-shape: Winding.CCW - // Moved into OutlineShape reverse -> Winding.CW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.728000f, 0.300000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.726000f, 0.381000f, false); - shape.addVertex(0, 0.690000f, 0.426000f, true); - // 002: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.654000f, 0.471000f, false); - shape.addVertex(0, 0.588000f, 0.471000f, true); - // 003: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.553000f, 0.471000f, false); - shape.addVertex(0, 0.526000f, 0.457000f, true); - // 005: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.498000f, 0.443000f, false); - shape.addVertex(0, 0.478000f, 0.420000f, true); - // 006: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.457000f, 0.396000f, false); - shape.addVertex(0, 0.446000f, 0.365000f, true); - // 007: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.434000f, 0.334000f, false); - shape.addVertex(0, 0.432000f, 0.300000f, true); - // 008: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.728000f, 0.300000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - // Inner e-shape: Winding.CCW - // Moved into OutlineShape same-order -> Winding.CCW -> ?? - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0.728000f, 0.300000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.726000f, 0.381000f, false); - shape.addVertex(0.690000f, 0.426000f, true); - // 002: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.654000f, 0.471000f, false); - shape.addVertex(0.588000f, 0.471000f, true); - // 003: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.553000f, 0.471000f, false); - shape.addVertex(0.526000f, 0.457000f, true); - // 005: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.498000f, 0.443000f, false); - shape.addVertex(0.478000f, 0.420000f, true); - // 006: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.457000f, 0.396000f, false); - shape.addVertex(0.446000f, 0.365000f, true); - // 007: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.434000f, 0.334000f, false); - shape.addVertex(0.432000f, 0.300000f, true); - // 008: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0.728000f, 0.300000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape01b.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - - if( true ) { - // Original Outer shape: Winding.CW - // Moved into OutlineShape reverse -> Winding.CCW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.252000f, -0.011000f, true); - // 009: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.208000f, -0.011000f, false); - shape.addVertex(0, 0.171000f, -0.002000f, true); - // 011: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.133000f, 0.007000f, false); - shape.addVertex(0, 0.106000f, 0.026000f, true); - // 012: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.079000f, 0.046000f, false); - shape.addVertex(0, 0.064000f, 0.076000f, true); - // 013: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.048000f, 0.107000f, false); - shape.addVertex(0, 0.048000f, 0.151000f, true); - // 014: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.048000f, 0.193000f, false); - shape.addVertex(0, 0.064000f, 0.223000f, true); - // 016: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.080000f, 0.253000f, false); - shape.addVertex(0, 0.109000f, 0.272000f, true); - // 017: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.138000f, 0.292000f, false); - shape.addVertex(0, 0.178000f, 0.301000f, true); - // 018: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.218000f, 0.310000f, false); - shape.addVertex(0, 0.265000f, 0.310000f, true); - // 019: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.279000f, 0.310000f, false); - shape.addVertex(0, 0.294000f, 0.309000f, true); - // 021: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.310000f, 0.307000f, false); - shape.addVertex(0, 0.324000f, 0.305000f, true); - // 022: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.339000f, 0.302000f, false); - shape.addVertex(0, 0.349000f, 0.300000f, true); - // 023: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.360000f, 0.297000f, false); - shape.addVertex(0, 0.364000f, 0.295000f, true); - // 024: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.364000f, 0.327000f, true); - // 025: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.364000f, 0.354000f, false); - shape.addVertex(0, 0.360000f, 0.379000f, true); - // 027: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.356000f, 0.405000f, false); - shape.addVertex(0, 0.343000f, 0.425000f, true); - // 028: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.329000f, 0.446000f, false); - shape.addVertex(0, 0.305000f, 0.458000f, true); - // 029: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.280000f, 0.471000f, false); - shape.addVertex(0, 0.240000f, 0.471000f, true); - // 030: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.186000f, 0.471000f, false); - shape.addVertex(0, 0.156000f, 0.464000f, true); - // 032: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.126000f, 0.456000f, false); - shape.addVertex(0, 0.113000f, 0.451000f, true); - // 033: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.105000f, 0.507000f, true); - // 034: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.122000f, 0.515000f, false); - shape.addVertex(0, 0.158000f, 0.522000f, true); - // 036: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.194000f, 0.529000f, false); - shape.addVertex(0, 0.243000f, 0.529000f, true); - // 037: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.314000f, 0.529000f, false); - shape.addVertex(0, 0.354000f, 0.503000f, true); - // 039: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.395000f, 0.476000f, false); - shape.addVertex(0, 0.412000f, 0.431000f, true); - // 040: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.445000f, 0.480000f, false); - shape.addVertex(0, 0.491000f, 0.504000f, true); - // 042: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.537000f, 0.529000f, false); - shape.addVertex(0, 0.587000f, 0.529000f, true); - // 043: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.682000f, 0.529000f, false); - shape.addVertex(0, 0.738000f, 0.467000f, true); - // 045: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.795000f, 0.405000f, false); - shape.addVertex(0, 0.795000f, 0.276000f, true); - // 046: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.795000f, 0.268000f, false); - shape.addVertex(0, 0.795000f, 0.260000f, true); - // 048: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.794000f, 0.252000f, false); - shape.addVertex(0, 0.793000f, 0.245000f, true); - // 049: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.430000f, 0.245000f, true); - // 050: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.433000f, 0.150000f, false); - shape.addVertex(0, 0.477000f, 0.099000f, true); - // 052: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.521000f, 0.048000f, false); - shape.addVertex(0, 0.617000f, 0.048000f, true); - // 053: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.670000f, 0.048000f, false); - shape.addVertex(0, 0.701000f, 0.058000f, true); - // 055: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.732000f, 0.068000f, false); - shape.addVertex(0, 0.746000f, 0.075000f, true); - // 056: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.758000f, 0.019000f, true); - // 057: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.744000f, 0.011000f, false); - shape.addVertex(0, 0.706000f, 0.000000f, true); - // 059: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.667000f, -0.011000f, false); - shape.addVertex(0, 0.615000f, -0.011000f, true); - // 060: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.558000f, -0.011000f, false); - shape.addVertex(0, 0.514000f, 0.003000f, true); - // 062: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.470000f, 0.017000f, false); - shape.addVertex(0, 0.437000f, 0.049000f, true); - // 063: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.426000f, 0.040000f, false); - shape.addVertex(0, 0.410000f, 0.030000f, true); - // 065: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.393000f, 0.019000f, false); - shape.addVertex(0, 0.370000f, 0.010000f, true); - // 066: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.347000f, 0.001000f, false); - shape.addVertex(0, 0.318000f, -0.005000f, true); - // 067: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.289000f, -0.011000f, false); - shape.addVertex(0, 0.252000f, -0.011000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape02a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - // Outer shape: Winding.CW - // Moved into OutlineShape same-order -> Winding.CW -> OK now - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0.252000f, -0.011000f, true); - // 009: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.208000f, -0.011000f, false); - shape.addVertex(0.171000f, -0.002000f, true); - // 011: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.133000f, 0.007000f, false); - shape.addVertex(0.106000f, 0.026000f, true); - // 012: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.079000f, 0.046000f, false); - shape.addVertex(0.064000f, 0.076000f, true); - // 013: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.048000f, 0.107000f, false); - shape.addVertex(0.048000f, 0.151000f, true); - // 014: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.048000f, 0.193000f, false); - shape.addVertex(0.064000f, 0.223000f, true); - // 016: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.080000f, 0.253000f, false); - shape.addVertex(0.109000f, 0.272000f, true); - // 017: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.138000f, 0.292000f, false); - shape.addVertex(0.178000f, 0.301000f, true); - // 018: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.218000f, 0.310000f, false); - shape.addVertex(0.265000f, 0.310000f, true); - // 019: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.279000f, 0.310000f, false); - shape.addVertex(0.294000f, 0.309000f, true); - // 021: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.310000f, 0.307000f, false); - shape.addVertex(0.324000f, 0.305000f, true); - // 022: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.339000f, 0.302000f, false); - shape.addVertex(0.349000f, 0.300000f, true); - // 023: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.360000f, 0.297000f, false); - shape.addVertex(0.364000f, 0.295000f, true); - // 024: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0.364000f, 0.327000f, true); - // 025: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.364000f, 0.354000f, false); - shape.addVertex(0.360000f, 0.379000f, true); - // 027: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.356000f, 0.405000f, false); - shape.addVertex(0.343000f, 0.425000f, true); - // 028: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.329000f, 0.446000f, false); - shape.addVertex(0.305000f, 0.458000f, true); - // 029: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.280000f, 0.471000f, false); - shape.addVertex(0.240000f, 0.471000f, true); - // 030: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.186000f, 0.471000f, false); - shape.addVertex(0.156000f, 0.464000f, true); - // 032: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.126000f, 0.456000f, false); - shape.addVertex(0.113000f, 0.451000f, true); - // 033: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0.105000f, 0.507000f, true); - // 034: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.122000f, 0.515000f, false); - shape.addVertex(0.158000f, 0.522000f, true); - // 036: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.194000f, 0.529000f, false); - shape.addVertex(0.243000f, 0.529000f, true); - // 037: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.314000f, 0.529000f, false); - shape.addVertex(0.354000f, 0.503000f, true); - // 039: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.395000f, 0.476000f, false); - shape.addVertex(0.412000f, 0.431000f, true); - // 040: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.445000f, 0.480000f, false); - shape.addVertex(0.491000f, 0.504000f, true); - // 042: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.537000f, 0.529000f, false); - shape.addVertex(0.587000f, 0.529000f, true); - // 043: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.682000f, 0.529000f, false); - shape.addVertex(0.738000f, 0.467000f, true); - // 045: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.795000f, 0.405000f, false); - shape.addVertex(0.795000f, 0.276000f, true); - // 046: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.795000f, 0.268000f, false); - shape.addVertex(0.795000f, 0.260000f, true); - // 048: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.794000f, 0.252000f, false); - shape.addVertex(0.793000f, 0.245000f, true); - // 049: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0.430000f, 0.245000f, true); - // 050: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.433000f, 0.150000f, false); - shape.addVertex(0.477000f, 0.099000f, true); - // 052: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.521000f, 0.048000f, false); - shape.addVertex(0.617000f, 0.048000f, true); - // 053: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.670000f, 0.048000f, false); - shape.addVertex(0.701000f, 0.058000f, true); - // 055: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.732000f, 0.068000f, false); - shape.addVertex(0.746000f, 0.075000f, true); - // 056: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0.758000f, 0.019000f, true); - // 057: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.744000f, 0.011000f, false); - shape.addVertex(0.706000f, 0.000000f, true); - // 059: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.667000f, -0.011000f, false); - shape.addVertex(0.615000f, -0.011000f, true); - // 060: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.558000f, -0.011000f, false); - shape.addVertex(0.514000f, 0.003000f, true); - // 062: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.470000f, 0.017000f, false); - shape.addVertex(0.437000f, 0.049000f, true); - // 063: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.426000f, 0.040000f, false); - shape.addVertex(0.410000f, 0.030000f, true); - // 065: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.393000f, 0.019000f, false); - shape.addVertex(0.370000f, 0.010000f, true); - // 066: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.347000f, 0.001000f, false); - shape.addVertex(0.318000f, -0.005000f, true); - // 067: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.289000f, -0.011000f, false); - shape.addVertex(0.252000f, -0.011000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape02b.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - - if( true ) { - // Original Inner a-shape: Winding.CCW - // Moved into OutlineShape reverse -> Winding.CW -> OK now - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.365000f, 0.238000f, true); - // 068: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.354000f, 0.243000f, false); - shape.addVertex(0, 0.330000f, 0.248000f, true); - // 070: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.305000f, 0.254000f, false); - shape.addVertex(0, 0.263000f, 0.254000f, true); - // 071: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.239000f, 0.254000f, false); - shape.addVertex(0, 0.213000f, 0.251000f, true); - // 073: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.187000f, 0.247000f, false); - shape.addVertex(0, 0.165000f, 0.236000f, true); - // 074: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.143000f, 0.224000f, false); - shape.addVertex(0, 0.129000f, 0.204000f, true); - // 075: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.115000f, 0.184000f, false); - shape.addVertex(0, 0.115000f, 0.151000f, true); - // 076: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.115000f, 0.122000f, false); - shape.addVertex(0, 0.125000f, 0.102000f, true); - // 078: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.135000f, 0.082000f, false); - shape.addVertex(0, 0.153000f, 0.070000f, true); - // 079: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.172000f, 0.058000f, false); - shape.addVertex(0, 0.197000f, 0.053000f, true); - // 080: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.222000f, 0.047000f, false); - shape.addVertex(0, 0.252000f, 0.047000f, true); - // 081: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.314000f, 0.047000f, false); - shape.addVertex(0, 0.350000f, 0.063000f, true); - // 083: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.386000f, 0.080000f, false); - shape.addVertex(0, 0.400000f, 0.093000f, true); - // 084: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.384000f, 0.119000f, false); - shape.addVertex(0, 0.375000f, 0.154000f, true); - // 086: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.366000f, 0.190000f, false); - shape.addVertex(0, 0.365000f, 0.238000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape03a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - // Inner a-shape: Winding.CCW - // Moved into OutlineShape same-order -> Winding.CCW -> OK - // - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0.365000f, 0.238000f, true); - // 068: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.354000f, 0.243000f, false); - shape.addVertex(0.330000f, 0.248000f, true); - // 070: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.305000f, 0.254000f, false); - shape.addVertex(0.263000f, 0.254000f, true); - // 071: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.239000f, 0.254000f, false); - shape.addVertex(0.213000f, 0.251000f, true); - // 073: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.187000f, 0.247000f, false); - shape.addVertex(0.165000f, 0.236000f, true); - // 074: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.143000f, 0.224000f, false); - shape.addVertex(0.129000f, 0.204000f, true); - // 075: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.115000f, 0.184000f, false); - shape.addVertex(0.115000f, 0.151000f, true); - // 076: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.115000f, 0.122000f, false); - shape.addVertex(0.125000f, 0.102000f, true); - // 078: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.135000f, 0.082000f, false); - shape.addVertex(0.153000f, 0.070000f, true); - // 079: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0.172000f, 0.058000f, false); - shape.addVertex(0.197000f, 0.053000f, true); - // 080: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.222000f, 0.047000f, false); - shape.addVertex(0.252000f, 0.047000f, true); - // 081: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.314000f, 0.047000f, false); - shape.addVertex(0.350000f, 0.063000f, true); - // 083: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.386000f, 0.080000f, false); - shape.addVertex(0.400000f, 0.093000f, true); - // 084: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0.384000f, 0.119000f, false); - shape.addVertex(0.375000f, 0.154000f, true); - // 086: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0.366000f, 0.190000f, false); - shape.addVertex(0.365000f, 0.238000f, true); - System.err.println("Glyph02UbuntuLight_ae.shape03b.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - // End Shape for Glyph 193 - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph03FreeMonoRegular_M.java b/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph03FreeMonoRegular_M.java deleted file mode 100644 index 55fc7609e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph03FreeMonoRegular_M.java +++ /dev/null @@ -1,804 +0,0 @@ -/** - * Copyright 2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.testshapes; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent test object - * - FreeMono-Regular, capital case 'M' - * - TTF Shape for Glyph 48 - */ -public class Glyph03FreeMonoRegular_M extends UIShape { - - public Glyph03FreeMonoRegular_M(final Factory factory, final int renderModes) { - super(factory, renderModes); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @SuppressWarnings("unused") - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - if( false ) { - // Start TTF Shape for Glyph 48 - // GlyphShape<48>: offset 0 of 45/45 points - // pM[044] P[483/522, on true, end true] - // p0[000] P[326/169, on true, end false] - // p1[001] P[280/169, on true, end false] - // p2[002] P[121/522, on true, end false] - // 000: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.326000f, 0.169000f, true); - // 000: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.280000f, 0.169000f, true); - // GlyphShape<48>: offset 1 of 45/45 points - // pM[000] P[326/169, on true, end false] - // p0[001] P[280/169, on true, end false] - // p1[002] P[121/522, on true, end false] - // p2[003] P[113/522, on true, end false] - // 001: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.121000f, 0.522000f, true); - // GlyphShape<48>: offset 2 of 45/45 points - // pM[001] P[280/169, on true, end false] - // p0[002] P[121/522, on true, end false] - // p1[003] P[113/522, on true, end false] - // p2[004] P[113/41, on true, end false] - // 002: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.113000f, 0.522000f, true); - // GlyphShape<48>: offset 3 of 45/45 points - // pM[002] P[121/522, on true, end false] - // p0[003] P[113/522, on true, end false] - // p1[004] P[113/41, on true, end false] - // p2[005] P[187/41, on true, end false] - // 003: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.113000f, 0.041000f, true); - // GlyphShape<48>: offset 4 of 45/45 points - // pM[003] P[113/522, on true, end false] - // p0[004] P[113/41, on true, end false] - // p1[005] P[187/41, on true, end false] - // p2[006] P[215/41, on false, end false] - // 004: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.187000f, 0.041000f, true); - // GlyphShape<48>: offset 5 of 45/45 points - // pM[004] P[113/41, on true, end false] - // p0[005] P[187/41, on true, end false] - // p1[006] P[215/41, on false, end false] - // p2[007] P[215/21, on true, end false] - // 005: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.215000f, 0.041000f, false); - shape.addVertex(0, 0.215000f, 0.021000f, true); - // GlyphShape<48>: offset 7 of 45/45 points - // pM[006] P[215/41, on false, end false] - // p0[007] P[215/21, on true, end false] - // p1[008] P[215/0, on false, end false] - // p2[009] P[187/0, on true, end false] - // 007: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.215000f, 0.000000f, false); - shape.addVertex(0, 0.187000f, 0.000000f, true); - // GlyphShape<48>: offset 9 of 45/45 points - // pM[008] P[215/0, on false, end false] - // p0[009] P[187/0, on true, end false] - // p1[010] P[38/0, on true, end false] - // p2[011] P[11/0, on false, end false] - // 009: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.038000f, 0.000000f, true); - // GlyphShape<48>: offset 10 of 45/45 points - // pM[009] P[187/0, on true, end false] - // p0[010] P[38/0, on true, end false] - // p1[011] P[11/0, on false, end false] - // p2[012] P[11/21, on true, end false] - // 010: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.011000f, 0.000000f, false); - shape.addVertex(0, 0.011000f, 0.021000f, true); - // GlyphShape<48>: offset 12 of 45/45 points - // pM[011] P[11/0, on false, end false] - // p0[012] P[11/21, on true, end false] - // p1[013] P[11/41, on false, end false] - // p2[014] P[38/41, on true, end false] - // 012: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.011000f, 0.041000f, false); - shape.addVertex(0, 0.038000f, 0.041000f, true); - // GlyphShape<48>: offset 14 of 45/45 points - // pM[013] P[11/41, on false, end false] - // p0[014] P[38/41, on true, end false] - // p1[015] P[72/41, on true, end false] - // p2[016] P[72/522, on true, end false] - // 014: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.072000f, 0.041000f, true); - // GlyphShape<48>: offset 15 of 45/45 points - // pM[014] P[38/41, on true, end false] - // p0[015] P[72/41, on true, end false] - // p1[016] P[72/522, on true, end false] - // p2[017] P[47/522, on true, end false] - // 015: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.072000f, 0.522000f, true); - // GlyphShape<48>: offset 16 of 45/45 points - // pM[015] P[72/41, on true, end false] - // p0[016] P[72/522, on true, end false] - // p1[017] P[47/522, on true, end false] - // p2[018] P[20/522, on false, end false] - // 016: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.047000f, 0.522000f, true); - // GlyphShape<48>: offset 17 of 45/45 points - // pM[016] P[72/522, on true, end false] - // p0[017] P[47/522, on true, end false] - // p1[018] P[20/522, on false, end false] - // p2[019] P[20/543, on true, end false] - // 017: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.522000f, false); - shape.addVertex(0, 0.020000f, 0.543000f, true); - // GlyphShape<48>: offset 19 of 45/45 points - // pM[018] P[20/522, on false, end false] - // p0[019] P[20/543, on true, end false] - // p1[020] P[20/563, on false, end false] - // p2[021] P[47/563, on true, end false] - // 019: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.563000f, false); - shape.addVertex(0, 0.047000f, 0.563000f, true); - // GlyphShape<48>: offset 21 of 45/45 points - // pM[020] P[20/563, on false, end false] - // p0[021] P[47/563, on true, end false] - // p1[022] P[146/563, on true, end false] - // p2[023] P[303/215, on true, end false] - // 021: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.146000f, 0.563000f, true); - // GlyphShape<48>: offset 22 of 45/45 points - // pM[021] P[47/563, on true, end false] - // p0[022] P[146/563, on true, end false] - // p1[023] P[303/215, on true, end false] - // p2[024] P[457/563, on true, end false] - // 022: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.303000f, 0.215000f, true); - // GlyphShape<48>: offset 23 of 45/45 points - // pM[022] P[146/563, on true, end false] - // p0[023] P[303/215, on true, end false] - // p1[024] P[457/563, on true, end false] - // p2[025] P[557/563, on true, end false] - // 023: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.457000f, 0.563000f, true); - // GlyphShape<48>: offset 24 of 45/45 points - // pM[023] P[303/215, on true, end false] - // p0[024] P[457/563, on true, end false] - // p1[025] P[557/563, on true, end false] - // p2[026] P[584/563, on false, end false] - // 024: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.557000f, 0.563000f, true); - // GlyphShape<48>: offset 25 of 45/45 points - // pM[024] P[457/563, on true, end false] - // p0[025] P[557/563, on true, end false] - // p1[026] P[584/563, on false, end false] - // p2[027] P[584/543, on true, end false] - // 025: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.584000f, 0.563000f, false); - shape.addVertex(0, 0.584000f, 0.543000f, true); - // GlyphShape<48>: offset 27 of 45/45 points - // pM[026] P[584/563, on false, end false] - // p0[027] P[584/543, on true, end false] - // p1[028] P[584/522, on false, end false] - // p2[029] P[557/522, on true, end false] - // 027: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.584000f, 0.522000f, false); - shape.addVertex(0, 0.557000f, 0.522000f, true); - // GlyphShape<48>: offset 29 of 45/45 points - // pM[028] P[584/522, on false, end false] - // p0[029] P[557/522, on true, end false] - // p1[030] P[532/522, on true, end false] - // p2[031] P[532/41, on true, end false] - // 029: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.532000f, 0.522000f, true); - // GlyphShape<48>: offset 30 of 45/45 points - // pM[029] P[557/522, on true, end false] - // p0[030] P[532/522, on true, end false] - // p1[031] P[532/41, on true, end false] - // p2[032] P[566/41, on true, end false] - // 030: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.532000f, 0.041000f, true); - // GlyphShape<48>: offset 31 of 45/45 points - // pM[030] P[532/522, on true, end false] - // p0[031] P[532/41, on true, end false] - // p1[032] P[566/41, on true, end false] - // p2[033] P[593/41, on false, end false] - // 031: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.566000f, 0.041000f, true); - // GlyphShape<48>: offset 32 of 45/45 points - // pM[031] P[532/41, on true, end false] - // p0[032] P[566/41, on true, end false] - // p1[033] P[593/41, on false, end false] - // p2[034] P[593/21, on true, end false] - // 032: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.593000f, 0.041000f, false); - shape.addVertex(0, 0.593000f, 0.021000f, true); - // GlyphShape<48>: offset 34 of 45/45 points - // pM[033] P[593/41, on false, end false] - // p0[034] P[593/21, on true, end false] - // p1[035] P[593/0, on false, end false] - // p2[036] P[566/0, on true, end false] - // 034: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.593000f, 0.000000f, false); - shape.addVertex(0, 0.566000f, 0.000000f, true); - // GlyphShape<48>: offset 36 of 45/45 points - // pM[035] P[593/0, on false, end false] - // p0[036] P[566/0, on true, end false] - // p1[037] P[417/0, on true, end false] - // p2[038] P[390/0, on false, end false] - // 036: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.417000f, 0.000000f, true); - // GlyphShape<48>: offset 37 of 45/45 points - // pM[036] P[566/0, on true, end false] - // p0[037] P[417/0, on true, end false] - // p1[038] P[390/0, on false, end false] - // p2[039] P[390/21, on true, end false] - // 037: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.390000f, 0.000000f, false); - shape.addVertex(0, 0.390000f, 0.021000f, true); - // GlyphShape<48>: offset 39 of 45/45 points - // pM[038] P[390/0, on false, end false] - // p0[039] P[390/21, on true, end false] - // p1[040] P[390/41, on false, end false] - // p2[041] P[417/41, on true, end false] - // 039: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.390000f, 0.041000f, false); - shape.addVertex(0, 0.417000f, 0.041000f, true); - // GlyphShape<48>: offset 41 of 45/45 points - // pM[040] P[390/41, on false, end false] - // p0[041] P[417/41, on true, end false] - // p1[042] P[491/41, on true, end false] - // p2[043] P[491/522, on true, end false] - // 041: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.491000f, 0.041000f, true); - // GlyphShape<48>: offset 42 of 45/45 points - // pM[041] P[417/41, on true, end false] - // p0[042] P[491/41, on true, end false] - // p1[043] P[491/522, on true, end false] - // p2[044] P[483/522, on true, end true] - // 042: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.491000f, 0.522000f, true); - // GlyphShape<48>: offset 43 of 45/45 points - // pM[042] P[491/41, on true, end false] - // p0[043] P[491/522, on true, end false] - // p1[044] P[483/522, on true, end true] - // p2[000] P[326/169, on true, end false] - // 043: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.483000f, 0.522000f, true); - // GlyphShape<48>: offset 44 of 45/45 points - // pM[043] P[491/522, on true, end false] - // p0[044] P[483/522, on true, end true] - // p1[000] P[326/169, on true, end false] - // p2[001] P[280/169, on true, end false] - // 044: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.326000f, 0.169000f, true); - System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - - // End Shape for Glyph 48 - } else if( false ) { - // Start TTF Shape for Glyph 48 - // GlyphShape<48>: offset 0 of 45/45 points - // pM[044] P[483/522, on true, end true] - // p0[000] P[326/169, on true, end false] - // p1[001] P[280/169, on true, end false] - // p2[002] P[121/522, on true, end false] - // 000: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.326000f, 0.169000f, true); - // 000: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.280000f, 0.169000f, true); - // GlyphShape<48>: offset 1 of 45/45 points - // pM[000] P[326/169, on true, end false] - // p0[001] P[280/169, on true, end false] - // p1[002] P[121/522, on true, end false] - // p2[003] P[113/522, on true, end false] - // 001: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.121000f, 0.522000f, true); - // GlyphShape<48>: offset 2 of 45/45 points - // pM[001] P[280/169, on true, end false] - // p0[002] P[121/522, on true, end false] - // p1[003] P[113/522, on true, end false] - // p2[004] P[113/41, on true, end false] - // 002: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.113000f, 0.522000f, true); - // GlyphShape<48>: offset 3 of 45/45 points - // pM[002] P[121/522, on true, end false] - // p0[003] P[113/522, on true, end false] - // p1[004] P[113/41, on true, end false] - // p2[005] P[187/41, on true, end false] - // 003: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.113000f, 0.041000f, true); - // GlyphShape<48>: offset 4 of 45/45 points - // pM[003] P[113/522, on true, end false] - // p0[004] P[113/41, on true, end false] - // p1[005] P[187/41, on true, end false] - // p2[006] P[215/41, on false, end false] - // 004: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.187000f, 0.041000f, true); - // GlyphShape<48>: offset 5 of 45/45 points - // pM[004] P[113/41, on true, end false] - // p0[005] P[187/41, on true, end false] - // p1[006] P[215/41, on false, end false] - // p2[007] P[215/21, on true, end false] - // 005: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.215000f, 0.041000f, true); // curve -> line - shape.addVertex(0, 0.215000f, 0.021000f, true); - // GlyphShape<48>: offset 7 of 45/45 points - // pM[006] P[215/41, on false, end false] - // p0[007] P[215/21, on true, end false] - // p1[008] P[215/0, on false, end false] - // p2[009] P[187/0, on true, end false] - // 007: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.215000f, 0.000000f, true); // curve -> line - shape.addVertex(0, 0.187000f, 0.000000f, true); - // GlyphShape<48>: offset 9 of 45/45 points - // pM[008] P[215/0, on false, end false] - // p0[009] P[187/0, on true, end false] - // p1[010] P[38/0, on true, end false] - // p2[011] P[11/0, on false, end false] - // 009: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.038000f, 0.000000f, true); - // GlyphShape<48>: offset 10 of 45/45 points - // pM[009] P[187/0, on true, end false] - // p0[010] P[38/0, on true, end false] - // p1[011] P[11/0, on false, end false] - // p2[012] P[11/21, on true, end false] - // 010: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.011000f, 0.000000f, true); // curve -> line - shape.addVertex(0, 0.011000f, 0.021000f, true); - // GlyphShape<48>: offset 12 of 45/45 points - // pM[011] P[11/0, on false, end false] - // p0[012] P[11/21, on true, end false] - // p1[013] P[11/41, on false, end false] - // p2[014] P[38/41, on true, end false] - // 012: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.011000f, 0.041000f, true); // curve -> line - shape.addVertex(0, 0.038000f, 0.041000f, true); - // GlyphShape<48>: offset 14 of 45/45 points - // pM[013] P[11/41, on false, end false] - // p0[014] P[38/41, on true, end false] - // p1[015] P[72/41, on true, end false] - // p2[016] P[72/522, on true, end false] - // 014: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.072000f, 0.041000f, true); - // GlyphShape<48>: offset 15 of 45/45 points - // pM[014] P[38/41, on true, end false] - // p0[015] P[72/41, on true, end false] - // p1[016] P[72/522, on true, end false] - // p2[017] P[47/522, on true, end false] - // 015: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.072000f, 0.522000f, true); - // GlyphShape<48>: offset 16 of 45/45 points - // pM[015] P[72/41, on true, end false] - // p0[016] P[72/522, on true, end false] - // p1[017] P[47/522, on true, end false] - // p2[018] P[20/522, on false, end false] - // 016: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.047000f, 0.522000f, true); - // GlyphShape<48>: offset 17 of 45/45 points - // pM[016] P[72/522, on true, end false] - // p0[017] P[47/522, on true, end false] - // p1[018] P[20/522, on false, end false] - // p2[019] P[20/543, on true, end false] - // 017: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.522000f, true); // curve -> line - shape.addVertex(0, 0.020000f, 0.543000f, true); - // GlyphShape<48>: offset 19 of 45/45 points - // pM[018] P[20/522, on false, end false] - // p0[019] P[20/543, on true, end false] - // p1[020] P[20/563, on false, end false] - // p2[021] P[47/563, on true, end false] - // 019: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.563000f, true); // curve -> line - shape.addVertex(0, 0.047000f, 0.563000f, true); - // GlyphShape<48>: offset 21 of 45/45 points - // pM[020] P[20/563, on false, end false] - // p0[021] P[47/563, on true, end false] - // p1[022] P[146/563, on true, end false] - // p2[023] P[303/215, on true, end false] - // 021: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.146000f, 0.563000f, true); - // GlyphShape<48>: offset 22 of 45/45 points - // pM[021] P[47/563, on true, end false] - // p0[022] P[146/563, on true, end false] - // p1[023] P[303/215, on true, end false] - // p2[024] P[457/563, on true, end false] - // 022: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.303000f, 0.215000f, true); - // GlyphShape<48>: offset 23 of 45/45 points - // pM[022] P[146/563, on true, end false] - // p0[023] P[303/215, on true, end false] - // p1[024] P[457/563, on true, end false] - // p2[025] P[557/563, on true, end false] - // 023: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.457000f, 0.563000f, true); - // GlyphShape<48>: offset 24 of 45/45 points - // pM[023] P[303/215, on true, end false] - // p0[024] P[457/563, on true, end false] - // p1[025] P[557/563, on true, end false] - // p2[026] P[584/563, on false, end false] - // 024: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.557000f, 0.563000f, true); - // GlyphShape<48>: offset 25 of 45/45 points - // pM[024] P[457/563, on true, end false] - // p0[025] P[557/563, on true, end false] - // p1[026] P[584/563, on false, end false] - // p2[027] P[584/543, on true, end false] - // 025: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.584000f, 0.563000f, true); // curve -> line - shape.addVertex(0, 0.584000f, 0.543000f, true); - // GlyphShape<48>: offset 27 of 45/45 points - // pM[026] P[584/563, on false, end false] - // p0[027] P[584/543, on true, end false] - // p1[028] P[584/522, on false, end false] - // p2[029] P[557/522, on true, end false] - // 027: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.584000f, 0.522000f, true); // curve -> line - shape.addVertex(0, 0.557000f, 0.522000f, true); - // GlyphShape<48>: offset 29 of 45/45 points - // pM[028] P[584/522, on false, end false] - // p0[029] P[557/522, on true, end false] - // p1[030] P[532/522, on true, end false] - // p2[031] P[532/41, on true, end false] - // 029: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.532000f, 0.522000f, true); - // GlyphShape<48>: offset 30 of 45/45 points - // pM[029] P[557/522, on true, end false] - // p0[030] P[532/522, on true, end false] - // p1[031] P[532/41, on true, end false] - // p2[032] P[566/41, on true, end false] - // 030: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.532000f, 0.041000f, true); - // GlyphShape<48>: offset 31 of 45/45 points - // pM[030] P[532/522, on true, end false] - // p0[031] P[532/41, on true, end false] - // p1[032] P[566/41, on true, end false] - // p2[033] P[593/41, on false, end false] - // 031: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.566000f, 0.041000f, true); - // GlyphShape<48>: offset 32 of 45/45 points - // pM[031] P[532/41, on true, end false] - // p0[032] P[566/41, on true, end false] - // p1[033] P[593/41, on false, end false] - // p2[034] P[593/21, on true, end false] - // 032: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.593000f, 0.041000f, true); // curve -> line - shape.addVertex(0, 0.593000f, 0.021000f, true); - // GlyphShape<48>: offset 34 of 45/45 points - // pM[033] P[593/41, on false, end false] - // p0[034] P[593/21, on true, end false] - // p1[035] P[593/0, on false, end false] - // p2[036] P[566/0, on true, end false] - // 034: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.593000f, 0.000000f, true); // curve -> line - shape.addVertex(0, 0.566000f, 0.000000f, true); - // GlyphShape<48>: offset 36 of 45/45 points - // pM[035] P[593/0, on false, end false] - // p0[036] P[566/0, on true, end false] - // p1[037] P[417/0, on true, end false] - // p2[038] P[390/0, on false, end false] - // 036: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.417000f, 0.000000f, true); - // GlyphShape<48>: offset 37 of 45/45 points - // pM[036] P[566/0, on true, end false] - // p0[037] P[417/0, on true, end false] - // p1[038] P[390/0, on false, end false] - // p2[039] P[390/21, on true, end false] - // 037: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.390000f, 0.000000f, true); // curve -> line - shape.addVertex(0, 0.390000f, 0.021000f, true); - // GlyphShape<48>: offset 39 of 45/45 points - // pM[038] P[390/0, on false, end false] - // p0[039] P[390/21, on true, end false] - // p1[040] P[390/41, on false, end false] - // p2[041] P[417/41, on true, end false] - // 039: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.390000f, 0.041000f, true); // curve -> line - shape.addVertex(0, 0.417000f, 0.041000f, true); - // GlyphShape<48>: offset 41 of 45/45 points - // pM[040] P[390/41, on false, end false] - // p0[041] P[417/41, on true, end false] - // p1[042] P[491/41, on true, end false] - // p2[043] P[491/522, on true, end false] - // 041: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.491000f, 0.041000f, true); - // GlyphShape<48>: offset 42 of 45/45 points - // pM[041] P[417/41, on true, end false] - // p0[042] P[491/41, on true, end false] - // p1[043] P[491/522, on true, end false] - // p2[044] P[483/522, on true, end true] - // 042: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.491000f, 0.522000f, true); - // GlyphShape<48>: offset 43 of 45/45 points - // pM[042] P[491/41, on true, end false] - // p0[043] P[491/522, on true, end false] - // p1[044] P[483/522, on true, end true] - // p2[000] P[326/169, on true, end false] - // 043: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.483000f, 0.522000f, true); - // GlyphShape<48>: offset 44 of 45/45 points - // pM[043] P[491/522, on true, end false] - // p0[044] P[483/522, on true, end true] - // p1[000] P[326/169, on true, end false] - // p2[001] P[280/169, on true, end false] - // 044: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.326000f, 0.169000f, true); - System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } else { - final boolean with_left_leg = true; // ERROR - final boolean with_right_leg = false; // OK - - // Start TTF Shape for Glyph 48 - // GlyphShape<48>: offset 0 of 45/45 points - // pM[044] P[483/522, on true, end true] - // p0[000] P[326/169, on true, end false] - // p1[001] P[280/169, on true, end false] - // p2[002] P[121/522, on true, end false] - // 000: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.326000f, 0.169000f, true); - // 000: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.280000f, 0.169000f, true); - // GlyphShape<48>: offset 1 of 45/45 points - // pM[000] P[326/169, on true, end false] - // p0[001] P[280/169, on true, end false] - // p1[002] P[121/522, on true, end false] - // p2[003] P[113/522, on true, end false] - // 001: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.121000f, 0.522000f, true); // ID 11 - - // GlyphShape<48>: offset 2 of 45/45 points - // pM[001] P[280/169, on true, end false] - // p0[002] P[121/522, on true, end false] - // p1[003] P[113/522, on true, end false] - // p2[004] P[113/41, on true, end false] - // 002: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.113000f, 0.522000f, true); - - if( with_left_leg ) { - // GlyphShape<48>: offset 3 of 45/45 points - // pM[002] P[121/522, on true, end false] - // p0[003] P[113/522, on true, end false] - // p1[004] P[113/41, on true, end false] - // p2[005] P[187/41, on true, end false] - // 003: B1: line-to p0-p1 - // Shape.LineTo: - // shape.addVertex(0, 0.113000f, 0.041000f, true); - - shape.addVertex(0, 0.113000f, 0.000000f, true); - shape.addVertex(0, 0.072000f, 0.000000f, true); - - // GlyphShape<48>: offset 14 of 45/45 points - // pM[013] P[11/41, on false, end false] - // p0[014] P[38/41, on true, end false] - // p1[015] P[72/41, on true, end false] - // p2[016] P[72/522, on true, end false] - // 014: B1: line-to p0-p1 - // Shape.LineTo: - // shape.addVertex(0, 0.072000f, 0.041000f, true); - - // GlyphShape<48>: offset 15 of 45/45 points - // pM[014] P[38/41, on true, end false] - // p0[015] P[72/41, on true, end false] - // p1[016] P[72/522, on true, end false] - // p2[017] P[47/522, on true, end false] - // 015: B1: line-to p0-p1 - // Shape.LineTo: - // shape.addVertex(0, 0.072000f, 0.522000f, true); - - shape.addVertex(0, 0.072000f, 0.563000f, true); // ID 7 - } else { - shape.addVertex(0, 0.113000f, 0.563000f, true); - } - - // GlyphShape<48>: offset 21 of 45/45 points - // pM[020] P[20/563, on false, end false] - // p0[021] P[47/563, on true, end false] - // p1[022] P[146/563, on true, end false] - // p2[023] P[303/215, on true, end false] - // 021: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.146000f, 0.563000f, true); - // GlyphShape<48>: offset 22 of 45/45 points - // pM[021] P[47/563, on true, end false] - // p0[022] P[146/563, on true, end false] - // p1[023] P[303/215, on true, end false] - // p2[024] P[457/563, on true, end false] - // 022: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.303000f, 0.215000f, true); - // GlyphShape<48>: offset 23 of 45/45 points - // pM[022] P[146/563, on true, end false] - // p0[023] P[303/215, on true, end false] - // p1[024] P[457/563, on true, end false] - // p2[025] P[557/563, on true, end false] - // 023: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.457000f, 0.563000f, true); // ID 4 - - if( with_right_leg ) { - shape.addVertex(0, 0.532000f, 0.563000f, true); - - // GlyphShape<48>: offset 29 of 45/45 points - // pM[028] P[584/522, on false, end false] - // p0[029] P[557/522, on true, end false] - // p1[030] P[532/522, on true, end false] - // p2[031] P[532/41, on true, end false] - // 029: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.532000f, 0.522000f, true); - // GlyphShape<48>: offset 30 of 45/45 points - // pM[029] P[557/522, on true, end false] - // p0[030] P[532/522, on true, end false] - // p1[031] P[532/41, on true, end false] - // p2[032] P[566/41, on true, end false] - // 030: B1: line-to p0-p1 - // Shape.LineTo: - // shape.addVertex(0, 0.532000f, 0.041000f, true); - - shape.addVertex(0, 0.532000f, 0.000000f, true); - shape.addVertex(0, 0.491000f, 0.000000f, true); - } else { - shape.addVertex(0, 0.491000f, 0.563000f, true); // ID 3 - } - - // GlyphShape<48>: offset 41 of 45/45 points - // pM[040] P[390/41, on false, end false] - // p0[041] P[417/41, on true, end false] - // p1[042] P[491/41, on true, end false] - // p2[043] P[491/522, on true, end false] - // 041: B1: line-to p0-p1 - // Shape.LineTo: - // shape.addVertex(0, 0.491000f, 0.041000f, true); - - // GlyphShape<48>: offset 42 of 45/45 points - // pM[041] P[417/41, on true, end false] - // p0[042] P[491/41, on true, end false] - // p1[043] P[491/522, on true, end false] - // p2[044] P[483/522, on true, end true] - // 042: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.491000f, 0.522000f, true); // ID 2 - // GlyphShape<48>: offset 43 of 45/45 points - // pM[042] P[491/41, on true, end false] - // p0[043] P[491/522, on true, end false] - // p1[044] P[483/522, on true, end true] - // p2[000] P[326/169, on true, end false] - // 043: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.483000f, 0.522000f, true); // ID 1 - // GlyphShape<48>: offset 44 of 45/45 points - // pM[043] P[491/522, on true, end false] - // p0[044] P[483/522, on true, end true] - // p1[000] P[326/169, on true, end false] - // p2[001] P[280/169, on true, end false] - // 044: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.326000f, 0.169000f, true); - System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph04FreeSans_0.java b/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph04FreeSans_0.java deleted file mode 100644 index 5b677b622..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph04FreeSans_0.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright 2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.testshapes; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent test object - * - FreeSans, '0' - * - TTF Shape for Glyph 19 - */ -public class Glyph04FreeSans_0 extends UIShape { - - public Glyph04FreeSans_0(final Factory factory, final int renderModes) { - super(factory, renderModes); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - // Start TTF Shape for Glyph 19 - // 000: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.043000f, 0.343000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.043000f, 0.432000f, false); - shape.addVertex(0, 0.058000f, 0.500000f, true); - // 002: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.073000f, 0.568000f, false); - shape.addVertex(0, 0.096000f, 0.606000f, true); - // 003: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.119000f, 0.645000f, false); - shape.addVertex(0, 0.151000f, 0.669000f, true); - // 004: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.183000f, 0.693000f, false); - shape.addVertex(0, 0.212000f, 0.701000f, true); - // 005: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.242000f, 0.709000f, false); - shape.addVertex(0, 0.275000f, 0.709000f, true); - // 006: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.507000f, 0.709000f, false); - shape.addVertex(0, 0.507000f, 0.337000f, true); - // 008: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.507000f, 0.162000f, false); - shape.addVertex(0, 0.448000f, 0.070000f, true); - // 010: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.388000f, -0.023000f, false); - shape.addVertex(0, 0.275000f, -0.023000f, true); - // 011: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.161000f, -0.023000f, false); - shape.addVertex(0, 0.102000f, 0.070000f, true); - // 013: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.043000f, 0.164000f, false); - shape.addVertex(0, 0.043000f, 0.343000f, true); - System.err.println("Glyph04FreeSans_0.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - - // 021: B0b: move-to pM - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.417000f, 0.345000f, true); - // 021: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.417000f, 0.631000f, false); - shape.addVertex(0, 0.275000f, 0.631000f, true); - // 015: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.133000f, 0.631000f, false); - shape.addVertex(0, 0.133000f, 0.342000f, true); - // 016: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.133000f, 0.050000f, false); - shape.addVertex(0, 0.273000f, 0.050000f, true); - // 018: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.347000f, 0.050000f, false); - shape.addVertex(0, 0.382000f, 0.122000f, true); - // 020: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.417000f, 0.194000f, false); - shape.addVertex(0, 0.417000f, 0.345000f, true); - System.err.println("Glyph04FreeSans_0.shape02a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - - // End Shape for Glyph 19 - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph05FreeSerifBoldItalic_ae.java b/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph05FreeSerifBoldItalic_ae.java deleted file mode 100644 index e7f726b1f..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/testshapes/Glyph05FreeSerifBoldItalic_ae.java +++ /dev/null @@ -1,287 +0,0 @@ -/** - * Copyright 2023 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.graph.testshapes; - -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape; -import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; - -/** - * GPU based resolution independent test object - * - FreeSans, '0' - * - TTF Shape for Glyph 19 - */ -public class Glyph05FreeSerifBoldItalic_ae extends UIShape { - - public Glyph05FreeSerifBoldItalic_ae(final Factory factory, final int renderModes) { - super(factory, renderModes); - } - - @Override - protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { - } - - @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); - - // Start TTF Shape for Glyph 168 - // 000: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.450000f, -0.013000f, true); - // 000: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.386000f, -0.013000f, false); - shape.addVertex(0, 0.353000f, 0.018000f, true); - // 002: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.319000f, 0.049000f, false); - shape.addVertex(0, 0.307000f, 0.118000f, true); - // 003: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.265000f, 0.049000f, false); - shape.addVertex(0, 0.225000f, 0.019000f, true); - // 005: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.184000f, -0.012000f, false); - shape.addVertex(0, 0.134000f, -0.012000f, true); - // 006: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.085000f, -0.012000f, false); - shape.addVertex(0, 0.053000f, 0.021000f, true); - // 008: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.055000f, false); - shape.addVertex(0, 0.020000f, 0.106000f, true); - // 009: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.020000f, 0.185000f, false); - shape.addVertex(0, 0.062000f, 0.269000f, true); - // 011: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.105000f, 0.353000f, false); - shape.addVertex(0, 0.170000f, 0.407000f, true); - // 012: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.235000f, 0.462000f, false); - shape.addVertex(0, 0.296000f, 0.462000f, true); - // 013: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.328000f, 0.462000f, false); - shape.addVertex(0, 0.346000f, 0.448000f, true); - // 015: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.364000f, 0.433000f, false); - shape.addVertex(0, 0.377000f, 0.396000f, true); - // 016: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.395000f, 0.454000f, true); - // 017: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.498000f, 0.459000f, true); - // 018: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.478000f, 0.394000f, true); - // 019: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.510000f, 0.431000f, false); - shape.addVertex(0, 0.535000f, 0.445000f, true); - // 021: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.561000f, 0.459000f, false); - shape.addVertex(0, 0.598000f, 0.459000f, true); - // 022: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.645000f, 0.459000f, false); - shape.addVertex(0, 0.671000f, 0.436000f, true); - // 024: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.698000f, 0.413000f, false); - shape.addVertex(0, 0.698000f, 0.372000f, true); - // 025: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.698000f, 0.310000f, false); - shape.addVertex(0, 0.639000f, 0.263000f, true); - // 027: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.579000f, 0.215000f, false); - shape.addVertex(0, 0.470000f, 0.190000f, true); - // 028: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.431000f, 0.181000f, true); - // 029: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.426000f, 0.156000f, false); - shape.addVertex(0, 0.426000f, 0.134000f, true); - // 031: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.426000f, 0.096000f, false); - shape.addVertex(0, 0.444000f, 0.073000f, true); - // 033: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.462000f, 0.050000f, false); - shape.addVertex(0, 0.493000f, 0.050000f, true); - // 034: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.565000f, 0.050000f, false); - shape.addVertex(0, 0.616000f, 0.139000f, true); - // 036: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.644000f, 0.122000f, true); - // 037: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.578000f, -0.013000f, false); - shape.addVertex(0, 0.450000f, -0.013000f, true); - System.err.println("Glyph05FreeSerifBoldItalic_ae.shape01a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - - // 039: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.194000f, 0.058000f, true); - // 039: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.238000f, 0.058000f, false); - shape.addVertex(0, 0.278000f, 0.122000f, true); - // 041: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.319000f, 0.187000f, false); - shape.addVertex(0, 0.338000f, 0.256000f, true); - // 042: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.358000f, 0.326000f, false); - shape.addVertex(0, 0.358000f, 0.363000f, true); - // 043: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.358000f, 0.387000f, false); - shape.addVertex(0, 0.345000f, 0.403000f, true); - // 045: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.331000f, 0.419000f, false); - shape.addVertex(0, 0.310000f, 0.419000f, true); - // 046: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.267000f, 0.419000f, false); - shape.addVertex(0, 0.227000f, 0.356000f, true); - // 048: B5: quad-to pMh-p0-p1h ***** MID - // Shape.QuadTo: - shape.addVertex(0, 0.187000f, 0.293000f, false); - shape.addVertex(0, 0.167000f, 0.225000f, true); - // 049: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.146000f, 0.156000f, false); - shape.addVertex(0, 0.146000f, 0.119000f, true); - // 050: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.146000f, 0.092000f, false); - shape.addVertex(0, 0.159000f, 0.075000f, true); - // 052: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.172000f, 0.058000f, false); - shape.addVertex(0, 0.194000f, 0.058000f, true); - System.err.println("Glyph05FreeSerifBoldItalic_ae.shape02a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - - if( true ) { - // GlyphShape<168>: offset 0 of 8/61 points - // pM[060] P[443/231, on true, end true] - // p0[053] P[438/214, on true, end false] - // p1[054] P[498/223, on false, end false] - // p2[055] P[608/320, on false, end false] - // 053: B0a: move-to p0 - // Shape.MoveTo: - shape.closeLastOutline(false); - shape.addEmptyOutline(); - shape.addVertex(0, 0.438000f, 0.214000f, true); - // 053: B4: quad-to p0-p1-p2h **** MID - // Shape.QuadTo: - shape.addVertex(0, 0.498000f, 0.223000f, false); - shape.addVertex(0, 0.553000f, 0.271000f, true); - // GlyphShape<168>: offset 2 of 8/61 points - // pM[054] P[498/223, on false, end false] - // p0[055] P[608/320, on false, end false] - // p1[056] P[608/388, on true, end false] - // p2[057] P[608/429, on false, end false] - // 055: B6: quad-to pMh-p0-p1 - // Shape.QuadTo: - shape.addVertex(0, 0.608000f, 0.320000f, false); - shape.addVertex(0, 0.608000f, 0.388000f, true); - // GlyphShape<168>: offset 3 of 8/61 points - // pM[055] P[608/320, on false, end false] - // p0[056] P[608/388, on true, end false] - // p1[057] P[608/429, on false, end false] - // p2[058] P[575/429, on true, end false] - // 056: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.608000f, 0.429000f, false); - shape.addVertex(0, 0.575000f, 0.429000f, true); - // GlyphShape<168>: offset 5 of 8/61 points - // pM[057] P[608/429, on false, end false] - // p0[058] P[575/429, on true, end false] - // p1[059] P[502/429, on false, end false] - // p2[060] P[443/231, on true, end true] - // 058: B2: quad-to p0-p1-p2 - // Shape.QuadTo: - shape.addVertex(0, 0.502000f, 0.429000f, false); - shape.addVertex(0, 0.443000f, 0.231000f, true); - // GlyphShape<168>: offset 7 of 8/61 points - // pM[059] P[502/429, on false, end false] - // p0[060] P[443/231, on true, end true] - // p1[053] P[438/214, on true, end false] - // p2[054] P[498/223, on false, end false] - // 060: B1: line-to p0-p1 - // Shape.LineTo: - shape.addVertex(0, 0.438000f, 0.214000f, true); - System.err.println("Glyph05FreeSerifBoldItalic_ae.shape03a.winding_area: "+shape.getWindingOfLastOutline()); - shape.closeLastOutline(false); - } - - // End Shape for Glyph 168 - - shape.setIsQuadraticNurbs(); - shape.setSharpness(shapesSharpness); - region.addOutlineShape(shape, null, rgbaColor); - - box.resize(shape.getBounds()); - } - - @Override - public String getSubString() { - return super.getSubString(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneGLListener0A.java new file mode 100644 index 000000000..f49258832 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneGLListener0A.java @@ -0,0 +1,969 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.demos; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLAnimatorControl; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLPipelineFactory; +import com.jogamp.opengl.GLRunnable; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.common.net.Uri; +import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.font.FontScale; +import com.jogamp.graph.geom.SVertex; +import com.jogamp.graph.ui.gl.Scene; +import com.jogamp.graph.ui.gl.Shape; +import com.jogamp.graph.ui.gl.shapes.Button; +import com.jogamp.graph.ui.gl.shapes.GLButton; +import com.jogamp.graph.ui.gl.shapes.ImageButton; +import com.jogamp.graph.ui.gl.shapes.Label; +import com.jogamp.graph.ui.gl.shapes.MediaButton; +import com.jogamp.graph.ui.gl.shapes.RoundButton; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.PinchToZoomGesture; +import com.jogamp.newt.event.GestureHandler.GestureEvent; +import com.jogamp.newt.event.MouseEvent.PointerClass; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.test.junit.graph.FontSet01; +import com.jogamp.opengl.test.junit.graph.demos.MSAATool; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayerFactory; +import com.jogamp.opengl.util.texture.ImageSequence; +import com.jogamp.opengl.util.texture.TextureIO; + +public class GPUUISceneGLListener0A implements GLEventListener { + + private boolean debug = false; + private boolean trace = false; + + private final float noAADPIThreshold; + private final Scene sceneUICntrl; + + /** -1 == AUTO, TBD @ init(..) */ + private int renderModes; + + private final Font font; + private final Font fontFPS; + + private final float sceneDist = 3000f; + private final float zNear = 0.1f, zFar = 7000f; + + private final float relTop = 80f/100f; + private final float relMiddle = 22f/100f; + private final float relLeft = 11f/100f; + + /** Proportional Button Size to Window Height, per-vertical-pixels [PVP] */ + private final float buttonYSizePVP = 0.084f; + private final float buttonXSizePVP = 0.084f; // 0.105f; + private final float fontSizePt = 10f; + /** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */ + private final float fontSizeFixedPVP = 0.04f; + /** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */ + private final float fontSizeFpsPVP = 0.03f; + private float dpiV = 96; + + /** + * Default DPI threshold value to disable {@link Region#VBAA_RENDERING_BIT VBAA}: {@value} dpi + * @see #GPUUISceneGLListener0A(float) + * @see #GPUUISceneGLListener0A(float, boolean, boolean) + */ + public static final float DefaultNoAADPIThreshold = 200f; + + private int currentText = 0; + + private String actionText = null; + private Label[] labels = null; + private String[] strings = null; + private final List buttons = new ArrayList(); + private int buttonsLeftCount = 0; + private Label truePtSizeLabel = null; + private Label jogampLabel = null; + private Label fpsLabel = null; + + private GLAutoDrawable cDrawable; + + private final GLReadBufferUtil screenshot; + + private final String jogamp = "JogAmp - Jogl Graph Module Demo"; + private final String truePtSize = fontSizePt+" pt font size label - true scale!"; + + private final String longText = "JOGL: Java™ Binding for the OpenGL® API.\n\n"+ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec \n"+ + "Ut purus odio, rhoncus sit amet commodo eget, ullamcorper vel\n"+ + "quam iaculis urna cursus ornare. Nullam ut felis a ante ultrices\n"+ + "In hac habitasse platea dictumst. Vivamus et mi a quam lacinia\n"+ + "Morbi quis bibendum nibh. Donec lectus orci, sagittis in consequat\n"+ + "Donec ut dolor et nulla tristique varius. In nulla magna, fermentum\n"+ + "in lorem. Maecenas in ipsum ac justo scelerisque sollicitudin.\n"+ + "\n"+ + "Lyford’s in Texas & L’Anse-aux-Griffons in Québec;\n"+ + "Kwikpak on the Yukon delta, Kvæven in Norway, Kyulu in Kenya, not Rwanda.…\n"+ + "Ytterbium in the periodic table. Are Toussaint L’Ouverture, Wölfflin, Wolfe,\n"+ + "\n"+ + "The quick brown fox jumps over the lazy dog\n"; + + /** + * @param renderModes + */ + public GPUUISceneGLListener0A(final int renderModes) { + this(null, renderModes, false, false); + } + + /** + * @param renderModes + * @param debug + * @param trace + */ + public GPUUISceneGLListener0A(final String fontfilename, final int renderModes, final boolean debug, final boolean trace) { + this(fontfilename, 0f, renderModes, debug, trace); + } + + /** + * @param noAADPIThreshold see {@link #DefaultNoAADPIThreshold} + * @param debug + * @param trace + */ + public GPUUISceneGLListener0A(final String fontfilename, final float noAADPIThreshold, final boolean debug, final boolean trace) { + this(fontfilename, noAADPIThreshold, 0, debug, trace); + } + + private GPUUISceneGLListener0A(final String fontfilename, final float noAADPIThreshold, final int renderModes, final boolean debug, final boolean trace) { + this.noAADPIThreshold = noAADPIThreshold; + this.debug = debug; + this.trace = trace; + + this.renderModes = renderModes; + + try { + if( null == fontfilename ) { + font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf", + FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); + } else { + font = FontFactory.get( new File( fontfilename ) ); + } + System.err.println("Font "+font.getFullFamilyName()); + + fontFPS = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMonoBold.ttf", + FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); + System.err.println("Font FPS "+fontFPS.getFullFamilyName()); + + } catch (final IOException ioe) { + throw new RuntimeException(ioe); + } + { + final RenderState rs = RenderState.createRenderState(SVertex.factory()); + final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); + rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + // renderer = RegionRenderer.create(rs, null, null); + + sceneUICntrl = new Scene(renderer, sceneDist, zNear, zFar); + // sceneUIController.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? + } + screenshot = new GLReadBufferUtil(false, false); + } + + private void rotateButtons(float[] angdeg) { + angdeg = VectorUtil.scaleVec3(angdeg, angdeg, FloatUtil.PI / 180.0f); + for(int i=0; i "+buttonXSize+" x "+buttonYSize); + final float xStartLeft = 0f; // aligned to left edge w/ space via reshape + final float yStartTop = 0f; // aligned to top edge w/ space via reshape + final float diffX = 1.2f * buttonXSize; + final float diffY = 1.5f * buttonYSize; + + Button button = new Button(SVertex.factory(), renderModes, font, "Next Text", buttonXSize, buttonYSize); + button.setName(BUTTON_NEXTTEXT); + button.translate(xStartLeft,yStartTop-diffY*buttons.size(), 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + if( null != labels[currentText] ) { + labels[currentText].setEnabled(false); + } + currentText = (currentText+1)%labels.length; + if( null != labels[currentText] ) { + labels[currentText].setEnabled(true); + } + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + button = new Button(SVertex.factory(), renderModes, font, "Show FPS", buttonXSize, buttonYSize); + button.setName(BUTTON_FPS); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.setToggleable(true); + button.setToggle(fpsLabel.isEnabled()); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final GLAnimatorControl a = cDrawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + fpsLabel.setEnabled(!fpsLabel.isEnabled()); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + button = new Button(SVertex.factory(), renderModes, font, "V-Sync", buttonXSize, buttonYSize); + button.setName(BUTTON_VSYNC); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.setToggleable(true); + button.setToggle(gl.getSwapInterval()>0); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + cDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + gl.setSwapInterval(gl.getSwapInterval()<=0?1:0); + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + return true; + } + }); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + button = new Button(SVertex.factory(), renderModes, font, "< Tilt >", buttonXSize, buttonYSize); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { + rotateButtons(new float[] { 0f, -5f, 0f}); // left-half pressed + } else { + rotateButtons(new float[] { 0f, 5f, 0f}); // right-half pressed + } + } + @Override + public void mouseWheelMoved(final MouseEvent e) { + rotateButtons(new float[] { 0f, e.getRotation()[1], 0f}); + } } ); + buttons.add(button); + + if( pass2Mode ) { // second column to the left + button = new Button(SVertex.factory(), renderModes, font, "< Samples >", buttonXSize, buttonYSize); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + int sampleCount = sceneUICntrl.getSampleCount(); + if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { + // left-half pressed + sampleCount--; + } else { + // right-half pressed + sampleCount++; + } + sampleCount = sceneUICntrl.setSampleCount(sampleCount); // validated / clipped + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + button = new Button(SVertex.factory(), renderModes, font, "< Quality >", buttonXSize, buttonYSize); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + int quality = shapeEvent.shape.getQuality(); + + if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { + // left-half pressed + if( quality > 0 ) { + quality--; + } + } else { + // right-half pressed + if( quality < Region.MAX_QUALITY ) { + quality++; + } + } + sceneUICntrl.setAllShapesQuality(quality); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + } + + button = new Button(SVertex.factory(), renderModes, font, "Quit", buttonXSize, buttonYSize); + button.setName(BUTTON_QUIT); + button.translate(xStartLeft,yStartTop - diffY*buttons.size(), 0f); + button.setColor(0.7f, 0.0f, 0.0f, 1.0f); + button.setLabelColor(1.2f, 1.2f, 1.2f); + button.setPressedColorMod(1.1f, 0.0f, 0.0f, 1.0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + new InterruptSource.Thread() { + @Override + public void run() { + if( null != cDrawable ) { + final GLAnimatorControl actrl = cDrawable.getAnimator(); + if( null != actrl ) { + actrl.stop(); + } + cDrawable.destroy(); + } + } }.start(); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + // second column to the left + { + final int j = 1; // column + int k = 0; // row + button = new Button(SVertex.factory(), renderModes, font, "Y Flip", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + rotateButtons(new float[] { 0f, 180f, 0f}); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + + k++; + button = new Button(SVertex.factory(), renderModes, font, "X Flip", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + rotateButtons(new float[] { 180f, 0f, 0f}); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + k++; + + button = new Button(SVertex.factory(), renderModes, font, "+", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + // rel position to center + final float dx = shapeEvent.objPos[0] - shapeEvent.shape.getBounds().getCenter()[0] ; + final float dy = shapeEvent.objPos[1] - shapeEvent.shape.getBounds().getCenter()[1] ; + // per-cent position to center (remove dependency on dimension) + final float awdx = Math.abs(dx)/shapeEvent.shape.getBounds().getWidth(); + final float awdy = Math.abs(dy)/shapeEvent.shape.getBounds().getHeight(); + float tx = 0, ty = 0; + if ( awdx > awdy ) { + tx = dx < 0 ? -5 : 5; + } else { + ty = dy < 0 ? -5 : 5; + } + translateButtons(tx, ty, 0f); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + k++; + + button = new Button(SVertex.factory(), renderModes, font, "< Space >", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + final float dx, dy; + if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { + dx=-0.01f; dy=-0.005f; + } else { + dx=0.01f; dy=0.005f; + } + setButtonsSpacing(dx, dy); + } + @Override + public void mouseWheelMoved(final MouseEvent e) { + setButtonsSpacing(e.getRotation()[0]/100f, e.getRotation()[1]/200f); + } } ); + buttons.add(button); + k++; + + button = new Button(SVertex.factory(), renderModes, font, "< Corner >", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + final float dc; + if( shapeEvent.objPos[0] < shapeEvent.shape.getBounds().getCenter()[0] ) { + dc=-0.1f; + } else { + dc=0.1f; + } + setButtonsCorner(dc); + } + @Override + public void mouseWheelMoved(final MouseEvent e) { + setButtonsCorner(e.getRotation()[1]/20f); + } } ); + buttons.add(button); + k++; + + button = new Button(SVertex.factory(), renderModes, font, "Reset", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + resetButtons(); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + k++; + + button = new Button(SVertex.factory(), renderModes, font, "Snapshot", buttonXSize, buttonYSize); + button.translate(xStartLeft - diffX*j,yStartTop - diffY*k, 0f); + button.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + cDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + printScreen(drawable.getGL()); + return true; + } + }); + } } ); + button.addMouseListener(dragZoomRotateListener); + buttons.add(button); + k++; + } + + buttonsLeftCount = buttons.size(); + + final float button2XSize = 2f*buttonXSize; + final float button2YSize = 2f*buttonYSize; + final float xStartRight = -button2XSize - 8f; // aligned to right edge via reshape + final int texUnitMediaPlayer, texUnitImageButton, texUnitGLELButton; + { + // works - but not required .. + texUnitMediaPlayer=1; + texUnitImageButton=2; + texUnitGLELButton=3; + } + + if( true ) { + final GLMediaPlayer mPlayer = GLMediaPlayerFactory.createDefault(); + mPlayer.setTextureUnit(texUnitMediaPlayer); + final MediaButton mPlayerButton = new MediaButton(sceneUICntrl.getVertexFactory(), renderModes, + button2XSize, button2YSize, mPlayer); + mPlayerButton.setName(BUTTON_MOVIE); + mPlayerButton.setVerbose(true); + mPlayerButton.addDefaultEventListener(); + mPlayerButton.translate(xStartRight, yStartTop - diffY*1, 0f); + mPlayerButton.setToggleable(true); + mPlayerButton.setToggle(false); // toggle == false -> mute audio + mPlayerButton.setToggleOffColorMod(0f, 1f, 0f, 1.0f); + mPlayerButton.addMouseListener(dragZoomRotateListener); + mPlayerButton.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + mPlayer.setAudioVolume( mPlayerButton.isToggleOn() ? 1f : 0f ); + } } ); + buttons.add(mPlayerButton); + try { + final Uri streamLoc = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); + mPlayer.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT); + } catch (final URISyntaxException e1) { + e1.printStackTrace(); + } + } + if( true ) { + final ImageSequence imgSeq = new ImageSequence(texUnitImageButton, true); + final ImageButton imgButton = new ImageButton(sceneUICntrl.getVertexFactory(), renderModes, + button2XSize, button2YSize, imgSeq); + try { + imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-released-145x53.png", TextureIO.PNG); + imgSeq.addFrame(gl, GPUUISceneGLListener0A.class, "button-pressed-145x53.png", TextureIO.PNG); + } catch (final IOException e2) { + e2.printStackTrace(); + } + imgSeq.setManualStepping(true); + imgButton.translate(xStartRight, yStartTop - diffY*2.5f, 0f); + imgButton.addMouseListener(dragZoomRotateListener); + imgButton.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mousePressed(final MouseEvent e) { + imgButton.setCurrentIdx(1); + System.err.println("XXX: "+imgButton); + } + @Override + public void mouseReleased(final MouseEvent e) { + imgButton.setCurrentIdx(0); + } } ); + buttons.add(imgButton); + } + if( true ) { + // Issues w/ OSX and NewtCanvasAWT when rendering / animating + // Probably related to CALayer - FBO - FBO* (of this button) + final GLEventListener glel; + { + final GearsES2 gears = new GearsES2(0); + gears.setVerbose(false); + gears.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } ); + glel = gears; + } + final GLButton glelButton = new GLButton(sceneUICntrl.getVertexFactory(), renderModes, + button2XSize, button2YSize, + texUnitGLELButton, glel, false /* useAlpha */, + (int)(button2XSize), (int)(button2YSize)); + glelButton.setName(BUTTON_GLEL); + glelButton.setToggleable(true); + glelButton.setToggle(false); // toggle == true -> animation + glelButton.setAnimate(false); + glelButton.translate(xStartRight, yStartTop - diffY*4f, 0f); + glelButton.addMouseListener(dragZoomRotateListener); + glelButton.addMouseListener(new Shape.MouseGestureAdapter() { + @Override + public void mouseClicked(final MouseEvent e) { + glelButton.setAnimate( glelButton.isToggleOn() ); + } } ); + buttons.add(glelButton); + } + } + + private void initTexts() { + strings = new String[4]; + int i = 0; + + strings[i++] = "- Mouse Scroll Over Object\n"+ + " - General\n"+ + " - Z Translation\n"+ + " - Ctrl: Y-Rotation (Shift: X-Rotation)\n"+ + " - Tilt, Space and Corner\n"+ + " - Their respective action via wheel\n"+ + " (shift = other value)\n"+ + "\n"+ + "- Mouse Drag On Object\n"+ + " - Click on Object and drag mouse\n"+ + " - Current postion in status line at bottom\n"+ + "\n"+ + "- Tilt Button Rotate Whole Button Group"; + + strings[i++] = "abcdefghijklmn\nopqrstuvwxyz\n"+ + "ABCDEFGHIJKL\n"+ + "MNOPQRSTUVWXYZ\n"+ + "0123456789.:,;(*!?/\\\")$%^&-+@~#<>{}[]"; + + strings[i++] = "The quick brown fox jumps over the lazy dog"; + + strings[i++] = longText; + + labels = new Label[i]; + + currentText = strings.length - 1; + } + + + private static final boolean enableOthers = true; + private static final boolean reshape_ui = false; // incomplete: button positioning + + + private void setupUI(final GLAutoDrawable drawable) { + final float pixelSizeFixed = fontSizeFixedPVP * drawable.getSurfaceHeight(); + jogampLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSizeFixed, jogamp); + jogampLabel.addMouseListener(dragZoomRotateListener); + sceneUICntrl.addShape(jogampLabel); + jogampLabel.setEnabled(enableOthers); + + final float pixelSize10Pt = FontScale.toPixels(fontSizePt, dpiV); + System.err.println("10Pt PixelSize: Display "+dpiV+" dpi, fontSize "+fontSizePt+" ppi -> "+pixelSize10Pt+" pixel-size"); + truePtSizeLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSize10Pt, truePtSize); + sceneUICntrl.addShape(truePtSizeLabel); + truePtSizeLabel.setEnabled(enableOthers); + truePtSizeLabel.translate(0, - 1.5f * jogampLabel.getLineHeight(), 0f); + truePtSizeLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); + + /** + * + * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 + * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 + */ + final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); + fpsLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, fontFPS, pixelSizeFPS, "Nothing there yet"); + fpsLabel.addMouseListener(dragZoomRotateListener); + sceneUICntrl.addShape(fpsLabel); + fpsLabel.setEnabled(enableOthers); + fpsLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); + fpsLabel.translate(0f, pixelSizeFPS * (fontFPS.getMetrics().getLineGap() - fontFPS.getMetrics().getDescent()), 0f); + + initButtons(drawable.getGL().getGL2ES2(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); + for(int i=0; i "+pixelSize10Pt+" pixel-size"); + truePtSizeLabel.setPixelSize(pixelSize10Pt); + + /** + * + * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 + * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 + */ + final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); + fpsLabel.setPixelSize(pixelSizeFPS); + + final float buttonXSize = buttonXSizePVP * drawable.getSurfaceWidth(); + // final float buttonYSize = buttonYSizePVP * height; + final float buttonYSize = buttonXSize / 2.5f; + final float button2XSize = 2f*buttonXSize; + final float button2YSize = 2f*buttonYSize; + + for(int i=0; i= noAADPIThreshold; + final String noAAs = noAA ? " >= " : " < "; + System.err.println("AUTO RenderMode: dpi "+dpiV+noAAs+noAADPIThreshold+" -> noAA "+noAA); + renderModes = noAA ? 0 : Region.VBAA_RENDERING_BIT; + } + if(drawable instanceof GLWindow) { + System.err.println("GPUUISceneGLListener0A: init (1)"); + final GLWindow glw = (GLWindow) drawable; + sceneUICntrl.attachInputListenerTo(glw); + } else { + System.err.println("GPUUISceneGLListener0A: init (0)"); + } + cDrawable = drawable; + GL2ES2 gl = drawable.getGL().getGL2ES2(); + if(debug) { + gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2(); + } + if(trace) { + gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2(); + } + System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString()); + System.err.println("VSync Swap Interval: "+gl.getSwapInterval()); + System.err.println("Chosen: "+drawable.getChosenGLCapabilities()); + MSAATool.dump(drawable); + + gl.setSwapInterval(1); + gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL.GL_BLEND); + + initTexts(); + + sceneUICntrl.init(drawable); + + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + + setupUI(drawable); + } + + @Override + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { + System.err.println("GPUUISceneGLListener0A: reshape"); + + // + // Layout all shapes: Relational move regarding window coordinates + // + final float dw = width - lastWidth; + final float dh = height - lastHeight; + + final float dz = 0f; + final float dyTop = dh * relTop; + final float dxLeft = dw * relLeft; + final float dxRight = dw; + + if( reshape_ui ) { + reshapeUI(drawable); + } + for(int i=0; i 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(SceneMSAASamples); + } + System.out.println("Requested: " + caps); + + final int rmode; + if( GraphVBAAMode ) { + rmode = Region.VBAA_RENDERING_BIT; + } else if( GraphMSAAMode ) { + rmode = Region.MSAA_RENDERING_BIT; + } else { + rmode = 0; + } + + final GLWindow window = GLWindow.create(caps); + window.setPosition(x, y); + window.setSize(width, height); + window.setTitle("GraphUI Newt/AWT Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); + window.setSurfaceScale(reqSurfacePixelScale); + final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); + + final GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(fontfilename, GraphAutoMode, DEBUG, TRACE) : + new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); + + window.addGLEventListener(sceneGLListener); + sceneGLListener.attachInputListenerTo(window); + + final Animator animator = new Animator(); + animator.setUpdateFPSFrames(60, System.err); + animator.add(window); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowDestroyed(final WindowEvent e) { + animator.stop(); + } + }); + + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(window); + final Frame frame = new Frame("GraphUI Newt/AWT Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); + + setComponentSize(newtCanvasAWT, new Dimension(width, height)); + frame.add(newtCanvasAWT); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.pack(); + frame.setVisible(true); + } + }); + animator.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneNewtDemo.java new file mode 100644 index 000000000..36e8ee713 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneNewtDemo.java @@ -0,0 +1,197 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.demos; + +import com.jogamp.nativewindow.ScalableSurface; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.graph.curve.Region; +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; + +public class GPUUISceneNewtDemo { + static final boolean DEBUG = false; + static final boolean TRACE = false; + + static void sleep(final long ms) { + try { + Thread.sleep(ms); + } catch (final InterruptedException ie) {} + } + + public static void main(final String[] args) { + int SceneMSAASamples = 0; + boolean GraphVBAAMode = false; + boolean GraphMSAAMode = false; + float GraphAutoMode = GPUUISceneGLListener0A.DefaultNoAADPIThreshold; + + final float[] reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE }; + + String fontfilename = null; + + int width = 1280, height = 720; + + boolean forceES2 = false; + boolean forceES3 = false; + boolean forceGL3 = false; + boolean forceGLDef = false; + + if( 0 != args.length ) { + for(int i=0; i 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(SceneMSAASamples); + } + System.out.println("Requested: " + caps); + + final int rmode; + if( GraphVBAAMode ) { + rmode = Region.VBAA_RENDERING_BIT; + } else if( GraphMSAAMode ) { + rmode = Region.MSAA_RENDERING_BIT; + } else { + rmode = 0; + } + + final GLWindow window = GLWindow.create(screen, caps); + if( 0 == SceneMSAASamples ) { + window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(true)); + } + window.setSize(width, height); + window.setTitle("GraphUI Newt Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples); + window.setSurfaceScale(reqSurfacePixelScale); + // final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); + + final GPUUISceneGLListener0A scene = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(fontfilename, GraphAutoMode, DEBUG, TRACE) : + new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); + + window.addGLEventListener(scene); + scene.attachInputListenerTo(window); + + final Animator animator = new Animator(); + animator.setUpdateFPSFrames(5*60, null); + animator.add(window); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowDestroyed(final WindowEvent e) { + animator.stop(); + } + }); + + window.setVisible(true); + animator.start(); + + // sleep(3000); + // final UIShape movie = scene.getWidget(GPUUISceneGLListener0A.BUTTON_MOVIE); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneTextAnim01.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneTextAnim01.java new file mode 100644 index 000000000..49757e7a0 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/GPUUISceneTextAnim01.java @@ -0,0 +1,351 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.demos; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Locale; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.font.FontScale; +import com.jogamp.graph.geom.SVertex; +import com.jogamp.graph.ui.gl.Scene; +import com.jogamp.graph.ui.gl.Shape; +import com.jogamp.graph.ui.gl.shapes.Label; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.GestureHandler.GestureEvent; +import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseEvent.PointerClass; +import com.jogamp.newt.event.PinchToZoomGesture; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLAnimatorControl; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLPipelineFactory; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.VectorUtil; +import com.jogamp.opengl.test.junit.graph.FontSet01; +import com.jogamp.opengl.test.junit.graph.demos.MSAATool; +import com.jogamp.opengl.util.GLReadBufferUtil; + +public class GPUUISceneTextAnim01 implements GLEventListener { + + private boolean debug = false; + private boolean trace = false; + + private final float noAADPIThreshold; + private final Scene sceneUICntrl; + + /** -1 == AUTO, TBD @ init(..) */ + private int renderModes; + + private final Font font; + private final Font fontFPS; + + private final float sceneDist = 3000f; + private final float zNear = 0.1f, zFar = 7000f; + + // private final float relTop = 80f/100f; + private final float relMiddle = 22f/100f; + // private final float relLeft = 11f/100f; + + private final float fontSizePt = 10f; + /** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */ + private final float fontSizeFixedPVP = 0.04f; + /** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */ + private final float fontSizeFpsPVP = 0.03f; + private float dpiV = 96; + + /** + * Default DPI threshold value to disable {@link Region#VBAA_RENDERING_BIT VBAA}: {@value} dpi + * @see #GPUUISceneGLListener0A(float) + * @see #GPUUISceneGLListener0A(float, boolean, boolean) + */ + public static final float DefaultNoAADPIThreshold = 200f; + + private String actionText = null; + private Label jogampLabel = null; + private Label fpsLabel = null; + + // private GLAutoDrawable cDrawable; + + private final GLReadBufferUtil screenshot; + + private final String jogamp = "JogAmp - Jogl Graph Module Demo"; + + // private final String longText = "JOGL: Java™ Binding for the OpenGL® API."; + + public GPUUISceneTextAnim01(final String fontfilename, final float noAADPIThreshold, final int renderModes, final boolean debug, final boolean trace) { + this.noAADPIThreshold = noAADPIThreshold; + this.debug = debug; + this.trace = trace; + + this.renderModes = renderModes; + + try { + if( null == fontfilename ) { + font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf", + FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); + } else { + font = FontFactory.get( new File( fontfilename ) ); + } + System.err.println("Font "+font.getFullFamilyName()); + + fontFPS = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMonoBold.ttf", + FontSet01.class.getClassLoader(), FontSet01.class).getInputStream(), true); + System.err.println("Font FPS "+fontFPS.getFullFamilyName()); + + } catch (final IOException ioe) { + throw new RuntimeException(ioe); + } + + { + final RenderState rs = RenderState.createRenderState(SVertex.factory()); + final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); + rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); + // renderer = RegionRenderer.create(rs, null, null); + + sceneUICntrl = new Scene(renderer, sceneDist, zNear, zFar); + // sceneUIController.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? + } + screenshot = new GLReadBufferUtil(false, false); + } + + private void setupUI(final GLAutoDrawable drawable) { + final float pixelSizeFixed = fontSizeFixedPVP * drawable.getSurfaceHeight(); + jogampLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, font, pixelSizeFixed, jogamp); + jogampLabel.addMouseListener(dragZoomRotateListener); + sceneUICntrl.addShape(jogampLabel); + jogampLabel.setEnabled(true); + + final float pixelSize10Pt = FontScale.toPixels(fontSizePt, dpiV); + System.err.println("10Pt PixelSize: Display "+dpiV+" dpi, fontSize "+fontSizePt+" ppi -> "+pixelSize10Pt+" pixel-size"); + + /** + * + * [Label] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 18.814816 + * [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012 + */ + final float pixelSizeFPS = fontSizeFpsPVP * drawable.getSurfaceHeight(); + fpsLabel = new Label(sceneUICntrl.getVertexFactory(), renderModes, fontFPS, pixelSizeFPS, "Nothing there yet"); + fpsLabel.addMouseListener(dragZoomRotateListener); + sceneUICntrl.addShape(fpsLabel); + fpsLabel.setEnabled(true); + fpsLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f); + fpsLabel.translate(0f, pixelSizeFPS * (fontFPS.getMetrics().getLineGap() - fontFPS.getMetrics().getDescent()), 0f); + } + + @Override + public void init(final GLAutoDrawable drawable) { + final Object upObj = drawable.getUpstreamWidget(); + if( upObj instanceof Window ) { + final Window upWin = (Window)upObj; + final MonitorDevice monitor = upWin.getMainMonitor(); + final float[] monitorDPI = MonitorDevice.perMMToPerInch( monitor.getPixelsPerMM(new float[2]) ); + final float[] sDPI = MonitorDevice.perMMToPerInch( upWin.getPixelsPerMM(new float[2]) ); + dpiV = sDPI[1]; + System.err.println("Monitor detected: "+monitor); + System.err.println("Monitor dpi: "+monitorDPI[0]+" x "+monitorDPI[1]); + System.err.println("Surface scale: native "+Arrays.toString(upWin.getMaximumSurfaceScale(new float[2]))+", current "+Arrays.toString(upWin.getCurrentSurfaceScale(new float[2]))); + System.err.println("Surface dpi "+sDPI[0]+" x "+sDPI[1]); + } else { + System.err.println("Using default DPI of "+dpiV); + } + if( 0 == renderModes && !FloatUtil.isZero(noAADPIThreshold, FloatUtil.EPSILON)) { + final boolean noAA = dpiV >= noAADPIThreshold; + final String noAAs = noAA ? " >= " : " < "; + System.err.println("AUTO RenderMode: dpi "+dpiV+noAAs+noAADPIThreshold+" -> noAA "+noAA); + renderModes = noAA ? 0 : Region.VBAA_RENDERING_BIT; + } + if(drawable instanceof GLWindow) { + System.err.println("GPUUISceneGLListener0A: init (1)"); + final GLWindow glw = (GLWindow) drawable; + sceneUICntrl.attachInputListenerTo(glw); + } else { + System.err.println("GPUUISceneGLListener0A: init (0)"); + } + // cDrawable = drawable; + GL2ES2 gl = drawable.getGL().getGL2ES2(); + if(debug) { + gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2(); + } + if(trace) { + gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2(); + } + System.err.println(JoglVersion.getGLInfo(gl, null, false /* withCapsAndExts */).toString()); + System.err.println("VSync Swap Interval: "+gl.getSwapInterval()); + System.err.println("Chosen: "+drawable.getChosenGLCapabilities()); + MSAATool.dump(drawable); + + gl.setSwapInterval(1); + gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL.GL_BLEND); + + sceneUICntrl.init(drawable); + + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + + setupUI(drawable); + } + + @Override + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { + System.err.println("GPUUISceneGLListener0A: reshape"); + + // + // Layout all shapes: Relational move regarding window coordinates + // + final float dz = 0f; + + final float dxMiddleAbs = width * relMiddle; + final float dyTopLabelAbs = drawable.getSurfaceHeight() - 2f*jogampLabel.getLineHeight(); + jogampLabel.setTranslate(dxMiddleAbs, dyTopLabelAbs, dz); + fpsLabel.translate(0f, 0f, 0f); + + sceneUICntrl.reshape(drawable, x, y, width, height); + + lastWidth = width; + lastHeight = height; + } + float lastWidth = 0f, lastHeight = 0f; + + @Override + public void dispose(final GLAutoDrawable drawable) { + System.err.println("GPUUISceneGLListener0A: dispose"); + + sceneUICntrl.dispose(drawable); // disposes all registered UIShapes + + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + screenshot.dispose(gl); + } + + private int shotCount = 0; + + public void printScreen(final GL gl) { + final RegionRenderer renderer = sceneUICntrl.getRenderer(); + final String modeS = Region.getRenderModeString(jogampLabel.getRenderModes()); + final String filename = String.format((Locale)null, "GraphUIDemo-shot%03d-%03dx%03d-S_%s_%02d.png", + shotCount++, renderer.getWidth(), renderer.getHeight(), + modeS, sceneUICntrl.getSampleCount()); + gl.glFinish(); // just make sure rendering finished .. + if(screenshot.readPixels(gl, false)) { + screenshot.write(new File(filename)); + System.err.println("Wrote: "+filename); + } + } + + @Override + public void display(final GLAutoDrawable drawable) { + if( fpsLabel.isEnabled() ) { + final String text; + if( null == actionText ) { + text = sceneUICntrl.getStatusText(drawable, renderModes, fpsLabel.getQuality(), dpiV); + } else if( null != drawable.getAnimator() ) { + text = Scene.getStatusText(drawable.getAnimator())+", "+actionText; + } else { + text = actionText; + } + if( fpsLabel.setText(text) ) { // marks dirty only if text differs. + System.err.println(text); + } + } + sceneUICntrl.display(drawable); + } + + public void attachInputListenerTo(final GLWindow window) { + sceneUICntrl.attachInputListenerTo(window); + } + + public void detachInputListenerFrom(final GLWindow window) { + sceneUICntrl.detachInputListenerFrom(window); + } + + /** + * We can share this instance w/ all UI elements, + * since only mouse action / gesture is complete for a single one (press, drag, released and click). + */ + private final Shape.MouseGestureAdapter dragZoomRotateListener = new Shape.MouseGestureAdapter() { + @Override + public void mouseReleased(final MouseEvent e) { + actionText = null; + } + + @Override + public void mouseDragged(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + if( e.getPointerCount() == 1 ) { + final float[] tx = shapeEvent.shape.getTranslate(); + actionText = String.format((Locale)null, "Pos %6.2f / %6.2f / %6.2f", tx[0], tx[1], tx[2]); + } + } + + @Override + public void mouseWheelMoved(final MouseEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + final boolean isOnscreen = PointerClass.Onscreen == e.getPointerType(0).getPointerClass(); + if( 0 == ( ~InputEvent.BUTTONALL_MASK & e.getModifiers() ) && !isOnscreen ) { + // offscreen vertical mouse wheel zoom + final float tz = 100f*e.getRotation()[1]; // vertical: wheel + System.err.println("Rotate.Zoom.W: "+tz); + shapeEvent.shape.translate(0f, 0f, tz); + } else if( isOnscreen || e.isControlDown() ) { + final float[] rot = VectorUtil.scaleVec3(e.getRotation(), e.getRotation(), FloatUtil.PI / 180.0f); + if( isOnscreen ) { + System.err.println("XXX: "+e); + // swap axis for onscreen rotation matching natural feel + final float tmp = rot[0]; rot[0] = rot[1]; rot[1] = tmp; + VectorUtil.scaleVec3(rot, rot, 2f); + } + shapeEvent.shape.getRotation().rotateByEuler( rot ); + } + } + @Override + public void gestureDetected(final GestureEvent e) { + final Shape.UIShapeEvent shapeEvent = (Shape.UIShapeEvent) e.getAttachment(); + if( e instanceof PinchToZoomGesture.ZoomEvent ) { + final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) e; + final float tz = ze.getDelta() * ze.getScale(); + System.err.println("Rotate.Zoom.G: "+tz); + shapeEvent.shape.translate(0f, 0f, tz); + } + } }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UIShapeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UIShapeDemo01.java new file mode 100644 index 000000000..7ccd80f46 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UIShapeDemo01.java @@ -0,0 +1,569 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.demos; + +import java.io.File; +import java.io.IOException; + +import com.jogamp.opengl.FPSCounter; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLAnimatorControl; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLPipelineFactory; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.GLRunnable; +import com.jogamp.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.opengl.test.junit.graph.demos.MSAATool; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.graph.curve.opengl.TextRegionUtil; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.font.FontSet; +import com.jogamp.graph.geom.SVertex; +import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.graph.ui.gl.Shape; +import com.jogamp.graph.ui.gl.shapes.Button; +import com.jogamp.graph.ui.gl.shapes.CrossHair; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.PMVMatrix; + +/** + * Basic UIShape and Type Rendering demo. + * + * Action Keys: + * - 1/2: zoom in/out + * - 4/5: increase/decrease shape/text spacing + * - 6/7: increase/decrease corner size + * - 0/9: rotate + * - v: toggle v-sync + * - s: screenshot + */ +public class UIShapeDemo01 implements GLEventListener { + static final boolean DEBUG = false; + static final boolean TRACE = false; + + public static void main(final String[] args) throws IOException { + Font font = null; + if( 0 != args.length ) { + for(int i=0; i obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]); + } + } + glWinX = drawable.getSurfaceWidth(); + glWinY = drawable.getSurfaceHeight(); + if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) { + if( once ) { + System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]); + } + } + full_width_o = objCoord1[0] - objCoord0[0]; + } + final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); + final float full_width_s = full_width_o / txt_box_em.getWidth(); + final float txt_scale = full_width_s/2f; + pmv.glPushMatrix(); + pmv.glScalef(txt_scale, txt_scale, 1f); + pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new float[] { 0, 0, 0, 1 }, sampleCount, tempT1, tempT2); + if( once ) { + final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); + System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); + System.err.println("XXX: txt_box_em "+txt_box_em); + System.err.println("XXX: txt_box_e2 "+txt_box_em2); + System.err.println("XXX: txt_box_rg "+txt_box_r); + once = false; + } + pmv.glPopMatrix(); + } + renderer.enable(gl, false); + } + static boolean once = true; + + @Override + public void dispose(final GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + button.destroy(gl, getRegionRenderer()); + crossHair.destroy(gl, getRegionRenderer()); + + autoDrawable = null; + screenshot.dispose(gl); + rRenderer.destroy(gl); + } + + /** Attach the input listener to the window */ + public void attachInputListenerTo(final GLWindow window) { + if ( null == keyAction ) { + keyAction = new KeyAction(); + window.addKeyListener(keyAction); + } + if ( null == mouseAction ) { + mouseAction = new MouseAction(); + window.addMouseListener(mouseAction); + } + } + + public void detachFrom(final GLWindow window) { + if ( null == keyAction ) { + return; + } + if ( null == mouseAction ) { + return; + } + window.removeGLEventListener(this); + window.removeKeyListener(keyAction); + window.removeMouseListener(mouseAction); + } + + public void printScreen(final GLAutoDrawable drawable, final String dir, final String tech, final String objName, final boolean exportAlpha) throws GLException, IOException { + final String sw = String.format("-%03dx%03d-Z%04d-T%04d-%s", drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), (int)Math.abs(zTran), 0, objName); + + final String filename = dir + tech + sw +".png"; + if(screenshot.readPixels(drawable.getGL(), false)) { + screenshot.write(new File(filename)); + } + } + + int screenshot_num = 0; + + public void setIgnoreInput(final boolean v) { + ignoreInput = v; + } + public boolean getIgnoreInput() { + return ignoreInput; + } + + public class MouseAction implements MouseListener{ + + @Override + public void mouseClicked(final MouseEvent e) { + + } + + @Override + public void mouseEntered(final MouseEvent e) { + } + + @Override + public void mouseExited(final MouseEvent e) { + } + + @Override + public void mousePressed(final MouseEvent e) { + autoDrawable.invoke(false, new GLRunnable() { // avoid data-race + @Override + public boolean run(final GLAutoDrawable drawable) { + System.err.println("\n\nMouse: "+e); + + final RegionRenderer renderer = getRegionRenderer(); + final PMVMatrix pmv = renderer.getMatrix(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(xTran, yTran, zTran); + + // flip to GL window coordinates, origin bottom-left + final int[] viewport = renderer.getViewport(new int[4]); + final int glWinX = e.getX(); + final int glWinY = viewport[3] - e.getY() - 1; + + { + pmv.glPushMatrix(); + button.setTransform(pmv); + + final float[] objPos = new float[3]; + System.err.println("\n\nButton: "+button); + button.winToObjCoord(renderer, glWinX, glWinY, objPos); + System.err.println("Button: Click: Win "+glWinX+"/"+glWinY+" -> Obj "+objPos[0]+"/"+objPos[1]+"/"+objPos[1]); + + final int[] surfaceSize = new int[2]; + button.getSurfaceSize(renderer, surfaceSize); + System.err.println("Button: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); + + pmv.glPopMatrix(); + } + { + pmv.glPushMatrix(); + crossHair.setTransform(pmv); + + final float[] objPosC = crossHair.getBounds().getCenter(); + final int[] objWinPos = new int[2]; + System.err.println("\n\nCrossHair: "+crossHair); + if( crossHair.objToWinCoord(renderer, objPosC, objWinPos) ) { + System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]); + } + + final float[] objPos2 = new float[3]; + crossHair.winToObjCoord(renderer, objWinPos[0], objWinPos[1], objPos2); + System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]); + + final float[] winObjPos = new float[3]; + if( crossHair.winToObjCoord(renderer, glWinX, glWinY, winObjPos) ) { + // final float[] translate = crossHair.getTranslate(); + // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; + final float dx = winObjPos[0] - objPosC[0]; + final float dy = winObjPos[1] - objPosC[1]; + // final float dz = winObjPos[2] - objPosT[2]; + if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) { + System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); + crossHair.translate(dx, dy, 0f); + } else { + System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); + } + } + + final int[] surfaceSize = new int[2]; + crossHair.getSurfaceSize(renderer, surfaceSize); + System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); + + pmv.glPopMatrix(); + } + return true; + } } ); + + } + + @Override + public void mouseReleased(final MouseEvent e) { + } + + @Override + public void mouseMoved(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseDragged(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseWheelMoved(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + } + + public class KeyAction implements KeyListener { + @Override + public void keyPressed(final KeyEvent arg0) { + if(ignoreInput) { + return; + } + + if(arg0.getKeyCode() == KeyEvent.VK_1){ + button.translate(0f, 0f, -zTran/10f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_2){ + button.translate(0f, 0f, zTran/10f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_UP){ + button.translate(0f, button.getHeight()/10f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){ + button.translate(0f, -button.getHeight()/10f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){ + button.translate(-button.getWidth()/10f, 0f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){ + button.translate(button.getWidth()/10f, 0f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_4){ + button.setSpacing(button.getSpacingX()-0.01f, button.getSpacingY()-0.005f); + System.err.println("Button Spacing: " + button.getSpacingX()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_5){ + button.setSpacing(button.getSpacingX()+0.01f, button.getSpacingY()+0.005f); + System.err.println("Button Spacing: " + button.getSpacingX()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_6){ + button.setCorner(button.getCorner()-0.01f); + System.err.println("Button Corner: " + button.getCorner()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_7){ + button.setCorner(button.getCorner()+0.01f); + System.err.println("Button Corner: " + button.getCorner()); + } + else if(arg0.getKeyCode() == KeyEvent.VK_0){ + // rotate(1); + } + else if(arg0.getKeyCode() == KeyEvent.VK_9){ + // rotate(-1); + } + else if(arg0.getKeyCode() == KeyEvent.VK_V) { + if(null != autoDrawable) { + autoDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + final int _i = gl.getSwapInterval(); + final int i; + switch(_i) { + case 0: i = 1; break; + case 1: i = -1; break; + case -1: i = 0; break; + default: i = 1; break; + } + gl.setSwapInterval(i); + + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + if(drawable instanceof FPSCounter) { + ((FPSCounter)drawable).resetFPSCounter(); + } + System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval()); + return true; + } + }); + } + } + else if(arg0.getKeyCode() == KeyEvent.VK_S){ + if(null != autoDrawable) { + autoDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + try { + final String type = Region.getRenderModeString(renderModes); + printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false); + screenshot_num++; + } catch (final GLException e) { + e.printStackTrace(); + } catch (final IOException e) { + e.printStackTrace(); + } + return true; + } + }); + } + } + } + @Override + public void keyReleased(final KeyEvent arg0) {} + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UITypeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UITypeDemo01.java new file mode 100644 index 000000000..b2a1bc772 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/UITypeDemo01.java @@ -0,0 +1,617 @@ +/** + * Copyright 2010-2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.demos; + +import java.io.File; +import java.io.IOException; + +import com.jogamp.opengl.FPSCounter; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLAnimatorControl; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLPipelineFactory; +import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.GLRunnable; +import com.jogamp.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.opengl.test.junit.graph.demos.MSAATool; +import com.jogamp.opengl.test.junit.graph.ui.testshapes.Glyph03FreeMonoRegular_M; +import com.jogamp.opengl.test.junit.graph.ui.testshapes.Glyph04FreeSans_0; +import com.jogamp.opengl.test.junit.graph.ui.testshapes.Glyph05FreeSerifBoldItalic_ae; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.common.util.InterruptSource; +import com.jogamp.graph.curve.Region; +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.curve.opengl.TextRegionUtil; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.font.FontSet; +import com.jogamp.graph.font.Font.Glyph; +import com.jogamp.graph.geom.SVertex; +import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.graph.ui.gl.Shape; +import com.jogamp.graph.ui.gl.shapes.CrossHair; +import com.jogamp.graph.ui.gl.shapes.Rectangle; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.PMVMatrix; + +/** + * Basic UIShape and Type Rendering demo. + * + * Action Keys: + * - 1/2: zoom in/out + * - 4/5: increase/decrease shape/text spacing + * - 6/7: increase/decrease corner size + * - 0/9: rotate + * - v: toggle v-sync + * - s: screenshot + */ +public class UITypeDemo01 implements GLEventListener { + static final boolean DEBUG = false; + static final boolean TRACE = false; + + public static void main(final String[] args) throws IOException { + Font font = null; + String text = "Hello Origin."; + int glyph_id = Glyph.ID_UNKNOWN; + if( 0 != args.length ) { + for(int i=0; i obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord0[0], objCoord0[1], objCoord0[2]); + } + } + glWinX = drawable.getSurfaceWidth(); + glWinY = drawable.getSurfaceHeight(); + if( pmv.gluUnProject(glWinX, glWinY, winZ, renderer.getViewport(), 0, objCoord1, 0) ) { + if( once ) { + System.err.printf("winToObjCoord: win [%f, %f, %f] -> obj [%f, %f, %f]%n", glWinX, glWinY, winZ, objCoord1[0], objCoord1[1], objCoord1[2]); + } + } + full_width_o = objCoord1[0] - objCoord0[0]; + full_height_o = objCoord1[1] - objCoord0[1]; + } + pmv.glPushMatrix(); + + final Font.Glyph glyph; + if( Glyph.ID_UNKNOWN < glyph_id ) { + glyph = font.getGlyph(glyph_id); + if( once ) { + System.err.println("glyph_id "+glyph_id+": "+glyph); + } + } else { + glyph = null; + } + if( null != glyph && glyph.getID() != Glyph.ID_UNKNOWN ) { + final AABBox txt_box_em = glyph.getBBox(); + final float full_width_s = full_width_o / txt_box_em.getWidth(); + final float full_height_s = full_height_o / txt_box_em.getHeight(); + final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; + pmv.glScalef(txt_scale, txt_scale, 1f); + pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + if( null != glyph.getShape() ) { + final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); + region.addOutlineShape(glyph.getShape(), null, region.hasColorChannel() ? fg_color : null); + region.draw(gl, renderer, sampleCount); + region.destroy(gl); + } + if( once ) { + final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); + System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); + System.err.println("XXX: full_height: "+full_height_o+" / "+txt_box_em.getHeight()+" -> "+full_height_s); + System.err.println("XXX: txt_scale: "+txt_scale); + System.err.println("XXX: txt_box_em "+txt_box_em); + System.err.println("XXX: txt_box_e2 "+txt_box_em2); + } + } else if( Glyph.ID_UNKNOWN == glyph_id ) { + final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2); + final float full_width_s = full_width_o / txt_box_em.getWidth(); + final float full_height_s = full_height_o / txt_box_em.getHeight(); + final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f; + pmv.glScalef(txt_scale, txt_scale, 1f); + pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); + final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount, tempT1, tempT2); + if( once ) { + final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text); + System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s); + System.err.println("XXX: full_height: "+full_height_o+" / "+txt_box_em.getHeight()+" -> "+full_height_s); + System.err.println("XXX: txt_scale: "+txt_scale); + System.err.println("XXX: txt_box_em "+txt_box_em); + System.err.println("XXX: txt_box_e2 "+txt_box_em2); + System.err.println("XXX: txt_box_rg "+txt_box_r); + } + } + pmv.glPopMatrix(); + if( once ) { + try { + printScreen(drawable); + } catch (GLException | IOException e) { + e.printStackTrace(); + } + } + once = false; + } + renderer.enable(gl, false); + } + private boolean once = true; + + @Override + public void dispose(final GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + crossHair.destroy(gl, getRegionRenderer()); + testObj.destroy(gl, getRegionRenderer()); + + autoDrawable = null; + screenshot.dispose(gl); + rRenderer.destroy(gl); + } + + /** Attach the input listener to the window */ + public void attachInputListenerTo(final GLWindow window) { + if ( null == keyAction ) { + keyAction = new KeyAction(); + window.addKeyListener(keyAction); + } + if ( null == mouseAction ) { + mouseAction = new MouseAction(); + window.addMouseListener(mouseAction); + } + } + + public void detachFrom(final GLWindow window) { + if ( null == keyAction ) { + return; + } + if ( null == mouseAction ) { + return; + } + window.removeGLEventListener(this); + window.removeKeyListener(keyAction); + window.removeMouseListener(mouseAction); + } + + public void printScreen(final GLAutoDrawable drawable) throws GLException, IOException { + final String dir = "./"; + final String tech="demo-"+Region.getRenderModeString(renderModes); + final String objName = "snap"+screenshot_num; + { + final String sw = String.format("-%03dx%03d-Z%04d-T%04d-%s", drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), (int)Math.abs(zTran), 0, objName); + + final String filename = dir + tech + sw +".png"; + if(screenshot.readPixels(drawable.getGL(), false)) { + screenshot.write(new File(filename)); + } + } + screenshot_num++; + } + int screenshot_num = 0; + + public void setIgnoreInput(final boolean v) { + ignoreInput = v; + } + public boolean getIgnoreInput() { + return ignoreInput; + } + + public class MouseAction implements MouseListener{ + + @Override + public void mouseClicked(final MouseEvent e) { + + } + + @Override + public void mouseEntered(final MouseEvent e) { + } + + @Override + public void mouseExited(final MouseEvent e) { + } + + @Override + public void mousePressed(final MouseEvent e) { + autoDrawable.invoke(false, new GLRunnable() { // avoid data-race + @Override + public boolean run(final GLAutoDrawable drawable) { + System.err.println("\n\nMouse: "+e); + + final RegionRenderer renderer = getRegionRenderer(); + final PMVMatrix pmv = renderer.getMatrix(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(xTran, yTran, zTran); + + // flip to GL window coordinates, origin bottom-left + final int[] viewport = renderer.getViewport(new int[4]); + final int glWinX = e.getX(); + final int glWinY = viewport[3] - e.getY() - 1; + + { + pmv.glPushMatrix(); + crossHair.setTransform(pmv); + + final float[] objPosC = crossHair.getBounds().getCenter(); + final int[] objWinPos = new int[2]; + System.err.println("\n\nCrossHair: "+crossHair); + if( crossHair.objToWinCoord(renderer, objPosC, objWinPos) ) { + System.err.println("CrossHair: Obj: Obj "+objPosC[0]+"/"+objPosC[1]+"/"+objPosC[1]+" -> Win "+objWinPos[0]+"/"+objWinPos[1]); + } + + final float[] objPos2 = new float[3]; + crossHair.winToObjCoord(renderer, objWinPos[0], objWinPos[1], objPos2); + System.err.println("CrossHair: Obj: Win "+objWinPos[0]+"/"+objWinPos[1]+" -> Obj "+objPos2[0]+"/"+objPos2[1]+"/"+objPos2[1]); + + final float[] winObjPos = new float[3]; + if( crossHair.winToObjCoord(renderer, glWinX, glWinY, winObjPos) ) { + // final float[] translate = crossHair.getTranslate(); + // final float[] objPosT = new float[] { objPosC[0]+translate[0], objPosC[1]+translate[1], objPosC[2]+translate[2] }; + final float dx = winObjPos[0] - objPosC[0]; + final float dy = winObjPos[1] - objPosC[1]; + // final float dz = winObjPos[2] - objPosT[2]; + if( !FloatUtil.isZero(dx, FloatUtil.EPSILON) || !FloatUtil.isZero(dy, FloatUtil.EPSILON) ) { + System.err.println("CrossHair: Move.1: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); + crossHair.translate(dx, dy, 0f); + } else { + System.err.println("CrossHair: Move.0: Win "+glWinX+"/"+glWinY+" -> Obj "+winObjPos[0]+"/"+winObjPos[1]+"/"+winObjPos[1]+" -> diff "+dx+" / "+dy); + } + } + + final int[] surfaceSize = new int[2]; + crossHair.getSurfaceSize(renderer, surfaceSize); + System.err.println("CrossHair: Size: Pixel "+surfaceSize[0]+" x "+surfaceSize[1]); + + pmv.glPopMatrix(); + } + return true; + } } ); + + } + + @Override + public void mouseReleased(final MouseEvent e) { + } + + @Override + public void mouseMoved(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseDragged(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseWheelMoved(final MouseEvent e) { + // TODO Auto-generated method stub + + } + + } + + public class KeyAction implements KeyListener { + @Override + public void keyPressed(final KeyEvent arg0) { + if(ignoreInput) { + return; + } + + if(arg0.getKeyCode() == KeyEvent.VK_1){ + crossHair.translate(0f, 0f, -zTran/10f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_2){ + crossHair.translate(0f, 0f, zTran/10f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_UP){ + crossHair.translate(0f, crossHair.getHeight()/10f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_DOWN){ + crossHair.translate(0f, -crossHair.getHeight()/10f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_LEFT){ + crossHair.translate(-crossHair.getWidth()/10f, 0f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_RIGHT){ + crossHair.translate(crossHair.getWidth()/10f, 0f, 0f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_0){ + // rotate(1); + } + else if(arg0.getKeyCode() == KeyEvent.VK_9){ + // rotate(-1); + } + else if(arg0.getKeyCode() == KeyEvent.VK_V) { + if(null != autoDrawable) { + autoDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + final int _i = gl.getSwapInterval(); + final int i; + switch(_i) { + case 0: i = 1; break; + case 1: i = -1; break; + case -1: i = 0; break; + default: i = 1; break; + } + gl.setSwapInterval(i); + + final GLAnimatorControl a = drawable.getAnimator(); + if( null != a ) { + a.resetFPSCounter(); + } + if(drawable instanceof FPSCounter) { + ((FPSCounter)drawable).resetFPSCounter(); + } + System.err.println("Swap Interval: "+_i+" -> "+i+" -> "+gl.getSwapInterval()); + return true; + } + }); + } + } + else if(arg0.getKeyCode() == KeyEvent.VK_S){ + if(null != autoDrawable) { + autoDrawable.invoke(false, new GLRunnable() { + @Override + public boolean run(final GLAutoDrawable drawable) { + try { + printScreen(drawable); + } catch (final GLException e) { + e.printStackTrace(); + } catch (final IOException e) { + e.printStackTrace(); + } + return true; + } + }); + } + } + } + @Override + public void keyReleased(final KeyEvent arg0) {} + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-pressed-145x53.png b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-pressed-145x53.png new file mode 100644 index 000000000..1eba3a09e Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-pressed-145x53.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-released-145x53.png b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-released-145x53.png new file mode 100644 index 000000000..fe223c6d3 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/ui/demos/button-released-145x53.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph01UbuntuLight_o.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph01UbuntuLight_o.java new file mode 100644 index 000000000..a79a68d4e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph01UbuntuLight_o.java @@ -0,0 +1,316 @@ +/** + * Copyright 2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.testshapes; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.geom.plane.Winding; +import com.jogamp.graph.ui.gl.Shape; + +/** + * GPU based resolution independent test object + * - Ubuntu-Light, lower case 'o' + * - TTF Shape for Glyph 82 + */ +public class Glyph01UbuntuLight_o extends Shape { + + public Glyph01UbuntuLight_o(final Factory factory, final int renderModes) { + super(factory, renderModes); + } + + @Override + protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @SuppressWarnings("unused") + @Override + protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + + // Ubuntu-Light, lower case 'o' + // Start TTF Shape for Glyph 82 + if( false ) { + // Original Outer shape: Winding.CW + // Moved into OutlineShape reverse -> Winding.CCW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.527000f, 0.258000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.527000f, 0.197000f, false); + shape.addVertex(0, 0.510000f, 0.147000f, true); + // 002: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.492000f, 0.097000f, false); + shape.addVertex(0, 0.461000f, 0.062000f, true); + // 003: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.429000f, 0.027000f, false); + shape.addVertex(0, 0.386000f, 0.008000f, true); + // 004: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.343000f, -0.012000f, false); + shape.addVertex(0, 0.291000f, -0.012000f, true); + // 005: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.239000f, -0.012000f, false); + shape.addVertex(0, 0.196000f, 0.007000f, true); + // 007: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.153000f, 0.027000f, false); + shape.addVertex(0, 0.122000f, 0.062000f, true); + // 008: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.090000f, 0.097000f, false); + shape.addVertex(0, 0.073000f, 0.147000f, true); + // 009: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.055000f, 0.197000f, false); + shape.addVertex(0, 0.055000f, 0.258000f, true); + // 010: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.055000f, 0.319000f, false); + shape.addVertex(0, 0.072000f, 0.369000f, true); + // 012: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.090000f, 0.419000f, false); + shape.addVertex(0, 0.121000f, 0.454000f, true); + // 013: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.153000f, 0.490000f, false); + shape.addVertex(0, 0.196000f, 0.509000f, true); + // 014: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.239000f, 0.529000f, false); + shape.addVertex(0, 0.291000f, 0.529000f, true); + // 015: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.343000f, 0.529000f, false); + shape.addVertex(0, 0.386000f, 0.510000f, true); + // 017: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.429000f, 0.490000f, false); + shape.addVertex(0, 0.460000f, 0.455000f, true); + // 018: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.492000f, 0.419000f, false); + shape.addVertex(0, 0.509000f, 0.369000f, true); + // 019: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.527000f, 0.319000f, false); + shape.addVertex(0, 0.527000f, 0.258000f, true); + System.err.println("Glyph01UbuntuLight_o.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + // Outer shape: Winding.CW + // Moved into OutlineShape same-order -> Winding.CW -> ERROR (so we fix it in the end, see below) + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0.527000f, 0.258000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.527000f, 0.197000f, false); + shape.addVertex(0.510000f, 0.147000f, true); + // 002: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.492000f, 0.097000f, false); + shape.addVertex(0.461000f, 0.062000f, true); + // 003: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.429000f, 0.027000f, false); + shape.addVertex(0.386000f, 0.008000f, true); + // 004: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.343000f, -0.012000f, false); + shape.addVertex(0.291000f, -0.012000f, true); + // 005: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.239000f, -0.012000f, false); + shape.addVertex(0.196000f, 0.007000f, true); + // 007: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.153000f, 0.027000f, false); + shape.addVertex(0.122000f, 0.062000f, true); + // 008: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.090000f, 0.097000f, false); + shape.addVertex(0.073000f, 0.147000f, true); + // 009: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.055000f, 0.197000f, false); + shape.addVertex(0.055000f, 0.258000f, true); + // 010: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.055000f, 0.319000f, false); + shape.addVertex(0.072000f, 0.369000f, true); + // 012: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.090000f, 0.419000f, false); + shape.addVertex(0.121000f, 0.454000f, true); + // 013: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.153000f, 0.490000f, false); + shape.addVertex(0.196000f, 0.509000f, true); + // 014: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.239000f, 0.529000f, false); + shape.addVertex(0.291000f, 0.529000f, true); + // 015: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.343000f, 0.529000f, false); + shape.addVertex(0.386000f, 0.510000f, true); + // 017: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.429000f, 0.490000f, false); + shape.addVertex(0.460000f, 0.455000f, true); + // 018: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.492000f, 0.419000f, false); + shape.addVertex(0.509000f, 0.369000f, true); + // 019: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.527000f, 0.319000f, false); + shape.addVertex(0.527000f, 0.258000f, true); + System.err.println("Glyph01UbuntuLight_o.shape01b.1.winding_area: "+shape.getWindingOfLastOutline()); + shape.setWindingOfLastOutline(Winding.CCW); + System.err.println("Glyph01UbuntuLight_o.shape01b.2.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + + if( true ) { + // Original Inner shape: Winding.CCW + // Moved into OutlineShape reverse -> Winding.CW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.458000f, 0.258000f, true); + // 020: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.458000f, 0.355000f, false); + shape.addVertex(0, 0.413000f, 0.412000f, true); + // 022: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.368000f, 0.470000f, false); + shape.addVertex(0, 0.291000f, 0.470000f, true); + // 023: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.214000f, 0.470000f, false); + shape.addVertex(0, 0.169000f, 0.413000f, true); + // 025: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.124000f, 0.355000f, false); + shape.addVertex(0, 0.124000f, 0.258000f, true); + // 026: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.124000f, 0.161000f, false); + shape.addVertex(0, 0.169000f, 0.104000f, true); + // 028: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.214000f, 0.047000f, false); + shape.addVertex(0, 0.291000f, 0.047000f, true); + // 029: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.368000f, 0.047000f, false); + shape.addVertex(0, 0.413000f, 0.104000f, true); + // 031: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.458000f, 0.161000f, false); + shape.addVertex(0, 0.458000f, 0.258000f, true); + System.err.println("Glyph01UbuntuLight_o.shape02a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + // Inner shape: Winding.CCW + // Moved into OutlineShape same-order -> Winding.CCW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + + shape.addVertex(0.458000f, 0.258000f, true); + // 020: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.458000f, 0.355000f, false); + shape.addVertex(0.413000f, 0.412000f, true); + // 022: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.368000f, 0.470000f, false); + shape.addVertex(0.291000f, 0.470000f, true); + // 023: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.214000f, 0.470000f, false); + shape.addVertex(0.169000f, 0.413000f, true); + // 025: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.124000f, 0.355000f, false); + shape.addVertex(0.124000f, 0.258000f, true); + // 026: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.124000f, 0.161000f, false); + shape.addVertex(0.169000f, 0.104000f, true); + // 028: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.214000f, 0.047000f, false); + shape.addVertex(0.291000f, 0.047000f, true); + // 029: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.368000f, 0.047000f, false); + shape.addVertex(0.413000f, 0.104000f, true); + // 031: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.458000f, 0.161000f, false); + shape.addVertex(0.458000f, 0.258000f, true); + + System.err.println("Glyph01UbuntuLight_o.shape02b.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + // End Shape for Glyph 82 + + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + + box.resize(shape.getBounds()); + } + + @Override + public String getSubString() { + return super.getSubString(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph02UbuntuLight_ae.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph02UbuntuLight_ae.java new file mode 100644 index 000000000..b81eb546f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph02UbuntuLight_ae.java @@ -0,0 +1,652 @@ +/** + * Copyright 2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.testshapes; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.ui.gl.Shape; + +/** + * GPU based resolution independent test object + * - Ubuntu-Light, lower case 'æ' + * - TTF Shape for Glyph 193 + */ +public class Glyph02UbuntuLight_ae extends Shape { + + public Glyph02UbuntuLight_ae(final Factory factory, final int renderModes) { + super(factory, renderModes); + } + + @Override + protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @SuppressWarnings("unused") + @Override + protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + + // Ubuntu-Light, lower case 'æ' + + // Start TTF Shape for Glyph 193 + if( true ) { + // Original Inner e-shape: Winding.CCW + // Moved into OutlineShape reverse -> Winding.CW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.728000f, 0.300000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.726000f, 0.381000f, false); + shape.addVertex(0, 0.690000f, 0.426000f, true); + // 002: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.654000f, 0.471000f, false); + shape.addVertex(0, 0.588000f, 0.471000f, true); + // 003: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.553000f, 0.471000f, false); + shape.addVertex(0, 0.526000f, 0.457000f, true); + // 005: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.498000f, 0.443000f, false); + shape.addVertex(0, 0.478000f, 0.420000f, true); + // 006: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.457000f, 0.396000f, false); + shape.addVertex(0, 0.446000f, 0.365000f, true); + // 007: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.434000f, 0.334000f, false); + shape.addVertex(0, 0.432000f, 0.300000f, true); + // 008: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.728000f, 0.300000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + // Inner e-shape: Winding.CCW + // Moved into OutlineShape same-order -> Winding.CCW -> ?? + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0.728000f, 0.300000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.726000f, 0.381000f, false); + shape.addVertex(0.690000f, 0.426000f, true); + // 002: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.654000f, 0.471000f, false); + shape.addVertex(0.588000f, 0.471000f, true); + // 003: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.553000f, 0.471000f, false); + shape.addVertex(0.526000f, 0.457000f, true); + // 005: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.498000f, 0.443000f, false); + shape.addVertex(0.478000f, 0.420000f, true); + // 006: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.457000f, 0.396000f, false); + shape.addVertex(0.446000f, 0.365000f, true); + // 007: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.434000f, 0.334000f, false); + shape.addVertex(0.432000f, 0.300000f, true); + // 008: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0.728000f, 0.300000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape01b.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + + if( true ) { + // Original Outer shape: Winding.CW + // Moved into OutlineShape reverse -> Winding.CCW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.252000f, -0.011000f, true); + // 009: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.208000f, -0.011000f, false); + shape.addVertex(0, 0.171000f, -0.002000f, true); + // 011: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.133000f, 0.007000f, false); + shape.addVertex(0, 0.106000f, 0.026000f, true); + // 012: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.079000f, 0.046000f, false); + shape.addVertex(0, 0.064000f, 0.076000f, true); + // 013: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.048000f, 0.107000f, false); + shape.addVertex(0, 0.048000f, 0.151000f, true); + // 014: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.048000f, 0.193000f, false); + shape.addVertex(0, 0.064000f, 0.223000f, true); + // 016: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.080000f, 0.253000f, false); + shape.addVertex(0, 0.109000f, 0.272000f, true); + // 017: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.138000f, 0.292000f, false); + shape.addVertex(0, 0.178000f, 0.301000f, true); + // 018: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.218000f, 0.310000f, false); + shape.addVertex(0, 0.265000f, 0.310000f, true); + // 019: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.279000f, 0.310000f, false); + shape.addVertex(0, 0.294000f, 0.309000f, true); + // 021: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.310000f, 0.307000f, false); + shape.addVertex(0, 0.324000f, 0.305000f, true); + // 022: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.339000f, 0.302000f, false); + shape.addVertex(0, 0.349000f, 0.300000f, true); + // 023: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.360000f, 0.297000f, false); + shape.addVertex(0, 0.364000f, 0.295000f, true); + // 024: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.364000f, 0.327000f, true); + // 025: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.364000f, 0.354000f, false); + shape.addVertex(0, 0.360000f, 0.379000f, true); + // 027: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.356000f, 0.405000f, false); + shape.addVertex(0, 0.343000f, 0.425000f, true); + // 028: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.329000f, 0.446000f, false); + shape.addVertex(0, 0.305000f, 0.458000f, true); + // 029: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.280000f, 0.471000f, false); + shape.addVertex(0, 0.240000f, 0.471000f, true); + // 030: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.186000f, 0.471000f, false); + shape.addVertex(0, 0.156000f, 0.464000f, true); + // 032: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.126000f, 0.456000f, false); + shape.addVertex(0, 0.113000f, 0.451000f, true); + // 033: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.105000f, 0.507000f, true); + // 034: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.122000f, 0.515000f, false); + shape.addVertex(0, 0.158000f, 0.522000f, true); + // 036: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.194000f, 0.529000f, false); + shape.addVertex(0, 0.243000f, 0.529000f, true); + // 037: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.314000f, 0.529000f, false); + shape.addVertex(0, 0.354000f, 0.503000f, true); + // 039: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.395000f, 0.476000f, false); + shape.addVertex(0, 0.412000f, 0.431000f, true); + // 040: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.445000f, 0.480000f, false); + shape.addVertex(0, 0.491000f, 0.504000f, true); + // 042: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.537000f, 0.529000f, false); + shape.addVertex(0, 0.587000f, 0.529000f, true); + // 043: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.682000f, 0.529000f, false); + shape.addVertex(0, 0.738000f, 0.467000f, true); + // 045: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.795000f, 0.405000f, false); + shape.addVertex(0, 0.795000f, 0.276000f, true); + // 046: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.795000f, 0.268000f, false); + shape.addVertex(0, 0.795000f, 0.260000f, true); + // 048: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.794000f, 0.252000f, false); + shape.addVertex(0, 0.793000f, 0.245000f, true); + // 049: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.430000f, 0.245000f, true); + // 050: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.433000f, 0.150000f, false); + shape.addVertex(0, 0.477000f, 0.099000f, true); + // 052: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.521000f, 0.048000f, false); + shape.addVertex(0, 0.617000f, 0.048000f, true); + // 053: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.670000f, 0.048000f, false); + shape.addVertex(0, 0.701000f, 0.058000f, true); + // 055: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.732000f, 0.068000f, false); + shape.addVertex(0, 0.746000f, 0.075000f, true); + // 056: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.758000f, 0.019000f, true); + // 057: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.744000f, 0.011000f, false); + shape.addVertex(0, 0.706000f, 0.000000f, true); + // 059: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.667000f, -0.011000f, false); + shape.addVertex(0, 0.615000f, -0.011000f, true); + // 060: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.558000f, -0.011000f, false); + shape.addVertex(0, 0.514000f, 0.003000f, true); + // 062: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.470000f, 0.017000f, false); + shape.addVertex(0, 0.437000f, 0.049000f, true); + // 063: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.426000f, 0.040000f, false); + shape.addVertex(0, 0.410000f, 0.030000f, true); + // 065: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.393000f, 0.019000f, false); + shape.addVertex(0, 0.370000f, 0.010000f, true); + // 066: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.347000f, 0.001000f, false); + shape.addVertex(0, 0.318000f, -0.005000f, true); + // 067: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.289000f, -0.011000f, false); + shape.addVertex(0, 0.252000f, -0.011000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape02a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + // Outer shape: Winding.CW + // Moved into OutlineShape same-order -> Winding.CW -> OK now + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0.252000f, -0.011000f, true); + // 009: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.208000f, -0.011000f, false); + shape.addVertex(0.171000f, -0.002000f, true); + // 011: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.133000f, 0.007000f, false); + shape.addVertex(0.106000f, 0.026000f, true); + // 012: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.079000f, 0.046000f, false); + shape.addVertex(0.064000f, 0.076000f, true); + // 013: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.048000f, 0.107000f, false); + shape.addVertex(0.048000f, 0.151000f, true); + // 014: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.048000f, 0.193000f, false); + shape.addVertex(0.064000f, 0.223000f, true); + // 016: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.080000f, 0.253000f, false); + shape.addVertex(0.109000f, 0.272000f, true); + // 017: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.138000f, 0.292000f, false); + shape.addVertex(0.178000f, 0.301000f, true); + // 018: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.218000f, 0.310000f, false); + shape.addVertex(0.265000f, 0.310000f, true); + // 019: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.279000f, 0.310000f, false); + shape.addVertex(0.294000f, 0.309000f, true); + // 021: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.310000f, 0.307000f, false); + shape.addVertex(0.324000f, 0.305000f, true); + // 022: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.339000f, 0.302000f, false); + shape.addVertex(0.349000f, 0.300000f, true); + // 023: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.360000f, 0.297000f, false); + shape.addVertex(0.364000f, 0.295000f, true); + // 024: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0.364000f, 0.327000f, true); + // 025: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.364000f, 0.354000f, false); + shape.addVertex(0.360000f, 0.379000f, true); + // 027: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.356000f, 0.405000f, false); + shape.addVertex(0.343000f, 0.425000f, true); + // 028: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.329000f, 0.446000f, false); + shape.addVertex(0.305000f, 0.458000f, true); + // 029: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.280000f, 0.471000f, false); + shape.addVertex(0.240000f, 0.471000f, true); + // 030: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.186000f, 0.471000f, false); + shape.addVertex(0.156000f, 0.464000f, true); + // 032: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.126000f, 0.456000f, false); + shape.addVertex(0.113000f, 0.451000f, true); + // 033: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0.105000f, 0.507000f, true); + // 034: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.122000f, 0.515000f, false); + shape.addVertex(0.158000f, 0.522000f, true); + // 036: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.194000f, 0.529000f, false); + shape.addVertex(0.243000f, 0.529000f, true); + // 037: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.314000f, 0.529000f, false); + shape.addVertex(0.354000f, 0.503000f, true); + // 039: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.395000f, 0.476000f, false); + shape.addVertex(0.412000f, 0.431000f, true); + // 040: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.445000f, 0.480000f, false); + shape.addVertex(0.491000f, 0.504000f, true); + // 042: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.537000f, 0.529000f, false); + shape.addVertex(0.587000f, 0.529000f, true); + // 043: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.682000f, 0.529000f, false); + shape.addVertex(0.738000f, 0.467000f, true); + // 045: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.795000f, 0.405000f, false); + shape.addVertex(0.795000f, 0.276000f, true); + // 046: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.795000f, 0.268000f, false); + shape.addVertex(0.795000f, 0.260000f, true); + // 048: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.794000f, 0.252000f, false); + shape.addVertex(0.793000f, 0.245000f, true); + // 049: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0.430000f, 0.245000f, true); + // 050: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.433000f, 0.150000f, false); + shape.addVertex(0.477000f, 0.099000f, true); + // 052: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.521000f, 0.048000f, false); + shape.addVertex(0.617000f, 0.048000f, true); + // 053: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.670000f, 0.048000f, false); + shape.addVertex(0.701000f, 0.058000f, true); + // 055: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.732000f, 0.068000f, false); + shape.addVertex(0.746000f, 0.075000f, true); + // 056: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0.758000f, 0.019000f, true); + // 057: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.744000f, 0.011000f, false); + shape.addVertex(0.706000f, 0.000000f, true); + // 059: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.667000f, -0.011000f, false); + shape.addVertex(0.615000f, -0.011000f, true); + // 060: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.558000f, -0.011000f, false); + shape.addVertex(0.514000f, 0.003000f, true); + // 062: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.470000f, 0.017000f, false); + shape.addVertex(0.437000f, 0.049000f, true); + // 063: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.426000f, 0.040000f, false); + shape.addVertex(0.410000f, 0.030000f, true); + // 065: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.393000f, 0.019000f, false); + shape.addVertex(0.370000f, 0.010000f, true); + // 066: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.347000f, 0.001000f, false); + shape.addVertex(0.318000f, -0.005000f, true); + // 067: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.289000f, -0.011000f, false); + shape.addVertex(0.252000f, -0.011000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape02b.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + + if( true ) { + // Original Inner a-shape: Winding.CCW + // Moved into OutlineShape reverse -> Winding.CW -> OK now + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.365000f, 0.238000f, true); + // 068: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.354000f, 0.243000f, false); + shape.addVertex(0, 0.330000f, 0.248000f, true); + // 070: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.305000f, 0.254000f, false); + shape.addVertex(0, 0.263000f, 0.254000f, true); + // 071: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.239000f, 0.254000f, false); + shape.addVertex(0, 0.213000f, 0.251000f, true); + // 073: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.187000f, 0.247000f, false); + shape.addVertex(0, 0.165000f, 0.236000f, true); + // 074: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.143000f, 0.224000f, false); + shape.addVertex(0, 0.129000f, 0.204000f, true); + // 075: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.115000f, 0.184000f, false); + shape.addVertex(0, 0.115000f, 0.151000f, true); + // 076: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.115000f, 0.122000f, false); + shape.addVertex(0, 0.125000f, 0.102000f, true); + // 078: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.135000f, 0.082000f, false); + shape.addVertex(0, 0.153000f, 0.070000f, true); + // 079: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.172000f, 0.058000f, false); + shape.addVertex(0, 0.197000f, 0.053000f, true); + // 080: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.222000f, 0.047000f, false); + shape.addVertex(0, 0.252000f, 0.047000f, true); + // 081: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.314000f, 0.047000f, false); + shape.addVertex(0, 0.350000f, 0.063000f, true); + // 083: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.386000f, 0.080000f, false); + shape.addVertex(0, 0.400000f, 0.093000f, true); + // 084: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.384000f, 0.119000f, false); + shape.addVertex(0, 0.375000f, 0.154000f, true); + // 086: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.366000f, 0.190000f, false); + shape.addVertex(0, 0.365000f, 0.238000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape03a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + // Inner a-shape: Winding.CCW + // Moved into OutlineShape same-order -> Winding.CCW -> OK + // + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0.365000f, 0.238000f, true); + // 068: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.354000f, 0.243000f, false); + shape.addVertex(0.330000f, 0.248000f, true); + // 070: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.305000f, 0.254000f, false); + shape.addVertex(0.263000f, 0.254000f, true); + // 071: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.239000f, 0.254000f, false); + shape.addVertex(0.213000f, 0.251000f, true); + // 073: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.187000f, 0.247000f, false); + shape.addVertex(0.165000f, 0.236000f, true); + // 074: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.143000f, 0.224000f, false); + shape.addVertex(0.129000f, 0.204000f, true); + // 075: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.115000f, 0.184000f, false); + shape.addVertex(0.115000f, 0.151000f, true); + // 076: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.115000f, 0.122000f, false); + shape.addVertex(0.125000f, 0.102000f, true); + // 078: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.135000f, 0.082000f, false); + shape.addVertex(0.153000f, 0.070000f, true); + // 079: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0.172000f, 0.058000f, false); + shape.addVertex(0.197000f, 0.053000f, true); + // 080: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.222000f, 0.047000f, false); + shape.addVertex(0.252000f, 0.047000f, true); + // 081: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.314000f, 0.047000f, false); + shape.addVertex(0.350000f, 0.063000f, true); + // 083: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.386000f, 0.080000f, false); + shape.addVertex(0.400000f, 0.093000f, true); + // 084: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0.384000f, 0.119000f, false); + shape.addVertex(0.375000f, 0.154000f, true); + // 086: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0.366000f, 0.190000f, false); + shape.addVertex(0.365000f, 0.238000f, true); + System.err.println("Glyph02UbuntuLight_ae.shape03b.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + // End Shape for Glyph 193 + + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + + box.resize(shape.getBounds()); + } + + @Override + public String getSubString() { + return super.getSubString(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java new file mode 100644 index 000000000..053134866 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java @@ -0,0 +1,804 @@ +/** + * Copyright 2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.testshapes; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.ui.gl.Shape; + +/** + * GPU based resolution independent test object + * - FreeMono-Regular, capital case 'M' + * - TTF Shape for Glyph 48 + */ +public class Glyph03FreeMonoRegular_M extends Shape { + + public Glyph03FreeMonoRegular_M(final Factory factory, final int renderModes) { + super(factory, renderModes); + } + + @Override + protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @SuppressWarnings("unused") + @Override + protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + + if( false ) { + // Start TTF Shape for Glyph 48 + // GlyphShape<48>: offset 0 of 45/45 points + // pM[044] P[483/522, on true, end true] + // p0[000] P[326/169, on true, end false] + // p1[001] P[280/169, on true, end false] + // p2[002] P[121/522, on true, end false] + // 000: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.326000f, 0.169000f, true); + // 000: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.280000f, 0.169000f, true); + // GlyphShape<48>: offset 1 of 45/45 points + // pM[000] P[326/169, on true, end false] + // p0[001] P[280/169, on true, end false] + // p1[002] P[121/522, on true, end false] + // p2[003] P[113/522, on true, end false] + // 001: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.121000f, 0.522000f, true); + // GlyphShape<48>: offset 2 of 45/45 points + // pM[001] P[280/169, on true, end false] + // p0[002] P[121/522, on true, end false] + // p1[003] P[113/522, on true, end false] + // p2[004] P[113/41, on true, end false] + // 002: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.113000f, 0.522000f, true); + // GlyphShape<48>: offset 3 of 45/45 points + // pM[002] P[121/522, on true, end false] + // p0[003] P[113/522, on true, end false] + // p1[004] P[113/41, on true, end false] + // p2[005] P[187/41, on true, end false] + // 003: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.113000f, 0.041000f, true); + // GlyphShape<48>: offset 4 of 45/45 points + // pM[003] P[113/522, on true, end false] + // p0[004] P[113/41, on true, end false] + // p1[005] P[187/41, on true, end false] + // p2[006] P[215/41, on false, end false] + // 004: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.187000f, 0.041000f, true); + // GlyphShape<48>: offset 5 of 45/45 points + // pM[004] P[113/41, on true, end false] + // p0[005] P[187/41, on true, end false] + // p1[006] P[215/41, on false, end false] + // p2[007] P[215/21, on true, end false] + // 005: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.215000f, 0.041000f, false); + shape.addVertex(0, 0.215000f, 0.021000f, true); + // GlyphShape<48>: offset 7 of 45/45 points + // pM[006] P[215/41, on false, end false] + // p0[007] P[215/21, on true, end false] + // p1[008] P[215/0, on false, end false] + // p2[009] P[187/0, on true, end false] + // 007: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.215000f, 0.000000f, false); + shape.addVertex(0, 0.187000f, 0.000000f, true); + // GlyphShape<48>: offset 9 of 45/45 points + // pM[008] P[215/0, on false, end false] + // p0[009] P[187/0, on true, end false] + // p1[010] P[38/0, on true, end false] + // p2[011] P[11/0, on false, end false] + // 009: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.038000f, 0.000000f, true); + // GlyphShape<48>: offset 10 of 45/45 points + // pM[009] P[187/0, on true, end false] + // p0[010] P[38/0, on true, end false] + // p1[011] P[11/0, on false, end false] + // p2[012] P[11/21, on true, end false] + // 010: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.011000f, 0.000000f, false); + shape.addVertex(0, 0.011000f, 0.021000f, true); + // GlyphShape<48>: offset 12 of 45/45 points + // pM[011] P[11/0, on false, end false] + // p0[012] P[11/21, on true, end false] + // p1[013] P[11/41, on false, end false] + // p2[014] P[38/41, on true, end false] + // 012: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.011000f, 0.041000f, false); + shape.addVertex(0, 0.038000f, 0.041000f, true); + // GlyphShape<48>: offset 14 of 45/45 points + // pM[013] P[11/41, on false, end false] + // p0[014] P[38/41, on true, end false] + // p1[015] P[72/41, on true, end false] + // p2[016] P[72/522, on true, end false] + // 014: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.072000f, 0.041000f, true); + // GlyphShape<48>: offset 15 of 45/45 points + // pM[014] P[38/41, on true, end false] + // p0[015] P[72/41, on true, end false] + // p1[016] P[72/522, on true, end false] + // p2[017] P[47/522, on true, end false] + // 015: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.072000f, 0.522000f, true); + // GlyphShape<48>: offset 16 of 45/45 points + // pM[015] P[72/41, on true, end false] + // p0[016] P[72/522, on true, end false] + // p1[017] P[47/522, on true, end false] + // p2[018] P[20/522, on false, end false] + // 016: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.047000f, 0.522000f, true); + // GlyphShape<48>: offset 17 of 45/45 points + // pM[016] P[72/522, on true, end false] + // p0[017] P[47/522, on true, end false] + // p1[018] P[20/522, on false, end false] + // p2[019] P[20/543, on true, end false] + // 017: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.522000f, false); + shape.addVertex(0, 0.020000f, 0.543000f, true); + // GlyphShape<48>: offset 19 of 45/45 points + // pM[018] P[20/522, on false, end false] + // p0[019] P[20/543, on true, end false] + // p1[020] P[20/563, on false, end false] + // p2[021] P[47/563, on true, end false] + // 019: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.563000f, false); + shape.addVertex(0, 0.047000f, 0.563000f, true); + // GlyphShape<48>: offset 21 of 45/45 points + // pM[020] P[20/563, on false, end false] + // p0[021] P[47/563, on true, end false] + // p1[022] P[146/563, on true, end false] + // p2[023] P[303/215, on true, end false] + // 021: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.146000f, 0.563000f, true); + // GlyphShape<48>: offset 22 of 45/45 points + // pM[021] P[47/563, on true, end false] + // p0[022] P[146/563, on true, end false] + // p1[023] P[303/215, on true, end false] + // p2[024] P[457/563, on true, end false] + // 022: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.303000f, 0.215000f, true); + // GlyphShape<48>: offset 23 of 45/45 points + // pM[022] P[146/563, on true, end false] + // p0[023] P[303/215, on true, end false] + // p1[024] P[457/563, on true, end false] + // p2[025] P[557/563, on true, end false] + // 023: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.457000f, 0.563000f, true); + // GlyphShape<48>: offset 24 of 45/45 points + // pM[023] P[303/215, on true, end false] + // p0[024] P[457/563, on true, end false] + // p1[025] P[557/563, on true, end false] + // p2[026] P[584/563, on false, end false] + // 024: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.557000f, 0.563000f, true); + // GlyphShape<48>: offset 25 of 45/45 points + // pM[024] P[457/563, on true, end false] + // p0[025] P[557/563, on true, end false] + // p1[026] P[584/563, on false, end false] + // p2[027] P[584/543, on true, end false] + // 025: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.584000f, 0.563000f, false); + shape.addVertex(0, 0.584000f, 0.543000f, true); + // GlyphShape<48>: offset 27 of 45/45 points + // pM[026] P[584/563, on false, end false] + // p0[027] P[584/543, on true, end false] + // p1[028] P[584/522, on false, end false] + // p2[029] P[557/522, on true, end false] + // 027: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.584000f, 0.522000f, false); + shape.addVertex(0, 0.557000f, 0.522000f, true); + // GlyphShape<48>: offset 29 of 45/45 points + // pM[028] P[584/522, on false, end false] + // p0[029] P[557/522, on true, end false] + // p1[030] P[532/522, on true, end false] + // p2[031] P[532/41, on true, end false] + // 029: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.532000f, 0.522000f, true); + // GlyphShape<48>: offset 30 of 45/45 points + // pM[029] P[557/522, on true, end false] + // p0[030] P[532/522, on true, end false] + // p1[031] P[532/41, on true, end false] + // p2[032] P[566/41, on true, end false] + // 030: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.532000f, 0.041000f, true); + // GlyphShape<48>: offset 31 of 45/45 points + // pM[030] P[532/522, on true, end false] + // p0[031] P[532/41, on true, end false] + // p1[032] P[566/41, on true, end false] + // p2[033] P[593/41, on false, end false] + // 031: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.566000f, 0.041000f, true); + // GlyphShape<48>: offset 32 of 45/45 points + // pM[031] P[532/41, on true, end false] + // p0[032] P[566/41, on true, end false] + // p1[033] P[593/41, on false, end false] + // p2[034] P[593/21, on true, end false] + // 032: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.593000f, 0.041000f, false); + shape.addVertex(0, 0.593000f, 0.021000f, true); + // GlyphShape<48>: offset 34 of 45/45 points + // pM[033] P[593/41, on false, end false] + // p0[034] P[593/21, on true, end false] + // p1[035] P[593/0, on false, end false] + // p2[036] P[566/0, on true, end false] + // 034: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.593000f, 0.000000f, false); + shape.addVertex(0, 0.566000f, 0.000000f, true); + // GlyphShape<48>: offset 36 of 45/45 points + // pM[035] P[593/0, on false, end false] + // p0[036] P[566/0, on true, end false] + // p1[037] P[417/0, on true, end false] + // p2[038] P[390/0, on false, end false] + // 036: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.417000f, 0.000000f, true); + // GlyphShape<48>: offset 37 of 45/45 points + // pM[036] P[566/0, on true, end false] + // p0[037] P[417/0, on true, end false] + // p1[038] P[390/0, on false, end false] + // p2[039] P[390/21, on true, end false] + // 037: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.390000f, 0.000000f, false); + shape.addVertex(0, 0.390000f, 0.021000f, true); + // GlyphShape<48>: offset 39 of 45/45 points + // pM[038] P[390/0, on false, end false] + // p0[039] P[390/21, on true, end false] + // p1[040] P[390/41, on false, end false] + // p2[041] P[417/41, on true, end false] + // 039: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.390000f, 0.041000f, false); + shape.addVertex(0, 0.417000f, 0.041000f, true); + // GlyphShape<48>: offset 41 of 45/45 points + // pM[040] P[390/41, on false, end false] + // p0[041] P[417/41, on true, end false] + // p1[042] P[491/41, on true, end false] + // p2[043] P[491/522, on true, end false] + // 041: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.491000f, 0.041000f, true); + // GlyphShape<48>: offset 42 of 45/45 points + // pM[041] P[417/41, on true, end false] + // p0[042] P[491/41, on true, end false] + // p1[043] P[491/522, on true, end false] + // p2[044] P[483/522, on true, end true] + // 042: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.491000f, 0.522000f, true); + // GlyphShape<48>: offset 43 of 45/45 points + // pM[042] P[491/41, on true, end false] + // p0[043] P[491/522, on true, end false] + // p1[044] P[483/522, on true, end true] + // p2[000] P[326/169, on true, end false] + // 043: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.483000f, 0.522000f, true); + // GlyphShape<48>: offset 44 of 45/45 points + // pM[043] P[491/522, on true, end false] + // p0[044] P[483/522, on true, end true] + // p1[000] P[326/169, on true, end false] + // p2[001] P[280/169, on true, end false] + // 044: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.326000f, 0.169000f, true); + System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + + // End Shape for Glyph 48 + } else if( false ) { + // Start TTF Shape for Glyph 48 + // GlyphShape<48>: offset 0 of 45/45 points + // pM[044] P[483/522, on true, end true] + // p0[000] P[326/169, on true, end false] + // p1[001] P[280/169, on true, end false] + // p2[002] P[121/522, on true, end false] + // 000: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.326000f, 0.169000f, true); + // 000: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.280000f, 0.169000f, true); + // GlyphShape<48>: offset 1 of 45/45 points + // pM[000] P[326/169, on true, end false] + // p0[001] P[280/169, on true, end false] + // p1[002] P[121/522, on true, end false] + // p2[003] P[113/522, on true, end false] + // 001: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.121000f, 0.522000f, true); + // GlyphShape<48>: offset 2 of 45/45 points + // pM[001] P[280/169, on true, end false] + // p0[002] P[121/522, on true, end false] + // p1[003] P[113/522, on true, end false] + // p2[004] P[113/41, on true, end false] + // 002: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.113000f, 0.522000f, true); + // GlyphShape<48>: offset 3 of 45/45 points + // pM[002] P[121/522, on true, end false] + // p0[003] P[113/522, on true, end false] + // p1[004] P[113/41, on true, end false] + // p2[005] P[187/41, on true, end false] + // 003: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.113000f, 0.041000f, true); + // GlyphShape<48>: offset 4 of 45/45 points + // pM[003] P[113/522, on true, end false] + // p0[004] P[113/41, on true, end false] + // p1[005] P[187/41, on true, end false] + // p2[006] P[215/41, on false, end false] + // 004: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.187000f, 0.041000f, true); + // GlyphShape<48>: offset 5 of 45/45 points + // pM[004] P[113/41, on true, end false] + // p0[005] P[187/41, on true, end false] + // p1[006] P[215/41, on false, end false] + // p2[007] P[215/21, on true, end false] + // 005: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.215000f, 0.041000f, true); // curve -> line + shape.addVertex(0, 0.215000f, 0.021000f, true); + // GlyphShape<48>: offset 7 of 45/45 points + // pM[006] P[215/41, on false, end false] + // p0[007] P[215/21, on true, end false] + // p1[008] P[215/0, on false, end false] + // p2[009] P[187/0, on true, end false] + // 007: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.215000f, 0.000000f, true); // curve -> line + shape.addVertex(0, 0.187000f, 0.000000f, true); + // GlyphShape<48>: offset 9 of 45/45 points + // pM[008] P[215/0, on false, end false] + // p0[009] P[187/0, on true, end false] + // p1[010] P[38/0, on true, end false] + // p2[011] P[11/0, on false, end false] + // 009: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.038000f, 0.000000f, true); + // GlyphShape<48>: offset 10 of 45/45 points + // pM[009] P[187/0, on true, end false] + // p0[010] P[38/0, on true, end false] + // p1[011] P[11/0, on false, end false] + // p2[012] P[11/21, on true, end false] + // 010: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.011000f, 0.000000f, true); // curve -> line + shape.addVertex(0, 0.011000f, 0.021000f, true); + // GlyphShape<48>: offset 12 of 45/45 points + // pM[011] P[11/0, on false, end false] + // p0[012] P[11/21, on true, end false] + // p1[013] P[11/41, on false, end false] + // p2[014] P[38/41, on true, end false] + // 012: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.011000f, 0.041000f, true); // curve -> line + shape.addVertex(0, 0.038000f, 0.041000f, true); + // GlyphShape<48>: offset 14 of 45/45 points + // pM[013] P[11/41, on false, end false] + // p0[014] P[38/41, on true, end false] + // p1[015] P[72/41, on true, end false] + // p2[016] P[72/522, on true, end false] + // 014: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.072000f, 0.041000f, true); + // GlyphShape<48>: offset 15 of 45/45 points + // pM[014] P[38/41, on true, end false] + // p0[015] P[72/41, on true, end false] + // p1[016] P[72/522, on true, end false] + // p2[017] P[47/522, on true, end false] + // 015: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.072000f, 0.522000f, true); + // GlyphShape<48>: offset 16 of 45/45 points + // pM[015] P[72/41, on true, end false] + // p0[016] P[72/522, on true, end false] + // p1[017] P[47/522, on true, end false] + // p2[018] P[20/522, on false, end false] + // 016: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.047000f, 0.522000f, true); + // GlyphShape<48>: offset 17 of 45/45 points + // pM[016] P[72/522, on true, end false] + // p0[017] P[47/522, on true, end false] + // p1[018] P[20/522, on false, end false] + // p2[019] P[20/543, on true, end false] + // 017: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.522000f, true); // curve -> line + shape.addVertex(0, 0.020000f, 0.543000f, true); + // GlyphShape<48>: offset 19 of 45/45 points + // pM[018] P[20/522, on false, end false] + // p0[019] P[20/543, on true, end false] + // p1[020] P[20/563, on false, end false] + // p2[021] P[47/563, on true, end false] + // 019: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.563000f, true); // curve -> line + shape.addVertex(0, 0.047000f, 0.563000f, true); + // GlyphShape<48>: offset 21 of 45/45 points + // pM[020] P[20/563, on false, end false] + // p0[021] P[47/563, on true, end false] + // p1[022] P[146/563, on true, end false] + // p2[023] P[303/215, on true, end false] + // 021: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.146000f, 0.563000f, true); + // GlyphShape<48>: offset 22 of 45/45 points + // pM[021] P[47/563, on true, end false] + // p0[022] P[146/563, on true, end false] + // p1[023] P[303/215, on true, end false] + // p2[024] P[457/563, on true, end false] + // 022: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.303000f, 0.215000f, true); + // GlyphShape<48>: offset 23 of 45/45 points + // pM[022] P[146/563, on true, end false] + // p0[023] P[303/215, on true, end false] + // p1[024] P[457/563, on true, end false] + // p2[025] P[557/563, on true, end false] + // 023: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.457000f, 0.563000f, true); + // GlyphShape<48>: offset 24 of 45/45 points + // pM[023] P[303/215, on true, end false] + // p0[024] P[457/563, on true, end false] + // p1[025] P[557/563, on true, end false] + // p2[026] P[584/563, on false, end false] + // 024: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.557000f, 0.563000f, true); + // GlyphShape<48>: offset 25 of 45/45 points + // pM[024] P[457/563, on true, end false] + // p0[025] P[557/563, on true, end false] + // p1[026] P[584/563, on false, end false] + // p2[027] P[584/543, on true, end false] + // 025: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.584000f, 0.563000f, true); // curve -> line + shape.addVertex(0, 0.584000f, 0.543000f, true); + // GlyphShape<48>: offset 27 of 45/45 points + // pM[026] P[584/563, on false, end false] + // p0[027] P[584/543, on true, end false] + // p1[028] P[584/522, on false, end false] + // p2[029] P[557/522, on true, end false] + // 027: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.584000f, 0.522000f, true); // curve -> line + shape.addVertex(0, 0.557000f, 0.522000f, true); + // GlyphShape<48>: offset 29 of 45/45 points + // pM[028] P[584/522, on false, end false] + // p0[029] P[557/522, on true, end false] + // p1[030] P[532/522, on true, end false] + // p2[031] P[532/41, on true, end false] + // 029: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.532000f, 0.522000f, true); + // GlyphShape<48>: offset 30 of 45/45 points + // pM[029] P[557/522, on true, end false] + // p0[030] P[532/522, on true, end false] + // p1[031] P[532/41, on true, end false] + // p2[032] P[566/41, on true, end false] + // 030: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.532000f, 0.041000f, true); + // GlyphShape<48>: offset 31 of 45/45 points + // pM[030] P[532/522, on true, end false] + // p0[031] P[532/41, on true, end false] + // p1[032] P[566/41, on true, end false] + // p2[033] P[593/41, on false, end false] + // 031: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.566000f, 0.041000f, true); + // GlyphShape<48>: offset 32 of 45/45 points + // pM[031] P[532/41, on true, end false] + // p0[032] P[566/41, on true, end false] + // p1[033] P[593/41, on false, end false] + // p2[034] P[593/21, on true, end false] + // 032: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.593000f, 0.041000f, true); // curve -> line + shape.addVertex(0, 0.593000f, 0.021000f, true); + // GlyphShape<48>: offset 34 of 45/45 points + // pM[033] P[593/41, on false, end false] + // p0[034] P[593/21, on true, end false] + // p1[035] P[593/0, on false, end false] + // p2[036] P[566/0, on true, end false] + // 034: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.593000f, 0.000000f, true); // curve -> line + shape.addVertex(0, 0.566000f, 0.000000f, true); + // GlyphShape<48>: offset 36 of 45/45 points + // pM[035] P[593/0, on false, end false] + // p0[036] P[566/0, on true, end false] + // p1[037] P[417/0, on true, end false] + // p2[038] P[390/0, on false, end false] + // 036: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.417000f, 0.000000f, true); + // GlyphShape<48>: offset 37 of 45/45 points + // pM[036] P[566/0, on true, end false] + // p0[037] P[417/0, on true, end false] + // p1[038] P[390/0, on false, end false] + // p2[039] P[390/21, on true, end false] + // 037: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.390000f, 0.000000f, true); // curve -> line + shape.addVertex(0, 0.390000f, 0.021000f, true); + // GlyphShape<48>: offset 39 of 45/45 points + // pM[038] P[390/0, on false, end false] + // p0[039] P[390/21, on true, end false] + // p1[040] P[390/41, on false, end false] + // p2[041] P[417/41, on true, end false] + // 039: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.390000f, 0.041000f, true); // curve -> line + shape.addVertex(0, 0.417000f, 0.041000f, true); + // GlyphShape<48>: offset 41 of 45/45 points + // pM[040] P[390/41, on false, end false] + // p0[041] P[417/41, on true, end false] + // p1[042] P[491/41, on true, end false] + // p2[043] P[491/522, on true, end false] + // 041: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.491000f, 0.041000f, true); + // GlyphShape<48>: offset 42 of 45/45 points + // pM[041] P[417/41, on true, end false] + // p0[042] P[491/41, on true, end false] + // p1[043] P[491/522, on true, end false] + // p2[044] P[483/522, on true, end true] + // 042: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.491000f, 0.522000f, true); + // GlyphShape<48>: offset 43 of 45/45 points + // pM[042] P[491/41, on true, end false] + // p0[043] P[491/522, on true, end false] + // p1[044] P[483/522, on true, end true] + // p2[000] P[326/169, on true, end false] + // 043: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.483000f, 0.522000f, true); + // GlyphShape<48>: offset 44 of 45/45 points + // pM[043] P[491/522, on true, end false] + // p0[044] P[483/522, on true, end true] + // p1[000] P[326/169, on true, end false] + // p2[001] P[280/169, on true, end false] + // 044: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.326000f, 0.169000f, true); + System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } else { + final boolean with_left_leg = true; // ERROR + final boolean with_right_leg = false; // OK + + // Start TTF Shape for Glyph 48 + // GlyphShape<48>: offset 0 of 45/45 points + // pM[044] P[483/522, on true, end true] + // p0[000] P[326/169, on true, end false] + // p1[001] P[280/169, on true, end false] + // p2[002] P[121/522, on true, end false] + // 000: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.326000f, 0.169000f, true); + // 000: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.280000f, 0.169000f, true); + // GlyphShape<48>: offset 1 of 45/45 points + // pM[000] P[326/169, on true, end false] + // p0[001] P[280/169, on true, end false] + // p1[002] P[121/522, on true, end false] + // p2[003] P[113/522, on true, end false] + // 001: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.121000f, 0.522000f, true); // ID 11 + + // GlyphShape<48>: offset 2 of 45/45 points + // pM[001] P[280/169, on true, end false] + // p0[002] P[121/522, on true, end false] + // p1[003] P[113/522, on true, end false] + // p2[004] P[113/41, on true, end false] + // 002: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.113000f, 0.522000f, true); + + if( with_left_leg ) { + // GlyphShape<48>: offset 3 of 45/45 points + // pM[002] P[121/522, on true, end false] + // p0[003] P[113/522, on true, end false] + // p1[004] P[113/41, on true, end false] + // p2[005] P[187/41, on true, end false] + // 003: B1: line-to p0-p1 + // Shape.LineTo: + // shape.addVertex(0, 0.113000f, 0.041000f, true); + + shape.addVertex(0, 0.113000f, 0.000000f, true); + shape.addVertex(0, 0.072000f, 0.000000f, true); + + // GlyphShape<48>: offset 14 of 45/45 points + // pM[013] P[11/41, on false, end false] + // p0[014] P[38/41, on true, end false] + // p1[015] P[72/41, on true, end false] + // p2[016] P[72/522, on true, end false] + // 014: B1: line-to p0-p1 + // Shape.LineTo: + // shape.addVertex(0, 0.072000f, 0.041000f, true); + + // GlyphShape<48>: offset 15 of 45/45 points + // pM[014] P[38/41, on true, end false] + // p0[015] P[72/41, on true, end false] + // p1[016] P[72/522, on true, end false] + // p2[017] P[47/522, on true, end false] + // 015: B1: line-to p0-p1 + // Shape.LineTo: + // shape.addVertex(0, 0.072000f, 0.522000f, true); + + shape.addVertex(0, 0.072000f, 0.563000f, true); // ID 7 + } else { + shape.addVertex(0, 0.113000f, 0.563000f, true); + } + + // GlyphShape<48>: offset 21 of 45/45 points + // pM[020] P[20/563, on false, end false] + // p0[021] P[47/563, on true, end false] + // p1[022] P[146/563, on true, end false] + // p2[023] P[303/215, on true, end false] + // 021: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.146000f, 0.563000f, true); + // GlyphShape<48>: offset 22 of 45/45 points + // pM[021] P[47/563, on true, end false] + // p0[022] P[146/563, on true, end false] + // p1[023] P[303/215, on true, end false] + // p2[024] P[457/563, on true, end false] + // 022: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.303000f, 0.215000f, true); + // GlyphShape<48>: offset 23 of 45/45 points + // pM[022] P[146/563, on true, end false] + // p0[023] P[303/215, on true, end false] + // p1[024] P[457/563, on true, end false] + // p2[025] P[557/563, on true, end false] + // 023: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.457000f, 0.563000f, true); // ID 4 + + if( with_right_leg ) { + shape.addVertex(0, 0.532000f, 0.563000f, true); + + // GlyphShape<48>: offset 29 of 45/45 points + // pM[028] P[584/522, on false, end false] + // p0[029] P[557/522, on true, end false] + // p1[030] P[532/522, on true, end false] + // p2[031] P[532/41, on true, end false] + // 029: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.532000f, 0.522000f, true); + // GlyphShape<48>: offset 30 of 45/45 points + // pM[029] P[557/522, on true, end false] + // p0[030] P[532/522, on true, end false] + // p1[031] P[532/41, on true, end false] + // p2[032] P[566/41, on true, end false] + // 030: B1: line-to p0-p1 + // Shape.LineTo: + // shape.addVertex(0, 0.532000f, 0.041000f, true); + + shape.addVertex(0, 0.532000f, 0.000000f, true); + shape.addVertex(0, 0.491000f, 0.000000f, true); + } else { + shape.addVertex(0, 0.491000f, 0.563000f, true); // ID 3 + } + + // GlyphShape<48>: offset 41 of 45/45 points + // pM[040] P[390/41, on false, end false] + // p0[041] P[417/41, on true, end false] + // p1[042] P[491/41, on true, end false] + // p2[043] P[491/522, on true, end false] + // 041: B1: line-to p0-p1 + // Shape.LineTo: + // shape.addVertex(0, 0.491000f, 0.041000f, true); + + // GlyphShape<48>: offset 42 of 45/45 points + // pM[041] P[417/41, on true, end false] + // p0[042] P[491/41, on true, end false] + // p1[043] P[491/522, on true, end false] + // p2[044] P[483/522, on true, end true] + // 042: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.491000f, 0.522000f, true); // ID 2 + // GlyphShape<48>: offset 43 of 45/45 points + // pM[042] P[491/41, on true, end false] + // p0[043] P[491/522, on true, end false] + // p1[044] P[483/522, on true, end true] + // p2[000] P[326/169, on true, end false] + // 043: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.483000f, 0.522000f, true); // ID 1 + // GlyphShape<48>: offset 44 of 45/45 points + // pM[043] P[491/522, on true, end false] + // p0[044] P[483/522, on true, end true] + // p1[000] P[326/169, on true, end false] + // p2[001] P[280/169, on true, end false] + // 044: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.326000f, 0.169000f, true); + System.err.println("Glyph03FreeMonoRegular_M.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + + box.resize(shape.getBounds()); + } + + @Override + public String getSubString() { + return super.getSubString(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph04FreeSans_0.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph04FreeSans_0.java new file mode 100644 index 000000000..1f8d87888 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph04FreeSans_0.java @@ -0,0 +1,150 @@ +/** + * Copyright 2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.testshapes; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.ui.gl.Shape; + +/** + * GPU based resolution independent test object + * - FreeSans, '0' + * - TTF Shape for Glyph 19 + */ +public class Glyph04FreeSans_0 extends Shape { + + public Glyph04FreeSans_0(final Factory factory, final int renderModes) { + super(factory, renderModes); + } + + @Override + protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + + // Start TTF Shape for Glyph 19 + // 000: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.043000f, 0.343000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.043000f, 0.432000f, false); + shape.addVertex(0, 0.058000f, 0.500000f, true); + // 002: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.073000f, 0.568000f, false); + shape.addVertex(0, 0.096000f, 0.606000f, true); + // 003: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.119000f, 0.645000f, false); + shape.addVertex(0, 0.151000f, 0.669000f, true); + // 004: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.183000f, 0.693000f, false); + shape.addVertex(0, 0.212000f, 0.701000f, true); + // 005: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.242000f, 0.709000f, false); + shape.addVertex(0, 0.275000f, 0.709000f, true); + // 006: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.507000f, 0.709000f, false); + shape.addVertex(0, 0.507000f, 0.337000f, true); + // 008: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.507000f, 0.162000f, false); + shape.addVertex(0, 0.448000f, 0.070000f, true); + // 010: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.388000f, -0.023000f, false); + shape.addVertex(0, 0.275000f, -0.023000f, true); + // 011: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.161000f, -0.023000f, false); + shape.addVertex(0, 0.102000f, 0.070000f, true); + // 013: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.043000f, 0.164000f, false); + shape.addVertex(0, 0.043000f, 0.343000f, true); + System.err.println("Glyph04FreeSans_0.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + + // 021: B0b: move-to pM + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.417000f, 0.345000f, true); + // 021: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.417000f, 0.631000f, false); + shape.addVertex(0, 0.275000f, 0.631000f, true); + // 015: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.133000f, 0.631000f, false); + shape.addVertex(0, 0.133000f, 0.342000f, true); + // 016: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.133000f, 0.050000f, false); + shape.addVertex(0, 0.273000f, 0.050000f, true); + // 018: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.347000f, 0.050000f, false); + shape.addVertex(0, 0.382000f, 0.122000f, true); + // 020: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.417000f, 0.194000f, false); + shape.addVertex(0, 0.417000f, 0.345000f, true); + System.err.println("Glyph04FreeSans_0.shape02a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + + // End Shape for Glyph 19 + + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + + box.resize(shape.getBounds()); + } + + @Override + public String getSubString() { + return super.getSubString(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph05FreeSerifBoldItalic_ae.java b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph05FreeSerifBoldItalic_ae.java new file mode 100644 index 000000000..c02ca56bc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/graph/ui/testshapes/Glyph05FreeSerifBoldItalic_ae.java @@ -0,0 +1,287 @@ +/** + * Copyright 2023 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.graph.ui.testshapes; + +import com.jogamp.opengl.GL2ES2; +import com.jogamp.graph.curve.OutlineShape; +import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; +import com.jogamp.graph.ui.gl.Shape; + +/** + * GPU based resolution independent test object + * - FreeSans, '0' + * - TTF Shape for Glyph 19 + */ +public class Glyph05FreeSerifBoldItalic_ae extends Shape { + + public Glyph05FreeSerifBoldItalic_ae(final Factory factory, final int renderModes) { + super(factory, renderModes); + } + + @Override + protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { + } + + @Override + protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + + // Start TTF Shape for Glyph 168 + // 000: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.450000f, -0.013000f, true); + // 000: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.386000f, -0.013000f, false); + shape.addVertex(0, 0.353000f, 0.018000f, true); + // 002: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.319000f, 0.049000f, false); + shape.addVertex(0, 0.307000f, 0.118000f, true); + // 003: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.265000f, 0.049000f, false); + shape.addVertex(0, 0.225000f, 0.019000f, true); + // 005: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.184000f, -0.012000f, false); + shape.addVertex(0, 0.134000f, -0.012000f, true); + // 006: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.085000f, -0.012000f, false); + shape.addVertex(0, 0.053000f, 0.021000f, true); + // 008: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.055000f, false); + shape.addVertex(0, 0.020000f, 0.106000f, true); + // 009: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.020000f, 0.185000f, false); + shape.addVertex(0, 0.062000f, 0.269000f, true); + // 011: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.105000f, 0.353000f, false); + shape.addVertex(0, 0.170000f, 0.407000f, true); + // 012: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.235000f, 0.462000f, false); + shape.addVertex(0, 0.296000f, 0.462000f, true); + // 013: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.328000f, 0.462000f, false); + shape.addVertex(0, 0.346000f, 0.448000f, true); + // 015: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.364000f, 0.433000f, false); + shape.addVertex(0, 0.377000f, 0.396000f, true); + // 016: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.395000f, 0.454000f, true); + // 017: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.498000f, 0.459000f, true); + // 018: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.478000f, 0.394000f, true); + // 019: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.510000f, 0.431000f, false); + shape.addVertex(0, 0.535000f, 0.445000f, true); + // 021: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.561000f, 0.459000f, false); + shape.addVertex(0, 0.598000f, 0.459000f, true); + // 022: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.645000f, 0.459000f, false); + shape.addVertex(0, 0.671000f, 0.436000f, true); + // 024: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.698000f, 0.413000f, false); + shape.addVertex(0, 0.698000f, 0.372000f, true); + // 025: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.698000f, 0.310000f, false); + shape.addVertex(0, 0.639000f, 0.263000f, true); + // 027: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.579000f, 0.215000f, false); + shape.addVertex(0, 0.470000f, 0.190000f, true); + // 028: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.431000f, 0.181000f, true); + // 029: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.426000f, 0.156000f, false); + shape.addVertex(0, 0.426000f, 0.134000f, true); + // 031: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.426000f, 0.096000f, false); + shape.addVertex(0, 0.444000f, 0.073000f, true); + // 033: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.462000f, 0.050000f, false); + shape.addVertex(0, 0.493000f, 0.050000f, true); + // 034: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.565000f, 0.050000f, false); + shape.addVertex(0, 0.616000f, 0.139000f, true); + // 036: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.644000f, 0.122000f, true); + // 037: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.578000f, -0.013000f, false); + shape.addVertex(0, 0.450000f, -0.013000f, true); + System.err.println("Glyph05FreeSerifBoldItalic_ae.shape01a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + + // 039: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.194000f, 0.058000f, true); + // 039: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.238000f, 0.058000f, false); + shape.addVertex(0, 0.278000f, 0.122000f, true); + // 041: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.319000f, 0.187000f, false); + shape.addVertex(0, 0.338000f, 0.256000f, true); + // 042: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.358000f, 0.326000f, false); + shape.addVertex(0, 0.358000f, 0.363000f, true); + // 043: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.358000f, 0.387000f, false); + shape.addVertex(0, 0.345000f, 0.403000f, true); + // 045: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.331000f, 0.419000f, false); + shape.addVertex(0, 0.310000f, 0.419000f, true); + // 046: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.267000f, 0.419000f, false); + shape.addVertex(0, 0.227000f, 0.356000f, true); + // 048: B5: quad-to pMh-p0-p1h ***** MID + // Shape.QuadTo: + shape.addVertex(0, 0.187000f, 0.293000f, false); + shape.addVertex(0, 0.167000f, 0.225000f, true); + // 049: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.146000f, 0.156000f, false); + shape.addVertex(0, 0.146000f, 0.119000f, true); + // 050: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.146000f, 0.092000f, false); + shape.addVertex(0, 0.159000f, 0.075000f, true); + // 052: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.172000f, 0.058000f, false); + shape.addVertex(0, 0.194000f, 0.058000f, true); + System.err.println("Glyph05FreeSerifBoldItalic_ae.shape02a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + + if( true ) { + // GlyphShape<168>: offset 0 of 8/61 points + // pM[060] P[443/231, on true, end true] + // p0[053] P[438/214, on true, end false] + // p1[054] P[498/223, on false, end false] + // p2[055] P[608/320, on false, end false] + // 053: B0a: move-to p0 + // Shape.MoveTo: + shape.closeLastOutline(false); + shape.addEmptyOutline(); + shape.addVertex(0, 0.438000f, 0.214000f, true); + // 053: B4: quad-to p0-p1-p2h **** MID + // Shape.QuadTo: + shape.addVertex(0, 0.498000f, 0.223000f, false); + shape.addVertex(0, 0.553000f, 0.271000f, true); + // GlyphShape<168>: offset 2 of 8/61 points + // pM[054] P[498/223, on false, end false] + // p0[055] P[608/320, on false, end false] + // p1[056] P[608/388, on true, end false] + // p2[057] P[608/429, on false, end false] + // 055: B6: quad-to pMh-p0-p1 + // Shape.QuadTo: + shape.addVertex(0, 0.608000f, 0.320000f, false); + shape.addVertex(0, 0.608000f, 0.388000f, true); + // GlyphShape<168>: offset 3 of 8/61 points + // pM[055] P[608/320, on false, end false] + // p0[056] P[608/388, on true, end false] + // p1[057] P[608/429, on false, end false] + // p2[058] P[575/429, on true, end false] + // 056: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.608000f, 0.429000f, false); + shape.addVertex(0, 0.575000f, 0.429000f, true); + // GlyphShape<168>: offset 5 of 8/61 points + // pM[057] P[608/429, on false, end false] + // p0[058] P[575/429, on true, end false] + // p1[059] P[502/429, on false, end false] + // p2[060] P[443/231, on true, end true] + // 058: B2: quad-to p0-p1-p2 + // Shape.QuadTo: + shape.addVertex(0, 0.502000f, 0.429000f, false); + shape.addVertex(0, 0.443000f, 0.231000f, true); + // GlyphShape<168>: offset 7 of 8/61 points + // pM[059] P[502/429, on false, end false] + // p0[060] P[443/231, on true, end true] + // p1[053] P[438/214, on true, end false] + // p2[054] P[498/223, on false, end false] + // 060: B1: line-to p0-p1 + // Shape.LineTo: + shape.addVertex(0, 0.438000f, 0.214000f, true); + System.err.println("Glyph05FreeSerifBoldItalic_ae.shape03a.winding_area: "+shape.getWindingOfLastOutline()); + shape.closeLastOutline(false); + } + + // End Shape for Glyph 168 + + shape.setIsQuadraticNurbs(); + shape.setSharpness(shapesSharpness); + region.addOutlineShape(shape, null, rgbaColor); + + box.resize(shape.getBounds()); + } + + @Override + public String getSubString() { + return super.getSubString(); + } +} -- cgit v1.2.3