diff options
author | Sven Gothel <[email protected]> | 2023-04-18 05:15:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-18 05:15:16 +0200 |
commit | c65c750e032118f229050ff8e834961264ed0591 (patch) | |
tree | 8500286ca6086eb21a9b275ccd586185090b1500 /src/jogl/classes/com/jogamp/graph/curve/opengl | |
parent | cd845589eea6c7773007e013bd5f2f37242cbe1a (diff) |
Graph + GraphUI: Consolidate Vertex: Drop SVertex and factory, use Vec[234]f instead of float[] and remove unused VectorUtil methods
After Matrix4f consolidation and proving same or better performance on non array types,
this enhances code readability, simplifies API, reduces bugs and may improve performance.
GraphUI:
- Have RoundButton as a functional class to make a round or rectangular backdrop,
i.e. impl. addShapeToRegion() via reused addRoundShapeToRegion()
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl')
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java | 14 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java | 17 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index 2f518d1cc..89a48e0c8 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -33,6 +33,7 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLUniformData; +import com.jogamp.opengl.math.Vec4f; import jogamp.common.os.PlatformPropsImpl; import jogamp.graph.curve.opengl.shader.UniformNames; @@ -241,13 +242,14 @@ public class RenderState { weight[0] = v; } - - public final float[] getColorStatic(final float[] rgbaColor) { - System.arraycopy(colorStatic, 0, rgbaColor, 0, 4); - return rgbaColor; + public final Vec4f getColorStatic(final Vec4f rgbaColor) { + return rgbaColor.set(colorStatic); } - public final void setColorStatic(final float[] rgbaColor){ - System.arraycopy(rgbaColor, 0, colorStatic, 0, 4); + public final void setColorStatic(final Vec4f rgbaColor){ + colorStatic[0] = rgbaColor.x(); + colorStatic[1] = rgbaColor.y(); + colorStatic[2] = rgbaColor.z(); + colorStatic[3] = rgbaColor.w(); } public final void setColorStatic(final float r, final float g, final float b, final float a){ colorStatic[0] = r; diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index 237d93184..6beb11be1 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -33,6 +33,7 @@ import java.util.Iterator; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLException; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; @@ -82,7 +83,7 @@ public class TextRegionUtil { * @return the bounding box of the given string by taking each glyph's font em-sized [0..1] OutlineShape into account. */ public static AABBox addStringToRegion(final Region region, final Font font, final AffineTransform transform, - final CharSequence str, final float[] rgbaColor) { + final CharSequence str, final Vec4f rgbaColor) { return addStringToRegion(region, font, transform, str, rgbaColor, new AffineTransform(), new AffineTransform()); } @@ -105,7 +106,7 @@ public class TextRegionUtil { * @return the bounding box of the given string by taking each glyph's font em-sized [0..1] OutlineShape into account. */ public static AABBox addStringToRegion(final Region region, final Font font, final AffineTransform transform, - final CharSequence str, final float[] rgbaColor, + final CharSequence str, final Vec4f rgbaColor, final AffineTransform temp1, final AffineTransform temp2) { final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { @Override @@ -113,7 +114,7 @@ public class TextRegionUtil { if( glyph.isWhiteSpace() ) { return; } - region.addOutlineShape(glyph.getShape(), t, region.hasColorChannel() ? rgbaColor : null); + region.addOutlineShape(glyph.getShape(), t, rgbaColor); } }; return font.processString(visitor, transform, str, temp1, temp2); @@ -167,7 +168,7 @@ public class TextRegionUtil { */ public AABBox drawString3D(final GL2ES2 gl, final RegionRenderer renderer, final Font font, final CharSequence str, - final float[] rgbaColor, final int[/*1*/] sampleCount) { + final Vec4f rgbaColor, final int[/*1*/] sampleCount) { if( !renderer.isInitialized() ) { throw new GLException("TextRendererImpl01: not initialized!"); } @@ -193,7 +194,7 @@ public class TextRegionUtil { */ public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, final RegionRenderer renderer, final Font font, final CharSequence str, - final float[] rgbaColor, final int[/*1*/] sampleCount) { + final Vec4f rgbaColor, final int[/*1*/] sampleCount) { return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform()); } @@ -228,7 +229,7 @@ public class TextRegionUtil { */ public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, final RegionRenderer renderer, final Font font, final CharSequence str, - final float[] rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) { + final Vec4f rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } @@ -246,7 +247,7 @@ public class TextRegionUtil { * </p> */ public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer, - final Font font, final CharSequence str, final float[] rgbaColor, final int[/*1*/] sampleCount) { + final Font font, final CharSequence str, final Vec4f rgbaColor, final int[/*1*/] sampleCount) { return drawString3D(gl, region, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform()); } @@ -278,7 +279,7 @@ public class TextRegionUtil { * @throws Exception if TextRenderer not initialized */ public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer, - final Font font, final CharSequence str, final float[] rgbaColor, + final Font font, final CharSequence str, final Vec4f rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); |