Skip to content

Initial work for GlyphString editing and extensible data path #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1,164 changes: 641 additions & 523 deletions src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions src/jogl/classes/com/jogamp/graph/curve/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public abstract class Region {
public static final boolean DEBUG = Debug.debug("graph.curve");
public static final boolean DEBUG_INSTANCE = false;

/** Default fast one pass MSAA region rendering.
*/
public static final int SINGLE_PASS_RENDERING = 0;

/** 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 TWO_PASS_RENDERING_BIT = 1 << 0;
Expand Down Expand Up @@ -68,7 +72,8 @@ public static boolean usesVariableCurveWeight(int renderModes) {
protected Region(int regionRenderModes) {
this.renderModes = regionRenderModes;
}



public final int getRenderModes() { return renderModes; }

public boolean usesTwoPassRendering() { return Region.usesTwoPassRendering(renderModes); }
Expand Down Expand Up @@ -154,8 +159,6 @@ public final boolean isFlipped() {
* 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)
*/
public final boolean isDirty() {
return dirty;
Expand All @@ -164,4 +167,10 @@ public final boolean isDirty() {
protected final void setDirty(boolean v) {
dirty = v;
}
}
public void clear(){
this.triangles.clear();
this.vertices.clear();
//this.box.reset();//(more useful?)
this.dirty = true;
}
}
5 changes: 3 additions & 2 deletions src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ public static GLRegion create(OutlineShape outlineShape, int renderModes) {
protected GLRegion(int renderModes) {
super(renderModes);
}



/** Updates a graph region by updating the ogl related
* objects for use in rendering if {@link #isDirty()}.
* <p>Allocates the ogl related data and initializes it the 1st time.<p>
* <p>Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.</p>
* @param rs TODO
*/
protected abstract void update(GL2ES2 gl, RenderState rs);
public abstract void update(GL2ES2 gl, RenderState rs);

/** Delete and clean the associated OGL
* objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@ protected String getShaderGLVersionSuffix(GL2ES2 gl) {
return "-gl2";
}

}
}
11 changes: 7 additions & 4 deletions src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class TextRenderer extends Renderer {
/**
* Create a Hardware accelerated Text Renderer.
* @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#TWO_PASS_RENDERING_BIT}
* @param renderModes either {@link com.jogamp.graph.curve.Region#SINGLE_PASS_RENDERING} or {@link com.jogamp.graph.curve.Region#TWO_PASS_RENDERING_BIT}
*/
public static TextRenderer create(RenderState rs, int type) {
return new jogamp.graph.curve.opengl.TextRendererImpl01(rs, type);
Expand Down Expand Up @@ -83,8 +83,11 @@ public GlyphString createString(GL2ES2 gl, Font font, int size, String str) {
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);

GlyphString glyphString = new GlyphString(rs.vertexFactory, font, size, str);

glyphString.createRegion(gl, rs, renderModes);

return glyphString;
}

Expand Down Expand Up @@ -196,4 +199,4 @@ protected final String getKey(Font font, String str, int fontSize) {
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;
}
}
63 changes: 49 additions & 14 deletions src/jogl/classes/com/jogamp/graph/geom/AABBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
* right corner of the box.
*
*/
public class AABBox implements Cloneable {
public class AABBox
extends Object
implements Cloneable,
Comparable<AABBox>
{
private float[] low = new float[3];
private float[] high = new float[3];
private float[] center = new float[3];
Expand Down Expand Up @@ -302,24 +306,55 @@ public final float getHeight() {
public final float getDepth() {
return high[2] - low[2];
}

public final AABBox clone() {
return new AABBox(this.low, this.high);
public AABBox clone() {
try {
AABBox clone = (AABBox)super.clone();
clone.low = clone.low.clone();
clone.center = clone.center.clone();
clone.high = clone.high.clone();
return clone;
}
catch (CloneNotSupportedException exc){
throw new InternalError();
}
}

public final boolean equals(Object obj) {
if( obj == this ) {
/**
* An instance of this class is usable as a hash map key while
* size is invariant.
* @return Size bits
* @see #getSize()
*/
public int hashCode(){
return Float.floatToIntBits(this.getSize());
}
public boolean equals(Object that){
if (that instanceof AABBox)
return this.equals( (AABBox)that);
else
return false;
}
public boolean equals(AABBox that){
if (this == that)
return true;
}
if( null == obj || !(obj instanceof AABBox) ) {
else if (null == that)
return false;
else {
return (VectorUtil.checkEquality(this.low,that.low) &&
VectorUtil.checkEquality(this.high,that.high));
}
final AABBox other = (AABBox) obj;
return VectorUtil.checkEquality(low, other.low) &&
VectorUtil.checkEquality(high, other.high) ;
}

public final String toString() {
public int compareTo(AABBox that){
if (this == that)
return 0;
else {
int c = VectorUtil.compare(this.low,that.low);
if (0 == c)
return VectorUtil.compare(this.high,that.high);
else
return c;
}
}
public String toString() {
return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+
center[0]+"/"+center[1]+"/"+center[1]+" ]";
}
Expand Down
Loading