From e9a0f5cdc2bca9ca97175d2fa3c1b722a574b267 Mon Sep 17 00:00:00 2001
From: Sven Gothel
* Cached {@link GLRegion}s will be destroyed w/ {@link #clear(GL2ES2)} or to free memory.
*
+ * 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)}
+ *
+ * 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)}
+ *
+ * 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)} + *
+ ** 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. + *
+ * The region's buffer size is pre-calculated via {@link #countStringRegion(Region, Font, CharSequence, int[])}. + *
*/ 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 { ** Origin of rendered text is 0/0 at bottom left. *
+ *+ * The region's buffer size is pre-calculated via {@link #countStringRegion(Region, Font, CharSequence, int[])}. + *
* @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; -- cgit v1.2.3