From 37224b6c84a66788813856f806a727d73991f546 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 19 Mar 2023 08:13:11 +0100 Subject: Graph UI: Adopt Shape implementations to Shape API changes (simplification) --- .../com/jogamp/graph/ui/gl/shapes/Button.java | 22 +++++++++------------- .../com/jogamp/graph/ui/gl/shapes/CrossHair.java | 6 +++--- .../com/jogamp/graph/ui/gl/shapes/GLButton.java | 4 ++-- .../com/jogamp/graph/ui/gl/shapes/ImageButton.java | 4 ++-- .../com/jogamp/graph/ui/gl/shapes/Label.java | 2 +- .../com/jogamp/graph/ui/gl/shapes/MediaButton.java | 4 ++-- .../com/jogamp/graph/ui/gl/shapes/Rectangle.java | 6 +++--- .../com/jogamp/graph/ui/gl/shapes/RoundButton.java | 8 ++++---- .../jogamp/graph/ui/gl/shapes/TexSeqButton.java | 6 ++---- 9 files changed, 28 insertions(+), 34 deletions(-) (limited to 'src/graphui') diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java index ff406991b..e108be53e 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java @@ -78,21 +78,17 @@ public class Button extends RoundButton { public String getLaben() { return label.getText(); } @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); - } + public void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { + // Setup poly offset for z-fighting + // gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); + // gl.glPolygonOffset(0f, 1f); + super.draw(gl, renderer, sampleCount); + // gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); } @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + protected void addShapeToRegion() { + final OutlineShape shape = new OutlineShape(vertexFactory); if(corner == 0.0f) { createSharpOutline(shape, twoPassLabelZOffset); } else { @@ -204,6 +200,6 @@ public class Button extends RoundButton { @Override public String getSubString() { - return super.getSubString()+", "+ label + ", " + "spacing: " + spacingX+"/"+spacingY; + return super.getSubString()+", "+ label + ", " + "spacing["+spacingX+", "+spacingY+"]"; } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java index b93639e5d..62c76d2b2 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java @@ -70,8 +70,8 @@ public class CrossHair extends Shape { } @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + protected void addShapeToRegion() { + final OutlineShape shape = new OutlineShape(vertexFactory); final float lwh = lineWidth/2f; @@ -106,6 +106,6 @@ public class CrossHair extends Shape { @Override public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight(); + return super.getSubString()+", dim "+getWidth() + " x " + getHeight(); } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/GLButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/GLButton.java index 77ac99861..792027d7d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/GLButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/GLButton.java @@ -92,7 +92,7 @@ public class GLButton extends TexSeqButton { public final GLOffscreenAutoDrawable.FBO getFBOAutoDrawable() { return fboGLAD; } @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { + public void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { final int[/*2*/] surfaceSize = new int[2]; final boolean got_sz = getSurfaceSize(renderer.getMatrix(), renderer.getViewport(), surfaceSize) && 0 < surfaceSize[0] && 0 < surfaceSize[1]; @@ -157,7 +157,7 @@ public class GLButton extends TexSeqButton { fboGLAD.display(); } - super.drawShape(gl, renderer, sampleCount); + super.draw(gl, renderer, sampleCount); if( animateGLEL ) { markStateDirty(); // keep on going diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/ImageButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/ImageButton.java index 6ebc0d7ba..957d7141f 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/ImageButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/ImageButton.java @@ -60,8 +60,8 @@ public class ImageButton extends TexSeqButton { } @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { - super.drawShape(gl, renderer, sampleCount); + public void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { + super.draw(gl, renderer, sampleCount); if( !((ImageSequence)texSeq).getManualStepping() ) { markStateDirty(); // keep on going } diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java index ce6cf9163..937e0454c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java @@ -129,7 +129,7 @@ public class Label extends Shape { }; @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { + protected void addShapeToRegion() { tempT1.setToScale(pixelScale, pixelScale); final AABBox fbox = font.processString(shapeVisitor, tempT1, text, tempT2, tempT3); final float[] ctr = box.getCenter(); diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java index 8aa26ffa4..f3090069c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/MediaButton.java @@ -122,7 +122,7 @@ public class MediaButton extends TexSeqButton { volatile boolean resetGL = true; @Override - public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { + public void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { final GLMediaPlayer mPlayer = (GLMediaPlayer)texSeq; if( resetGL ) { resetGL = false; @@ -133,7 +133,7 @@ public class MediaButton extends TexSeqButton { e.printStackTrace(); } } - super.drawShape(gl, renderer, sampleCount); + super.draw(gl, renderer, sampleCount); markStateDirty(); // keep on going }; diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java index 6a93bc842..2c9ec53a0 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java @@ -70,8 +70,8 @@ public class Rectangle extends Shape { } @Override - protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) { - final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory()); + protected void addShapeToRegion() { + final OutlineShape shape = new OutlineShape(vertexFactory); final float lwh = lineWidth/2f; @@ -111,6 +111,6 @@ public class Rectangle extends Shape { @Override public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight(); + return super.getSubString()+", dim "+getWidth() + " x " + getHeight(); } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/RoundButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/RoundButton.java index 56ab4146b..e8636f41e 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/RoundButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/RoundButton.java @@ -102,10 +102,10 @@ public abstract class RoundButton extends Shape { final float minY = 0; final float minZ = zOffset; - shape.addVertex(minX, minY + dC, minZ, true); - shape.addVertex(minX, minY, minZ, false); + shape.addVertex(minX, minY + dC, minZ, true); + shape.addVertex(minX, minY, minZ, false); - shape.addVertex(minX + dC, minY, minZ, true); + shape.addVertex(minX + dC, minY, minZ, true); shape.addVertex(minX + tw - dC, minY, minZ, true); shape.addVertex(minX + tw, minY, minZ, false); @@ -136,6 +136,6 @@ public abstract class RoundButton extends Shape { @Override public String getSubString() { - return super.getSubString()+", dim "+getWidth() + "x" + getHeight() + ", corner " + corner; + return super.getSubString()+", dim "+getWidth() + " x " + getHeight() + ", corner " + corner; } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java index 3ebde276f..365fa8e66 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java @@ -27,12 +27,10 @@ */ package com.jogamp.graph.ui.gl.shapes; -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.graph.ui.gl.Shape; @@ -65,8 +63,8 @@ public abstract class TexSeqButton extends RoundButton { 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()); + protected void addShapeToRegion() { + final OutlineShape shape = new OutlineShape(vertexFactory); if(corner == 0.0f) { createSharpOutline(shape, 0f); } else { -- cgit v1.2.3