diff options
author | Sven Gothel <[email protected]> | 2023-02-24 22:15:20 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-02-24 22:15:20 +0100 |
commit | 307479391f955a5bd611b4ad4db6f53e097d15c5 (patch) | |
tree | 90b1e4179caf24a4bb9cead9d5db0cfc43dab771 /src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java | |
parent | 6ac71d7fee514f1bf388990b9373d190424699d9 (diff) |
Graph Region: Address overflow issue using GL2ES3 integer indices (WIP...); Ease GLArrayData* buffer growth.
Using integer indices, i.e. GL_UNSIGNED_INT, requires us to pass a GLProfile 'hint' to the GLRegion ctor.
Region.max_indices is computed in this regard and used in Region.addOutlineShape().
TODO: If exceeding max_indices, the code path needs some work.
Buffer growth is eased via GLArrayData using its golden growth ratio
and manually triggering growth before processing all triangles in Region.addOutlineShape().
+++
TextRegionUtil static drawText() won't clear passed Region anymore, caller has to do this if so intended.
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.java | 15 |
1 files changed, 9 insertions, 6 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 88e972bdc..547a07fba 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -144,7 +144,7 @@ public class TextRegionUtil { GLRegion region = getCachedRegion(font, str); AABBox res; if(null == region) { - region = GLRegion.create(renderModes, null); + region = GLRegion.create(gl.getGLProfile(), renderModes, null); res = addStringToRegion(region, font, null, str, rgbaColor, tempT1, tempT2); addCachedRegion(gl, font, str, region); } else { @@ -185,7 +185,7 @@ public class TextRegionUtil { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } - final GLRegion region = GLRegion.create(renderModes, null); + final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); final AABBox res = addStringToRegion(region, font, null, str, rgbaColor); region.draw(gl, renderer, sampleCount); region.destroy(gl); @@ -193,8 +193,10 @@ public class TextRegionUtil { } /** - * Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of the given {@link GLRegion}, - * which will {@link GLRegion#clear(GL2ES2) cleared} beforehand. + * Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of the given {@link GLRegion}. + * <p> + * User might want to {@link GLRegion#clear(GL2ES2)} the region before calling this method. + * </p> * <p> * The shapes added to the GLRegion are in font em-size [0..1]. * </p> @@ -202,6 +204,8 @@ public class TextRegionUtil { * Origin of rendered text is 0/0 at bottom left. * </p> * @param gl the current GL state + * @param region + * @param renderer * @param font {@link Font} to be used * @param str text to be rendered * @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored. @@ -216,14 +220,13 @@ public class TextRegionUtil { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } - region.clear(gl); final AABBox res = addStringToRegion(region, font, null, str, rgbaColor); region.draw(gl, renderer, sampleCount); return res; } /** - * Clear all cached {@link GLRegions}. + * Clear all cached {@link GLRegions} and mapped values. */ public void clear(final GL2ES2 gl) { // fluchCache(gl) already called |