aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-20 22:00:11 +0200
committerSven Gothel <[email protected]>2023-04-20 22:00:11 +0200
commit2aae33b94cea15b2fc0c54479277611c67cdaf13 (patch)
treee1956d8361fd1ef6860c50f0a0aa8aab6b5ce612 /src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java
parentc21082a5d7caf0ae6e29144358b4b4a1eafec019 (diff)
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.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java20
1 files changed, 11 insertions, 9 deletions
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() );
}
}