aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-13 06:02:33 +0100
committerSven Gothel <[email protected]>2023-03-13 06:02:33 +0100
commite9a0f5cdc2bca9ca97175d2fa3c1b722a574b267 (patch)
treef492f20550cbac29b2072930b576e4e668c6e143 /src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
parent913b00f8b876e29af91677ef61b3eb35d6853e6e (diff)
Graph: Add GLRegion creation w/ pre-calculating its buffer sizes; TextRegionUtil: Use pre-calc'ing buffer sizes for GLRegion;
TextRendererGLELBase: Fix temp AffineTransform usage
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java23
1 files changed, 21 insertions, 2 deletions
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 8d55c6136..de9ff5636 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -125,6 +125,7 @@ public class TextRegionUtil {
* @param vertIndexCount the int[2] storage where the counted vertices and indices are added, vertices at [0] and indices at [1]
* @see Region#setBufferCapacity(int, int)
* @see Region#growBuffer(int, int)
+ * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)
*/
public static void countStringRegion(final Region region, final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) {
final OutlineShape.Visitor2 visitor = new OutlineShape.Visitor2() {
@@ -146,6 +147,9 @@ public class TextRegionUtil {
* <p>
* Cached {@link GLRegion}s will be destroyed w/ {@link #clear(GL2ES2)} or to free memory.
* </p>
+ * <p>
+ * The region's buffer size is pre-calculated via {@link GLRegion#create(com.jogamp.opengl.GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence, Font, CharSequence)}
+ * </p>
* @param gl the current GL state
* @param renderer TODO
* @param font {@link Font} to be used
@@ -165,7 +169,7 @@ public class TextRegionUtil {
GLRegion region = getCachedRegion(font, str);
AABBox res;
if(null == region) {
- region = GLRegion.create(gl.getGLProfile(), renderModes, null);
+ region = GLRegion.create(gl.getGLProfile(), renderModes, null, font, str);
res = addStringToRegion(region, font, null, str, rgbaColor, tempT1, tempT2);
addCachedRegion(gl, font, str, region);
} else {
@@ -178,6 +182,9 @@ public class TextRegionUtil {
/**
* Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ * <p>
+ * The region's buffer size is pre-calculated via {@link GLRegion#create(com.jogamp.opengl.GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence, Font, CharSequence)}
+ * </p>
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
@@ -194,6 +201,9 @@ public class TextRegionUtil {
* Origin of rendered text is 0/0 at bottom left.
* </p>
* <p>
+ * The region's buffer size is pre-calculated via {@link GLRegion#create(com.jogamp.opengl.GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence, Font, CharSequence)}
+ * </p>
+ * <p>
* In case of a multisampling region renderer, i.e. {@link Region#VBAA_RENDERING_BIT}, recreating the {@link GLRegion}
* is a huge performance impact.
* In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)}
@@ -217,7 +227,7 @@ public class TextRegionUtil {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
- final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null);
+ final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null, font, str);
final AABBox res = addStringToRegion(region, font, null, str, rgbaColor, tmp1, tmp2);
region.draw(gl, renderer, sampleCount);
region.destroy(gl);
@@ -226,6 +236,9 @@ public class TextRegionUtil {
/**
* Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ * <p>
+ * The region's buffer size is pre-calculated via {@link #countStringRegion(Region, Font, CharSequence, int[])}.
+ * </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) {
@@ -243,6 +256,9 @@ public class TextRegionUtil {
* <p>
* Origin of rendered text is 0/0 at bottom left.
* </p>
+ * <p>
+ * The region's buffer size is pre-calculated via {@link #countStringRegion(Region, Font, CharSequence, int[])}.
+ * </p>
* @param gl the current GL state
* @param region
* @param renderer
@@ -262,6 +278,9 @@ public class TextRegionUtil {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
+ final int[] vertIndCount = { 0, 0 };
+ TextRegionUtil.countStringRegion(region, font, str, vertIndCount);
+ region.growBuffer(vertIndCount[0], vertIndCount[1]);
final AABBox res = addStringToRegion(region, font, null, str, rgbaColor, tmp1, tmp2);
region.draw(gl, renderer, sampleCount);
return res;