aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-02-06 02:31:14 +0100
committerSven Gothel <[email protected]>2023-02-06 02:31:14 +0100
commit18fc81fab7ba11ae3a4cdd1e94c199371f7c2e91 (patch)
treed9fd6d156317270bb3bf536ab88a4c632ad12ab3 /src/test/com/jogamp/opengl
parenta671e88c59153a39e46a64f2cb924d205f06e3f8 (diff)
Graph: Path2D -> self-contained Path2D (w/ Iterator) fixed; OutlineShape: Add Path2F addPath(..), emphasize required Winding.CW
GPURegionGLListener01 used by TestRegionRendererNEWT01 covers Path2F CCW and CW (reverse add) methods.
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java51
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java133
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java179
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java (renamed from src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java)7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java9
5 files changed, 360 insertions, 19 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
index b5c0d259e..b9d62cac4 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
@@ -49,7 +49,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener01;
-import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener02;
+import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener10;
import com.jogamp.opengl.test.junit.graph.demos.GPURendererListenerBase01;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -88,7 +88,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
// caps.setOnscreen(false);
caps.setAlphaBits(4);
- final GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
+ final GLWindow window = createWindow("t00-shape-vbaa0-msaa0", caps, 800, 400);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
@@ -122,7 +122,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
- final GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
+ final GLWindow window = createWindow("t01-shape-vbaa0-msaa0", caps, 800, 400);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
@@ -153,7 +153,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
+ final GLWindow window = createWindow("t10-shape-vbaa0-msaa1", caps, 800, 400);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
@@ -189,7 +189,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
+ final GLWindow window = createWindow("t11-shape-vbaa0-msaa1", caps, 800, 400);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
@@ -224,9 +224,9 @@ public class TestRegionRendererNEWT01 extends UITestCase {
//caps.setOnscreen(false);
caps.setAlphaBits(4);
- final GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
+ final GLWindow window = createWindow("t20-shape-vbaa1-msaa0", caps, 800,400);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
- final GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 4, false, false);
+ final GPURegionGLListener10 demo02Listener = new GPURegionGLListener10 (rs, Region.VBAA_RENDERING_BIT, 4, false, false);
demo02Listener.attachInputListenerTo(window);
window.addGLEventListener(demo02Listener);
@@ -245,6 +245,39 @@ public class TestRegionRendererNEWT01 extends UITestCase {
destroyWindow(window);
}
+ private void test30RegionRendererShapesImpl(final GLCapabilities caps, final int shape_ctor_mode) throws InterruptedException {
+ final GLWindow window = createWindow("t30-shape0"+shape_ctor_mode+"-vbaa0-msaa1", caps, 800, 400);
+ final RenderState rs = RenderState.createRenderState(SVertex.factory());
+
+ final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (shape_ctor_mode, rs, 0, 0, false, false);
+ demo01Listener.attachInputListenerTo(window);
+ window.addGLEventListener(demo01Listener);
+
+ final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
+ window.addGLEventListener(listener);
+
+ // listener.setTech(-20, 00, -300, 0f, 2);
+ listener.setTech(-20, 00, -50, 0f, 4);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void test30RegionRendererShapes() throws InterruptedException {
+ final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ final GLCapabilities caps = new GLCapabilities(glp);
+ // caps.setOnscreen(false);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+
+ test30RegionRendererShapesImpl(caps, 1);
+ test30RegionRendererShapesImpl(caps, 2);
+ test30RegionRendererShapesImpl(caps, 3);
+ test30RegionRendererShapesImpl(caps, 4);
+ }
+
private static class RegionGLListener implements GLEventListener {
String winTitle;
String name;
@@ -260,10 +293,12 @@ public class TestRegionRendererNEWT01 extends UITestCase {
impl.setMatrix(xt, yt, zt, angle, sampleCount);
}
+ @Override
public void init(final GLAutoDrawable drawable) {
impl.init(drawable);
}
+ @Override
public void display(final GLAutoDrawable drawable) {
impl.display(drawable);
@@ -276,11 +311,13 @@ public class TestRegionRendererNEWT01 extends UITestCase {
}
}
+ @Override
public void dispose(final GLAutoDrawable drawable) {
impl.dispose(drawable);
}
+ @Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
impl.reshape(drawable, x, y, width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java
new file mode 100644
index 000000000..1059423f3
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java
@@ -0,0 +1,133 @@
+/**
+ * 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;
+
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLAutoDrawable;
+import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
+
+import com.jogamp.graph.curve.OutlineShape;
+import com.jogamp.graph.curve.opengl.GLRegion;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.opengl.util.PMVMatrix;
+
+/** Demonstrate the rendering of multiple outlines into one region/OutlineShape
+ * These Outlines are not necessary connected or contained.
+ * The output of this demo shows two identical shapes but the left one
+ * has some vertices with off-curve flag set to true, and the right allt he vertices
+ * are on the curve. Demos the Res. Independent Nurbs based Curve rendering
+ *
+ */
+public class GPURegionGLListener00 extends GPURendererListenerBase01 {
+ OutlineShape outlineShape = null;
+
+ public GPURegionGLListener00 (final RenderState rs, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) {
+ super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
+ setMatrix(-20, 00, -50, 0f, sampleCount);
+ }
+
+ private void createTestOutline(){
+ outlineShape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
+ outlineShape.addVertex(0.0f,-10.0f, true);
+ outlineShape.addVertex(15.0f,-10.0f, true);
+ outlineShape.addVertex(10.0f,5.0f, false);
+ outlineShape.addVertex(15.0f,10.0f, true);
+ outlineShape.addVertex(6.0f,15.0f, false);
+ outlineShape.addVertex(5.0f,8.0f, false);
+ outlineShape.addVertex(0.0f,10.0f,true);
+ outlineShape.closeLastOutline(true);
+ outlineShape.addEmptyOutline();
+ outlineShape.addVertex(5.0f,-5.0f,true);
+ outlineShape.addVertex(10.0f,-5.0f, false);
+ outlineShape.addVertex(10.0f,0.0f, true);
+ outlineShape.addVertex(5.0f,0.0f, false);
+ outlineShape.closeLastOutline(true);
+
+ /** Same shape as above but without any off-curve vertices */
+ final float offset = 30;
+ outlineShape.addEmptyOutline();
+ outlineShape.addVertex(offset+0.0f,-10.0f, true);
+ outlineShape.addVertex(offset+17.0f,-10.0f, true);
+ outlineShape.addVertex(offset+11.0f,5.0f, true);
+ outlineShape.addVertex(offset+16.0f,10.0f, true);
+ outlineShape.addVertex(offset+7.0f,15.0f, true);
+ outlineShape.addVertex(offset+6.0f,8.0f, true);
+ outlineShape.addVertex(offset+0.0f,10.0f, true);
+ outlineShape.closeLastOutline(true);
+ outlineShape.addEmptyOutline();
+ outlineShape.addVertex(offset+5.0f,0.0f, true);
+ outlineShape.addVertex(offset+5.0f,-5.0f, true);
+ outlineShape.addVertex(offset+10.0f,-5.0f, true);
+ outlineShape.addVertex(offset+10.0f,0.0f, true);
+ outlineShape.closeLastOutline(true);
+
+ region = GLRegion.create(getRenderModes(), null);
+ region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null);
+ }
+
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ super.init(drawable);
+
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ final RenderState rs = getRenderer().getRenderState();
+
+ gl.setSwapInterval(1);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glEnable(GL.GL_BLEND);
+ rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f);
+
+ createTestOutline();
+ }
+
+ @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 RegionRenderer regionRenderer = getRenderer();
+ final PMVMatrix pmv = regionRenderer.getMatrix();
+ pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmv.glLoadIdentity();
+ pmv.glTranslatef(getXTran(), getYTran(), getZTran());
+ pmv.glRotatef(getAngle(), 0, 1, 0);
+ if( weight != regionRenderer.getRenderState().getWeight() ) {
+ regionRenderer.getRenderState().setWeight(weight);
+ }
+ regionRenderer.enable(gl, true);
+ region.draw(gl, regionRenderer, getSampleCount());
+ regionRenderer.enable(gl, false);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java
index 73952684e..7dc217c2d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java
@@ -36,6 +36,8 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.geom.plane.Path2F;
+import com.jogamp.graph.geom.plane.WindingRule;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.opengl.util.PMVMatrix;
@@ -47,17 +49,21 @@ import com.jogamp.opengl.util.PMVMatrix;
*
*/
public class GPURegionGLListener01 extends GPURendererListenerBase01 {
+ final int shape_ctor_mode;
OutlineShape outlineShape = null;
public GPURegionGLListener01 (final RenderState rs, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) {
+ this(1, rs, renderModes, sampleCount, debug, trace);
+ }
+
+ public GPURegionGLListener01 (final int shape_ctor_mode, final RenderState rs, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) {
super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ this.shape_ctor_mode = shape_ctor_mode;
rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
setMatrix(-20, 00, -50, 0f, sampleCount);
}
- private void createTestOutline(){
- float offset = 0;
- outlineShape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
+ private void createTestOutline00(){
outlineShape.addVertex(0.0f,-10.0f, true);
outlineShape.addVertex(15.0f,-10.0f, true);
outlineShape.addVertex(10.0f,5.0f, false);
@@ -74,7 +80,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
outlineShape.closeLastOutline(true);
/** Same shape as above but without any off-curve vertices */
- offset = 30;
+ final float offset = 30;
outlineShape.addEmptyOutline();
outlineShape.addVertex(offset+0.0f,-10.0f, true);
outlineShape.addVertex(offset+17.0f,-10.0f, true);
@@ -90,9 +96,149 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
outlineShape.addVertex(offset+10.0f,-5.0f, true);
outlineShape.addVertex(offset+10.0f,0.0f, true);
outlineShape.closeLastOutline(true);
+ }
- region = GLRegion.create(getRenderModes(), null);
- region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null);
+ private void createTestOutline01(){
+ outlineShape.moveTo(0.0f,-10.0f);
+ outlineShape.lineTo(15.0f,-10.0f);
+ outlineShape.quadTo(10.0f,5.0f, 15.0f,10.0f);
+ outlineShape.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
+ outlineShape.closePath();
+ outlineShape.moveTo(5.0f,-5.0f);
+ outlineShape.quadTo(10.0f,-5.0f, 10.0f,0.0f);
+ outlineShape.quadTo(5.0f,0.0f, 5.0f,-5.0f);
+ outlineShape.closePath();
+
+ /** Same shape as above but without any off-curve vertices */
+ final float offset = 30;
+ outlineShape.moveTo(offset+0.0f,-10.0f);
+ outlineShape.lineTo(offset+17.0f,-10.0f);
+ outlineShape.lineTo(offset+11.0f,5.0f);
+ outlineShape.lineTo(offset+16.0f,10.0f);
+ outlineShape.lineTo(offset+7.0f,15.0f);
+ outlineShape.lineTo(offset+6.0f,8.0f);
+ outlineShape.lineTo(offset+0.0f,10.0f);
+ outlineShape.closePath();
+ outlineShape.moveTo(offset+5.0f,0.0f);
+ outlineShape.lineTo(offset+5.0f,-5.0f);
+ outlineShape.lineTo(offset+10.0f,-5.0f);
+ outlineShape.lineTo(offset+10.0f,0.0f);
+ outlineShape.closePath();
+ }
+
+ private void createTestOutline02(){
+ final Path2F path = new Path2F(WindingRule.NON_ZERO);
+ path.moveTo(0.0f,-10.0f);
+ path.lineTo(15.0f,-10.0f);
+ path.quadTo(10.0f,5.0f, 15.0f,10.0f);
+ path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
+ path.closePath();
+ path.moveTo(5.0f,-5.0f);
+ path.quadTo(10.0f,-5.0f, 10.0f,0.0f);
+ path.quadTo(5.0f,0.0f, 5.0f,-5.0f);
+ path.closePath();
+
+ /** Same shape as above but without any off-curve vertices */
+ final float offset = 30;
+ path.moveTo(offset+0.0f,-10.0f);
+ path.lineTo(offset+17.0f,-10.0f);
+ path.lineTo(offset+11.0f,5.0f);
+ path.lineTo(offset+16.0f,10.0f);
+ path.lineTo(offset+7.0f,15.0f);
+ path.lineTo(offset+6.0f,8.0f);
+ path.lineTo(offset+0.0f,10.0f);
+ path.closePath();
+ path.moveTo(offset+5.0f,0.0f);
+ path.lineTo(offset+5.0f,-5.0f);
+ path.lineTo(offset+10.0f,-5.0f);
+ path.lineTo(offset+10.0f,0.0f);
+ path.closePath();
+
+ System.err.println("GPURegionGLListener01.createTestOutline02.X: path "+path);
+ path.printSegments(System.err);
+ outlineShape.addPath(path, false /* connect */);
+ }
+
+ private void createTestOutline03(){
+ {
+ final Path2F path = new Path2F(WindingRule.NON_ZERO);
+ path.moveTo(0.0f,-10.0f);
+ path.lineTo(15.0f,-10.0f);
+ path.quadTo(10.0f,5.0f, 15.0f,10.0f);
+ path.cubicTo(6.0f,15.0f, 5.0f,8.0f, 0.0f,10.0f);
+ path.closePath();
+ System.err.println("GPURegionGLListener01.createTestOutline03.0: path "+path);
+ path.printSegments(System.err);
+ {
+ final Path2F path2 = new Path2F(WindingRule.NON_ZERO);
+ path2.moveTo(5.0f,-5.0f);
+ path2.quadTo(10.0f,-5.0f, 10.0f,0.0f);
+ path2.quadTo(5.0f,0.0f, 5.0f,-5.0f);
+ path2.closePath();
+ System.err.println("GPURegionGLListener01.createTestOutline03.0: path2 "+path2);
+ path2.printSegments(System.err);
+ path.append(path2, false);
+ System.err.println("GPURegionGLListener01.createTestOutline03.1: path "+path);
+ path.printSegments(System.err);
+ }
+ outlineShape.addPath(path, false /* connect */);
+ }
+ {
+ /** Same shape as above but without any off-curve vertices */
+ final float offset = 30;
+ final Path2F path = new Path2F(WindingRule.NON_ZERO);
+ path.moveTo(offset+0.0f,-10.0f);
+ path.lineTo(offset+17.0f,-10.0f);
+ path.lineTo(offset+11.0f,5.0f);
+ path.lineTo(offset+16.0f,10.0f);
+ path.lineTo(offset+7.0f,15.0f);
+ path.lineTo(offset+6.0f,8.0f);
+ path.lineTo(offset+0.0f,10.0f);
+ path.closePath();
+ path.moveTo(offset+5.0f,0.0f);
+ path.lineTo(offset+5.0f,-5.0f);
+ path.lineTo(offset+10.0f,-5.0f);
+ path.lineTo(offset+10.0f,0.0f);
+ path.closePath();
+ System.err.println("GPURegionGLListener01.createTestOutline03.3: path "+path);
+ path.printSegments(System.err);
+ outlineShape.addPath(path, false /* connect */);
+ }
+
+ }
+
+ private void createTestOutline04(){
+ final Path2F path = new Path2F(WindingRule.NON_ZERO);
+
+ path.moveTo(0.0f,10.0f);
+ path.cubicTo(5.0f,8.0f, 6.0f,15.0f, 15.0f,10.0f);
+ path.quadTo(10.0f,5.0f, 15.0f,-10.0f);
+ path.lineTo(0.0f,-10.0f);
+ path.closePath();
+ path.moveTo(5.0f,-5.0f);
+ path.quadTo(5.0f,0.0f, 10.0f,0.0f);
+ path.quadTo(10.0f,-5.0f, 5.0f,-5.0f);
+ path.closePath();
+
+ /** Same shape as above but without any off-curve vertices */
+ final float offset = 30;
+ path.moveTo(offset+0.0f,10.0f);
+ path.lineTo(offset+6.0f,8.0f);
+ path.lineTo(offset+7.0f,15.0f);
+ path.lineTo(offset+16.0f,10.0f);
+ path.lineTo(offset+11.0f,5.0f);
+ path.lineTo(offset+17.0f,-10.0f);
+ path.lineTo(offset+0.0f,-10.0f);
+ path.closePath();
+ path.moveTo(offset+10.0f,0.0f);
+ path.lineTo(offset+10.0f,-5.0f);
+ path.lineTo(offset+5.0f,-5.0f);
+ path.lineTo(offset+5.0f,0.0f);
+ path.closePath();
+
+ System.err.println("GPURegionGLListener01.createTestOutline04.X: path "+path);
+ path.printSegments(System.err);
+ outlineShape.addPathRev(path, false /* connect */);
}
@Override
@@ -108,7 +254,26 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
gl.glEnable(GL.GL_BLEND);
rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f);
- createTestOutline();
+ outlineShape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
+ switch( shape_ctor_mode ) {
+ case 0:
+ createTestOutline00();
+ break;
+ case 2:
+ createTestOutline02();
+ break;
+ case 3:
+ createTestOutline03();
+ break;
+ case 4:
+ createTestOutline04();
+ break;
+ default:
+ createTestOutline01();
+ break;
+ }
+ region = GLRegion.create(getRenderModes(), null);
+ region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null);
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java
index d79bbb970..13c168ee7 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java
@@ -46,17 +46,16 @@ import com.jogamp.opengl.util.PMVMatrix;
* into one region
*
*/
-public class GPURegionGLListener02 extends GPURendererListenerBase01 {
+public class GPURegionGLListener10 extends GPURendererListenerBase01 {
List<OutlineShape> outlineShapes = new ArrayList<OutlineShape>();
- public GPURegionGLListener02 (final RenderState rs, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) {
+ public GPURegionGLListener10 (final RenderState rs, final int renderModes, final int sampleCount, final boolean debug, final boolean trace) {
super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
setMatrix(-20, 00, -50, 0f, sampleCount);
}
private void createTestOutline(){
- float offset = 0;
OutlineShape shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
outlineShapes.add(shape);
shape.addVertex(0.0f,-10.0f,true);
@@ -77,7 +76,7 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
/** Same shape as above but without any off-curve vertices */
shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
outlineShapes.add(shape);
- offset = 30;
+ final float offset = 30;
shape.addVertex(offset+0.0f,-10.0f, true);
shape.addVertex(offset+17.0f,-10.0f, true);
shape.addVertex(offset+11.0f,5.0f, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
index fd6c9a882..a5990af89 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
@@ -53,6 +53,7 @@ public class GPURegionNewtDemo {
static final boolean DEBUG = false;
static final boolean TRACE = false;
+ static int shape_ctor_mode = 1;
static int SceneMSAASamples = 0;
static int GraphVBAASamples = 4;
static int GraphMSAASamples = 0;
@@ -93,11 +94,15 @@ public class GPURegionNewtDemo {
} else if(args[i].equals("-y")) {
i++;
y = MiscUtils.atoi(args[i], y);
+ } else if(args[i].equals("-shape_ctor")) {
+ i++;
+ shape_ctor_mode = MiscUtils.atoi(args[i], shape_ctor_mode);
}
}
}
System.err.println("Desired win size "+width+"x"+height);
System.err.println("Desired win pos "+x+"/"+y);
+ System.err.println("Shape_ctor_mode "+shape_ctor_mode);
System.err.println("Scene MSAA Samples "+SceneMSAASamples);
System.err.println("Graph MSAA Samples"+GraphMSAASamples);
System.err.println("Graph VBAA Samples "+GraphVBAASamples);
@@ -128,7 +133,7 @@ public class GPURegionNewtDemo {
window.setTitle("GPU Curve Region Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);
final RenderState rs = RenderState.createRenderState(SVertex.factory());
- final GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, rmode, sampleCount, DEBUG, TRACE);
+ final GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (shape_ctor_mode, rs, rmode, sampleCount, DEBUG, TRACE);
regionGLListener.attachInputListenerTo(window);
window.addGLEventListener(regionGLListener);
window.setVisible(true);
@@ -139,6 +144,7 @@ public class GPURegionNewtDemo {
animator.add(window);
window.addKeyListener(new KeyAdapter() {
+ @Override
public void keyPressed(final KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_F4) {
window.destroy();
@@ -146,6 +152,7 @@ public class GPURegionNewtDemo {
}
});
window.addWindowListener(new WindowAdapter() {
+ @Override
public void windowDestroyed(final WindowEvent e) {
animator.stop();
}