aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-08 05:21:50 +0200
committerSven Gothel <[email protected]>2011-05-08 05:21:50 +0200
commite122b2f92b2302362569cdc9a67efd5750f46eb1 (patch)
tree8941dcce577ff5e1378a7322932c4bbfc586373c /src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
parentf88a51cb1c811bba5b5803aee03829b41da308c3 (diff)
Graph: GLSL fix, Adding renderModes bits instead of dedicated booleans, Region/GLRegion, ..
GLSL fix: - allowing #version tag - add uniform textureSize (ES2) - fix int/float conversion Region/GLRegion: - non OpenGL Region and GL related GLRegion split Region/Renderer renderModes bits (def. in Region) - user creates a Renderer* impl .. and derive Region*'s from outline, possibly from a different code path. - to avoid mode explosion, a bit field is being used for now - Renderer: remove flushCache(), since non caching impl. is intended, or caching by an external user transparent object.
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
index 75f3e017a..073afe9bd 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
@@ -39,13 +39,16 @@ import jogamp.graph.font.FontInt;
import jogamp.graph.geom.plane.AffineTransform;
import jogamp.graph.geom.plane.Path2D;
+import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
+import com.jogamp.graph.geom.Vertex;
+import com.jogamp.graph.geom.Vertex.Factory;
public abstract class TextRenderer extends Renderer {
/**
* Create a Hardware accelerated Text Renderer.
* @param rs the used {@link RenderState}
- * @param renderType either {@link com.jogamp.graph.curve.Region#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#TWO_PASS}
+ * @param renderModes either {@link com.jogamp.graph.curve.opengl.GLRegion#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#TWO_PASS_RENDERING_BIT}
*/
public static TextRenderer create(RenderState rs, int type) {
return new jogamp.graph.curve.opengl.TextRendererImpl01(rs, type);
@@ -66,8 +69,8 @@ public abstract class TextRenderer extends Renderer {
* @param texSize texture size for multipass render
* @throws Exception if TextRenderer not initialized
*/
- public abstract void renderString3D(GL2ES2 gl, Font font,
- String str, float[] position, int fontSize, int texSize);
+ public abstract void drawString3D(GL2ES2 gl, Font font,
+ String str, float[] position, int fontSize, int texSize);
/**Create the resulting {@link GlyphString} that represents
* the String wrt to the font.
@@ -80,18 +83,12 @@ public abstract class TextRenderer extends Renderer {
if(DEBUG_INSTANCE) {
System.err.println("createString: "+getCacheSize()+"/"+getCacheLimit()+" - "+Font.NAME_UNIQUNAME + " - " + str + " - " + size);
}
- AffineTransform affineTransform = new AffineTransform(rs.getPointFactory());
-
- Path2D[] paths = new Path2D[str.length()];
- ((FontInt)font).getPaths(str, size, affineTransform, paths);
-
- GlyphString glyphString = new GlyphString(font.getName(Font.NAME_UNIQUNAME), str);
- glyphString.createfromFontPath(rs.getPointFactory(), paths, affineTransform);
- glyphString.generateRegion(gl, rs, renderType);
-
+ final GlyphString glyphString = GlyphString.createString(null, rs.getVertexFactory(), font, size, str);
+ glyphString.createRegion(gl, renderModes);
return glyphString;
}
+ /** FIXME
public void flushCache(GL2ES2 gl) {
Iterator<GlyphString> iterator = stringCacheMap.values().iterator();
while(iterator.hasNext()){
@@ -100,11 +97,18 @@ public abstract class TextRenderer extends Renderer {
}
stringCacheMap.clear();
stringCacheArray.clear();
- }
+ } */
@Override
- protected void disposeImpl(GL2ES2 gl) {
+ protected void destroyImpl(GL2ES2 gl) {
// fluchCache(gl) already called
+ Iterator<GlyphString> iterator = stringCacheMap.values().iterator();
+ while(iterator.hasNext()){
+ GlyphString glyphString = iterator.next();
+ glyphString.destroy(gl, rs);
+ }
+ stringCacheMap.clear();
+ stringCacheArray.clear();
}
/**
@@ -181,7 +185,9 @@ public abstract class TextRenderer extends Renderer {
}
protected final String getKey(Font font, String str, int fontSize) {
- return font.getName(Font.NAME_UNIQUNAME) + "." + str.hashCode() + "." + fontSize;
+ final StringBuilder sb = new StringBuilder();
+ return font.getName(sb, Font.NAME_UNIQUNAME)
+ .append(".").append(str.hashCode()).append(".").append(fontSize).toString();
}
/** Default cache limit, see {@link #setCacheLimit(int)} */