Package com.jogamp.graph.curve.opengl
Class TextRegionUtil
- java.lang.Object
-
- com.jogamp.graph.curve.opengl.TextRegionUtil
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TextRegionUtil.ShapeVisitor
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CACHE_LIMIT
Default cache limit, seesetCacheLimit(int)
int
renderModes
jogamp.graph.geom.plane.AffineTransform
tempT1
jogamp.graph.geom.plane.AffineTransform
tempT2
-
Constructor Summary
Constructors Constructor Description TextRegionUtil(int renderModes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addStringToRegion(GLRegion region, Vertex.Factory<? extends Vertex> vertexFactory, Font font, float pixelSize, CharSequence str, float[] rgbaColor, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Add the string in 3D space w.r.t.void
clear(GL2ES2 gl)
Clear all cachedGLRegions
.static void
drawString3D(GL2ES2 gl, int renderModes, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Render the string in 3D space w.r.t.static void
drawString3D(GL2ES2 gl, GLRegion region, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Render the string in 3D space w.r.t.void
drawString3D(GL2ES2 gl, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount)
Render the string in 3D space w.r.t.int
getCacheLimit()
int
getCacheSize()
static int
getCharCount(String s, char c)
static void
processString(TextRegionUtil.ShapeVisitor visitor, jogamp.graph.geom.plane.AffineTransform transform, Font font, float pixelSize, CharSequence str, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Visit eachFont.Glyph
'sOutlineShape
with the givenTextRegionUtil.ShapeVisitor
additionally passing the progressedAffineTransform
.void
setCacheLimit(int newLimit)
Sets the cache limit for reusing GlyphString's and their Region.void
setCacheLimit(GL2ES2 gl, int newLimit)
Sets the cache limit, seesetCacheLimit(int)
and validates the cache.
-
-
-
Field Detail
-
renderModes
public final int renderModes
-
DEFAULT_CACHE_LIMIT
public static final int DEFAULT_CACHE_LIMIT
Default cache limit, seesetCacheLimit(int)
- See Also:
- Constant Field Values
-
tempT1
public final jogamp.graph.geom.plane.AffineTransform tempT1
-
tempT2
public final jogamp.graph.geom.plane.AffineTransform tempT2
-
-
Method Detail
-
getCharCount
public static int getCharCount(String s, char c)
-
processString
public static void processString(TextRegionUtil.ShapeVisitor visitor, jogamp.graph.geom.plane.AffineTransform transform, Font font, float pixelSize, CharSequence str, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Visit eachFont.Glyph
'sOutlineShape
with the givenTextRegionUtil.ShapeVisitor
additionally passing the progressedAffineTransform
. The latter reflects the given font metric, pixelSize and hence character position.- Parameters:
visitor
-transform
- optional given transformfont
- the targetFont
pixelSize
- UseFont.getPixelSize(float, float)
for resolution correct pixel-size.str
- string texttemp1
- temporary AffineTransform storage, mandatory, will be passed toTextRegionUtil.ShapeVisitor.visit(OutlineShape, AffineTransform)
and can be modified.temp2
- temporary AffineTransform storage, mandatory, can be re-used inTextRegionUtil.ShapeVisitor.visit(OutlineShape, AffineTransform)
by user code.
-
addStringToRegion
public static void addStringToRegion(GLRegion region, Vertex.Factory<? extends Vertex> vertexFactory, Font font, float pixelSize, CharSequence str, float[] rgbaColor, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Add the string in 3D space w.r.t. the font and pixelSize at the end of theGLRegion
.- Parameters:
region
- theGLRegion
sinkvertexFactory
- vertex impl factoryVertex.Factory
font
- the targetFont
pixelSize
- UseFont.getPixelSize(float, float)
for resolution correct pixel-size.str
- string textrgbaColor
- ifRegion.hasColorChannel()
RGBA color must be passed, otherwise value is ignored.temp1
- temporary AffineTransform storage, mandatorytemp2
- temporary AffineTransform storage, mandatory
-
drawString3D
public void drawString3D(GL2ES2 gl, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount)
Render the string in 3D space w.r.t. the font and pixelSize using a cachedGLRegion
for reuse.Cached
GLRegion
s will be destroyed w/clear(GL2ES2)
or to free memory.- Parameters:
gl
- the current GL staterenderer
- TODOfont
-Font
to be usedpixelSize
- UseFont.getPixelSize(float, float)
for resolution correct pixel-size.str
- text to be renderedrgbaColor
- ifRegion.hasColorChannel()
RGBA color must be passed, otherwise value is ignored.sampleCount
- desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.- Throws:
Exception
- if TextRenderer not initialized
-
drawString3D
public static void drawString3D(GL2ES2 gl, int renderModes, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Render the string in 3D space w.r.t. the font and pixelSize using a temporaryGLRegion
, which will be destroyed afterwards.In case of a multisampling region renderer, i.e.
Region.VBAA_RENDERING_BIT
, recreating theGLRegion
is a huge performance impact. In such case better usedrawString3D(GL2ES2, GLRegion, RegionRenderer, Font, float, CharSequence, float[], int[], AffineTransform, AffineTransform)
instead.- Parameters:
gl
- the current GL staterenderModes
- TODOfont
-Font
to be usedpixelSize
- UseFont.getPixelSize(float, float)
for resolution correct pixel-size.str
- text to be renderedrgbaColor
- ifRegion.hasColorChannel()
RGBA color must be passed, otherwise value is ignored.sampleCount
- desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.temp1
- temporary AffineTransform storage, mandatorytemp2
- temporary AffineTransform storage, mandatory- Throws:
Exception
- if TextRenderer not initialized
-
drawString3D
public static void drawString3D(GL2ES2 gl, GLRegion region, RegionRenderer renderer, Font font, float pixelSize, CharSequence str, float[] rgbaColor, int[] sampleCount, jogamp.graph.geom.plane.AffineTransform temp1, jogamp.graph.geom.plane.AffineTransform temp2)
Render the string in 3D space w.r.t. the font and pixelSize using the givenGLRegion
, which willcleared
beforehand.- Parameters:
gl
- the current GL statefont
-Font
to be usedpixelSize
- UseFont.getPixelSize(float, float)
for resolution correct pixel-size.str
- text to be renderedrgbaColor
- ifRegion.hasColorChannel()
RGBA color must be passed, otherwise value is ignored.sampleCount
- desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.temp1
- temporary AffineTransform storage, mandatorytemp2
- temporary AffineTransform storage, mandatory- Throws:
Exception
- if TextRenderer not initialized
-
clear
public void clear(GL2ES2 gl)
Clear all cachedGLRegions
.
-
setCacheLimit
public final void setCacheLimit(int newLimit)
Sets the cache limit for reusing GlyphString's and their Region. Default is
DEFAULT_CACHE_LIMIT
, -1 unlimited, 0 turns cache off, >0 limitedThe cache will be validate when the next string rendering happens.
- Parameters:
newLimit
- new cache size- See Also:
DEFAULT_CACHE_LIMIT
-
setCacheLimit
public final void setCacheLimit(GL2ES2 gl, int newLimit)
Sets the cache limit, seesetCacheLimit(int)
and validates the cache.- Parameters:
gl
- current GL used to remove cached objects if requirednewLimit
- new cache size- See Also:
setCacheLimit(int)
-
getCacheLimit
public final int getCacheLimit()
- Returns:
- the current cache limit
-
getCacheSize
public final int getCacheSize()
- Returns:
- the current utilized cache size, <=
getCacheLimit()
-
-