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. --- src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java') 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 -- cgit v1.2.3