summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java74
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java17
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java57
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java32
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/opengl/UIRegion.java16
26 files changed, 537 insertions, 694 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);
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java
deleted file mode 100644
index 515583b14..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java
+++ /dev/null
@@ -1,74 +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 jogamp.graph.curve.opengl;
-
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
-
-/** RegionFactory to create a Context specific Region implementation.
- *
- * @see GLRegion
- */
-public class RegionFactory {
-
- /**
- * 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 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);
- }
- }
-
- /** Create a Single Pass Region using the passed render mode
- * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
- * {@link Region#VBAA_RENDERING_BIT}
- * @return
- */
- public static GLRegion createSinglePass(int renderModes) {
- return new VBORegionSPES2(renderModes);
- }
-
- /** Create a Two Pass (VBAA) Region using the passed render mode
- * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
- * {@link Region#VBAA_RENDERING_BIT}
- * @return
- */
- public static GLRegion createTwoPass(int renderModes, int textureUnit) {
- return new VBORegion2PES2(renderModes, textureUnit);
- }
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
index 51198fd75..c2762591a 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
@@ -32,23 +32,21 @@ import javax.media.opengl.GLException;
import jogamp.graph.curve.opengl.shader.AttributeNames;
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.opengl.GLExtensions;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
public class RegionRendererImpl01 extends RegionRenderer {
+
public RegionRendererImpl01(RenderState rs, int renderModes) {
super(rs, renderModes);
-
}
@Override
- protected boolean initShaderProgram(GL2ES2 gl) {
+ protected final boolean initImpl(GL2ES2 gl) {
final ShaderState st = rs.getShaderState();
final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader",
@@ -89,12 +87,7 @@ public class RegionRendererImpl01 extends RegionRenderer {
}
@Override
- protected void destroyImpl(GL2ES2 gl) {
- super.destroyImpl(gl);
- }
-
- @Override
- protected void drawImpl(GL2ES2 gl, Region region, int[] texSize) {
- ((GLRegion)region).draw(gl, rs, vp_width, vp_height, texSize);
+ protected final void destroyImpl(GL2ES2 gl) {
+ // NOP .. all will be destroyed via RenderState
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
index 77c862ed4..22364c373 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
@@ -41,8 +41,8 @@ import jogamp.graph.curve.opengl.shader.UniformNames;
import com.jogamp.common.nio.Buffers;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
-
import com.jogamp.graph.curve.opengl.GLRegion;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
@@ -62,7 +62,7 @@ public class VBORegion2PES2 extends GLRegion {
private FBObject fbo;
private TextureAttachment texA;
- private PMVMatrix fboPMVMatrix;
+ private final PMVMatrix fboPMVMatrix;
GLUniformData mgl_fboPMVMatrix;
private int tex_width_c = 0;
@@ -70,22 +70,18 @@ public class VBORegion2PES2 extends GLRegion {
GLUniformData mgl_ActiveTexture;
GLUniformData mgl_TextureSize; // if GLSL < 1.30
- public VBORegion2PES2(int renderModes, int textureEngine) {
+ public VBORegion2PES2(final int renderModes, final int textureUnit) {
super(renderModes);
fboPMVMatrix = new PMVMatrix();
mgl_fboPMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, fboPMVMatrix.glGetPMvMatrixf());
- mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine);
+ mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureUnit);
}
@Override
- public void update(GL2ES2 gl, RenderState rs) {
- if(!isDirty()) {
- return;
- }
-
+ public void update(final GL2ES2 gl, final RegionRenderer renderer) {
if(null == indicesFbo) {
final int initialElementCount = 256;
- final ShaderState st = rs.getShaderState();
+ final ShaderState st = renderer.getShaderState();
indicesFbo = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
@@ -120,6 +116,7 @@ public class VBORegion2PES2 extends GLRegion {
System.err.println("VBORegion2PES2 Create: " + this);
}
}
+ validateIndices();
// process triangles
indicesTxt.seal(gl, false);
indicesTxt.rewind();
@@ -128,17 +125,7 @@ public class VBORegion2PES2 extends GLRegion {
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]);
-
- indicesTxt.puts((short) t_vertices[0].getId());
- indicesTxt.puts((short) t_vertices[1].getId());
- indicesTxt.puts((short) t_vertices[2].getId());
+ throw new RuntimeException("Ooops Triangle #"+i+" - has unindexed vertices");
} else {
indicesTxt.puts((short) t_vertices[0].getId());
indicesTxt.puts((short) t_vertices[1].getId());
@@ -187,22 +174,22 @@ public class VBORegion2PES2 extends GLRegion {
// push data 2 GPU ..
indicesFbo.seal(gl, true);
indicesFbo.enableBuffer(gl, false);
-
- setDirty(false);
-
// the buffers were disabled, since due to real/fbo switching and other vbo usage
}
- int[] maxTexSize = new int[] { -1 } ;
+ final int[] maxTexSize = new int[] { -1 } ;
@Override
- protected void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) {
- if(vp_width <=0 || vp_height <= 0 || null==texWidth || texWidth[0] <= 0){
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] texWidth) {
+ final int width = renderer.getWidth();
+ final int height = renderer.getHeight();
+ if(width <=0 || height <= 0 || null==texWidth || texWidth[0] <= 0){
renderRegion(gl);
} else {
if(0 > maxTexSize[0]) {
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxTexSize, 0);
}
+ final RenderState rs = renderer.getRenderState();
if(texWidth[0] != tex_width_c) {
if(texWidth[0] > maxTexSize[0]) {
texWidth[0] = maxTexSize[0]; // clip to max - write-back user value!
@@ -210,11 +197,11 @@ public class VBORegion2PES2 extends GLRegion {
renderRegion2FBO(gl, rs, texWidth);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
- renderFBO(gl, rs, vp_width, vp_height);
+ renderFBO(gl, rs, width, height);
}
}
- private void renderFBO(GL2ES2 gl, RenderState rs, int width, int hight) {
+ private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int hight) {
final ShaderState st = rs.getShaderState();
gl.glViewport(0, 0, width, hight);
@@ -235,7 +222,7 @@ public class VBORegion2PES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(GL2ES2 gl, RenderState rs, int[/*1*/] texWidth) {
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int[/*1*/] texWidth) {
final ShaderState st = rs.getShaderState();
if(0>=texWidth[0]) {
@@ -280,13 +267,13 @@ public class VBORegion2PES2 extends GLRegion {
mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 2, Buffers.newDirectFloatBuffer(2));
}
final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
- texSize.put(0, (float)fbo.getWidth());
- texSize.put(1, (float)fbo.getHeight());
+ texSize.put(0, fbo.getWidth());
+ texSize.put(1, fbo.getHeight());
st.uniform(gl, mgl_TextureSize);
//}
}
- private void renderRegion(GL2ES2 gl) {
+ private void renderRegion(final GL2ES2 gl) {
verticeTxtAttr.enableBuffer(gl, true);
texCoordTxtAttr.enableBuffer(gl, true);
indicesTxt.bindBuffer(gl, true); // keeps VBO binding
@@ -299,11 +286,11 @@ public class VBORegion2PES2 extends GLRegion {
}
@Override
- public void destroy(GL2ES2 gl, RenderState rs) {
+ public void destroy(final GL2ES2 gl, final RegionRenderer renderer) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegion2PES2 Destroy: " + this);
}
- final ShaderState st = rs.getShaderState();
+ final ShaderState st = renderer.getShaderState();
if(null != fbo) {
fbo.destroy(gl);
fbo = null;
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 3cc6152b2..f7b9e73af 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -33,7 +33,7 @@ import javax.media.opengl.GL2ES2;
import jogamp.graph.curve.opengl.shader.AttributeNames;
import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.opengl.util.GLArrayDataServer;
@@ -44,19 +44,15 @@ public class VBORegionSPES2 extends GLRegion {
private GLArrayDataServer texCoordAttr = null;
private GLArrayDataServer indicesBuffer = null;
- protected VBORegionSPES2(int renderModes) {
+ public VBORegionSPES2(final int renderModes) {
super(renderModes);
}
@Override
- protected void update(GL2ES2 gl, RenderState rs) {
- if(!isDirty()) {
- return;
- }
-
+ public void update(final GL2ES2 gl, final RegionRenderer renderer) {
if(null == indicesBuffer) {
final int initialElementCount = 256;
- final ShaderState st = rs.getShaderState();
+ final ShaderState st = renderer.getShaderState();
indicesBuffer = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
@@ -76,6 +72,7 @@ public class VBORegionSPES2 extends GLRegion {
if(DEBUG_INSTANCE) {
System.err.println("VBORegionSPES2 Indices of "+triangles.size()+", triangles");
}
+ validateIndices();
// process triangles
indicesBuffer.seal(gl, false);
indicesBuffer.rewind();
@@ -84,21 +81,7 @@ public class VBORegionSPES2 extends GLRegion {
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]);
-
- indicesBuffer.puts((short) t_vertices[0].getId());
- indicesBuffer.puts((short) t_vertices[1].getId());
- indicesBuffer.puts((short) t_vertices[2].getId());
- if(DEBUG_INSTANCE) {
- System.err.println("VBORegionSPES2.Indices.1: "+
- t_vertices[0].getId()+", "+t_vertices[1].getId()+", "+t_vertices[2].getId());
- }
+ throw new RuntimeException("Ooops Triangle #"+i+" - has unindexed vertices");
} else {
indicesBuffer.puts((short) t_vertices[0].getId());
indicesBuffer.puts((short) t_vertices[1].getId());
@@ -133,12 +116,10 @@ public class VBORegionSPES2 extends GLRegion {
verticeAttr.enableBuffer(gl, false);
texCoordAttr.seal(gl, true);
texCoordAttr.enableBuffer(gl, false);
-
- setDirty(false);
}
@Override
- protected void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) {
+ protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] texWidth) {
verticeAttr.enableBuffer(gl, true);
texCoordAttr.enableBuffer(gl, true);
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
@@ -151,11 +132,11 @@ public class VBORegionSPES2 extends GLRegion {
}
@Override
- public final void destroy(GL2ES2 gl, RenderState rs) {
+ public void destroy(final GL2ES2 gl, final RegionRenderer renderer) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegionSPES2 Destroy: " + this);
}
- final ShaderState st = rs.getShaderState();
+ final ShaderState st = renderer.getShaderState();
if(null != verticeAttr) {
st.ownAttribute(verticeAttr, false);
verticeAttr.destroy(gl);
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 9e15746a6..619fe23c5 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -45,7 +45,7 @@ import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.Renderer;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRenderUtil;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
@@ -228,7 +228,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
gl.setSwapInterval(1);
gl.glEnable(GL.GL_DEPTH_TEST);
- final Renderer renderer = getRenderer();
+ final RegionRenderer renderer = getRenderer();
renderer.setAlpha(gl, 1.0f);
renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
index 1f4a95511..2a349b2de 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -41,8 +41,8 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRenderUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
index 704e98999..da1fb5515 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -34,8 +34,8 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRenderUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
@@ -201,4 +201,4 @@ public abstract class TextRendererGLELBase implements GLEventListener {
lastRow = -1;
}
}
-} \ No newline at end of file
+}
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 43e5537e9..2673a0e85 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
@@ -31,26 +31,27 @@ package com.jogamp.opengl.test.junit.graph.demos;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
+
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
/** Demonstrate the rendering of multiple outlines into one region/OutlineShape
* These Outlines are not necessary connected or contained.
* The output of this demo shows two identical shapes but the left one
- * has some vertices with off-curve flag set to true, and the right allt he vertices
- * are on the curve. Demos the Res. Independent Nurbs based Curve rendering
+ * has some vertices with off-curve flag set to true, and the right allt he vertices
+ * are on the curve. Demos the Res. Independent Nurbs based Curve rendering
*
*/
public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 {
OutlineShape outlineShape = null;
-
+
public GPURegionGLListener01 (RenderState rs, int renderModes, int fbosize, boolean debug, boolean trace) {
super(rs, renderModes, debug, trace);
setMatrix(-20, 00, 0f, -50, fbosize);
}
-
+
private void createTestOutline(){
float offset = 0;
outlineShape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
@@ -68,7 +69,7 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 {
outlineShape.addVertex(10.0f,0.0f, true);
outlineShape.addVertex(5.0f,0.0f, false);
outlineShape.closeLastOutline();
-
+
/** Same shape as above but without any off-curve vertices */
offset = 30;
outlineShape.addEmptyOutline();
@@ -86,23 +87,24 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 {
outlineShape.addVertex(offset+10.0f,-5.0f, true);
outlineShape.addVertex(offset+10.0f,0.0f, true);
outlineShape.closeLastOutline();
-
- region = GLRegion.create(outlineShape, getRenderModes());
+
+ region = GLRegion.create(getRenderModes());
+ region.addOutlineShape(outlineShape, null);
}
public void init(GLAutoDrawable drawable) {
super.init(drawable);
-
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
+ final RegionRenderer regionRenderer = getRenderer();
gl.setSwapInterval(1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
gl.glEnable(GL2ES2.GL_BLEND);
regionRenderer.setAlpha(gl, 1.0f);
regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
-
+
createTestOutline();
}
@@ -112,14 +114,14 @@ public class GPURegionGLListener01 extends GPURegionRendererListenerBase01 {
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
+ final RegionRenderer regionRenderer = getRenderer();
+
regionRenderer.resetModelview(null);
regionRenderer.translate(null, getXTran(), getYTran(), getZoom());
regionRenderer.rotate(gl, getAngle(), 0, 1, 0);
if( weight != regionRenderer.getWeight()) {
regionRenderer.setWeight(gl, weight);
}
- regionRenderer.draw(gl, region, getTexSize());
- }
+ region.draw(gl, regionRenderer, 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 3565dbc48..222265c37 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
@@ -37,8 +37,8 @@ import javax.media.opengl.GLAutoDrawable;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
/** Demonstrate the rendering of multiple OutlineShapes
* into one region
@@ -51,7 +51,7 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 {
super(rs, renderModes, debug, trace);
setMatrix(-20, 00, 0f, -50, fbosize);
}
-
+
private void createTestOutline(){
float offset = 0;
OutlineShape shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
@@ -70,7 +70,7 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 {
shape.addVertex(10.0f,0.0f, true);
shape.addVertex(5.0f,0.0f, false);
shape.closeLastOutline();
-
+
/** Same shape as above but without any off-curve vertices */
shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory());
outlineShapes.add(shape);
@@ -89,23 +89,24 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 {
shape.addVertex(offset+10.0f,-5.0f, true);
shape.addVertex(offset+10.0f,0.0f, true);
shape.closeLastOutline();
-
- region = GLRegion.create(outlineShapes, getRenderModes());
+
+ region = GLRegion.create(getRenderModes());
+ region.addOutlineShapes(outlineShapes);
}
public void init(GLAutoDrawable drawable) {
super.init(drawable);
-
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
+ final RegionRenderer regionRenderer = getRenderer();
gl.setSwapInterval(1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
gl.glEnable(GL2ES2.GL_BLEND);
regionRenderer.setAlpha(gl, 1.0f);
regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
-
+
createTestOutline();
}
@@ -115,15 +116,15 @@ public class GPURegionGLListener02 extends GPURegionRendererListenerBase01 {
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- final RegionRenderer regionRenderer = (RegionRenderer) getRenderer();
-
+ final RegionRenderer regionRenderer = getRenderer();
+
regionRenderer.resetModelview(null);
regionRenderer.translate(null, getXTran(), getYTran(), getZoom());
regionRenderer.rotate(gl, getAngle(), 0, 1, 0);
if( weight != regionRenderer.getWeight()) {
regionRenderer.setWeight(gl, weight);
}
- regionRenderer.draw(gl, region, getTexSize());
-
- }
+ region.draw(gl, regionRenderer, getTexSize());
+
+ }
}
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 8439d1fff..1ec69878a 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
@@ -37,7 +37,7 @@ import com.jogamp.graph.curve.opengl.RenderState;
* - 1/2: zoom in/out
* - 3/4: font +/-
* - 6/7: 2nd pass texture size
- * - 0/9: rotate
+ * - 0/9: rotate
* - s: toogle draw 'font set'
* - f: toggle draw fps
* - v: toggle v-sync
@@ -48,5 +48,5 @@ public abstract class GPURegionRendererListenerBase01 extends GPURendererListene
public GPURegionRendererListenerBase01(RenderState rs, int renderModes, boolean debug, boolean trace) {
super(RegionRenderer.create(rs, renderModes), renderModes, 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 4e3d271e1..7041f9f91 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
@@ -45,7 +45,7 @@ import javax.media.opengl.GLRunnable;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.Renderer;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -62,7 +62,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
* - s: screenshot
*/
public abstract class GPURendererListenerBase01 implements GLEventListener {
- private final Renderer renderer;
+ private final RegionRenderer renderer;
private final int renderModes;
private final boolean debug;
private final boolean trace;
@@ -86,7 +86,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
protected volatile float weight = 1.0f;
boolean ignoreInput = false;
- public GPURendererListenerBase01(Renderer renderer, int renderModes, boolean debug, boolean trace) {
+ public GPURendererListenerBase01(RegionRenderer renderer, int renderModes, boolean debug, boolean trace) {
this.renderer = renderer;
this.renderModes = renderModes;
this.debug = debug;
@@ -94,7 +94,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
this.screenshot = new GLReadBufferUtil(false, false);
}
- public final Renderer getRenderer() { return renderer; }
+ public final RegionRenderer getRenderer() { return renderer; }
public final int getRenderModes() { return renderModes; }
public final float getZoom() { return zoom; }
public final float getXTran() { return xTran; }
@@ -141,7 +141,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
autoDrawable = null;
GL2ES2 gl = drawable.getGL().getGL2ES2();
if(null != region) {
- region.destroy(gl, renderer.getRenderState());
+ region.destroy(gl, renderer);
}
screenshot.dispose(gl);
renderer.destroy(gl);
@@ -163,7 +163,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
dumpMatrix();
}
public void editGlobalWeight(float delta) {
- if( !Renderer.isWeightValid(weight+delta) ) {
+ if( !RegionRenderer.isWeightValid(weight+delta) ) {
return;
}
weight += delta;
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 4d544019c..05914b5bf 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
@@ -32,7 +32,7 @@ import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.Renderer;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.glsl.ShaderState;
@@ -57,7 +57,7 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 {
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final Renderer renderer = getRenderer();
+ final RegionRenderer renderer = getRenderer();
gl.setSwapInterval(1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
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 d90b4f849..3fbe5b816 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
@@ -35,9 +35,8 @@ import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLException;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.Renderer;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRenderUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
@@ -154,7 +153,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Demo02 needs to have this set here as well .. hmm ?
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- final Renderer renderer = getRenderer();
+ final RegionRenderer renderer = getRenderer();
renderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f);
renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
final GLAnimatorControl animator = drawable.getAnimator();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
index c9f27df80..0c4d5fbbf 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java
@@ -11,8 +11,8 @@ import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLRunnable;
import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
@@ -300,8 +300,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
regionRenderer.scale(gl, 1.5f, 1.5f, 1.0f);
regionRenderer.rotate(gl, angText , 0, 1, 0);
regionRenderer.setColorStatic(gl, 0.0f, 1.0f, 0.0f);
- regionRenderer.draw(gl, jogampRegion.getRegion(gl, regionRenderer, 0), null);
-
+ jogampRegion.getRegion(gl, regionRenderer, 0).draw(gl, regionRenderer, null);
if(null == labelRegions[currentText]) {
if( null == labels[currentText]) {
labels[currentText] = new Label(SVertex.factory(), font, fontSizeFixed, strings[currentText]){
@@ -321,14 +320,14 @@ public class GPUUISceneGLListener0A implements GLEventListener {
regionRenderer.rotate(gl, zoomText, 0, 1, 0);
regionRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
- regionRenderer.draw(gl, labelRegions[currentText].getRegion(gl, regionRenderer, renderModes2), texSize2);
+ labelRegions[currentText].getRegion(gl, regionRenderer, renderModes2).draw(gl, regionRenderer, texSize2);
final GLAnimatorControl animator = drawable.getAnimator();
final boolean _drawFPS = showFPS && null != animator;
if(_drawFPS && fps != animator.getTotalFPS()) {
if(null != fpsRegion) {
- fpsRegion.destroy(gl, rs);
+ fpsRegion.destroy(gl, regionRenderer);
}
fps = animator.getTotalFPS();
final String fpsS = String.valueOf(fps);
@@ -344,7 +343,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
if(showFPS && null != fpsRegion) {
regionRenderer.translate(gl, 0, -60, 0);
regionRenderer.scale(null, zoomText, zoomText, 1);
- regionRenderer.draw(gl, fpsRegion.getRegion(gl, regionRenderer, 0), null);
+ fpsRegion.getRegion(gl, regionRenderer, renderModes2).draw(gl, regionRenderer, null);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
index baaae3521..4ce732ef7 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java
@@ -27,14 +27,10 @@
*/
package com.jogamp.opengl.test.junit.graph.demos.ui;
-import java.util.HashMap;
-
import javax.media.opengl.GL2ES2;
-import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.curve.opengl.TextRenderUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.Vertex;
@@ -91,14 +87,14 @@ public abstract class Label extends UIShape implements UITextShape {
}
@Override
- protected void clearImpl(GL2ES2 gl, Renderer renderer) {
+ protected void clearImpl(GL2ES2 gl, RegionRenderer renderer) {
if(null != glyphRegion) {
- glyphRegion.destroy(gl, renderer.getRenderState());
+ glyphRegion.destroy(gl, renderer);
}
}
@Override
- protected void createShape(Renderer renderer) {
+ protected void createShape(RegionRenderer renderer) {
clearImpl(null, null);
glyphRegion = TextRenderUtil.createRegion(renderer.getRenderModes(), renderer.getRenderState().getVertexFactory(),
font, text, size);
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 d291c903a..6a3b9fc73 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
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.graph.demos.ui;
import javax.media.opengl.GL2ES2;
import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
@@ -79,12 +78,12 @@ public abstract class RIButton extends UIShape {
}
@Override
- protected void clearImpl(GL2ES2 gl, Renderer renderer) {
+ protected void clearImpl(GL2ES2 gl, RegionRenderer renderer) {
label.clear();
}
@Override
- protected void createShape(Renderer renderer) {
+ protected void createShape(RegionRenderer renderer) {
// FIXME: Only possible if all data (color) is
// is incl. in Outline Shape.
// Until then - draw each separately!
@@ -215,7 +214,7 @@ public abstract class RIButton extends UIShape {
if(!selection){
renderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]);
}
- renderer.draw(gl, buttonRegion.getRegion(gl, renderer, renderModes), texSize);
+ buttonRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, texSize);
gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
float[] lColor = labelColor;
@@ -225,7 +224,7 @@ public abstract class RIButton extends UIShape {
if(!selection){
renderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]);
}
- renderer.draw(gl, labelRegion.getRegion(gl, renderer, renderModes), texSize);
+ labelRegion.getRegion(gl, renderer, renderModes).draw(gl, renderer, texSize);
}
public void setPressed(boolean b) {
super.setPressed(b);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
index 7f0254ce6..08fd97ec4 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java
@@ -12,8 +12,8 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLRunnable;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
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 bfb7d8487..fa3817de8 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
@@ -34,8 +34,8 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
@@ -109,19 +109,19 @@ public class UIGLListener01 extends UIListenerBase01 {
regionRenderer.setColorStatic(gl, bColor[0], bColor[1], bColor[2]);
regionRenderer.translate(gl, button.getPosition()[0], button.getPosition()[1], button.getPosition()[2]);
- regionRenderer.draw(gl, regionButton.getRegion(gl, regionRenderer, 0), null);
+ regionButton.getRegion(gl, regionRenderer, 0).draw(gl, regionRenderer, null);
regionRenderer.setColorStatic(gl, lColor[0], lColor[1], lColor[2]);
- regionRenderer.draw(gl, regionLabel.getRegion(gl, regionRenderer, 0), null);
+ regionLabel.getRegion(gl, regionRenderer, 0).draw(gl, regionRenderer, null);
}
public void dispose(GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
if(null != regionButton) {
- regionButton.destroy(gl, getRegionRenderer().getRenderState());
+ regionButton.destroy(gl, getRegionRenderer());
regionButton = null;
}
if(null != regionLabel) {
- regionLabel.destroy(gl, getRegionRenderer().getRenderState());
+ regionLabel.destroy(gl, getRegionRenderer());
regionButton = null;
}
super.dispose(drawable);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
index ff494a5ea..acc91ce65 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
@@ -31,7 +31,6 @@ import javax.media.opengl.GL2ES2;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
import com.jogamp.opengl.math.geom.AABBox;
@@ -87,9 +86,9 @@ public abstract class UIShape {
public float[] getScale() { return scale; }
public float[] getPosition() { return position; }
- protected abstract void clearImpl(GL2ES2 gl, Renderer renderer);
+ protected abstract void clearImpl(GL2ES2 gl, RegionRenderer renderer);
- protected abstract void createShape(Renderer renderer);
+ protected abstract void createShape(RegionRenderer renderer);
public boolean updateShape() {
if( isShapeDirty() ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/opengl/UIRegion.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/opengl/UIRegion.java
index 01e1827ab..8cf987bb3 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/opengl/UIRegion.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/opengl/UIRegion.java
@@ -30,8 +30,7 @@ package com.jogamp.opengl.test.junit.graph.demos.ui.opengl;
import javax.media.opengl.GL2ES2;
import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.Renderer;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape;
import com.jogamp.opengl.test.junit.graph.demos.ui.UITextShape;
@@ -46,13 +45,14 @@ public class UIRegion {
this.uiShape = uis;
}
- public boolean updateRegion(GL2ES2 gl, Renderer renderer, int renderModes) {
+ public boolean updateRegion(GL2ES2 gl, RegionRenderer renderer, int renderModes) {
if( uiShape.updateShape() || isRegionDirty() ) {
- destroy(gl, renderer.getRenderState());
+ destroy(gl, renderer);
if(uiShape instanceof UITextShape) {
region = ((UITextShape)uiShape).getRegion();
} else {
- region = GLRegion.create(uiShape.getShape(), renderModes);
+ region = GLRegion.create(renderModes);
+ region.addOutlineShape(uiShape.getShape(), null);
}
dirty &= ~DIRTY_REGION;
return true;
@@ -60,7 +60,7 @@ public class UIRegion {
return false;
}
- public GLRegion getRegion(GL2ES2 gl, Renderer renderer, int renderModes) {
+ public GLRegion getRegion(GL2ES2 gl, RegionRenderer renderer, int renderModes) {
updateRegion(gl, renderer, renderModes);
return region;
}
@@ -69,9 +69,9 @@ public class UIRegion {
return 0 != ( dirty & DIRTY_REGION ) ;
}
- public void destroy(GL2ES2 gl, RenderState rs) {
+ public void destroy(GL2ES2 gl, RegionRenderer renderer) {
if(null != region) {
- region.destroy(gl, rs);
+ region.destroy(gl, renderer);
region = null;
}
}