Class TextRegionUtil


  • public class TextRegionUtil
    extends Object
    Text GLRegion Utility Class
    • Field Detail

      • renderModes

        public final int renderModes
      • tempT1

        public final jogamp.graph.geom.plane.AffineTransform tempT1
      • tempT2

        public final jogamp.graph.geom.plane.AffineTransform tempT2
    • Constructor Detail

      • TextRegionUtil

        public TextRegionUtil​(int renderModes)
    • Method Detail

      • getCharCount

        public static int getCharCount​(String s,
                                       char c)
      • 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 the GLRegion.
        Parameters:
        region - the GLRegion sink
        vertexFactory - vertex impl factory Vertex.Factory
        font - the target Font
        pixelSize - Use Font.getPixelSize(float, float) for resolution correct pixel-size.
        str - string text
        rgbaColor - if Region.hasColorChannel() RGBA color must be passed, otherwise value is ignored.
        temp1 - temporary AffineTransform storage, mandatory
        temp2 - 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 cached GLRegion for reuse.

        Cached GLRegions will be destroyed w/ clear(GL2ES2) or to free memory.

        Parameters:
        gl - the current GL state
        renderer - TODO
        font - Font to be used
        pixelSize - Use Font.getPixelSize(float, float) for resolution correct pixel-size.
        str - text to be rendered
        rgbaColor - if Region.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,
                                        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 given GLRegion, which will cleared beforehand.
        Parameters:
        gl - the current GL state
        font - Font to be used
        pixelSize - Use Font.getPixelSize(float, float) for resolution correct pixel-size.
        str - text to be rendered
        rgbaColor - if Region.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, mandatory
        temp2 - temporary AffineTransform storage, mandatory
        Throws:
        Exception - if TextRenderer not initialized
      • clear

        public void clear​(GL2ES2 gl)
        Clear all cached GLRegions.
      • 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 limited

        The 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, see setCacheLimit(int) and validates the cache.
        Parameters:
        gl - current GL used to remove cached objects if required
        newLimit - 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()