diff options
Diffstat (limited to 'src')
25 files changed, 407 insertions, 291 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index 38b68702f..5b0d985ad 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -114,7 +114,7 @@ public class OutlineShape implements Comparable<OutlineShape> { /** The list of {@link Outline}s that are part of this * outline shape. */ - private ArrayList<Outline> outlines; + /* pp */ ArrayList<Outline> outlines; private AABBox bbox; /** dirty bits DIRTY_BOUNDS */ diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index af15f9dc4..f7f51758b 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -28,159 +28,199 @@ package com.jogamp.graph.curve; import java.util.ArrayList; +import java.util.List; +import jogamp.graph.curve.opengl.RegionFactory; import jogamp.opengl.Debug; +import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -/** Abstract Outline shape GL representation - * define the method an OutlineShape(s) is - * binded rendered. - * - * @see GLRegion - */ +/** Abstract Outline shape GL representation define the method an OutlineShape(s) + * is bound and rendered. + * + * @see GLRegion */ public abstract class Region { - - /** Debug flag for region impl (graph.curve) - */ + + /** Debug flag for region impl (graph.curve) */ public static final boolean DEBUG = Debug.debug("graph.curve"); - + public static final boolean DEBUG_INSTANCE = false; - /** View based Anti-Aliasing, A Two pass region rendering, slower - * and more resource hungry (FBO), but AA is perfect. - * Otherwise the default fast one pass MSAA region rendering is being used. - */ + /** View based Anti-Aliasing, A Two pass region rendering, slower and more + * resource hungry (FBO), but AA is perfect. Otherwise the default fast one + * pass MSAA region rendering is being used. */ public static final int VBAA_RENDERING_BIT = 1 << 0; /** Use non uniform weights [0.0 .. 1.9] for curve region rendering. - * Otherwise the default weight 1.0 for uniform curve region rendering is being applied. - */ + * Otherwise the default weight 1.0 for uniform curve region rendering is + * being applied. */ public static final int VARIABLE_CURVE_WEIGHT_BIT = 1 << 1; public static final int TWO_PASS_DEFAULT_TEXTURE_UNIT = 0; private final int renderModes; - private boolean dirty = true; - protected int numVertices = 0; + private boolean dirty = true; + protected int numVertices = 0; protected final AABBox box = new AABBox(); protected ArrayList<Triangle> triangles = new ArrayList<Triangle>(); protected ArrayList<Vertex> vertices = new ArrayList<Vertex>(); - public static boolean isVBAA(int renderModes) { - return 0 != ( renderModes & Region.VBAA_RENDERING_BIT ); + public static boolean isVBAA(int renderModes) { + return 0 != (renderModes & Region.VBAA_RENDERING_BIT); } /** Check if render mode capable of non uniform weights - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, - * {@link Region#VBAA_RENDERING_BIT} - * @return true of capable of non uniform weights + * + * @param renderModes + * bit-field of modes, e.g. + * {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, + * {@link Region#VBAA_RENDERING_BIT} + * @return true of capable of non uniform weights */ + public static boolean isNonUniformWeight(int renderModes) { + return 0 != (renderModes & Region.VARIABLE_CURVE_WEIGHT_BIT); + } + + /** Create a {@link Region} defining the list of {@link OutlineShape}. + * Combining the Shapes into single buffers. + * @return the resulting Region inclusive the generated region */ - public static boolean isNonUniformWeight(int renderModes) { - return 0 != ( renderModes & Region.VARIABLE_CURVE_WEIGHT_BIT ); + public static Region create(List<OutlineShape> outlineShapes, int renderModes) { + final Region region = RegionFactory.create(renderModes); + region.addOutlineShapes(outlineShapes); + return region; } + /** + * Create a {@link Region} defining this {@link OutlineShape} + * @return the resulting Region. + */ + public static Region create(OutlineShape outlineShape, int renderModes) { + final Region region = RegionFactory.create(renderModes); + region.addOutlineShape(outlineShape); + return region; + } + protected Region(int regionRenderModes) { this.renderModes = regionRenderModes; } /** Get current Models - * @return bit-field of render modes - */ - public final int getRenderModes() { - return renderModes; + * + * @return bit-field of render modes */ + public final int getRenderModes() { + return renderModes; } /** Check if current Region is using VBAA - * @return true if capable of two pass rendering - VBAA - */ - public boolean isVBAA() { - return Region.isVBAA(renderModes); + * + * @return true if capable of two pass rendering - VBAA */ + public boolean isVBAA() { + return Region.isVBAA(renderModes); } - /** Check if current instance uses non uniform weights - * @return true if capable of nonuniform weights - */ - public boolean isNonUniformWeight() { - return Region.isNonUniformWeight(renderModes); + /** Check if current instance uses non uniform weights + * + * @return true if capable of nonuniform weights */ + public boolean isNonUniformWeight() { + return Region.isNonUniformWeight(renderModes); } - /** Get the current number of vertices associated - * with this region. This number is not necessary equal to - * the OGL bound number of vertices. - * @return vertices count - */ - public final int getNumVertices(){ + /** Get the current number of vertices associated with this region. This + * number is not necessary equal to the OGL bound number of vertices. + * + * @return vertices count */ + public final int getNumVertices() { return numVertices; } - /** Adds a {@link Triangle} object to the Region - * This triangle will be bound to OGL objects - * on the next call to {@code update} - * @param tri a triangle object + /** Adds a {@link Triangle} object to the Region This triangle will be bound + * to OGL objects on the next call to {@code update} * - * @see update(GL2ES2) - */ + * @param tri + * a triangle object + * + * @see update(GL2ES2) */ public void addTriangle(Triangle tri) { triangles.add(tri); setDirty(true); } - /** Adds a list of {@link Triangle} objects to the Region - * These triangles are to be binded to OGL objects - * on the next call to {@code update} - * @param tris an arraylist of triangle objects + /** Adds a list of {@link Triangle} objects to the Region These triangles are + * to be binded to OGL objects on the next call to {@code update} * - * @see update(GL2ES2) - */ - public void addTriangles(ArrayList<Triangle> tris) { + * @param tris + * a list of triangle objects + * + * @see update(GL2ES2) */ + public void addTriangles(List<Triangle> tris) { triangles.addAll(tris); setDirty(true); } - /** Adds a {@link Vertex} object to the Region - * This vertex will be bound to OGL objects - * on the next call to {@code update} - * @param vert a vertex objects + /** Adds a {@link Vertex} object to the Region This vertex will be bound to + * OGL objects on the next call to {@code update} * - * @see update(GL2ES2) - */ + * @param vert + * a vertex objects + * + * @see update(GL2ES2) */ public void addVertex(Vertex vert) { vertices.add(vert); numVertices++; setDirty(true); } - /** Adds a list of {@link Vertex} objects to the Region - * These vertices are to be binded to OGL objects - * on the next call to {@code update} - * @param verts an arraylist of vertex objects + /** Adds a list of {@link Vertex} objects to the Region These vertices are to + * be binded to OGL objects on the next call to {@code update} * - * @see update(GL2ES2) - */ - public void addVertices(ArrayList<Vertex> verts) { + * @param verts + * a list of vertex objects + * + * @see update(GL2ES2) */ + public void addVertices(List<Vertex> verts) { vertices.addAll(verts); numVertices = vertices.size(); setDirty(true); } - /** - * @return the AxisAligned bounding box of - * current region - */ - public final AABBox getBounds(){ + public void addOutlineShape(OutlineShape shape) { + shape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); + List<Triangle> tris = shape.triangulate(); + if(null != tris) { + triangles.addAll(tris); + for (int j = 0; j < shape.outlines.size(); j++) { + final ArrayList<Vertex> sovs = shape.outlines.get(j).getVertices(); + for (int k = 0; k < sovs.size(); k++) { + final Vertex v = sovs.get(k); + v.setId(numVertices++); + vertices.add(v); + } + } + } + setDirty(true); + } + + public void addOutlineShapes(List<OutlineShape> shapes) { + for (int i = 0; i < shapes.size(); i++) { + addOutlineShape(shapes.get(i)); + } + setDirty(true); + } + + /** @return the AxisAligned bounding box of current region */ + public final AABBox getBounds() { return box; } - /** Check if this region is dirty. A region is marked dirty - * when new Vertices, Triangles, and or Lines are added after a - * call to update() + /** Check if this region is dirty. A region is marked dirty when new + * Vertices, Triangles, and or Lines are added after a call to update() + * * @return true if region is Dirty, false otherwise * - * @see update(GL2ES2) - */ + * @see update(GL2ES2) */ public final boolean isDirty() { return dirty; } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java index 63713887b..e046c91cb 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -27,17 +27,13 @@ */
package com.jogamp.graph.curve.opengl;
-
-import java.util.ArrayList;
+import java.util.List;
import javax.media.opengl.GL2ES2;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.geom.Triangle;
-import com.jogamp.graph.geom.Vertex;
-import jogamp.graph.curve.opengl.RegionFactory;
/** A GLRegion is the OGL binding of one or more OutlineShapes
* Defined by its vertices and generated triangles. The Region
@@ -55,44 +51,18 @@ public abstract class GLRegion extends Region { * Combining the Shapes into single buffers.
* @return the resulting Region inclusive the generated region
*/
- public static GLRegion create(OutlineShape[] outlineShapes, int renderModes) {
- final GLRegion region = RegionFactory.create(renderModes);
-
- int numVertices = region.getNumVertices();
-
- for(int index=0; index<outlineShapes.length; index++) {
- OutlineShape outlineShape = outlineShapes[index];
- outlineShape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS);
-
- ArrayList<Triangle> triangles = outlineShape.triangulate();
- region.addTriangles(triangles);
-
- ArrayList<Vertex> vertices = outlineShape.getVertices();
- for(int pos=0; pos < vertices.size(); pos++){
- Vertex vert = vertices.get(pos);
- vert.setId(numVertices++);
- }
- region.addVertices(vertices);
- }
-
- return region;
+ public static GLRegion create(List<OutlineShape> outlineShapes, int renderModes) {
+ return (GLRegion) Region.create(outlineShapes, renderModes);
}
/**
- * Create an ogl {@link GLRegion} defining this {@link OutlineShape}
+ * Create an ogl {@link Region} defining this {@link OutlineShape}
* @return the resulting Region.
*/
public static GLRegion create(OutlineShape outlineShape, int renderModes) {
- final GLRegion region = RegionFactory.create(renderModes);
-
- outlineShape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS);
- ArrayList<Triangle> triangles = (ArrayList<Triangle>) outlineShape.triangulate();
- ArrayList<Vertex> vertices = (ArrayList<Vertex>) outlineShape.getVertices();
- region.addVertices(vertices);
- region.addTriangles(triangles);
- return region;
+ return (GLRegion) Region.create(outlineShape, renderModes);
}
-
+
protected GLRegion(int renderModes) {
super(renderModes);
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index 2f078d7bb..4b7c12fea 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -53,12 +53,11 @@ public abstract class RegionRenderer extends Renderer { /** Render an {@link OutlineShape} in 3D space at the position provided * the triangles of the shapes will be generated, if not yet generated * @param region the OutlineShape to Render. - * @param position the initial translation of the outlineShape. * @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 HwRegionRenderer not initialized */ - public final void draw(GL2ES2 gl, Region region, float[] position, int[/*1*/] texWidth) { + public final void draw(GL2ES2 gl, Region region, int[/*1*/] texWidth) { if(!isInitialized()) { throw new GLException("RegionRenderer: not initialized!"); } @@ -66,14 +65,14 @@ public abstract class RegionRenderer extends Renderer { throw new GLException("Incompatible render modes, : region modes "+region.getRenderModes()+ " doesn't contain renderer modes "+this.getRenderModes()); } - drawImpl(gl, region, position, texWidth); + drawImpl(gl, region, texWidth); } /** * Usually just dispatched the draw call to the Region's draw implementation, * e.g. {@link com.jogamp.graph.curve.opengl.GLRegion#draw(GL2ES2, RenderState, int, int, int[]) GLRegion#draw(GL2ES2, RenderState, int, int, int[])}. */ - protected abstract void drawImpl(GL2ES2 gl, Region region, float[] position, int[] texWidth); + protected abstract void drawImpl(GL2ES2 gl, Region region, int[] texWidth); @Override protected void destroyImpl(GL2ES2 gl) { diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index 3c23733a5..c9cb13ad4 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -101,7 +101,7 @@ public abstract class Renderer { * Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext * if not initialized yet. * <p>Leaves the renderer enabled, ie ShaderState.</p> - * <p>Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, float[], int)}</p> + * <p>Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, int)}</p> * * @param gl referencing the current GLContext to which the ShaderState is bound to * @throws GLException if initialization failed 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 8dc41b0c0..44007ca79 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java @@ -35,36 +35,42 @@ import javax.media.opengl.GL2ES2; import jogamp.graph.curve.text.GlyphString; +import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; +import com.jogamp.graph.geom.Vertex.Factory; +/** + * @deprecated use {@link com.jogamp.graph.font.Font#getOutlineShapes(java.util.List, CharSequence, float, Factory)}, + * {@link com.jogamp.graph.curve.Region#create(OutlineShape, int)} + * and a {@link com.jogamp.graph.curve.opengl.RegionRenderer}. + */ public abstract class TextRenderer extends Renderer { - /** + /** * Create a Hardware accelerated Text Renderer. - * @param rs the used {@link RenderState} + * @param rs the used {@link RenderState} * @param renderModes either {@link com.jogamp.graph.curve.opengl.GLRegion#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#VBAA_RENDERING_BIT} */ public static TextRenderer create(RenderState rs, int renderModes) { return new jogamp.graph.curve.opengl.TextRendererImpl01(rs, renderModes); } - + protected TextRenderer(RenderState rs, int type) { super(rs, type); } - + /** Render the String in 3D space wrt to the font provided at the position provided * the outlines will be generated, if not yet generated * @param gl the current GL state * @param font {@link Font} to be used - * @param str text to be rendered - * @param position the lower left corner of the string + * @param str text to be rendered * @param fontSize font size - * @param texWidth desired texture width for multipass-rendering. + * @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 abstract void drawString3D(GL2ES2 gl, Font font, - String str, float[] position, int fontSize, int[/*1*/] texSize); + String str, int fontSize, int[/*1*/] texSize); /**Create the resulting {@link GlyphString} that represents * the String wrt to the font. @@ -77,11 +83,11 @@ public abstract class TextRenderer extends Renderer { if(DEBUG_INSTANCE) { System.err.println("createString: "+getCacheSize()+"/"+getCacheLimit()+" - "+Font.NAME_UNIQUNAME + " - " + str + " - " + size); } - final GlyphString glyphString = GlyphString.createString(null, rs.getVertexFactory(), font, size, str); - glyphString.createRegion(gl, renderModes); + 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(); @@ -89,10 +95,10 @@ public abstract class TextRenderer extends Renderer { GlyphString glyphString = iterator.next(); glyphString.destroy(gl, rs); } - stringCacheMap.clear(); + stringCacheMap.clear(); stringCacheArray.clear(); } */ - + @Override protected void destroyImpl(GL2ES2 gl) { // fluchCache(gl) already called @@ -101,42 +107,42 @@ public abstract class TextRenderer extends Renderer { GlyphString glyphString = iterator.next(); glyphString.destroy(gl, rs); } - stringCacheMap.clear(); + stringCacheMap.clear(); stringCacheArray.clear(); } - + /** * <p>Sets the cache limit for reusing GlyphString's and their Region. * Default is {@link #DEFAULT_CACHE_LIMIT}, -1 unlimited, 0 turns cache off, >0 limited </p> - * + * * <p>The cache will be validate when the next string rendering happens.</p> - * + * * @param newLimit new cache size - * + * * @see #DEFAULT_CACHE_LIMIT */ public final void setCacheLimit(int newLimit ) { stringCacheLimit = newLimit; } - + /** * Sets the cache limit, see {@link #setCacheLimit(int)} and validates the cache. - * + * * @see #setCacheLimit(int) - * + * * @param gl current GL used to remove cached objects if required * @param newLimit new cache size */ public final void setCacheLimit(GL2ES2 gl, int newLimit ) { stringCacheLimit = newLimit; validateCache(gl, 0); } - + /** * @return the current cache limit */ public final int getCacheLimit() { return stringCacheLimit; } - - /** + + /** * @return the current utilized cache size, <= {@link #getCacheLimit()} */ public final int getCacheSize() { return stringCacheArray.size(); } - + protected final void validateCache(GL2ES2 gl, int space) { if ( getCacheLimit() > 0 ) { while ( getCacheSize() + space > getCacheLimit() ) { @@ -144,7 +150,7 @@ public abstract class TextRenderer extends Renderer { } } } - + protected final GlyphString getCachedGlyphString(Font font, String str, int fontSize) { return stringCacheMap.get(getKey(font, str, fontSize)); } @@ -160,13 +166,13 @@ public abstract class TextRenderer extends Renderer { } /// else overwrite is nop .. } } - + protected final void removeCachedGlyphString(GL2ES2 gl, Font font, String str, int fontSize) { final String key = getKey(font, str, fontSize); GlyphString glyphString = stringCacheMap.remove(key); if(null != glyphString) { glyphString.destroy(gl, rs); - } + } stringCacheArray.remove(key); } @@ -177,7 +183,7 @@ public abstract class TextRenderer extends Renderer { glyphString.destroy(gl, rs); } } - + protected final String getKey(Font font, String str, int fontSize) { final StringBuilder sb = new StringBuilder(); return font.getName(sb, Font.NAME_UNIQUNAME) @@ -186,8 +192,8 @@ public abstract class TextRenderer extends Renderer { /** Default cache limit, see {@link #setCacheLimit(int)} */ public static final int DEFAULT_CACHE_LIMIT = 256; - - private HashMap<String, GlyphString> stringCacheMap = new HashMap<String, GlyphString>(DEFAULT_CACHE_LIMIT); - private ArrayList<String> stringCacheArray = new ArrayList<String>(DEFAULT_CACHE_LIMIT); - private int stringCacheLimit = DEFAULT_CACHE_LIMIT; + + private final HashMap<String, GlyphString> stringCacheMap = new HashMap<String, GlyphString>(DEFAULT_CACHE_LIMIT); + private final ArrayList<String> stringCacheArray = new ArrayList<String>(DEFAULT_CACHE_LIMIT); + private int stringCacheLimit = DEFAULT_CACHE_LIMIT; }
\ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index e2b3fe5d7..97510bcd0 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -27,7 +27,12 @@ */ package com.jogamp.graph.font; +import java.util.List; + +import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.geom.AABBox; +import com.jogamp.graph.geom.Vertex; +import com.jogamp.graph.geom.Vertex.Factory; /** * Interface wrapper for font implementation. @@ -82,8 +87,11 @@ public interface Font { public Font getFont(); public char getSymbol(); + public short getID(); + public float getScale(float pixelSize); public AABBox getBBox(float pixelSize); public float getAdvance(float pixelSize, boolean useFrationalMetrics); + public int hashCode(); } @@ -107,6 +115,22 @@ public interface Font { public AABBox getStringBounds(CharSequence string, float pixelSize); public boolean isPrintableChar( char c ); + + /** + * @param glyph source of the created OutlineShape + * @param vertexFactory factory for vertices + * @return OutlineShape of the glyph + */ + public OutlineShape getOutlineShape(Glyph glyph, Factory<? extends Vertex> vertexFactory); + + /** + * @param shapes optional storage of OutlineShapes passed by user, new shapes are appended + * @param string source of the created OutlineShapes + * @param pixelSize + * @param vertexFactory factory for vertices + * @return List of OutlineShapes, one OutlineShape per character + */ + public List<OutlineShape> getOutlineShapes(List<OutlineShape> shapes, CharSequence string, float pixelSize, Factory<? extends Vertex> vertexFactory); /** Shall return {@link #getFullFamilyName()} */ public String toString(); diff --git a/src/jogl/classes/com/jogamp/graph/geom/AABBox.java b/src/jogl/classes/com/jogamp/graph/geom/AABBox.java index 87f084919..834b1a9e4 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/graph/geom/AABBox.java @@ -320,7 +320,8 @@ public class AABBox implements Cloneable { } public final String toString() { - return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+ - center[0]+"/"+center[1]+"/"+center[1]+" ]"; + return "[ dim "+getWidth()+" x "+getHeight()+" x "+getDepth()+ + ", box "+low[0]+" / "+low[1]+" / "+low[2]+" .. "+high[0]+" / "+high[1]+" / "+high[2]+ + ", ctr "+center[0]+" / "+center[1]+" / "+center[2]+" ]"; } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index c34d1cbeb..e6001f4c2 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -87,7 +87,7 @@ public class RegionRendererImpl01 extends RegionRenderer { } @Override - protected void drawImpl(GL2ES2 gl, Region region, float[] position, int[] texSize) { + protected void drawImpl(GL2ES2 gl, Region region, int[] texSize) { ((GLRegion)region).draw(gl, rs, vp_width, vp_height, texSize); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 158f0240a..f8b1b090b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -80,7 +80,7 @@ public class TextRendererImpl01 extends TextRenderer { } @Override - public void drawString3D(GL2ES2 gl, Font font, String str, float[] position, int fontSize, int[/*1*/] texSize) { + public void drawString3D(GL2ES2 gl, Font font, String str, int fontSize, int[/*1*/] texSize) { if(!isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index 10b6d6847..078f2f332 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -125,8 +125,9 @@ public class CDTriangulator2D implements Triangulator{ } } Triangle tri = loop.cut(true); - if(tri != null) + if(tri != null) { triangles.add(tri); + } } return triangles; } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 578148699..12da966a2 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -29,71 +29,84 @@ package jogamp.graph.curve.text; import java.util.ArrayList; +import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex.Factory; import com.jogamp.graph.curve.OutlineShape; -import com.jogamp.graph.math.Quaternion; +// import com.jogamp.graph.math.Quaternion; public class GlyphShape { - private Quaternion quat= null; - private OutlineShape shape = null; + // private Quaternion quat= null; + private Glyph glyph; + private OutlineShape shape; /** Create a new Glyph shape * based on Parametric curve control polyline */ public GlyphShape(Vertex.Factory<? extends Vertex> factory){ - shape = new OutlineShape(factory); + this.shape = new OutlineShape(factory); + this.glyph = null; } /** Create a new GlyphShape from a {@link OutlineShape} * @param factory vertex impl factory {@link Factory} * @param shape {@link OutlineShape} representation of the Glyph */ - public GlyphShape(Vertex.Factory<? extends Vertex> factory, OutlineShape shape){ + public GlyphShape(Vertex.Factory<? extends Vertex> factory, Glyph glyph, OutlineShape shape){ this(factory); this.shape = shape; - this.shape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); + this.shape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); + this.glyph = glyph; + } + + public final void destroy() { + shape.clear(); + shape = null; + glyph = null; } public final Vertex.Factory<? extends Vertex> vertexFactory() { return shape.vertexFactory(); } - public OutlineShape getShape() { + public final Glyph getGlyph() { + return glyph; + } + + public final OutlineShape getShape() { return shape; } - public int getNumVertices() { + public final int getNumVertices() { return shape.getVertices().size(); } /** Get the rotational Quaternion attached to this Shape * @return the Quaternion Object - */ - public Quaternion getQuat() { + public final Quaternion getQuat() { return quat; } - /** Set the Quaternion that shall defien the rotation + * Set the Quaternion that shall defien the rotation * of this shape. * @param quat - */ - public void setQuat(Quaternion quat) { + public final void setQuat(Quaternion quat) { this.quat = quat; } + */ /** Triangluate the glyph shape * @return ArrayList of triangles which define this shape */ - public ArrayList<Triangle> triangulate(){ + public final ArrayList<Triangle> triangulate(){ return shape.triangulate(); } /** Get the list of Vertices of this Object * @return arrayList of Vertices */ - public ArrayList<Vertex> getVertices(){ + public final ArrayList<Vertex> getVertices(){ return shape.getVertices(); } } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index f86d02f40..13da49d9e 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -28,6 +28,7 @@ package jogamp.graph.curve.text; import java.util.ArrayList; +import java.util.List; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.AABBox; @@ -39,7 +40,7 @@ import com.jogamp.graph.geom.opengl.SVertex; import javax.media.opengl.GL2ES2; import jogamp.graph.curve.opengl.RegionFactory; -import jogamp.graph.font.FontInt; +import jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; @@ -47,56 +48,61 @@ import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.opengl.util.PMVMatrix; +/** + * @deprecated use {@link com.jogamp.graph.font.Font#getOutlineShapes(java.util.List, CharSequence, float, Factory)}, + * {@link com.jogamp.graph.curve.Region#create(OutlineShape, int)} + * and a {@link com.jogamp.graph.curve.opengl.RegionRenderer}. + */ public class GlyphString { /** Static font size for all default font OutlineShape generations via {@link #createString(OutlineShape, Factory, Font, String)}. * <p>The actual font size shall be accomplished by the GL PMV matrix.</p> */ public static final int STATIC_FONT_SIZE = 10; - - private ArrayList<GlyphShape> glyphs = new ArrayList<GlyphShape>(); - private CharSequence str; - private String fontname; + + private final ArrayList<GlyphShape> glyphs = new ArrayList<GlyphShape>(); + private final CharSequence str; + private final String fontname; private GLRegion region; - - private SVertex origin = new SVertex(); + + private final SVertex origin = new SVertex(); /** * <p>Uses {@link #STATIC_FONT_SIZE}.</p> * <p>No caching is performed.</p> - * + * * @param shape is not null, add all {@link GlyphShape}'s {@link Outline} to this instance. * @param vertexFactory vertex impl factory {@link Factory} - * @param font the target {@link Font} + * @param font the target {@link Font} * @param str string text * @return the created {@link GlyphString} instance */ public static GlyphString createString(OutlineShape shape, Factory<? extends Vertex> vertexFactory, Font font, String str) { - return createString(shape, vertexFactory, font, STATIC_FONT_SIZE, str); + return createString(shape, vertexFactory, font, STATIC_FONT_SIZE, str); } - + /** * <p>No caching is performed.</p> - * + * * @param shape is not null, add all {@link GlyphShape}'s {@link Outline} to this instance. * @param vertexFactory vertex impl factory {@link Factory} - * @param font the target {@link Font} + * @param font the target {@link Font} * @param fontSize font size * @param str string text * @return the created {@link GlyphString} instance */ - public static GlyphString createString(OutlineShape shape, Factory<? extends Vertex> vertexFactory, Font font, int fontSize, String str) { - ArrayList<OutlineShape> shapes = ((FontInt)font).getOutlineShapes(str, fontSize, vertexFactory); - + public static GlyphString createString(OutlineShape shape, Factory<? extends Vertex> vertexFactory, Font font, int fontSize, CharSequence str) { + List<OutlineShape> shapes = font.getOutlineShapes(null, str, fontSize, vertexFactory); + GlyphString glyphString = new GlyphString(font.getName(Font.NAME_UNIQUNAME), str); - glyphString.createfromOutlineShapes(vertexFactory, shapes); + glyphString.createfromOutlineShapes(vertexFactory, font, str, shapes); if(null != shape) { for(int i=0; i<glyphString.glyphs.size(); i++) { shape.addOutlineShape(glyphString.glyphs.get(i).getShape()); - } + } } return glyphString; } - + /** Create a new GlyphString object * @param fontname the name of the font that this String is * associated with @@ -106,62 +112,77 @@ public class GlyphString { this.fontname = fontname; this.str = str; } - + public void addGlyphShape(GlyphShape glyph){ glyphs.add(glyph); } - + public CharSequence getString(){ return str; } - /**Creates the Curve based Glyphs from a list of {@link OutlineShape} + /**Creates the Curve based Glyphs from a list of {@link OutlineShape} * @param vertexFactory vertex impl factory {@link Factory} - * @param shapes list of {@link OutlineShape} + * @param shapes list of {@link OutlineShape} */ - public void createfromOutlineShapes(Factory<? extends Vertex> vertexFactory, ArrayList<OutlineShape> shapes) { + public void createfromOutlineShapes(Factory<? extends Vertex> vertexFactory, Font font, CharSequence str, List<OutlineShape> shapes) { + if(shapes.size() != str.length()) { + throw new InternalError("XXX"); + } final int numGlyps = shapes.size(); for (int index=0;index<numGlyps;index++){ if(shapes.get(index) == null){ continue; } - GlyphShape glyphShape = new GlyphShape(vertexFactory, shapes.get(index)); - + GlyphShape glyphShape = new GlyphShape(vertexFactory, + font.getGlyph(str.charAt(index)), + shapes.get(index)); + if(glyphShape.getNumVertices() < 3) { continue; - } + } addGlyphShape(glyphShape); } } - - + + /** Generate a OGL Region to represent this Object. * @param gl the current gl object * @param rs the current attached RenderState - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} */ public GLRegion createRegion(GL2ES2 gl, int renderModes){ region = RegionFactory.create(renderModes); // region.setFlipped(true); - + float y = 0; + float advanceTotal = 0; + AffineTransform t = new AffineTransform(); + int numVertices = region.getNumVertices(); - + for(int i=0; i< glyphs.size(); i++) { - final GlyphShape glyph = glyphs.get(i); - ArrayList<Triangle> gtris = glyph.triangulate(); + final GlyphShape glyphShape = glyphs.get(i); + Font.Metrics metrics = glyphShape.getGlyph().getFont().getMetrics(); + final float scale = metrics.getScale(STATIC_FONT_SIZE); + t.translate(advanceTotal, y); + t.scale(scale, scale); + + ArrayList<Triangle> gtris = glyphShape.triangulate(); region.addTriangles(gtris); - - final ArrayList<Vertex> gVertices = glyph.getVertices(); + + final ArrayList<Vertex> gVertices = glyphShape.getVertices(); for(int j=0; j<gVertices.size(); j++) { final Vertex gVert = gVertices.get(j); gVert.setId(numVertices++); region.addVertex(gVert); } + + advanceTotal += glyphShape.getGlyph().getAdvance(STATIC_FONT_SIZE, true); } return region; } - - /** Generate a Hashcode for this object + + /** Generate a Hashcode for this object * @return a string defining the hashcode */ public String getTextHashCode(){ @@ -180,15 +201,15 @@ public class GlyphString { * @param rs the RenderState to be used * @param vp_width current screen width * @param vp_height current screen height - * @param texWidth desired texture width for multipass-rendering. + * @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. */ public void renderString3D(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) { region.draw(gl, rs, vp_width, vp_height, texWidth); } - + /** Get the Origin of this GlyphString - * @return + * @return */ public Vertex getOrigin() { return origin; @@ -206,7 +227,7 @@ public class GlyphString { } glyphs.clear(); } - + public AABBox getBounds(){ return region.getBounds(); } diff --git a/src/jogl/classes/jogamp/graph/font/FontInt.java b/src/jogl/classes/jogamp/graph/font/FontInt.java index 20e1ec028..7528a692b 100644 --- a/src/jogl/classes/jogamp/graph/font/FontInt.java +++ b/src/jogl/classes/jogamp/graph/font/FontInt.java @@ -27,14 +27,9 @@ */ package jogamp.graph.font; -import java.util.ArrayList; - 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 interface FontInt extends Font { @@ -43,5 +38,4 @@ public interface FontInt extends Font { public Path2D getPath(float pixelSize); } - public ArrayList<OutlineShape> getOutlineShapes(CharSequence string, float pixelSize, Factory<? extends Vertex> vertexFactory); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 8e465de99..2d13ae32d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -27,7 +27,7 @@ */ package jogamp.graph.font.typecast; -import java.util.ArrayList; +import java.util.List; import jogamp.graph.font.FontInt; import jogamp.graph.font.typecast.ot.OTFont; @@ -44,7 +44,6 @@ import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; @@ -148,25 +147,31 @@ class TypecastFont implements FontInt { char2Glyph = new IntObjectHashMap(cmapentries + cmapentries/4); } + @Override public StringBuilder getName(StringBuilder sb, int nameIndex) { return font.getName(nameIndex, sb); } + @Override public String getName(int nameIndex) { return getName(null, nameIndex).toString(); } + @Override public StringBuilder getAllNames(StringBuilder sb, String separator) { return font.getAllNames(sb, separator); } + @Override public StringBuilder getFullFamilyName(StringBuilder sb) { sb = getName(sb, Font.NAME_FAMILY).append("-"); getName(sb, Font.NAME_SUBFAMILY); return sb; } + @Override public float getAdvanceWidth(int i, float pixelSize) { return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize); } + @Override public Metrics getMetrics() { if (metrics == null) { metrics = new TypecastHMetrics(this); @@ -174,6 +179,7 @@ class TypecastFont implements FontInt { return metrics; } + @Override public Glyph getGlyph(char symbol) { TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); if (null == result) { @@ -218,12 +224,19 @@ class TypecastFont implements FontInt { } return result; } - - public ArrayList<OutlineShape> getOutlineShapes(CharSequence string, float pixelSize, Factory<? extends Vertex> vertexFactory) { + + @Override + public OutlineShape getOutlineShape(Glyph glyph, Factory<? extends Vertex> vertexFactory) { + return TypecastRenderer.getOutlineShape(this, glyph, vertexFactory); + } + + @Override + public List<OutlineShape> getOutlineShapes(List<OutlineShape> shapes, CharSequence string, float pixelSize, Factory<? extends Vertex> vertexFactory) { AffineTransform transform = new AffineTransform(vertexFactory); - return TypecastRenderer.getOutlineShapes(this, string, pixelSize, transform, vertexFactory); + return TypecastRenderer.getOutlineShapes(shapes, this, string, pixelSize, transform, vertexFactory); } + @Override public float getStringWidth(CharSequence string, float pixelSize) { float width = 0; final int len = string.length(); @@ -241,6 +254,7 @@ class TypecastFont implements FontInt { return (int)(width + 0.5f); } + @Override public float getStringHeight(CharSequence string, float pixelSize) { int height = 0; @@ -257,6 +271,7 @@ class TypecastFont implements FontInt { return height; } + @Override public AABBox getStringBounds(CharSequence string, float pixelSize) { if (string == null) { return new AABBox(); @@ -287,14 +302,17 @@ class TypecastFont implements FontInt { return new AABBox(0, 0, 0, totalWidth, totalHeight,0); } + @Override final public int getNumGlyphs() { return font.getNumGlyphs(); } + @Override public boolean isPrintableChar( char c ) { return FontFactory.isPrintableChar(c); } + @Override public String toString() { return getFullFamilyName(null).toString(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index a1f1a3292..cdaa2df7e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -228,5 +228,11 @@ public class TypecastGlyph implements FontInt.GlyphInt { this.pathSized = AffineTransform.getScaleInstance(null, size, size).createTransformedShape(getPath()); } return this.pathSized; + } + + public int hashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + font.getName(Font.NAME_UNIQUNAME).hashCode(); + return ((hash << 5) - hash) + id; } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index f155345aa..d62f19cb7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -28,6 +28,7 @@ package jogamp.graph.font.typecast; import java.util.ArrayList; +import java.util.List; import jogamp.graph.font.FontInt.GlyphInt; import jogamp.graph.font.typecast.ot.OTGlyph; @@ -64,9 +65,10 @@ public class TypecastRenderer { } AffineTransform t = new AffineTransform(); + final int len = string.length(); float advanceY = lineGap - descent + ascent; float y = 0; - for (int i=0; i<string.length(); i++) + for (int i=0; i<len; i++) { p[i] = new Path2D(); p[i].reset(); @@ -75,26 +77,44 @@ public class TypecastRenderer { if (character == '\n') { y += advanceY; advanceTotal = 0; - continue; } else if (character == ' ') { advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize); - continue; - } - Glyph glyph = font.getGlyph(character); - Path2D gp = ((GlyphInt)glyph).getPath(); - float scale = metrics.getScale(pixelSize); - t.translate(advanceTotal, y); - t.scale(scale, scale); - p[i].append(gp.iterator(t), false); - advanceTotal += glyph.getAdvance(pixelSize, true); + } else { + final Glyph glyph = font.getGlyph(character); + final Path2D gp = ((GlyphInt)glyph).getPath(); + final float scale = metrics.getScale(pixelSize); + t.translate(advanceTotal, y); + t.scale(scale, scale); + p[i].append(gp.iterator(t), false); + advanceTotal += glyph.getAdvance(pixelSize, true); + } } } - public static ArrayList<OutlineShape> getOutlineShapes(TypecastFont font, CharSequence string, float pixelSize, AffineTransform transform, Factory<? extends Vertex> vertexFactory) { + public static OutlineShape getOutlineShape(TypecastFont font, Glyph glyph, Factory<? extends Vertex> vertexFactory) { + Path2D path = ((GlyphInt)glyph).getPath(); + AffineTransform transform = new AffineTransform(vertexFactory); + OutlineShape shape = new OutlineShape(vertexFactory); + + PathIterator iterator = path.iterator(transform); + if(null != iterator){ + while(!iterator.isDone()){ + float[] coords = new float[6]; + int segmentType = iterator.currentSegment(coords); + addPathVertexToOutline(shape, vertexFactory, coords, segmentType); + iterator.next(); + } + } + return shape; + } + + public static List<OutlineShape> getOutlineShapes(List<OutlineShape> shapes, TypecastFont font, CharSequence string, float pixelSize, AffineTransform transform, Factory<? extends Vertex> vertexFactory) { Path2D[] paths = new Path2D[string.length()]; getPaths(font, string, pixelSize, transform, paths); - ArrayList<OutlineShape> shapes = new ArrayList<OutlineShape>(); + if(null == shapes) { + shapes = new ArrayList<OutlineShape>(); + } final int numGlyps = paths.length; for (int index=0;index<numGlyps;index++) { if(paths[index] == null){ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java index a09cc76ac..738d40971 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -63,7 +63,6 @@ public class TestTextRendererNEWT00 extends UITestCase { static final boolean TRACE = false; static long duration = 100; // ms - static final float[] textPosition = new float[] {0,0,0}; static final int[] texSize = new int[] { 0 }; static final int fontSize = 24; static Font font; @@ -172,7 +171,7 @@ public class TestTextRendererNEWT00 extends UITestCase { dy -= (int)textBox.getHeight() * ( row + 1 ); renderer.resetModelview(null); renderer.translate(gl, dx, dy, z0); - renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize); + renderer.drawString3D(gl, font, text, fontSize, texSize); lastRow = row; } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java index dbeae0dfc..c9f28309c 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -55,7 +55,6 @@ public class TestTextRendererNEWT10 extends UITestCase { static final boolean TRACE = false; static long duration = 100; // ms - static final float[] textPosition = new float[] {0,0,0}; static final int[] texSize = new int[] { 0 }; static final int fontSize = 24; static Font font; @@ -160,7 +159,7 @@ public class TestTextRendererNEWT10 extends UITestCase { dy -= (int)textBox.getHeight() * ( row + 1 ); renderer.resetModelview(null); renderer.translate(gl, dx, dy, z0); - renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize); + renderer.drawString3D(gl, font, text, fontSize, texSize); lastRow = row; } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java index 46557e8c8..43e5537e9 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java @@ -120,6 +120,6 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - regionRenderer.draw(gl, region, getPosition(), getTexSize()); + regionRenderer.draw(gl, region, getTexSize()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java index 525c5e648..3565dbc48 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java @@ -28,6 +28,9 @@ package com.jogamp.opengl.test.junit.graph.demos; +import java.util.ArrayList; +import java.util.List; + import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; @@ -42,7 +45,7 @@ import com.jogamp.graph.curve.opengl.RenderState; * */ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { - OutlineShape[] outlineShapes = new OutlineShape[2]; + List<OutlineShape> outlineShapes = new ArrayList<OutlineShape>(); public GPURegionGLListener02 (RenderState rs, int renderModes, int fbosize, boolean debug, boolean trace) { super(rs, renderModes, debug, trace); @@ -51,39 +54,41 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { private void createTestOutline(){ float offset = 0; - outlineShapes[0] = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); - outlineShapes[0].addVertex(0.0f,-10.0f,true); - outlineShapes[0].addVertex(15.0f,-10.0f, true); - outlineShapes[0].addVertex(10.0f,5.0f, false); - outlineShapes[0].addVertex(15.0f,10.0f, true); - outlineShapes[0].addVertex(6.0f,15.0f, false); - outlineShapes[0].addVertex(5.0f,8.0f, false); - outlineShapes[0].addVertex(0.0f,10.0f,true); - outlineShapes[0].closeLastOutline(); - outlineShapes[0].addEmptyOutline(); - outlineShapes[0].addVertex(5.0f,-5.0f,true); - outlineShapes[0].addVertex(10.0f,-5.0f, false); - outlineShapes[0].addVertex(10.0f,0.0f, true); - outlineShapes[0].addVertex(5.0f,0.0f, false); - outlineShapes[0].closeLastOutline(); + OutlineShape shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + outlineShapes.add(shape); + shape.addVertex(0.0f,-10.0f,true); + shape.addVertex(15.0f,-10.0f, true); + shape.addVertex(10.0f,5.0f, false); + shape.addVertex(15.0f,10.0f, true); + shape.addVertex(6.0f,15.0f, false); + shape.addVertex(5.0f,8.0f, false); + shape.addVertex(0.0f,10.0f,true); + shape.closeLastOutline(); + shape.addEmptyOutline(); + shape.addVertex(5.0f,-5.0f,true); + shape.addVertex(10.0f,-5.0f, false); + shape.addVertex(10.0f,0.0f, true); + shape.addVertex(5.0f,0.0f, false); + shape.closeLastOutline(); /** Same shape as above but without any off-curve vertices */ - outlineShapes[1] = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); + outlineShapes.add(shape); offset = 30; - outlineShapes[1].addVertex(offset+0.0f,-10.0f, true); - outlineShapes[1].addVertex(offset+17.0f,-10.0f, true); - outlineShapes[1].addVertex(offset+11.0f,5.0f, true); - outlineShapes[1].addVertex(offset+16.0f,10.0f, true); - outlineShapes[1].addVertex(offset+7.0f,15.0f, true); - outlineShapes[1].addVertex(offset+6.0f,8.0f, true); - outlineShapes[1].addVertex(offset+0.0f,10.0f, true); - outlineShapes[1].closeLastOutline(); - outlineShapes[1].addEmptyOutline(); - outlineShapes[1].addVertex(offset+5.0f,0.0f, true); - outlineShapes[1].addVertex(offset+5.0f,-5.0f, true); - outlineShapes[1].addVertex(offset+10.0f,-5.0f, true); - outlineShapes[1].addVertex(offset+10.0f,0.0f, true); - outlineShapes[1].closeLastOutline(); + shape.addVertex(offset+0.0f,-10.0f, true); + shape.addVertex(offset+17.0f,-10.0f, true); + shape.addVertex(offset+11.0f,5.0f, true); + shape.addVertex(offset+16.0f,10.0f, true); + shape.addVertex(offset+7.0f,15.0f, true); + shape.addVertex(offset+6.0f,8.0f, true); + shape.addVertex(offset+0.0f,10.0f, true); + shape.closeLastOutline(); + shape.addEmptyOutline(); + shape.addVertex(offset+5.0f,0.0f, true); + shape.addVertex(offset+5.0f,-5.0f, true); + shape.addVertex(offset+10.0f,-5.0f, true); + shape.addVertex(offset+10.0f,0.0f, true); + shape.closeLastOutline(); region = GLRegion.create(outlineShapes, getRenderModes()); } @@ -118,7 +123,7 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { if( weight != regionRenderer.getWeight()) { regionRenderer.setWeight(gl, weight); } - regionRenderer.draw(gl, region, getPosition(), getTexSize()); + regionRenderer.draw(gl, region, getTexSize()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 7fb199a5d..9c18b741a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -162,7 +162,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final int fpsSp = fpsS.indexOf('.'); textRenderer.resetModelview(null); textRenderer.translate(gl, fontSizeFixed, fontSizeFixed, -6000); - textRenderer.drawString3D(gl, font, fpsS.substring(0, fpsSp+2)+" fps", getPosition(), fontSizeFixed*3, getTexSize()); + textRenderer.drawString3D(gl, font, fpsS.substring(0, fpsSp+2)+" fps", fontSizeFixed*3, getTexSize()); } int dx = width-(int)fontNameBox.getWidth()-2 ; @@ -170,7 +170,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRenderer.resetModelview(null); textRenderer.translate(gl, dx, dy, -6000); - textRenderer.drawString3D(gl, font, fontName, getPosition(), fontSizeFixed*2, getTexSize()); + textRenderer.drawString3D(gl, font, fontName, fontSizeFixed*2, getTexSize()); dx = 10; dy += -(int)fontNameBox.getHeight() - 10; @@ -178,7 +178,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB if(null != headtext) { textRenderer.resetModelview(null); textRenderer.translate(gl, dx, dy, -6000); - textRenderer.drawString3D(gl, font, headtext, getPosition(), fontSizeFixed*3, getTexSize()); + textRenderer.drawString3D(gl, font, headtext, fontSizeFixed*3, getTexSize()); } textRenderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f); @@ -188,9 +188,9 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRenderer.rotate(gl, getAngle(), 0, 1, 0); textRenderer.setColorStatic(gl, 1.0f, 0.0f, 0.0f); if(!userInput) { - textRenderer.drawString3D(gl, font, text2, getPosition(), fontSize, getTexSize()); + textRenderer.drawString3D(gl, font, text2, fontSize, getTexSize()); } else { - textRenderer.drawString3D(gl, font, userString.toString(), getPosition(), fontSize, getTexSize()); + textRenderer.drawString3D(gl, font, userString.toString(), fontSize, getTexSize()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index eaac2b1bf..b68b24a7a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -301,7 +301,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { regionRenderer.scale(gl, 1.5f, 1.5f, 1.0f); regionRenderer.rotate(gl, angText , 0, 1, 0); regionRenderer.setColorStatic(gl, 0.0f, 1.0f, 0.0f); - regionRenderer.draw(gl, jogampRegion.getRegion(gl, rs, 0), new float[]{0,0,0}, null); + regionRenderer.draw(gl, jogampRegion.getRegion(gl, rs, 0), null); if(null == labelRegions[currentText]) { if( null == labels[currentText]) { @@ -322,7 +322,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { regionRenderer.rotate(gl, zoomText, 0, 1, 0); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - regionRenderer.draw(gl, labelRegions[currentText].getRegion(gl, rs, renderModes2), new float[]{0,0,0}, texSize2); + regionRenderer.draw(gl, labelRegions[currentText].getRegion(gl, rs, renderModes2), texSize2); final GLAnimatorControl animator = drawable.getAnimator(); final boolean _drawFPS = showFPS && null != animator; @@ -345,7 +345,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { if(showFPS && null != fpsRegion) { regionRenderer.translate(gl, 0, -60, 0); regionRenderer.scale(null, zoomText, zoomText, 1); - regionRenderer.draw(gl, fpsRegion.getRegion(gl, rs, 0), new float[]{0,0,0}, null); + regionRenderer.draw(gl, fpsRegion.getRegion(gl, rs, 0), null); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java index bf403900d..150082200 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java @@ -215,7 +215,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]); } - renderer.draw(gl, buttonRegion.getRegion(gl, rs, renderModes), getPosition(), texSize); + renderer.draw(gl, buttonRegion.getRegion(gl, rs, renderModes), texSize); gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL); float[] lColor = labelColor; @@ -225,7 +225,7 @@ public abstract class RIButton extends UIShape { if(!selection){ renderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]); } - renderer.draw(gl, labelRegion.getRegion(gl, rs, renderModes), getPosition(), texSize); + renderer.draw(gl, labelRegion.getRegion(gl, rs, renderModes), texSize); } public void setPressed(boolean b) { super.setPressed(b); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java index da94f6a7c..0915ea523 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java @@ -109,10 +109,10 @@ public class UIGLListener01 extends UIListenerBase01 { } regionRenderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]); - regionRenderer.draw(gl, regionButton.getRegion(gl, rs, 0), getPosition(), null); -// regionRenderer.translate(gl, button.getPosition()[0], button.getPosition()[1], button.getPosition()[2]); + regionRenderer.translate(gl, button.getPosition()[0], button.getPosition()[1], button.getPosition()[2]); + regionRenderer.draw(gl, regionButton.getRegion(gl, rs, 0), null); regionRenderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]); - regionRenderer.draw(gl, regionLabel.getRegion(gl, rs, 0), getPosition(), null); + regionRenderer.draw(gl, regionLabel.getRegion(gl, rs, 0), null); } public void dispose(GLAutoDrawable drawable) { |