diff options
author | Sven Gothel <[email protected]> | 2014-02-28 15:35:17 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-28 15:35:17 +0100 |
commit | 4701edd64be6a7c4e57d176344fb29ee71699744 (patch) | |
tree | 88e6fff6ee2823387e70646d0e5bf2f646438359 /src/jogl/classes/com/jogamp/graph | |
parent | af621a92250681a83e76293e7d33f685a0fc07e6 (diff) |
Bug 801: TextRenderUtil/TextRendererGLELBase - Pass Font and fontSize to all methods ; TestTextRendererNEWT00 make font/fontSize configurable, animate fontSize
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph')
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java | 44 |
1 files changed, 22 insertions, 22 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 7e8ed4023..0d1e87ad1 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -55,22 +55,22 @@ public class TextRegionUtil { } /** - * Add the string in 3D space w.r.t. the font and pixelSize at the end of the {@link GLRegion}. + * Add the string in 3D space w.r.t. the font and fontSize at the end of the {@link GLRegion}. * @param region the {@link GLRegion} sink * @param vertexFactory vertex impl factory {@link Factory} * @param font the target {@link Font} + * @param fontSize * @param str string text - * @param pixelSize */ public static void addStringToRegion(final GLRegion region, final Factory<? extends Vertex> vertexFactory, - final Font font, final CharSequence str, final int pixelSize) { + final Font font, final float fontSize, final CharSequence str) { final int charCount = str.length(); // region.setFlipped(true); final Font.Metrics metrics = font.getMetrics(); - final float lineHeight = font.getLineHeight(pixelSize); + final float lineHeight = font.getLineHeight(fontSize); - final float scale = metrics.getScale(pixelSize); + final float scale = metrics.getScale(fontSize); final AffineTransform transform = new AffineTransform(vertexFactory); final AffineTransform t = new AffineTransform(vertexFactory); @@ -83,7 +83,7 @@ public class TextRegionUtil { y -= lineHeight; advanceTotal = 0; } else if (character == ' ') { - advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize); + advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, fontSize); } else { if(Region.DEBUG_INSTANCE) { System.err.println("XXXXXXXXXXXXXXx char: "+character+", scale: "+scale+"; translate: "+advanceTotal+", "+y); @@ -99,62 +99,62 @@ public class TextRegionUtil { } region.addOutlineShape(glyphShape, t); - advanceTotal += glyph.getAdvance(pixelSize, true); + advanceTotal += glyph.getAdvance(fontSize, true); } } } /** - * Render the string in 3D space w.r.t. the font and pixelSize + * Render the string in 3D space w.r.t. the font and fontSize * using a cached {@link GLRegion} for reuse. * <p> * Cached {@link GLRegion}s will be destroyed w/ {@link #clear(GL2ES2)} or to free memory. * </p> * @param gl the current GL state * @param font {@link Font} to be used + * @param fontSize font size * @param str text to be rendered - * @param pixelSize font size * @param texSize desired texture width for multipass-rendering. * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. * @throws Exception if TextRenderer not initialized */ public void drawString3D(final GL2ES2 gl, - final Font font, final CharSequence str, final int pixelSize, + final Font font, final float fontSize, final CharSequence str, final int[/*1*/] texSize) { if( !renderer.isInitialized() ) { throw new GLException("TextRendererImpl01: not initialized!"); } final RenderState rs = renderer.getRenderState(); final int special = 0; - GLRegion region = getCachedRegion(font, str, pixelSize, special); + GLRegion region = getCachedRegion(font, str, fontSize, special); if(null == region) { region = GLRegion.create(renderer.getRenderModes()); - addStringToRegion(region, rs.getVertexFactory(), font, str, pixelSize); - addCachedRegion(gl, font, str, pixelSize, special, region); + addStringToRegion(region, rs.getVertexFactory(), font, fontSize, str); + addCachedRegion(gl, font, str, fontSize, special, region); } region.draw(gl, renderer, texSize); } /** - * Render the string in 3D space w.r.t. the font and pixelSize + * Render the string in 3D space w.r.t. the font and fontSize * using a temporary {@link GLRegion}, which will be destroyed afterwards. * @param gl the current GL state * @param font {@link Font} to be used - * @param str text to be rendered * @param fontSize font size + * @param str text to be rendered * @param texWidth desired texture width for multipass-rendering. * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. * @throws Exception if TextRenderer not initialized */ public static void drawString3D(final RegionRenderer renderer, final GL2ES2 gl, - final Font font, final CharSequence str, final int fontSize, + final Font font, final float fontSize, final CharSequence str, final int[/*1*/] texSize) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } final RenderState rs = renderer.getRenderState(); final GLRegion region = GLRegion.create(renderer.getRenderModes()); - addStringToRegion(region, rs.getVertexFactory(), font, str, fontSize); + addStringToRegion(region, rs.getVertexFactory(), font, fontSize, str); region.draw(gl, renderer, texSize); region.destroy(gl, renderer); } @@ -213,11 +213,11 @@ public class TextRegionUtil { } } - protected final GLRegion getCachedRegion(Font font, CharSequence str, int fontSize, int special) { + protected final GLRegion getCachedRegion(Font font, CharSequence str, float fontSize, int special) { return stringCacheMap.get(getKey(font, str, fontSize, special)); } - protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, int special, GLRegion glyphString) { + protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, float fontSize, int special, GLRegion glyphString) { if ( 0 != getCacheLimit() ) { final String key = getKey(font, str, fontSize, special); final GLRegion oldRegion = stringCacheMap.put(key, glyphString); @@ -231,7 +231,7 @@ public class TextRegionUtil { protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, int special) { final String key = getKey(font, str, fontSize, special); - GLRegion region = stringCacheMap.remove(key); + final GLRegion region = stringCacheMap.remove(key); if(null != region) { region.destroy(gl, renderer); } @@ -248,10 +248,10 @@ public class TextRegionUtil { } } - protected final String getKey(Font font, CharSequence str, int fontSize, int special) { + protected final String getKey(Font font, CharSequence str, float fontSize, int special) { final StringBuilder sb = new StringBuilder(); return font.getName(sb, Font.NAME_UNIQUNAME) - .append(".").append(str.hashCode()).append(".").append(fontSize).append(special).toString(); + .append(".").append(str.hashCode()).append(".").append(Float.floatToIntBits(fontSize)).append(special).toString(); } /** Default cache limit, see {@link #setCacheLimit(int)} */ |