diff options
author | Sven Gothel <[email protected]> | 2023-04-20 22:00:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-20 22:00:11 +0200 |
commit | 2aae33b94cea15b2fc0c54479277611c67cdaf13 (patch) | |
tree | e1956d8361fd1ef6860c50f0a0aa8aab6b5ce612 /src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java | |
parent | c21082a5d7caf0ae6e29144358b4b4a1eafec019 (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/BaseButton.java')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java | 18 |
1 files changed, 11 insertions, 7 deletions
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; } |