From 2aae33b94cea15b2fc0c54479277611c67cdaf13 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 20 Apr 2023 22:00:11 +0200 Subject: GraphUI GraphShape: createGLRegion() -> updateGLRegion(), called by addShapeToRegion() impl to utilize OutlineShape -> GLRegion ctor w/ proper buffer-size This way we avoid unnecessary buffer growth and allow creation of 'always' fitting buffer sizes. +++ Update or freshly create the GLRegion, while allocating its buffers with given initial `vertexCount` and `indexCount`. Method shall be invoked by the addShapeToRegion(GLProfile, GL2ES2) implementation before actually adding the OutlineShape to the GLRegion. addShapeToRegion(GLProfile, GL2ES2) is capable to determine initial `vertexCount` and `indexCount` buffer sizes, as it composes the OutlineShapes to be added. updateGLRegion(GLProfile, GL2ES2, TextureSequence, OutlineShape) maybe used for convenience. In case GLRegion is `null`, a new instance is being created. In case the GLRegion already exists, it will be either cleared if the GL2ES2 `gl` instance is not `null` or earmarked for deletion at a later time and a new instance is being created. --- .../classes/com/jogamp/graph/ui/GraphShape.java | 75 ++++++++++++++++------ src/graphui/classes/com/jogamp/graph/ui/Group.java | 4 +- src/graphui/classes/com/jogamp/graph/ui/Scene.java | 8 +-- src/graphui/classes/com/jogamp/graph/ui/Shape.java | 51 +++++++++++---- .../com/jogamp/graph/ui/shapes/BaseButton.java | 18 ++++-- .../classes/com/jogamp/graph/ui/shapes/Button.java | 25 ++++---- .../com/jogamp/graph/ui/shapes/CrossHair.java | 8 ++- .../com/jogamp/graph/ui/shapes/GlyphShape.java | 20 +++--- .../classes/com/jogamp/graph/ui/shapes/Label.java | 12 ++-- .../com/jogamp/graph/ui/shapes/Rectangle.java | 7 +- .../com/jogamp/graph/ui/shapes/TexSeqButton.java | 15 ++--- 11 files changed, 156 insertions(+), 87 deletions(-) (limited to 'src/graphui/classes/com/jogamp/graph') diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java index 89e77d2fe..abe56eca3 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java @@ -40,7 +40,7 @@ import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.util.texture.TextureSequence; /** - * Graph based {@link GLRegion} UI {@link Shape} + * Graph based {@link GLRegion} {@link Shape} *

* GraphUI is GPU based and resolution independent. *

@@ -125,8 +125,53 @@ public abstract class GraphShape extends Shape { region.draw(gl, renderer, sampleCount); } - protected GLRegion createGLRegion(final GLProfile glp) { - return GLRegion.create(glp, renderModes, null); + /** + * Update or freshly create the {@link GLRegion}, while allocating its buffers with given initial `vertexCount` and `indexCount`. + * + * Method shall be invoked by the {@link #addShapeToRegion(GLProfile, GL2ES2)} implementation + * before actually adding the {@link OutlineShape} to the {@link GLRegion}. + * + * {@link #addShapeToRegion(GLProfile, GL2ES2)} is capable to determine initial `vertexCount` and `indexCount` buffer sizes, + * as it composes the {@link OutlineShape}s to be added. + * + * {@link #updateGLRegion(GLProfile, GL2ES2, TextureSequence, OutlineShape)} maybe used for convenience. + * + * In case {@link GLRegion} is `null`, a new instance is being created. + * + * In case the {@link GLRegion} already exists, it will be either {@link GLRegion#clear(GL2ES2) cleared} if the {@link GL2ES2} `gl` + * instance is not `null` or earmarked for deletion at a later time and a new instance is being created. + * + * @param glp the used GLProfile, never `null` + * @param gl the optional current {@link GL2ES2} instance, maybe `null`. + * @param colorTexSeq optional {@link TextureSequence} for {@link Region#COLORTEXTURE_RENDERING_BIT} rendering mode. + * @param vertexCount the initial {@link GLRegion} vertex buffer size + * @param indexCount the initial {@link GLRegion} index buffer size + * @see #updateGLRegion(GLProfile, GL2ES2, TextureSequence, OutlineShape) + */ + protected void updateGLRegion(final GLProfile glp, final GL2ES2 gl, final TextureSequence colorTexSeq, final int vertexCount, final int indexCount) { + if( null == region ) { + region = GLRegion.create(glp, renderModes, colorTexSeq, vertexCount, indexCount); + } else if( null == gl ) { + dirtyRegions.add(region); + region = GLRegion.create(glp, renderModes, colorTexSeq, vertexCount, indexCount); + } else { + region.clear(gl); + region.setBufferCapacity(vertexCount, indexCount); + } + } + /** + * Convenient {@link #updateGLRegion(GLProfile, GL2ES2, TextureSequence, int, int)} variant determining initial + * {@link GLRegion} buffer sizes via {@link Region#countOutlineShape(OutlineShape, int[])}. + * + * @param glp the used GLProfile, never `null` + * @param gl the optional current {@link GL2ES2} instance, maybe `null`. + * @param colorTexSeq optional {@link TextureSequence} for {@link Region#COLORTEXTURE_RENDERING_BIT} rendering mode. + * @param shape the {@link OutlineShape} used to determine {@link GLRegion}'s buffer sizes via {@link Region#countOutlineShape(OutlineShape, int[])} + * @see #updateGLRegion(GLProfile, GL2ES2, TextureSequence, int, int) + */ + protected void updateGLRegion(final GLProfile glp, final GL2ES2 gl, final TextureSequence colorTexSeq, final OutlineShape shape) { + final int[/*2*/] vertIndexCount = Region.countOutlineShape(shape, new int[2]); + updateGLRegion(glp, gl, colorTexSeq, vertIndexCount[0], vertIndexCount[1]); } @Override @@ -135,17 +180,9 @@ public abstract class GraphShape extends Shape { clearDirtyRegions(gl); } if( isShapeDirty() ) { - if( null == region ) { - region = createGLRegion(glp); - } else if( null == gl ) { - dirtyRegions.add(region); - region = createGLRegion(glp); - } else { - region.clear(gl); - } - addShapeToRegion(); - if( hasDebugBox() ) { - addDebugOutline(); + addShapeToRegion(glp, gl); // calls updateGLRegion(..) + if( hasBorder() ) { + addBorderOutline(); } region.setQuality(regionQuality); } else if( isStateDirty() ) { @@ -153,9 +190,7 @@ public abstract class GraphShape extends Shape { } } - private final Vec4f dbgColor = new Vec4f(0.3f, 0.3f, 0.3f, 0.5f); - - protected void addDebugOutline() { + protected void addBorderOutline() { final OutlineShape shape = new OutlineShape(); final float x1 = box.getMinX(); final float x2 = box.getMaxX(); @@ -175,7 +210,7 @@ public abstract class GraphShape extends Shape { { // Inner OutlineShape as Winding.CW. final float dxy0 = box.getWidth() < box.getHeight() ? box.getWidth() : box.getHeight(); - final float dxy = dxy0 * getDebugBox(); + final float dxy = dxy0 * getBorderThickness(); shape.moveTo(x1+dxy, y1+dxy, z); shape.lineTo(x1+dxy, y2-dxy, z); shape.lineTo(x2-dxy, y2-dxy, z); @@ -185,13 +220,13 @@ public abstract class GraphShape extends Shape { } shape.setIsQuadraticNurbs(); shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, dbgColor); + region.addOutlineShape(shape, null, borderColor); } protected void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) { } protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) { } - protected abstract void addShapeToRegion(); + protected abstract void addShapeToRegion(GLProfile glp, GL2ES2 gl); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index c45292f1b..1de20240d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -44,7 +44,7 @@ import com.jogamp.opengl.util.PMVMatrix; import jogamp.graph.ui.TreeTool; /** - * Group of UI {@link Shape}s, optionally utilizing a {@link Group.Layout}. + * Group of {@link Shape}s, optionally utilizing a {@link Group.Layout}. * @see Scene * @see Shape * @see Group.Layout @@ -126,7 +126,7 @@ public class Group extends Shape implements Container { /** Removes given shape and destroy it. */ public void removeShape(final GL2ES2 gl, final RegionRenderer renderer, final Shape s) { - s.setDebugBox(0f); + s.setBorder(0f); shapes.remove(s); s.destroy(gl, renderer); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index c5fb5cd01..4955e683a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -217,12 +217,12 @@ public final class Scene implements Container, GLEventListener { } @Override public void addShape(final Shape s) { - s.setDebugBox(dbgbox_thickness); + s.setBorder(dbgbox_thickness); shapes.add(s); } @Override public Shape removeShape(final Shape s) { - s.setDebugBox(0f); + s.setBorder(0f); return shapes.remove(s) ? s : null; } @Override @@ -232,7 +232,7 @@ public final class Scene implements Container, GLEventListener { /** Removes given shape and destroy it. */ public void removeShape(final GL2ES2 gl, final Shape s) { - s.setDebugBox(0f); + s.setBorder(0f); shapes.remove(s); s.destroy(gl, renderer); } @@ -321,7 +321,7 @@ public final class Scene implements Container, GLEventListener { public final void setDebugBox(final float v) { dbgbox_thickness = v; for(int i=0; i * A shape includes the following build-in user-interactions * - drag shape w/ 1-pointer click, see {@link #setDraggable(boolean)} @@ -136,7 +136,8 @@ public abstract class Shape { private boolean resizable = true; private boolean interactive = true; private boolean enabled = true; - private float dbgbox_thickness = 0f; // fractional thickness of bounds, 0f for no debug box + private float border_thickness = 0f; + protected final Vec4f borderColor = new Vec4f(0.75f, 0.75f, 0.75f, 1.0f); private ArrayList mouseListeners = new ArrayList(); private Listener onMoveListener = null; @@ -158,17 +159,18 @@ public abstract class Shape { public final Shape setEnabled(final boolean v) { enabled = v; return this; } /** - * Sets the {@link #getBounds()} fractional thickness of the debug box ranging [0..1], zero for no debug box (default). - * @param v fractional thickness of {@link #getBounds()} ranging [0..1], zero for no debug box + * Sets the thickness of the debug box, zero for no border (default). + * @param v border thickness, zero for no debug box */ - public final Shape setDebugBox(final float v) { - dbgbox_thickness = Math.min(1f, Math.max(0f, v)); + public final Shape setBorder(final float v) { + border_thickness = Math.max(0f, v); return this; } - /** Returns true if a debug box has been enabled via {@link #setDebugBox(float)}. */ - public final boolean hasDebugBox() { return !FloatUtil.isZero(dbgbox_thickness); } - /** Returns the fractional thickness of the debug box ranging [0..1], see {@link #setDebugBox(float)}. */ - public final float getDebugBox() { return dbgbox_thickness; } + /** Returns true if a border has been enabled via {@link #setBorder(float)}. */ + public final boolean hasBorder() { return !FloatUtil.isZero(border_thickness); } + + /** Returns the border thickness, see {@link #setBorder(float)}. */ + public final float getBorderThickness() { return border_thickness; } /** * Clears all data and reset all states as if this instance was newly created @@ -760,9 +762,7 @@ public abstract class Shape { return this.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, objPos); } - public Vec4f getColor() { - return rgbaColor; - } + public Vec4f getColor() { return rgbaColor; } /** * Set base color. @@ -775,6 +775,17 @@ public abstract class Shape { return this; } + /** + * Set base color. + *

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

+ */ + public final Shape setColor(final Vec4f c) { + this.rgbaColor.set(c); + return this; + } + /** * Set pressed color. *

@@ -808,6 +819,20 @@ public abstract class Shape { return this; } + public Vec4f getBorderColor() { return borderColor; } + + /** Set border color. */ + public final Shape setBorderColor(final float r, final float g, final float b, final float a) { + this.borderColor.set(r, g, b, a); + return this; + } + + /** Set border color. */ + public final Shape setBorderColor(final Vec4f c) { + this.borderColor.set(c); + return this; + } + @Override public final String toString() { return getClass().getSimpleName()+"["+getSubString()+"]"; diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java index 7c1997d2d..a4d0ee67a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java @@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; /** * An abstract GraphUI base filled button {@link GraphShape}, @@ -97,10 +99,15 @@ public class BaseButton extends GraphShape { } @Override - protected void addShapeToRegion() { - addBaseShapeToRegion(0f); + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { + final OutlineShape shape = createBaseShape(0f); + updateGLRegion(glp, gl, null, shape); + region.addOutlineShape(shape, null, rgbaColor); + box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); } - protected OutlineShape addBaseShapeToRegion(final float zOffset) { + + protected OutlineShape createBaseShape(final float zOffset) { final OutlineShape shape = new OutlineShape(); if(corner == 0.0f) { createSharpOutline(shape, zOffset); @@ -109,11 +116,8 @@ public class BaseButton extends GraphShape { } shape.setIsQuadraticNurbs(); shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, rgbaColor); - box.resize(shape.getBounds()); - setRotationPivot( box.getCenter() ); if( DEBUG_DRAW ) { - System.err.println("GraphShape.RoundButton: Added Shape: "+shape+", "+box); + System.err.println("GraphShape.RoundButton: Shape: "+shape+", "+box); } return shape; } diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java index a19a58003..3473c2c68 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -31,8 +31,8 @@ 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.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; @@ -97,20 +97,17 @@ public class Button extends BaseButton { } @Override - protected GLRegion createGLRegion(final GLProfile glp) { - final int[] vertIndexCount = { 0, 0 }; - final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { - @Override - public final void visit(final char symbol, final Font.Glyph glyph) { - Region.countOutlineShape(glyph.getShape(), vertIndexCount); - } }; - this.label.getFont().processString(visitor, this.label.getText()); - return GLRegion.create(glp, renderModes, null, 16+vertIndexCount[0], 16+vertIndexCount[1]); - } + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { + final OutlineShape shape = createBaseShape( FloatUtil.isZero(labelZOffset) ? 0f : -labelZOffset ); + box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); - @Override - protected void addShapeToRegion() { - addBaseShapeToRegion( FloatUtil.isZero(labelZOffset) ? 0f : -labelZOffset ); + // Sum Region buffer size of base-shape + text + final int[/*2*/] vertIndexCount = Region.countOutlineShape(shape, new int[2]); + TextRegionUtil.countStringRegion(label.getFont(), label.getText(), vertIndexCount); + updateGLRegion(glp, gl, null, vertIndexCount[0], vertIndexCount[1]); + + region.addOutlineShape(shape, null, rgbaColor); // Precompute text-box size .. guessing pixelSize final float lw = box.getWidth() * ( 1f - spacingX ) ; diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java index f0c6b1369..bd088c90e 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java @@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; /** * A GraphUI Crosshair {@link GraphShape} @@ -58,7 +60,7 @@ public class CrossHair extends GraphShape { } @Override - protected void addShapeToRegion() { + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { final OutlineShape shape = new OutlineShape(); final float lwh = lineWidth/2f; @@ -87,9 +89,11 @@ public class CrossHair extends GraphShape { shape.setIsQuadraticNurbs(); shape.setSharpness(oshapeSharpness); - region.addOutlineShape(shape, null, rgbaColor); + updateGLRegion(glp, gl, null, shape); + region.addOutlineShape(shape, null, rgbaColor); box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); } @Override diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java index 568270073..dd4398c63 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java @@ -36,6 +36,7 @@ import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.math.geom.AABBox; @@ -52,6 +53,8 @@ import com.jogamp.opengl.util.texture.TextureSequence; public class GlyphShape extends GraphShape { private final char symbol; private final Glyph glyph; + private final int regionVertCount; + private final int regionIdxCount; private final Vec3f origPos; /** @@ -71,6 +74,9 @@ public class GlyphShape extends GraphShape { if( glyph.isWhiteSpace() || null == glyph.getShape() ) { setEnabled(false); } + final int[/*2*/] vertIndexCount = Region.countOutlineShape(glyph.getShape(), new int[2]); + regionVertCount = vertIndexCount[0]; + regionIdxCount = vertIndexCount[1]; } /** @@ -82,13 +88,7 @@ public class GlyphShape extends GraphShape { * @param y the intended unscaled Y position of this Glyph, e.g. if part of a string - otherwise use zero. */ public GlyphShape(final int renderModes, final Font font, final char symbol, final float x, final float y) { - super(renderModes); - this.symbol = symbol; - this.glyph = font.getGlyph( font.getGlyphID(symbol) ); - this.origPos = new Vec3f(x, y, 0f); - if( glyph.isWhiteSpace() || null == glyph.getShape() ) { - setEnabled(false); - } + this(renderModes, symbol, font.getGlyph( font.getGlyphID(symbol) ), x, y); } /** Returns the char symbol to be rendered. */ @@ -181,7 +181,7 @@ public class GlyphShape extends GraphShape { } @Override - protected void addShapeToRegion() { + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { final OutlineShape shape = glyph.getShape(); box.reset(); if( null != shape ) { @@ -191,9 +191,11 @@ public class GlyphShape extends GraphShape { // but keep the underline (decline) intact! tmp.setToTranslation(-sbox.getMinX(), -sbox.getMinY() + glyph.getBounds().getMinY()); shape.setSharpness(oshapeSharpness); + + updateGLRegion(glp, gl, null, regionVertCount, regionIdxCount); region.addOutlineShape(shape, tmp, rgbaColor); - setRotationPivot( sbox.getCenter() ); box.resize(tmp.transform(sbox, new AABBox())); + setRotationPivot( box.getCenter() ); } } diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java index 50b53e6f5..c270903d9 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java @@ -31,8 +31,8 @@ import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; +import com.jogamp.graph.curve.opengl.TextRegionUtil; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.geom.plane.AffineTransform; @@ -190,11 +190,6 @@ public class Label extends GraphShape { } } - @Override - protected GLRegion createGLRegion(final GLProfile glp) { - return GLRegion.create(glp, getRenderModes(), null, font, text); - } - private final Font.GlyphVisitor glyphVisitor = new Font.GlyphVisitor() { @Override public void visit(final char symbol, final Glyph glyph, final AffineTransform t) { @@ -208,7 +203,10 @@ public class Label extends GraphShape { }; @Override - protected void addShapeToRegion() { + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { + final int[] vertIndCount = TextRegionUtil.countStringRegion(font, text, new int[2]); + updateGLRegion(glp, gl, null, vertIndCount[0], vertIndCount[1]); + AABBox fbox = font.getGlyphBounds(text, tempT2, tempT3); tempT1.setToScale(fontScale, fontScale); tempT1.translate(-fbox.getMinX(), -fbox.getMinY(), tempT2); // enforce bottom-left origin @ 0/0 for good drag-zoom experience diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java index dd6a272cb..d11e3bdb1 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java @@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.ui.GraphShape; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; /** * A GraphUI Rectangle {@link GraphShape} @@ -58,7 +60,7 @@ public class Rectangle extends GraphShape { } @Override - protected void addShapeToRegion() { + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { final OutlineShape shape = new OutlineShape(); final float x1 = 0f; final float y1 = 0f; @@ -88,8 +90,11 @@ public class Rectangle extends GraphShape { } shape.setIsQuadraticNurbs(); shape.setSharpness(oshapeSharpness); + + updateGLRegion(glp, gl, null, shape); region.addOutlineShape(shape, null, rgbaColor); box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); } @Override diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java index 4768b4974..86cff4dae 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java @@ -27,10 +27,10 @@ */ package com.jogamp.graph.ui.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.ui.GraphShape; import com.jogamp.opengl.util.texture.TextureSequence; @@ -53,15 +53,14 @@ public abstract class TexSeqButton extends BaseButton { 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() { - addBaseShapeToRegion( 0f ); + protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { + final OutlineShape shape = createBaseShape(0f); + updateGLRegion(glp, gl, texSeq, shape); + region.addOutlineShape(shape, null, rgbaColor); + box.resize(shape.getBounds()); + setRotationPivot( box.getCenter() ); } } -- cgit v1.2.3