diff options
author | Rami Santina <rami.santina@gmail.com> | 2011-05-02 19:28:47 +0300 |
---|---|---|
committer | Rami Santina <rami.santina@gmail.com> | 2011-05-02 19:28:47 +0300 |
commit | 307ba4ea320a91d5731274ed3191bea840d1fe70 (patch) | |
tree | eb385521092a9db150bcb1963b232e8ba5d5efa4 | |
parent | 73ce473d7bf4de653bb23baa318cc8cdcb03e8ce (diff) |
Added nonuniform weight impl; misc enhancements/cleanups
Seperate texcoords from shaprness
Added NonUniform weight shader impl for region impl only (not text)
Refactor p1y --> weight (equiv to nurbs weight)
cleanup shader uniforms (rename/remove unneeded)
Enhanced blending of text
GPURegionNewtDemo01 - added weight W/Q to manipulate weight
refactor r2t --> vbaa (matching algorithm name)
30 files changed, 291 insertions, 153 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(); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 0b47606e4..6f79e1407 100755 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -41,20 +41,29 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState;
public class RegionRendererImpl01 extends RegionRenderer {
- public RegionRendererImpl01(RenderState rs, int type) {
- super(rs, type);
- // rs.getSharpness().setData(0.5f);
- // rs.getAlpha().setData(1.0f);
- // rs.getStrength().setData(3.0f);
+ public RegionRendererImpl01(RenderState rs, int type, boolean uniform) {
+ super(rs, type, uniform);
+
+ }
+
+ private String getVertexShaderName(){
+ return "curverenderer01";
+ }
+
+ private String getFragmentShaderName(){
+ if(!isUniform()){
+ return "curverenderer02";
+ }
+ return "curverenderer01";
}
protected boolean initShaderProgram(GL2ES2 gl) {
final ShaderState st = rs.getShaderState();
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RegionRendererImpl01.class,
- "shader", "shader/bin", "curverenderer01");
+ "shader", "shader/bin", getVertexShaderName());
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RegionRendererImpl01.class,
- "shader", "shader/bin", "curverenderer01");
+ "shader", "shader/bin", getFragmentShaderName());
ShaderProgram sp = new ShaderProgram();
sp.add(rsVp);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index eef64dab5..350c77d98 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -49,14 +49,13 @@ public class RenderStateImpl implements RenderState { private final GLUniformData gcu_PMVMatrix; /** - * Sharpness is equivalent to the texture-coord component <i>t</i> - * on the off-curve vertex. Higher values of sharpness will - * result in higher curvature. + * weight is equivalent to the + * global off-curve vertex weight. + * TODO: change to per vertex */ - private final GLUniformData gcu_Sharpness; + private final GLUniformData gcu_Weight; private final GLUniformData gcu_Alpha; private final GLUniformData gcu_ColorStatic; - private final GLUniformData gcu_Strength; public static final RenderState getRenderState(GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); @@ -69,14 +68,14 @@ public class RenderStateImpl implements RenderState { this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); st.ownUniform(gcu_PMVMatrix); - gcu_Sharpness = new GLUniformData(UniformNames.gcu_P1Y, 0.5f); + gcu_Weight = new GLUniformData(UniformNames.gcu_Weight, 1.0f); st.ownUniform(gcu_PMVMatrix); gcu_Alpha = new GLUniformData(UniformNames.gcu_Alpha, 1.0f); st.ownUniform(gcu_Alpha); gcu_ColorStatic = new GLUniformData(UniformNames.gcu_ColorStatic, 3, FloatBuffer.allocate(3)); st.ownUniform(gcu_ColorStatic); - gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); - st.ownUniform(gcu_Strength); +// gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); +// st.ownUniform(gcu_Strength); } public RenderStateImpl(ShaderState st, Vertex.Factory<? extends Vertex> pointFactory) { @@ -94,10 +93,10 @@ public class RenderStateImpl implements RenderState { public final Vertex.Factory<? extends Vertex> getPointFactory () { return pointFactory; } public final PMVMatrix pmvMatrix() { return pmvMatrix; } public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; } - public final GLUniformData getSharpness() { return gcu_Sharpness; } + public final GLUniformData getWeight() { return gcu_Weight; } public final GLUniformData getAlpha() { return gcu_Alpha; } public final GLUniformData getColorStatic() { return gcu_ColorStatic; } - public final GLUniformData getStrength() { return gcu_Strength; } + //public final GLUniformData getStrength() { return gcu_Strength; } public void destroy(GL2ES2 gl) { st.destroy(gl); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 2255251a7..257d05fca 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -42,11 +42,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class TextRendererImpl01 extends TextRenderer { public TextRendererImpl01(RenderState rs, int type) { - super(rs, type); - // rs.getSharpness().setData(0.5f); - // rs.getAlpha().setData(1.0f); - // rs.getStrength().setData(3.0f); - rs.getStrength().setData(1.9f); + super(rs, type); } @Override diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java index 2e04278ca..bb6ff987d 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java @@ -4,7 +4,6 @@ public class UniformNames { public static final String gcu_PMVMatrix = "gcu_PMVMatrix"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi public static final String gcu_ColorStatic = "gcu_ColorStatic"; public static final String gcu_Alpha = "gcu_Alpha"; - public static final String gcu_P1Y = "gcu_P1Y"; - public static final String gcu_Strength = "gcu_Strength"; + public static final String gcu_Weight = "gcu_Weight"; public static final String gcu_TextureUnit = "gcu_TextureUnit"; } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp index 975c2dc5b..b3693ec88 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp @@ -12,8 +12,8 @@ #include uniforms.glsl #include varyings.glsl -const vec3 b_color = vec3(0.0, 0.0, 0.0); -const vec4 weights = vec4(0.075, 0.06, 0.045, 0.025); +const vec3 b_color = vec3(1.0, 1.0, 1.0); +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); void main (void) { @@ -33,25 +33,25 @@ void main (void) rtex -= 5.0; vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*weights.x; + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*weights.y; + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*weights.z; + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*weights.w; + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; if(t.w == 0.0){ discard; @@ -85,7 +85,7 @@ void main (void) alpha = gcu_Alpha; } else if (a <= 0.0) { - alpha = 0.0;//discard; + discard; } else { alpha = gcu_Alpha * a; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp new file mode 100755 index 000000000..e3d5bc074 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02.fp @@ -0,0 +1,97 @@ +//Copyright 2010 JogAmp Community. All rights reserved.
+/**
+#ifdef GL_ES
+ #version 100
+#else
+ #version 110
+#endif
+ */
+
+#include uniforms.glsl
+#include varyings.glsl
+
+const vec3 b_color = vec3(0.0, 0.0, 0.0);
+const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025);
+
+void main (void)
+{
+ vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y));
+ vec3 c = gcu_ColorStatic.rgb;
+
+ float alpha = 0.0;
+
+ if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)){
+ alpha = gcu_Alpha;
+ }
+ else if((gcv_TexCoord.x >= 5.0)){
+ vec2 dfx = dFdx(gcv_TexCoord);
+ vec2 dfy = dFdy(gcv_TexCoord);
+
+ vec2 size = 1.0/textureSize(gcu_TextureUnit,0); //version 130 - FIXME: replace with uniform value
+ rtex -= 5.0;
+ vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18;
+
+ t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x;
+ t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x;
+ t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x;
+ t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x;
+
+ t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y;
+ t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y;
+ t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y;
+ t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y;
+
+ t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z;
+ t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z;
+ t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z;
+ t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z;
+
+ t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w;
+ t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w;
+ t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w;
+ t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w;
+
+ if(t.w == 0.0){
+ discard;
+ }
+
+ c = t.xyz;
+ alpha = gcu_Alpha * t.w;
+ }
+ ///////////////////////////////////////////////////////////
+ else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
+ rtex.y -= 0.1;
+
+ if(rtex.y < 0.0) {
+ if(gcv_TexCoord.y < 0.0)
+ discard;
+ else{
+ rtex.y = 0.0;
+ }
+ }
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ float w = gcu_Weight;
+ float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
+ float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);
+
+ float aph = 2.0 - 2.0*w;
+
+ float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
+ vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2*rtex.x))/gd));
+
+ float d = position/(length(f));
+ float a = (0.5 - d * sign(gcv_TexCoord.y));
+ if (a >= 1.0){
+ alpha = gcu_Alpha;
+ }
+ else if (a <= 0.0) {
+ discard;
+ }
+ else {
+ alpha = gcu_Alpha*a;
+ }
+ }
+ gl_FragColor = vec4(c, alpha);
+}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl index 677c7324f..332edd02b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/uniforms.glsl @@ -9,8 +9,7 @@ uniform HIGHP mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi uniform HIGHP vec3 gcu_ColorStatic; uniform HIGHP float gcu_Alpha; -uniform HIGHP float gcu_P1Y; -uniform HIGHP float gcu_Strength; +uniform HIGHP float gcu_Weight; uniform sampler2D gcu_TextureUnit; // uniform HIGHP mat3 gcu_NormalMatrix; // transpose(inverse(ModelView)).3x3 diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl index e70c25266..0b821524c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -6,7 +6,7 @@ #include consts.glsl -varying vec4 gcv_FrontColor; +//varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; #endif // varyings_glsl diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 4d1880064..91a7e4246 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -145,11 +145,10 @@ public class GlyphShape { } /** Triangluate the glyph shape - * @param sharpness sharpness of the curved regions default = 0.5 * @return ArrayList of triangles which define this shape */ - public ArrayList<Triangle> triangulate(float sharpness){ - return shape.triangulate(sharpness); + public ArrayList<Triangle> triangulate(){ + return shape.triangulate(); } /** Get the list of Vertices of this Object diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index 1faee87ff..a904c2b48 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -73,18 +73,18 @@ public class GlyphString { } /** Creates the Curve based Glyphs from a Font - * @param pointFactory TODO + * @param vertexFactory vertex impl factory {@link Factory} * @param paths a list of FontPath2D objects that define the outline * @param affineTransform a global affine transformation applied to the paths. */ - public void createfromFontPath(Factory<? extends Vertex> pointFactory, Path2D[] paths, AffineTransform affineTransform) { + public void createfromFontPath(Factory<? extends Vertex> vertexFactory, Path2D[] paths, AffineTransform affineTransform) { final int numGlyps = paths.length; for (int index=0;index<numGlyps;index++){ if(paths[index] == null){ continue; } PathIterator iterator = paths[index].iterator(affineTransform); - GlyphShape glyphShape = new GlyphShape(pointFactory, iterator); + GlyphShape glyphShape = new GlyphShape(vertexFactory, iterator); if(glyphShape.getNumVertices() < 3) { continue; @@ -93,25 +93,26 @@ public class GlyphString { } } - private ArrayList<Triangle> initializeTriangles(float sharpness){ + private ArrayList<Triangle> initializeTriangles(){ ArrayList<Triangle> triangles = new ArrayList<Triangle>(); for(GlyphShape glyph:glyphs){ - ArrayList<Triangle> tris = glyph.triangulate(sharpness); + ArrayList<Triangle> tris = glyph.triangulate(); triangles.addAll(tris); } return triangles; } - + /** Generate a OGL Region to represent this Object. - * @param context the GLContext which the region is defined by. - * @param shaprness the curvature sharpness of the object. - * @param st shader state + * @param gl the current gl object + * @param rs the current attached RenderState + * @param type either {@link com.jogamp.graph.curve.Region#SINGLE_PASS} + * or {@link com.jogamp.graph.curve.Region#TWO_PASS} */ public void generateRegion(GL2ES2 gl, RenderState rs, int type){ region = RegionFactory.create(rs, type); region.setFlipped(true); - ArrayList<Triangle> tris = initializeTriangles(rs.getSharpness().floatValue()); + ArrayList<Triangle> tris = initializeTriangles(); region.addTriangles(tris); int numVertices = region.getNumVertices(); @@ -155,7 +156,7 @@ public class GlyphString { } /** Destroy the associated OGL objects - * @param rs TODO + * @param rs the current attached RenderState */ public void destroy(GL2ES2 gl, RenderState rs){ region.destroy(gl, rs); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java index c948efc2d..9dec119bc 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java @@ -66,9 +66,9 @@ public class TestRegionRendererNEWT01 extends UITestCase { //caps.setOnscreen(false);
caps.setAlphaBits(4);
- GLWindow window = createWindow("shape-r2t1-msaa0", caps, 800,400);
+ GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
- GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.TWO_PASS, 1140, false, false);
+ GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.TWO_PASS, true, 1140, false, false);
demo02Listener.attachInputListenerTo(window);
window.addGLEventListener(demo02Listener);
@@ -96,10 +96,40 @@ public class TestRegionRendererNEWT01 extends UITestCase { caps.setSampleBuffers(true);
caps.setNumSamples(4);
- GLWindow window = createWindow("shape-r2t0-msaa1", caps, 800, 400);
+ GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
- GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.SINGLE_PASS, 0, false, false);
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.SINGLE_PASS, true, 0, false, false);
+ demo01Listener.attachInputListenerTo(window);
+ window.addGLEventListener(demo01Listener);
+
+ RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void testRegionRendererMSAA02() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+
+ GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
+ RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
+
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.SINGLE_PASS, false, 0, false, false);
demo01Listener.attachInputListenerTo(window);
window.addGLEventListener(demo01Listener);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java index f05b2ed35..78e89b792 100755 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -68,7 +68,7 @@ public class TestTextRendererNEWT01 extends UITestCase { GLCapabilities caps = new GLCapabilities(glp);
caps.setAlphaBits(4);
- GLWindow window = createWindow("text-r2t1-msaa0", caps, 800,400);
+ GLWindow window = createWindow("text-vbaa1-msaa0", caps, 800,400);
RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, Region.TWO_PASS, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
@@ -105,7 +105,7 @@ public class TestTextRendererNEWT01 extends UITestCase { caps.setSampleBuffers(true);
caps.setNumSamples(4);
- GLWindow window = createWindow("text-r2t0-msaa1", caps, 800, 400);
+ GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, Region.SINGLE_PASS, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
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 1d086d93d..215dae30a 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 @@ -45,8 +45,8 @@ import com.jogamp.graph.curve.opengl.RenderState; public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { OutlineShape outlineShape = null; - public GPURegionGLListener01 (RenderState rs, int numpass, int fbosize, boolean debug, boolean trace) { - super(rs, numpass, debug, trace); + public GPURegionGLListener01 (RenderState rs, int numpass, boolean uniform, int fbosize, boolean debug, boolean trace) { + super(rs, numpass, uniform, debug, trace); setMatrix(-20, 00, 0f, -50, fbosize); } @@ -96,12 +96,10 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { gl.setSwapInterval(1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL2ES2.GL_BLEND); regionRenderer.init(gl); regionRenderer.setAlpha(gl, 1.0f); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - //gl.glSampleCoverage(0.95f, false); - //gl.glEnable(GL2GL3.GL_SAMPLE_COVERAGE); // sample coverage doesn't really make a difference to lines - //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE); MSAATool.dump(drawable); createTestOutline(); @@ -118,7 +116,10 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 { regionRenderer.resetModelview(null); regionRenderer.translate(null, getXTran(), getYTran(), getZoom()); regionRenderer.rotate(gl, getAngle(), 0, 1, 0); - + if(weightUpdated){ + regionRenderer.setWeight(gl, weight); + weightUpdated = false; + } regionRenderer.renderOutlineShape(gl, outlineShape, getPosition(), 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 1f57914a0..d7d335625 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 @@ -43,8 +43,8 @@ import com.jogamp.graph.curve.opengl.RenderState; public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { OutlineShape[] outlineShapes = new OutlineShape[2]; - public GPURegionGLListener02 (RenderState rs, int numpass, int fbosize, boolean debug, boolean trace) { - super(rs, numpass, debug, trace); + public GPURegionGLListener02 (RenderState rs, int numpass, boolean uniform, int fbosize, boolean debug, boolean trace) { + super(rs, numpass, uniform, debug, trace); setMatrix(-20, 00, 0f, -50, fbosize); } @@ -94,6 +94,7 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 { gl.setSwapInterval(1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL2ES2.GL_BLEND); regionRenderer.init(gl); regionRenderer.setAlpha(gl, 1.0f); regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java index 7b9278591..d7f71301d 100755 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java @@ -67,10 +67,10 @@ public class GPURegionNewtDemo01 { final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); - window.setTitle("GPU Curve Region Newt Demo 01 - r2t0 msaa1"); + window.setTitle("GPU Curve Region Newt Demo 01 - vbaa0 msaa1"); RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory()); - GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, Region.SINGLE_PASS, 0, DEBUG, TRACE); + GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, Region.SINGLE_PASS, false, 0, DEBUG, TRACE); regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java index 98978b39b..1440221a8 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo02.java @@ -67,10 +67,10 @@ public class GPURegionNewtDemo02 { final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); - window.setTitle("GPU Curve Region Newt Demo 02 - r2t1 msaa0"); + window.setTitle("GPU Curve Region Newt Demo 02 - vbaa1 msaa0"); RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory()); - GPURegionGLListener02 regionGLListener = new GPURegionGLListener02 (rs, Region.TWO_PASS, 1140, DEBUG, TRACE); + GPURegionGLListener02 regionGLListener = new GPURegionGLListener02 (rs, Region.TWO_PASS, true, 1140, DEBUG, TRACE); regionGLListener.attachInputListenerTo(window); window.addGLEventListener(regionGLListener); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java index f824b2e70..a0c25ab1a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java @@ -46,7 +46,7 @@ import com.jogamp.graph.curve.opengl.RenderState; public abstract class GPURegionRendererListenerBase01 extends GPURendererListenerBase01 { OutlineShape outlineShape = null; - public GPURegionRendererListenerBase01(RenderState rs, int mode, boolean debug, boolean trace) { - super(RegionRenderer.create(rs, mode), debug, trace); + public GPURegionRendererListenerBase01(RenderState rs, int mode, boolean uniform, boolean debug, boolean trace) { + super(RegionRenderer.create(rs, mode,uniform), debug, trace); } }
\ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index 3daa97ab3..3f060d15f 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -52,6 +52,7 @@ import com.jogamp.newt.opengl.GLWindow; * - 1/2: zoom in/out * - 6/7: 2nd pass texture size * - 0/9: rotate + * - Q/W: change weight * - v: toggle v-sync * - s: screenshot */ @@ -73,6 +74,8 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { private float zoom = -70f; private int texSize = 400; + protected float weight = 1.0f; + protected boolean weightUpdated = false; boolean ignoreInput = false; public GPURendererListenerBase01(Renderer renderer, boolean debug, boolean trace) { @@ -144,6 +147,13 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { ang %= 360.0f; dumpMatrix(); } + public void editGlobalWeight(float delta){ + if((weight+delta) > 1.9f || (weight+delta) < 0.0f) + return; + weight += delta; + weightUpdated = true; + System.err.println("Global Weight: "+ weight); + } void dumpMatrix() { System.err.println("Matrix: " + xTran + "/" + yTran + " x"+zoom + " @"+ang); @@ -221,6 +231,12 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { else if(arg0.getKeyCode() == KeyEvent.VK_9){ rotate(-1); } + else if(arg0.getKeyCode() == KeyEvent.VK_Q){ + editGlobalWeight(-0.1f); + } + else if(arg0.getKeyCode() == KeyEvent.VK_W){ + editGlobalWeight(0.1f); + } else if(arg0.getKeyCode() == KeyEvent.VK_V) { if(null != autoDrawable) { autoDrawable.invoke(false, new GLRunnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java index 7153c1827..a88b6b3ca 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java @@ -49,13 +49,10 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { gl.setSwapInterval(1); gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL2ES2.GL_BLEND); textRenderer.init(gl); textRenderer.setAlpha(gl, 1.0f); textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); - //gl.glSampleCoverage(0.95f, false); - //gl.glEnable(GL2GL3.GL_SAMPLE_COVERAGE); // sample coverage doesn't really make a difference to lines - //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_COVERAGE); - //gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE); MSAATool.dump(drawable); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java index 41761dbc0..6b1bbee35 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java @@ -60,7 +60,7 @@ public class GPUTextNewtDemo01 { final GLWindow window = GLWindow.create(caps); window.setPosition(10, 10); window.setSize(800, 400); - window.setTitle("GPU Text Newt Demo 01 - r2t0 msaa1"); + window.setTitle("GPU Text Newt Demo 01 - vbaa0 msaa1"); final RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory()); GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.SINGLE_PASS, 0, DEBUG, TRACE); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java index 6626ca2ad..0f1b95165 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java @@ -70,7 +70,7 @@ public class GPUTextNewtDemo02 { window.setPosition(10, 10); window.setSize(800, 400); - window.setTitle("GPU Text Newt Demo 02 - r2t1 msaa0"); + window.setTitle("GPU Text Newt Demo 02 - vbaa1 msaa0"); RenderState rs = Renderer.createRenderState(new ShaderState(), SVertex.factory()); GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.TWO_PASS, window.getWidth()*3, DEBUG, TRACE); 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 3f7ddfcef..39ebba6e5 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 @@ -80,15 +80,24 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB static final String text1 = "abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n0123456789.:,;(*!?/\\\")$%^&-+@~#<>{}[]"; static final String text2 = "The quick brown fox jumps over the lazy dog"; static final String textX = - "Residents of evacuated areas near Japan's stricken Fukushima\n"+ - "nuclear plant have been warned that they may not be able\n"+ - "to return to their homes for months as Japan's nuclear crisis\n"+ - "stretched into a third week. The neighbourhoods near the plant\n"+ - "will remain empty \"for the long term\", Yukio Edano, the country's\n"+ - "chief cabinet secretary, said on Friday. Though he did not set a\n"+ - "timetable, he said residents would not be able to return permanently\n"+ - "\"in a matter of days or weeks. It will be longer than that\".\n"; + "JOGAMP graph demo using Resolution Independent NURBS\n"+ + "JOGAMP JOGL - OpenGL ES2 profile\n"+ + "Press 1/2 to zoom in/out the below text\n"+ + "Press 6/7 to edit texture size if using VBAA\n"+ + "Press 0/9 to rotate the below string\n"+ + "Press v to toggle vsync\n"+ + "Press i for live input text input (CR ends it, backspace supported)\n"+ + "Press f to toggle fps. H for different text, space for font type\n"; + static final String textX2 = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec sapien tellus. \n"+ + "Ut purus odio, rhoncus sit amet commodo eget, ullamcorper vel urna. Mauris ultricies \n"+ + "quam iaculis urna cursus ornare. Nullam ut felis a ante ultrices ultricies nec a elit. \n"+ + "In hac habitasse platea dictumst. Vivamus et mi a quam lacinia pharetra at venenatis est.\n"+ + "Morbi quis bibendum nibh. Donec lectus orci, sagittis in consequat nec, volutpat nec nisi.\n"+ + "Donec ut dolor et nulla tristique varius. In nulla magna, fermentum id tempus quis, semper \n"+ + "in lorem. Maecenas in ipsum ac justo scelerisque sollicitudin. Quisque sit amet neque lorem,\n" + + "-------Press H to change text---------\n"; StringBuffer userString = new StringBuffer(); boolean userInput = false; @@ -110,13 +119,16 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } void switchHeadBox() { - headType = ( headType + 1 ) % 3 ; + headType = ( headType + 1 ) % 4 ; switch(headType) { case 0: headtext = null; break; case 1: + headtext= textX2; + break; + case 2: headtext= textX; break; @@ -138,7 +150,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB final TextRenderer textRenderer = (TextRenderer) getRenderer(); textRenderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f); - + textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); final GLAnimatorControl animator = drawable.getAnimator(); final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFPSFrames()>10; @@ -172,7 +184,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB textRenderer.resetModelview(null); textRenderer.translate(null, getXTran(), getYTran(), getZoom()); textRenderer.rotate(gl, getAngle(), 0, 1, 0); - + textRenderer.setColorStatic(gl, 1.0f, 0.0f, 0.0f); if(!userInput) { textRenderer.renderString3D(gl, font, text2, getPosition(), fontSize, getTexSize()); } else { @@ -264,8 +276,6 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB public void keyTyped(KeyEvent arg0) { if(userInput) { - // System.err.println(arg0); - char c = arg0.getKeyChar(); if(c == 0x0d) { 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 015819798..2f734ea2c 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 @@ -77,7 +77,6 @@ public class RIButton extends UIControl{ } public void generate(AABBox lbox) { -// AABBox lbox = font.getStringBounds(label, 10); createOutline(factory, lbox); scale[0] = getWidth()/(2*spacing + lbox.getWidth()); scale[1] = getHeight()/(2*spacing + lbox.getHeight()); 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 e9e5bc105..ce4c07873 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 @@ -71,9 +71,6 @@ public class UIGLListener01 extends UIListenerBase01 { gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL); regionRenderer.init(gl); - // default is 1.0f .. regionRenderer.setAlpha(gl, 1.0f); - // default is 0.5f .. regionRenderer.setSharpness(gl, 0.5f); - // FIXME: What if Sharpness diff for text/outline-only ?! glyphString = textRenderer.createString(gl, button.getFont(), 10, button.getLabel()); glyphString.generateRegion(gl, regionRenderer.getRenderState(), regionRenderer.getRenderType()); |