summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java159
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java62
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java45
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java284
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java302
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java35
6 files changed, 424 insertions, 463 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index ee1dae4ca..ffaaca91c 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -156,29 +156,32 @@ public class OutlineShape implements Comparable<OutlineShape> {
dirtyBits = 0;
}
- /** Returns the associated vertex factory of this outline shape
+ /**
+ * Returns the associated vertex factory of this outline shape
* @return Vertex.Factory object
*/
public final Vertex.Factory<? extends Vertex> vertexFactory() { return vertexFactory; }
- public int getOutlineNumber() {
+ public final int getOutlineNumber() {
return outlines.size();
}
- /** Add a new empty {@link Outline}
+ /**
+ * Add a new empty {@link Outline}
* to the end of this shape's outline list.
* <p>If the {@link #getLastOutline()} is empty already, no new one will be added.</p>
*
* After a call to this function all new vertices added
* will belong to the new outline
*/
- public void addEmptyOutline() {
+ public final void addEmptyOutline() {
if( !getLastOutline().isEmpty() ) {
outlines.add(new Outline());
}
}
- /** Appends the {@link Outline} element to the end,
+ /**
+ * Appends the {@link Outline} element to the end,
* ensuring a clean tail.
*
* <p>A clean tail is ensured, no double empty Outlines are produced
@@ -187,11 +190,12 @@ public class OutlineShape implements Comparable<OutlineShape> {
* @param outline Outline object to be added
* @throws NullPointerException if the {@link Outline} element is null
*/
- public void addOutline(Outline outline) throws NullPointerException {
+ public final void addOutline(Outline outline) throws NullPointerException {
addOutline(outlines.size(), outline);
}
- /** Insert the {@link Outline} element at the given {@code position}.
+ /**
+ * Insert the {@link Outline} element at the given {@code position}.
*
* <p>If the {@code position} indicates the end of this list,
* a clean tail is ensured, no double empty Outlines are produced
@@ -202,7 +206,7 @@ public class OutlineShape implements Comparable<OutlineShape> {
* @throws NullPointerException if the {@link Outline} element is null
* @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
*/
- public void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
+ public final void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
if (null == outline) {
throw new NullPointerException("outline is null");
}
@@ -228,14 +232,15 @@ public class OutlineShape implements Comparable<OutlineShape> {
dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES;
}
- /** Insert the {@link OutlineShape} elements of type {@link Outline}, .. at the end of this shape,
+ /**
+ * Insert the {@link OutlineShape} elements of type {@link Outline}, .. at the end of this shape,
* using {@link #addOutline(Outline)} for each element.
* <p>Closes the current last outline via {@link #closeLastOutline()} before adding the new ones.</p>
* @param outlineShape OutlineShape elements to be added.
* @throws NullPointerException if the {@link OutlineShape} is null
* @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
*/
- public void addOutlineShape(OutlineShape outlineShape) throws NullPointerException {
+ public final void addOutlineShape(OutlineShape outlineShape) throws NullPointerException {
if (null == outlineShape) {
throw new NullPointerException("OutlineShape is null");
}
@@ -245,7 +250,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
}
}
- /** Replaces the {@link Outline} element at the given {@code position}.
+ /**
+ * Replaces the {@link Outline} element at the given {@code position}.
* <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
*
* @param position of the replaced Outline
@@ -253,7 +259,7 @@ public class OutlineShape implements Comparable<OutlineShape> {
* @throws NullPointerException if the {@link Outline} element is null
* @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
*/
- public void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
+ public final void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
if (null == outline) {
throw new NullPointerException("outline is null");
}
@@ -261,7 +267,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
dirtyBits |= DIRTY_BOUNDS | DIRTY_TRIANGLES | DIRTY_VERTICES;
}
- /** Removes the {@link Outline} element at the given {@code position}.
+ /**
+ * Removes the {@link Outline} element at the given {@code position}.
* <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
*
* @param position of the to be removed Outline
@@ -272,7 +279,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
return outlines.remove(position);
}
- /** Get the last added outline to the list
+ /**
+ * Get the last added outline to the list
* of outlines that define the shape
* @return the last outline
*/
@@ -280,15 +288,16 @@ public class OutlineShape implements Comparable<OutlineShape> {
return outlines.get(outlines.size()-1);
}
- /** @return the {@code Outline} at {@code position}
+ /**
+ * Returns the {@code Outline} at {@code position}
* @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
*/
- public Outline getOutline(int position) throws IndexOutOfBoundsException {
+ public final Outline getOutline(int position) throws IndexOutOfBoundsException {
return outlines.get(position);
}
- /** Adds a vertex to the last open outline in the
- * shape.
+ /**
+ * Adds a vertex to the last open outline to the shape's tail.
* @param v the vertex to be added to the OutlineShape
*/
public final void addVertex(Vertex v) {
@@ -301,8 +310,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES;
}
- /** Adds a vertex to the last open outline in the shape.
- * at {@code position}
+ /**
+ * Adds a vertex to the last open outline to the shape at {@code position}
* @param position indx at which the vertex will be added
* @param v the vertex to be added to the OutlineShape
*/
@@ -315,7 +324,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES;
}
- /** Add a 2D {@link Vertex} to the last outline by defining the coordniate attribute
+ /**
+ * Add a 2D {@link Vertex} to the last outline by defining the coordinate attribute
* of the vertex. The 2D vertex will be represented as Z=0.
*
* @param x the x coordinate
@@ -327,7 +337,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
addVertex(vertexFactory.create(x, y, 0f, onCurve));
}
- /** Add a 3D {@link Vertex} to the last outline by defining the coordniate attribute
+ /**
+ * Add a 3D {@link Vertex} to the last outline by defining the coordniate attribute
* of the vertex.
* @param x the x coordinate
* @param y the y coordinate
@@ -339,7 +350,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
addVertex(vertexFactory.create(x, y, z, onCurve));
}
- /** Add a vertex to the last outline by passing a float array and specifying the
+ /**
+ * Add a vertex to the last outline by passing a float array and specifying the
* offset and length in which. The attributes of the vertex are located.
* The attributes should be continuous (stride = 0).
* Attributes which value are not set (when length less than 3)
@@ -354,19 +366,20 @@ public class OutlineShape implements Comparable<OutlineShape> {
addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve));
}
- /** Closes the last outline in the shape.
+ /**
+ * Closes the last outline in the shape.
* <p>If last vertex is not equal to first vertex.
* A new temp vertex is added at the end which
* is equal to the first.</p>
*/
- public void closeLastOutline() {
+ public final void closeLastOutline() {
if( getLastOutline().setClosed(true) ) {
dirtyBits |= DIRTY_TRIANGLES | DIRTY_VERTICES;
}
}
/**
- * @return the outline's vertices state, {@link OutlineShape.VerticesState}
+ * Return the outline's vertices state, {@link OutlineShape.VerticesState}
*/
public final VerticesState getOutlineState() {
return outlineState;
@@ -379,7 +392,7 @@ public class OutlineShape implements Comparable<OutlineShape> {
* @param destinationType the target outline's vertices state. Currently only
* {@link OutlineShape.VerticesState#QUADRATIC_NURBS} are supported.
*/
- public void transformOutlines(VerticesState destinationType) {
+ protected final void transformOutlines(VerticesState destinationType) {
if(outlineState != destinationType){
if(destinationType == VerticesState.QUADRATIC_NURBS){
transformOutlines2Quadratic();
@@ -401,20 +414,20 @@ public class OutlineShape implements Comparable<OutlineShape> {
outline.addVertex(index, vertexFactory.create(v1, 0, 3, false));
outline.addVertex(index+2, vertexFactory.create(v3, 0, 3, false));
- dirtyBits |= DIRTY_VERTICES;
}
- /** Check overlaps between curved triangles
- * first check if any vertex in triangle a is in triangle b
- * second check if edges of triangle a intersect segments of triangle b
- * if any of the two tests is true we divide current triangle
- * and add the other to the list of overlaps
+ /**
+ * Check overlaps between curved triangles
+ * first check if any vertex in triangle a is in triangle b
+ * second check if edges of triangle a intersect segments of triangle b
+ * if any of the two tests is true we divide current triangle
+ * and add the other to the list of overlaps
*
- * Loop until overlap array is empty. (check only in first pass)
+ * Loop until overlap array is empty. (check only in first pass)
*/
private void checkOverlaps() {
- ArrayList<Vertex> overlaps = new ArrayList<Vertex>(3);
- int count = getOutlineNumber();
+ final ArrayList<Vertex> overlaps = new ArrayList<Vertex>(3);
+ final int count = getOutlineNumber();
boolean firstpass = true;
do {
for (int cc = 0; cc < count; cc++) {
@@ -442,8 +455,9 @@ public class OutlineShape implements Comparable<OutlineShape> {
vertexCount+=2;
if(overlap != null && !overlap.isOnCurve()) {
- if(!overlaps.contains(overlap))
+ if(!overlaps.contains(overlap)) {
overlaps.add(overlap);
+ }
}
}
}
@@ -506,12 +520,10 @@ public class OutlineShape implements Comparable<OutlineShape> {
i++;
vertexCount++;
outline.addVertex(i, v);
- dirtyBits |= DIRTY_VERTICES;
}
}
if(vertexCount <= 0) {
outlines.remove(outline);
- dirtyBits |= DIRTY_VERTICES;
cc--;
count--;
continue;
@@ -527,16 +539,15 @@ public class OutlineShape implements Comparable<OutlineShape> {
outlineState = VerticesState.QUADRATIC_NURBS;
}
- private void generateVertexIds() {
+ private int generateVertexIds() {
int maxVertexId = 0;
for(int i=0; i<outlines.size(); i++) {
final ArrayList<Vertex> vertices = outlines.get(i).getVertices();
for(int pos=0; pos<vertices.size(); pos++) {
- Vertex vert = vertices.get(pos);
- vert.setId(maxVertexId);
- maxVertexId++;
+ vertices.get(pos).setId(maxVertexId++);
}
}
+ return maxVertexId;
}
/**
@@ -545,15 +556,27 @@ public class OutlineShape implements Comparable<OutlineShape> {
* <p>
* Vertices are cached until marked dirty.
* </p>
+ * <p>
+ * Should always be called <i>after</i> {@link #getTriangles(VerticesState)},
+ * since the latter will mark all cached vertices dirty!
+ * </p>
* FIXME: Add memory optimization, i.e. VBO layout
+ * FIXME: Add Runnable task-per-vertices !
*/
- public ArrayList<Vertex> getVertices() {
+ public final ArrayList<Vertex> getVertices() {
+ final boolean updated;
if( 0 != ( DIRTY_VERTICES & dirtyBits ) ) {
vertices.clear();
for(int i=0; i<outlines.size(); i++) {
vertices.addAll(outlines.get(i).getVertices());
}
dirtyBits &= ~DIRTY_VERTICES;
+ updated = true;
+ } else {
+ updated = false;
+ }
+ if(Region.DEBUG_INSTANCE) {
+ System.err.println("OutlineShape.getVertices(): o "+outlines.size()+", v "+vertices.size()+", updated "+updated);
}
return vertices;
}
@@ -571,34 +594,6 @@ public class OutlineShape implements Comparable<OutlineShape> {
triangulator2d.generate(triangles);
triangulator2d.reset();
}
- dirtyBits &= ~DIRTY_TRIANGLES;
- }
-
- /**
- * Triangulate the {@link OutlineShape} generating a list of triangles
- * while {@link #transformOutlines(VerticesState)} beforehand w/
- * {@link OutlineShape.VerticesState#QUADRATIC_NURBS}.
- * <p>
- * Triangles are cached until marked dirty.
- * </p>
- * @return an arraylist of triangles representing the filled region
- * which is produced by the combination of the outlines
- * FIXME: Add memory optimization, i.e. VBO layout
- */
- public ArrayList<Triangle> getTriangles() {
- final boolean updated;
- if( 0 != ( DIRTY_TRIANGLES & dirtyBits ) ) {
- transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS);
- triangulateImpl();
- updated = true;
- } else {
- updated = false;
- }
- if(Region.DEBUG_INSTANCE) {
- System.err.println("OutlineShape.getTriangles().1: "+triangles.size()+", updated "+updated);
- }
-
- return triangles;
}
/**
@@ -617,6 +612,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
transformOutlines(destinationType);
triangulateImpl();
updated = true;
+ dirtyBits |= DIRTY_VERTICES;
+ dirtyBits &= ~DIRTY_TRIANGLES;
} else {
updated = false;
}
@@ -634,24 +631,24 @@ public class OutlineShape implements Comparable<OutlineShape> {
Collections.reverse(outlines);
}
- /** Compare two outline shapes with Bounding Box area
+ /**
+ * Compare two outline shapes with Bounding Box area
* as criteria.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public final int compareTo(OutlineShape outline) {
- float size = getBounds().getSize();
- float newSize = outline.getBounds().getSize();
- if(size < newSize){
+ public final int compareTo(final OutlineShape other) {
+ final float thisSize = getBounds().getSize();
+ final float otherSize = other.getBounds().getSize();
+ if( thisSize < otherSize ){
return -1;
- }
- else if(size > newSize){
+ } else if( thisSize > otherSize ) {
return 1;
}
- return 0;
+ return 0; // FIXME: No epsilon, i.e. smallest accurate float value ?
}
- private final void validateBoundingBox() {
+ private void validateBoundingBox() {
dirtyBits &= ~DIRTY_BOUNDS;
bbox.reset();
for (int i=0; i<outlines.size(); i++) {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 2b6da2084..79ec305d1 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -30,7 +30,8 @@ package com.jogamp.graph.curve;
import java.util.ArrayList;
import java.util.List;
-import jogamp.graph.curve.opengl.RegionFactory;
+import jogamp.graph.curve.opengl.VBORegion2PES2;
+import jogamp.graph.curve.opengl.VBORegionSPES2;
import jogamp.graph.geom.plane.AffineTransform;
import jogamp.opengl.Debug;
@@ -39,7 +40,8 @@ import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.opengl.math.geom.AABBox;
-/** Abstract Outline shape GL representation define the method an OutlineShape(s)
+/**
+ * Abstract Outline shape representation define the method an OutlineShape(s)
* is bound and rendered.
*
* @see GLRegion */
@@ -85,24 +87,22 @@ public abstract class Region {
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 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.
+ * Create a Region using the passed render mode
+ *
+ * <p> In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit
+ * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.</p>
+ *
+ * @param rs the RenderState to be used
+ * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT}
*/
- public static Region create(OutlineShape outlineShape, int renderModes) {
- final Region region = RegionFactory.create(renderModes);
- region.addOutlineShape(outlineShape, null);
- return region;
+ public static GLRegion create(int renderModes) {
+ if( 0 != ( Region.VBAA_RENDERING_BIT & renderModes ) ){
+ return new VBORegion2PES2(renderModes, Region.TWO_PASS_DEFAULT_TEXTURE_UNIT);
+ }
+ else{
+ return new VBORegionSPES2(renderModes);
+ }
}
protected Region(int regionRenderModes) {
@@ -116,6 +116,11 @@ public abstract class Region {
return renderModes;
}
+
+ public final ArrayList<Triangle> getTriangles() { return triangles; }
+
+ public final ArrayList<Vertex> getVertices() { return vertices; }
+
/** Check if current Region is using VBAA
*
* @return true if capable of two pass rendering - VBAA */
@@ -213,6 +218,7 @@ public abstract class Region {
}
// final List<Vertex> verts = shape.getVertices();
// vertices.addAll(verts);
+ // FIXME: use OutlineShape.getVertices(Runnable task-per-vertex) !!
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++) {
@@ -234,6 +240,26 @@ public abstract class Region {
setDirty(true);
}
+ public void validateIndices() {
+ final int verticeCountPre = vertices.size();
+ for(int i=0; i<triangles.size(); i++) {
+ final Triangle t = triangles.get(i);
+ final Vertex[] t_vertices = t.getVertices();
+
+ if(t_vertices[0].getId() == Integer.MAX_VALUE){
+ t_vertices[0].setId(numVertices++);
+ t_vertices[1].setId(numVertices++);
+ t_vertices[2].setId(numVertices++);
+ vertices.add(t_vertices[0]);
+ vertices.add(t_vertices[1]);
+ vertices.add(t_vertices[2]);
+ }
+ }
+ if( verticeCountPre < vertices.size() ) {
+ setDirty(true);
+ }
+ }
+
public void addOutlineShapes(List<OutlineShape> shapes) {
for (int i = 0; i < shapes.size(); i++) {
addOutlineShape(shapes.get(i), null);
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 d63e02a9c..78c8660fa 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -30,8 +30,8 @@ package com.jogamp.graph.curve.opengl;
import java.util.List;
import javax.media.opengl.GL2ES2;
-import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
@@ -47,20 +47,17 @@ import com.jogamp.graph.curve.Region;
*/
public abstract class GLRegion extends Region {
- /** Create an ogl {@link GLRegion} defining the list of {@link OutlineShape}.
- * Combining the Shapes into single buffers.
- * @return the resulting Region inclusive the generated region
- */
- public static GLRegion create(List<OutlineShape> outlineShapes, int renderModes) {
- return (GLRegion) Region.create(outlineShapes, renderModes);
- }
-
/**
- * Create an ogl {@link Region} defining this {@link OutlineShape}
- * @return the resulting Region.
+ * Create a GLRegion using the passed render mode
+ *
+ * <p> In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit
+ * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.</p>
+ *
+ * @param rs the RenderState to be used
+ * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT}
*/
- public static GLRegion create(OutlineShape outlineShape, int renderModes) {
- return (GLRegion) Region.create(outlineShape, renderModes);
+ public static GLRegion create(int renderModes) {
+ return Region.create(renderModes);
}
protected GLRegion(int renderModes) {
@@ -73,27 +70,29 @@ public abstract class GLRegion extends Region {
* <p>Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.</p>
* @param rs TODO
*/
- protected abstract void update(GL2ES2 gl, RenderState rs);
+ protected abstract void update(GL2ES2 gl, RegionRenderer renderer);
/** Delete and clean the associated OGL
* objects
*/
- public abstract void destroy(GL2ES2 gl, RenderState rs);
+ public abstract void destroy(GL2ES2 gl, RegionRenderer renderer);
- /** Renders the associated OGL objects specifying
+ /**
+ * Renders the associated OGL objects specifying
* current width/hight of window for multi pass rendering
* of the region.
* @param matrix current {@link PMVMatrix}.
- * @param rs the RenderState to be used
- * @param vp_width current screen width
- * @param vp_height current screen height
+ * @param renderer the {@link RegionRenderer} to be used
* @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 final void draw(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) {
- update(gl, rs);
- drawImpl(gl, rs, vp_width, vp_height, texWidth);
+ public final void draw(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] texWidth) {
+ if(isDirty()) {
+ update(gl, renderer);
+ setDirty(false);
+ }
+ drawImpl(gl, renderer, texWidth);
}
- protected abstract void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth);
+ protected abstract void drawImpl(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] texWidth);
}
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 faaf72a99..a9e258f36 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -27,13 +27,32 @@
*/
package com.jogamp.graph.curve.opengl;
+import java.nio.FloatBuffer;
+
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLException;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderState;
+import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
-public abstract class RegionRenderer extends Renderer {
+/**
+ * OpenGL {@link Region} renderer
+ * <p>
+ * All OpenGL related operations regarding {@link Region}s
+ * are passed through an instance of this class.
+ * </p>
+ */
+public abstract class RegionRenderer {
+ protected static final boolean DEBUG = Region.DEBUG;
+ protected static final boolean DEBUG_INSTANCE = Region.DEBUG_INSTANCE;
+
+ public static boolean isWeightValid(float v) {
+ return 0.0f <= v && v <= 1.9f ;
+ }
/**
* Create a Hardware accelerated Region Renderer.
@@ -45,39 +64,256 @@ public abstract class RegionRenderer extends Renderer {
return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, renderModes);
}
+ protected final int renderModes;
+ protected final RenderState rs;
+
+ protected int vp_width;
+ protected int vp_height;
+ protected boolean initialized;
+ private boolean vboSupported = false;
+
+ public final boolean isInitialized() { return initialized; }
+
+ public final int getWidth() { return vp_width; }
+ public final int getHeight() { return vp_height; }
+
+ public final float getWeight() { return rs.getWeight().floatValue(); }
+ public final float getAlpha() { return rs.getAlpha().floatValue(); }
+ public final PMVMatrix getMatrix() { return rs.pmvMatrix(); }
+
+ /**
+ * Implementation shall load, compile and link the shader program and leave it active.
+ * @param gl referencing the current GLContext to which the ShaderState is bound to
+ * @return
+ */
+ protected abstract boolean initImpl(GL2ES2 gl);
+
+ /** Delete and clean the associated OGL objects */
+ protected abstract void destroyImpl(GL2ES2 gl);
+
+ //////////////////////////////////////
+
+ /**
+ * @param rs the used {@link RenderState}
+ * @param renderModes bit-field of modes
+ */
protected RegionRenderer(RenderState rs, int renderModes) {
- super(rs, renderModes);
+ this.rs = rs;
+ this.renderModes = renderModes;
+ }
+
+ public final int getRenderModes() {
+ return renderModes;
}
+ public final boolean usesVariableCurveWeight() { return Region.isNonUniformWeight(renderModes); }
- /** 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 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
+ /**
+ * @return true if Region's renderModes contains all bits as this Renderer's renderModes
+ * except {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, otherwise false.
*/
- public final void draw(GL2ES2 gl, Region region, int[/*1*/] texWidth) {
- if(!isInitialized()) {
- throw new GLException("RegionRenderer: not initialized!");
- }
- if( !areRenderModesCompatible(region) ) {
- throw new GLException("Incompatible render modes, : region modes "+region.getRenderModes()+
- " doesn't contain renderer modes "+this.getRenderModes());
- }
- drawImpl(gl, region, texWidth);
+ public final boolean areRenderModesCompatible(final Region region) {
+ final int cleanRenderModes = getRenderModes() & ( Region.VARIABLE_CURVE_WEIGHT_BIT );
+ return cleanRenderModes == ( region.getRenderModes() & cleanRenderModes );
}
+ public final boolean isVBOSupported() { return vboSupported; }
+
/**
- * 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[])}.
+ * 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, int)}</p>
+ *
+ * @param gl referencing the current GLContext to which the ShaderState is bound to
+ * @throws GLException if initialization failed
*/
- protected abstract void drawImpl(GL2ES2 gl, Region region, int[] texWidth);
+ public final void init(GL2ES2 gl) throws GLException {
+ if(initialized){
+ return;
+ }
+ vboSupported = gl.isFunctionAvailable("glGenBuffers") &&
+ gl.isFunctionAvailable("glBindBuffer") &&
+ gl.isFunctionAvailable("glBufferData") &&
+ gl.isFunctionAvailable("glDrawElements") &&
+ gl.isFunctionAvailable("glVertexAttribPointer") &&
+ gl.isFunctionAvailable("glDeleteBuffers");
+
+ if(DEBUG) {
+ System.err.println("TextRendererImpl01: VBO Supported = " + isVBOSupported());
+ }
+
+ if(!vboSupported){
+ throw new GLException("VBO not supported");
+ }
+
+ rs.attachTo(gl);
+
+ gl.glEnable(GL2ES2.GL_BLEND);
+ gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA); // FIXME: alpha blending stage ?
+
+ initialized = initImpl(gl);
+ if(!initialized) {
+ throw new GLException("Shader initialization failed");
+ }
- @Override
- protected void destroyImpl(GL2ES2 gl) {
- // nop
+ if(!rs.getShaderState().uniform(gl, rs.getPMVMatrix())) {
+ throw new GLException("Error setting PMVMatrix in shader: "+rs.getShaderState());
+ }
+
+ if( Region.isNonUniformWeight( getRenderModes() ) ) {
+ if(!rs.getShaderState().uniform(gl, rs.getWeight())) {
+ throw new GLException("Error setting weight in shader: "+rs.getShaderState());
+ }
+ }
+
+ if(!rs.getShaderState().uniform(gl, rs.getAlpha())) {
+ throw new GLException("Error setting global alpha in shader: "+rs.getShaderState());
+ }
+
+ if(!rs.getShaderState().uniform(gl, rs.getColorStatic())) {
+ throw new GLException("Error setting global color in shader: "+rs.getShaderState());
+ }
+ }
+
+ public final void destroy(GL2ES2 gl) {
+ if(!initialized){
+ if(DEBUG_INSTANCE) {
+ System.err.println("TextRenderer: Not initialized!");
+ }
+ return;
+ }
+ rs.getShaderState().useProgram(gl, false);
+ destroyImpl(gl);
+ rs.destroy(gl);
+ initialized = false;
}
+ public final RenderState getRenderState() { return rs; }
+ public final ShaderState getShaderState() { return rs.getShaderState(); }
-}
+ public final void enable(GL2ES2 gl, boolean enable) {
+ rs.getShaderState().useProgram(gl, enable);
+ }
+
+ public final void setWeight(GL2ES2 gl, float v) {
+ if( !isWeightValid(v) ) {
+ throw new IllegalArgumentException("Weight out of range");
+ }
+ rs.getWeight().setData(v);
+ if(null != gl && rs.getShaderState().inUse() && Region.isNonUniformWeight( getRenderModes() ) ) {
+ rs.getShaderState().uniform(gl, rs.getWeight());
+ }
+ }
+
+ public final void setAlpha(GL2ES2 gl, float alpha_t) {
+ rs.getAlpha().setData(alpha_t);
+ if(null != gl && rs.getShaderState().inUse()) {
+ rs.getShaderState().uniform(gl, rs.getAlpha());
+ }
+
+ }
+
+ public final void getColorStatic(GL2ES2 gl, float[] rgb) {
+ FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer();
+ rgb[0] = fb.get(0);
+ rgb[1] = fb.get(1);
+ rgb[2] = fb.get(2);
+ }
+
+ public final void setColorStatic(GL2ES2 gl, float r, float g, float b){
+ FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer();
+ fb.put(0, r);
+ fb.put(1, g);
+ fb.put(2, b);
+ if(null != gl && rs.getShaderState().inUse()) {
+ rs.getShaderState().uniform(gl, rs.getColorStatic());
+ }
+ }
+
+ public final void rotate(GL2ES2 gl, float angle, float x, float y, float z) {
+ rs.pmvMatrix().glRotatef(angle, x, y, z);
+ updateMatrix(gl);
+ }
+
+ public final void translate(GL2ES2 gl, float x, float y, float z) {
+ rs.pmvMatrix().glTranslatef(x, y, z);
+ updateMatrix(gl);
+ }
+
+ public final void scale(GL2ES2 gl, float x, float y, float z) {
+ rs.pmvMatrix().glScalef(x, y, z);
+ updateMatrix(gl);
+ }
+
+ public final void resetModelview(GL2ES2 gl) {
+ rs.pmvMatrix().glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ rs.pmvMatrix().glLoadIdentity();
+ updateMatrix(gl);
+ }
+
+ public final void updateMatrix(GL2ES2 gl) {
+ if(initialized && null != gl && rs.getShaderState().inUse()) {
+ rs.getShaderState().uniform(gl, rs.getPMVMatrix());
+ }
+ }
+
+ /** No PMVMatrix operation is performed here. PMVMatrix will be updated if gl is not null. */
+ public final boolean reshapeNotify(GL2ES2 gl, int width, int height) {
+ this.vp_width = width;
+ this.vp_height = height;
+ updateMatrix(gl);
+ return true;
+ }
+
+ public final boolean reshapePerspective(GL2ES2 gl, float angle, int width, int height, float near, float far) {
+ this.vp_width = width;
+ this.vp_height = height;
+ final float ratio = (float)width/(float)height;
+ final PMVMatrix p = rs.pmvMatrix();
+ p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ p.glLoadIdentity();
+ p.gluPerspective(angle, ratio, near, far);
+ updateMatrix(gl);
+ return true;
+ }
+
+ public final boolean reshapeOrtho(GL2ES2 gl, int width, int height, float near, float far) {
+ this.vp_width = width;
+ this.vp_height = height;
+ final PMVMatrix p = rs.pmvMatrix();
+ p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ p.glLoadIdentity();
+ p.glOrthof(0, width, 0, height, near, far);
+ updateMatrix(gl);
+ return true;
+ }
+
+ protected String getVertexShaderName() {
+ return "curverenderer" + getImplVersion();
+ }
+
+ protected String getFragmentShaderName() {
+ final String version = getImplVersion();
+ final String pass = Region.isVBAA(renderModes) ? "-2pass" : "-1pass" ;
+ final String weight = Region.isNonUniformWeight(renderModes) ? "-weight" : "" ;
+ return "curverenderer" + version + pass + weight;
+ }
+
+ // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode ..
+ public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n";
+
+ protected String getFragmentShaderPrecision(GL2ES2 gl) {
+ if( gl.isGLES() ) {
+ return es2_precision_fp;
+ }
+ if( ShaderCode.requiresGL3DefaultPrecision(gl) ) {
+ return ShaderCode.gl3_default_precision_fp;
+ }
+ return null;
+ }
+
+ protected String getImplVersion() {
+ return "01";
+ }
+} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java
deleted file mode 100644
index 31e4f0b8f..000000000
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.graph.curve.opengl;
-
-import java.nio.FloatBuffer;
-
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLException;
-import javax.media.opengl.fixedfunc.GLMatrixFunc;
-
-import com.jogamp.opengl.util.glsl.ShaderCode;
-import com.jogamp.opengl.util.glsl.ShaderState;
-import com.jogamp.opengl.util.PMVMatrix;
-
-import com.jogamp.graph.curve.Region;
-
-public abstract class Renderer {
- protected static final boolean DEBUG = Region.DEBUG;
- protected static final boolean DEBUG_INSTANCE = Region.DEBUG_INSTANCE;
-
- public static boolean isWeightValid(float v) {
- return 0.0f <= v && v <= 1.9f ;
- }
-
- protected final int renderModes;
- protected int vp_width;
- protected int vp_height;
- protected boolean initialized;
- protected final RenderState rs;
- private boolean vboSupported = false;
-
- public final boolean isInitialized() { return initialized; }
-
- public final int getWidth() { return vp_width; }
- public final int getHeight() { return vp_height; }
-
- public float getWeight() { return rs.getWeight().floatValue(); }
- public float getAlpha() { return rs.getAlpha().floatValue(); }
- public final PMVMatrix getMatrix() { return rs.pmvMatrix(); }
-
- /**
- * Implementation shall load, compile and link the shader program and leave it active.
- * @param gl referencing the current GLContext to which the ShaderState is bound to
- * @return
- */
- protected abstract boolean initShaderProgram(GL2ES2 gl);
-
- protected abstract void destroyImpl(GL2ES2 gl);
-
- /**
- * @param rs the used {@link RenderState}
- * @param renderModes bit-field of modes
- */
- protected Renderer(RenderState rs, int renderModes) {
- this.rs = rs;
- this.renderModes = renderModes;
- }
-
- public final int getRenderModes() {
- return renderModes;
- }
-
- public boolean usesVariableCurveWeight() { return Region.isNonUniformWeight(renderModes); }
-
- /**
- * @return true if Region's renderModes contains all bits as this Renderer's renderModes
- * except {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, otherwise false.
- */
- public final boolean areRenderModesCompatible(Region region) {
- final int cleanRenderModes = getRenderModes() & ( Region.VARIABLE_CURVE_WEIGHT_BIT );
- return cleanRenderModes == ( region.getRenderModes() & cleanRenderModes );
- }
-
- public final boolean isVBOSupported() { return vboSupported; }
-
- /**
- * 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, int)}</p>
- *
- * @param gl referencing the current GLContext to which the ShaderState is bound to
- * @throws GLException if initialization failed
- */
- public final void init(GL2ES2 gl) throws GLException {
- if(initialized){
- return;
- }
- vboSupported = gl.isFunctionAvailable("glGenBuffers") &&
- gl.isFunctionAvailable("glBindBuffer") &&
- gl.isFunctionAvailable("glBufferData") &&
- gl.isFunctionAvailable("glDrawElements") &&
- gl.isFunctionAvailable("glVertexAttribPointer") &&
- gl.isFunctionAvailable("glDeleteBuffers");
-
- if(DEBUG) {
- System.err.println("TextRendererImpl01: VBO Supported = " + isVBOSupported());
- }
-
- if(!vboSupported){
- throw new GLException("VBO not supported");
- }
-
- rs.attachTo(gl);
-
- gl.glEnable(GL2ES2.GL_BLEND);
- gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA); // FIXME: alpha blending stage ?
-
- initialized = initShaderProgram(gl);
- if(!initialized) {
- throw new GLException("Shader initialization failed");
- }
-
- if(!rs.getShaderState().uniform(gl, rs.getPMVMatrix())) {
- throw new GLException("Error setting PMVMatrix in shader: "+rs.getShaderState());
- }
-
- if( Region.isNonUniformWeight( getRenderModes() ) ) {
- if(!rs.getShaderState().uniform(gl, rs.getWeight())) {
- throw new GLException("Error setting weight in shader: "+rs.getShaderState());
- }
- }
-
- if(!rs.getShaderState().uniform(gl, rs.getAlpha())) {
- throw new GLException("Error setting global alpha in shader: "+rs.getShaderState());
- }
-
- if(!rs.getShaderState().uniform(gl, rs.getColorStatic())) {
- throw new GLException("Error setting global color in shader: "+rs.getShaderState());
- }
- }
-
- public final void flushCache(GL2ES2 gl) {
- // FIXME: REMOVE !
- }
-
- public void destroy(GL2ES2 gl) {
- if(!initialized){
- if(DEBUG_INSTANCE) {
- System.err.println("TextRenderer: Not initialized!");
- }
- return;
- }
- rs.getShaderState().useProgram(gl, false);
- destroyImpl(gl);
- rs.destroy(gl);
- initialized = false;
- }
-
- public final RenderState getRenderState() { return rs; }
- public final ShaderState getShaderState() { return rs.getShaderState(); }
-
- public final void enable(GL2ES2 gl, boolean enable) {
- rs.getShaderState().useProgram(gl, enable);
- }
-
- public void setWeight(GL2ES2 gl, float v) {
- if( !isWeightValid(v) ) {
- throw new IllegalArgumentException("Weight out of range");
- }
- rs.getWeight().setData(v);
- if(null != gl && rs.getShaderState().inUse() && Region.isNonUniformWeight( getRenderModes() ) ) {
- rs.getShaderState().uniform(gl, rs.getWeight());
- }
- }
-
- public void setAlpha(GL2ES2 gl, float alpha_t) {
- rs.getAlpha().setData(alpha_t);
- if(null != gl && rs.getShaderState().inUse()) {
- rs.getShaderState().uniform(gl, rs.getAlpha());
- }
-
- }
-
- public void getColorStatic(GL2ES2 gl, float[] rgb) {
- FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer();
- rgb[0] = fb.get(0);
- rgb[1] = fb.get(1);
- rgb[2] = fb.get(2);
- }
-
- public void setColorStatic(GL2ES2 gl, float r, float g, float b){
- FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer();
- fb.put(0, r);
- fb.put(1, g);
- fb.put(2, b);
- if(null != gl && rs.getShaderState().inUse()) {
- rs.getShaderState().uniform(gl, rs.getColorStatic());
- }
- }
-
- public void rotate(GL2ES2 gl, float angle, float x, float y, float z) {
- rs.pmvMatrix().glRotatef(angle, x, y, z);
- updateMatrix(gl);
- }
-
- public void translate(GL2ES2 gl, float x, float y, float z) {
- rs.pmvMatrix().glTranslatef(x, y, z);
- updateMatrix(gl);
- }
-
- public void scale(GL2ES2 gl, float x, float y, float z) {
- rs.pmvMatrix().glScalef(x, y, z);
- updateMatrix(gl);
- }
-
- public void resetModelview(GL2ES2 gl) {
- rs.pmvMatrix().glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- rs.pmvMatrix().glLoadIdentity();
- updateMatrix(gl);
- }
-
- public void updateMatrix(GL2ES2 gl) {
- if(initialized && null != gl && rs.getShaderState().inUse()) {
- rs.getShaderState().uniform(gl, rs.getPMVMatrix());
- }
- }
-
- /** No PMVMatrix operation is performed here. PMVMatrix will be updated if gl is not null. */
- public boolean reshapeNotify(GL2ES2 gl, int width, int height) {
- this.vp_width = width;
- this.vp_height = height;
- updateMatrix(gl);
- return true;
- }
-
- public boolean reshapePerspective(GL2ES2 gl, float angle, int width, int height, float near, float far) {
- this.vp_width = width;
- this.vp_height = height;
- final float ratio = (float)width/(float)height;
- final PMVMatrix p = rs.pmvMatrix();
- p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- p.glLoadIdentity();
- p.gluPerspective(angle, ratio, near, far);
- updateMatrix(gl);
- return true;
- }
-
- public boolean reshapeOrtho(GL2ES2 gl, int width, int height, float near, float far) {
- this.vp_width = width;
- this.vp_height = height;
- final PMVMatrix p = rs.pmvMatrix();
- p.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- p.glLoadIdentity();
- p.glOrthof(0, width, 0, height, near, far);
- updateMatrix(gl);
- return true;
- }
-
- protected String getVertexShaderName() {
- return "curverenderer" + getImplVersion();
- }
-
- protected String getFragmentShaderName() {
- final String version = getImplVersion();
- final String pass = Region.isVBAA(renderModes) ? "-2pass" : "-1pass" ;
- final String weight = Region.isNonUniformWeight(renderModes) ? "-weight" : "" ;
- return "curverenderer" + version + pass + weight;
- }
-
- // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode ..
- public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n";
-
- protected String getFragmentShaderPrecision(GL2ES2 gl) {
- if( gl.isGLES() ) {
- return es2_precision_fp;
- }
- if( ShaderCode.requiresGL3DefaultPrecision(gl) ) {
- return ShaderCode.gl3_default_precision_fp;
- }
- return null;
- }
-
- protected String getImplVersion() {
- return "01";
- }
-} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java
index cef589f4f..6ac3d926f 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java
@@ -35,7 +35,6 @@ import java.util.List;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLException;
-import jogamp.graph.curve.opengl.RegionFactory;
import jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.curve.OutlineShape;
@@ -53,9 +52,9 @@ import com.jogamp.graph.geom.Vertex.Factory;
*/
public class TextRenderUtil {
- public final Renderer renderer;
+ public final RegionRenderer renderer;
- public TextRenderUtil(final Renderer renderer) {
+ public TextRenderUtil(final RegionRenderer renderer) {
this.renderer = renderer;
}
@@ -75,7 +74,7 @@ public class TextRenderUtil {
final Font font, final CharSequence str, final int pixelSize) {
final int charCount = str.length();
- final GLRegion region = RegionFactory.create(renderModes);
+ final GLRegion region = Region.create(renderModes);
// region.setFlipped(true);
final Font.Metrics metrics = font.getMetrics();
@@ -108,7 +107,7 @@ public class TextRenderUtil {
final Font.Glyph glyph = font.getGlyph(character);
final OutlineShape glyphShape = glyph.getShape();
- if( null == glyphShape || glyphShape.getVertices().size() < 3 ) {
+ if( null == glyphShape ) {
continue;
}
// glyphShape.closeLastOutline();
@@ -116,10 +115,16 @@ public class TextRenderUtil {
if( false ) {
region.addOutlineShape(glyphShape, t);
} else {
- final ArrayList<Triangle> trisIn = glyphShape.getTriangles();
+ // System.err.println("XXXXX Pre TRI");
+ // glyphShape.getVertices();
+ final ArrayList<Triangle> trisIn = glyphShape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS);
+ final ArrayList<Vertex> gVertices = glyphShape.getVertices();
+
+ if( gVertices.size() < 3 ) {
+ continue;
+ }
region.addTriangles(trisIn, t, numVertices);
- final ArrayList<Vertex> gVertices = glyphShape.getVertices();
for(int j=0; j<gVertices.size(); j++) {
final Vertex vert = gVertices.get(j);
final Vertex svert = t.transform(vert, null);
@@ -156,13 +161,13 @@ public class TextRenderUtil {
shapesOut.add(glyphShape);
}
- final GLRegion region = RegionFactory.create(renderModes);
+ final GLRegion region = Region.create(renderModes);
// region.setFlipped(true);
int numVertices = region.getNumVertices();
for(int i=0; i< shapesOut.size(); i++) {
final OutlineShape shape = shapesOut.get(i);
- ArrayList<Triangle> gtris = shape.getTriangles();
+ ArrayList<Triangle> gtris = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS);
region.addTriangles(gtris, null, 0);
final ArrayList<Vertex> gVertices = shape.getVertices();
@@ -198,7 +203,7 @@ public class TextRenderUtil {
region = createRegion(renderer.getRenderModes(), rs.getVertexFactory(), font, str, pixelSize);
addCachedRegion(gl, font, str, pixelSize, region);
}
- region.draw(gl, rs, renderer.getWidth(), renderer.getHeight(), texSize);
+ region.draw(gl, renderer, texSize);
}
/**
@@ -212,14 +217,14 @@ public class TextRenderUtil {
* 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 static void drawString3D(final Renderer renderer, final GL2ES2 gl,
+ public static void drawString3D(final RegionRenderer renderer, final GL2ES2 gl,
final Font font, final CharSequence str, final int fontSize, final int[/*1*/] texSize) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
final RenderState rs = renderer.getRenderState();
GLRegion region = createRegion(renderer.getRenderModes(), rs.getVertexFactory(), font, str, fontSize);
- region.draw(gl, rs, renderer.getWidth(), renderer.getHeight(), texSize);
+ region.draw(gl, renderer, texSize);
}
/** FIXME
@@ -238,7 +243,7 @@ public class TextRenderUtil {
final Iterator<GLRegion> iterator = stringCacheMap.values().iterator();
while(iterator.hasNext()){
final GLRegion region = iterator.next();
- region.destroy(gl, renderer.getRenderState());
+ region.destroy(gl, renderer);
}
stringCacheMap.clear();
stringCacheArray.clear();
@@ -304,7 +309,7 @@ public class TextRenderUtil {
final String key = getKey(font, str, fontSize);
GLRegion region = stringCacheMap.remove(key);
if(null != region) {
- region.destroy(gl, renderer.getRenderState());
+ region.destroy(gl, renderer);
}
stringCacheArray.remove(key);
}
@@ -313,7 +318,7 @@ public class TextRenderUtil {
final String key = stringCacheArray.remove(idx);
final GLRegion region = stringCacheMap.remove(key);
if(null != region) {
- region.destroy(gl, renderer.getRenderState());
+ region.destroy(gl, renderer);
}
}