diff options
Diffstat (limited to 'src/jogl/classes/com')
6 files changed, 38 insertions, 50 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index 724380f4a..c995b3749 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -264,28 +264,19 @@ public class OutlineShape { return vertices;
}
- /** Triangulate the outline shape generating a list of triangles
- * @return an arraylist of triangles representing the filled region
- * which is produced by the combination of the outlines
- */
- public ArrayList<Triangle> triangulate(){
- return triangulate(0.5f);
- }
/**Triangulate the {@link OutlineShape} generating a list of triangles
- * @param sharpness defines the curvature strength around the off-curve vertices.
- * defaults to 0.5f
* @return an arraylist of triangles representing the filled region
* which is produced by the combination of the outlines
*/
- public ArrayList<Triangle> triangulate(float sharpness){
+ public ArrayList<Triangle> triangulate(){
if(outlines.size() == 0){
return null;
}
sortOutlines();
generateVertexIds();
- CDTriangulator2D triangulator2d = new CDTriangulator2D(sharpness);
+ CDTriangulator2D triangulator2d = new CDTriangulator2D();
for(int index = 0; index< outlines.size();index++){
Outline outline = outlines.get(index);
triangulator2d.addCurve(outline);
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 69fdd5c4a..03a696f35 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -41,17 +41,34 @@ import com.jogamp.graph.geom.Vertex; public abstract class RegionRenderer extends Renderer { + private boolean uniform = true; /** - * Create a Hardware accelerated Text Renderer. + * Create a Hardware accelerated Region 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 type either {@link com.jogamp.graph.curve.Region#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#TWO_PASS} + * @return an instance of Region Renderer */ public static RegionRenderer create(RenderState rs, int type) { - return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, type); + return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, type, true); } - protected RegionRenderer(RenderState rs, int type) { + /** Create a Hardware accelerated Region Renderer. + * @param rs the used {@link RenderState} + * @param type either {@link com.jogamp.graph.curve.Region#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#TWO_PASS} + * @param unifrom flag true unifrom weights for offcurve vertex, else otherwise. + * @return an instance of Region Renderer + */ + public static RegionRenderer create(RenderState rs, int type, boolean unifrom) { + return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, type, unifrom); + } + + protected RegionRenderer(RenderState rs, int type, boolean unifrom) { super(rs, type); + this.uniform = unifrom; + } + + public boolean isUniform(){ + return uniform; } /** Render an array of {@link OutlineShape}s combined in one region @@ -97,7 +114,7 @@ public abstract class RegionRenderer extends Renderer { Region region = RegionFactory.create(rs, renderType); outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList<Triangle> triangles = (ArrayList<Triangle>) outlineShape.triangulate(rs.getSharpness().floatValue()); + ArrayList<Triangle> triangles = (ArrayList<Triangle>) outlineShape.triangulate(); ArrayList<Vertex> vertices = (ArrayList<Vertex>) outlineShape.getVertices(); region.addVertices(vertices); region.addTriangles(triangles); @@ -118,7 +135,7 @@ public abstract class RegionRenderer extends Renderer { for(OutlineShape outlineShape:outlineShapes){ outlineShape.transformOutlines(OutlineShape.QUADRATIC_NURBS); - ArrayList<Triangle> triangles = outlineShape.triangulate(rs.getSharpness().floatValue()); + ArrayList<Triangle> triangles = outlineShape.triangulate(); region.addTriangles(triangles); ArrayList<Vertex> vertices = outlineShape.getVertices(); diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index 84323f6e5..991d07012 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -42,10 +42,10 @@ public interface RenderState { Vertex.Factory<? extends Vertex> getPointFactory(); PMVMatrix pmvMatrix(); GLUniformData getPMVMatrix(); - GLUniformData getSharpness(); + GLUniformData getWeight(); GLUniformData getAlpha(); GLUniformData getColorStatic(); - GLUniformData getStrength(); + // GLUniformData getStrength(); RenderState attachTo(GL2ES2 gl); boolean detachFrom(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 35022f769..c96488853 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -144,9 +144,9 @@ public abstract class Renderer { return false; } - if(!rs.getShaderState().uniform(gl, rs.getSharpness())) { + if(!rs.getShaderState().uniform(gl, rs.getWeight())) { if(DEBUG){ - System.err.println("Error setting sharpness in shader: "+rs.getShaderState()); + System.err.println("Error setting weight in shader: "+rs.getShaderState()); } return false; } @@ -164,10 +164,6 @@ public abstract class Renderer { } return false; } - - if(!rs.getShaderState().uniform(gl, rs.getStrength())) { - System.err.println("Error setting antialias strength in shader: "+rs.getShaderState()); - } return initialized; } @@ -193,25 +189,16 @@ public abstract class Renderer { rs.getShaderState().useProgram(gl, enable); } - public float getSharpness() { - return rs.getSharpness().floatValue(); + public float getWeight() { + return rs.getWeight().floatValue(); } - public void setSharpness(GL2ES2 gl, float v) { - rs.getSharpness().setData(v); - if(null != gl && rs.getShaderState().inUse()) { - rs.getShaderState().uniform(gl, rs.getSharpness()); - } - } - - public float getStrength() { - return rs.getStrength().floatValue(); - } - - public void setStrength(GL2ES2 gl, float v) { - rs.getStrength().setData(v); + public void setWeight(GL2ES2 gl, float v) { + if(v > 1.9f || v < 0.0f) + return; + rs.getWeight().setData(v); if(null != gl && rs.getShaderState().inUse()) { - rs.getShaderState().uniform(gl, rs.getStrength()); + rs.getShaderState().uniform(gl, rs.getWeight()); } } 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 deaa1dfad..75f3e017a 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java @@ -83,7 +83,7 @@ public abstract class TextRenderer extends Renderer { AffineTransform affineTransform = new AffineTransform(rs.getPointFactory()); Path2D[] paths = new Path2D[str.length()]; - ((FontInt)font).getOutline(str, size, affineTransform, paths); + ((FontInt)font).getPaths(str, size, affineTransform, paths); GlyphString glyphString = new GlyphString(font.getName(Font.NAME_UNIQUNAME), str); glyphString.createfromFontPath(rs.getPointFactory(), paths, affineTransform); diff --git a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java index 42eebf7a8..2954157c6 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -58,16 +58,9 @@ public class CDTriangulator2D { private int maxTriID = 0; - public CDTriangulator2D() { - this(0.5f); - } - /** Constructor for a new Delaunay triangulator - * @param curveSharpness the curvature around - * the off-curve vertices */ - public CDTriangulator2D(float curveSharpness) { - this.sharpness = curveSharpness; + public CDTriangulator2D() { reset(); } |