summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java15
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java28
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java5
-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.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java40
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java49
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java102
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java72
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java178
23 files changed, 348 insertions, 287 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
index 55a043a14..fd1486995 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
@@ -50,7 +50,6 @@ import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener01;
import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener02;
import com.jogamp.opengl.test.junit.graph.demos.GPURendererListenerBase01;
import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.glsl.ShaderState;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -88,7 +87,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setAlphaBits(4);
GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
demo01Listener.attachInputListenerTo(window);
@@ -122,9 +121,9 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setAlphaBits(4);
GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
- GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARIABLE_CURVE_WEIGHT_BIT, 0, false, false);
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
demo01Listener.attachInputListenerTo(window);
window.addGLEventListener(demo01Listener);
@@ -153,7 +152,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setNumSamples(4);
GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
demo01Listener.attachInputListenerTo(window);
@@ -189,9 +188,9 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setNumSamples(4);
GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
- GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARIABLE_CURVE_WEIGHT_BIT, 0, false, false);
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
demo01Listener.attachInputListenerTo(window);
window.addGLEventListener(demo01Listener);
@@ -224,7 +223,7 @@ public class TestRegionRendererNEWT01 extends UITestCase {
caps.setAlphaBits(4);
GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 4, false, false);
demo02Listener.attachInputListenerTo(window);
window.addGLEventListener(demo02Listener);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
index d00e1c5ee..b5d52739e 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
@@ -60,7 +60,6 @@ import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLReadBufferUtil;
-import com.jogamp.opengl.util.glsl.ShaderState;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -210,7 +209,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
UITestCase.waitForKey("Start");
}
- final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ final RenderState rs = RenderState.createRenderState(SVertex.factory());
final int rendererMode, sampleCount;
if( graphVBAASamples > 0 ) {
rendererMode = Region.VBAA_RENDERING_BIT;
@@ -381,9 +380,11 @@ public class TestTextRendererNEWT00 extends UITestCase {
lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeAnim,
drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]);
- if( false ) {
+ if( true ) {
// renderString(drawable, font, pixelSize, "I - / H P 7 0", 0, 0, 0, 0, -1000f, true);
- renderString(drawable, font, pixelSize, "A M > } ] ", 0, 0, 0, 0, -1000f, true);
+ // renderString(drawable, font, pixelSize, "A M > } ] ", 0, 0, 0, 0, -1000f, true);
+ renderString(drawable, font, pixelSize, "M", 0, 0, 0, 0, -1000f, true);
+ // renderString(drawable, font, pixelSize, "0 6 9 a b O Q A M > } ] ", 0, 0, 0, 0, -1000f, true);
// renderString(drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, true);
// renderString(drawable, font, pixelSize, textX2, 0, 0, 0, 0, -1000f, true);
// renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000f, regionFPS); // no-cache
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 8121fc03f..c1c1dc18e 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -51,7 +51,6 @@ import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.graph.demos.GPUTextRendererListenerBase01;
import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.glsl.ShaderState;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -120,7 +119,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
window.display();
System.err.println("Chosen: "+window.getChosenGLCapabilities());
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
@@ -169,7 +168,7 @@ public class TestTextRendererNEWT01 extends UITestCase {
window.display();
System.err.println("Chosen: "+window.getChosenGLCapabilities());
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
textGLListener.attachInputListenerTo(window);
window.addGLEventListener(textGLListener);
@@ -227,10 +226,8 @@ public class TestTextRendererNEWT01 extends UITestCase {
gl.setSwapInterval(1);
gl.glEnable(GL.GL_DEPTH_TEST);
- final RegionRenderer renderer = getRenderer();
-
- renderer.setAlpha(gl, 1.0f);
- renderer.setColorStatic(gl, 0.1f, 0.1f, 0.1f);
+ final RenderState rs = getRenderer().getRenderState();
+ rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
}
public void display(GLAutoDrawable drawable) {
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 a23a50db7..ebb897484 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -52,7 +52,6 @@ import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.PMVMatrix;
-import com.jogamp.opengl.util.glsl.ShaderState;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -140,21 +139,20 @@ public class TestTextRendererNEWT10 extends UITestCase {
System.err.println("Chosen: "+winctx.window.getChosenCapabilities());
- final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ final RenderState rs = RenderState.createRenderState(SVertex.factory());
final RegionRenderer renderer = RegionRenderer.create(rs, 0, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
final TextRegionUtil textRenderUtil = new TextRegionUtil(renderer);
// init
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
renderer.init(gl);
- renderer.setAlpha(gl, 1.0f);
- renderer.setColorStatic(gl, 0.1f, 0.1f, 0.1f);
+ rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
// reshape
gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
// renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
- renderer.reshapeOrtho(gl, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
+ renderer.reshapeOrtho(drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
@@ -189,16 +187,15 @@ public class TestTextRendererNEWT10 extends UITestCase {
if(0>row) {
row = lastRow + 1;
}
- AABBox textBox = font.getStringBounds(text, fontSize);
+ AABBox textBox = font.getMetricBounds(text, fontSize);
dx += font.getAdvanceWidth('X', fontSize) * column;
dy -= (int)textBox.getHeight() * ( row + 1 );
- final PMVMatrix pmv = textRenderUtil.renderer.getMatrix();
+ final PMVMatrix pmv = textRenderUtil.renderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- textRenderUtil.renderer.updateMatrix(gl);
- textRenderUtil.drawString3D(gl, font, fontSize, text, texSize);
+ textRenderUtil.drawString3D(gl, font, fontSize, text, null, texSize);
lastRow = row;
}
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 4b89a85fb..fb4d0baf4 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -44,7 +44,6 @@ import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.Window;
import com.jogamp.opengl.util.PMVMatrix;
-import com.jogamp.opengl.util.glsl.ShaderState;
public abstract class TextRendererGLELBase implements GLEventListener {
public final int usrRenderModes;
@@ -134,16 +133,14 @@ public abstract class TextRendererGLELBase implements GLEventListener {
public void init(GLAutoDrawable drawable) {
if( null == this.rs ) {
exclusivePMVMatrix = null == sharedPMVMatrix;
- this.rs = RenderState.createRenderState(new ShaderState(), SVertex.factory(), sharedPMVMatrix);
+ this.rs = RenderState.createRenderState(SVertex.factory(), sharedPMVMatrix);
}
this.renderer = RegionRenderer.create(rs, usrRenderModes, enableCallback, disableCallback);
this.textRenderUtil = new TextRegionUtil(renderer);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
renderer.init(gl);
- renderer.setAlpha(gl, staticRGBAColor[3]);
- renderer.setColorStatic(gl, staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2]);
- final ShaderState st = rs.getShaderState();
- st.useProgram(gl, false);
+ rs.setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
+ renderer.enable(gl, false);
final Object upObj = drawable.getUpstreamWidget();
if( upObj instanceof Window ) {
@@ -157,16 +154,15 @@ public abstract class TextRendererGLELBase implements GLEventListener {
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
if( null != renderer ) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- final ShaderState st = rs.getShaderState();
- st.useProgram(gl, true);
+ renderer.enable(gl, true);
if( exclusivePMVMatrix ) {
// renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 1000.0f);
- renderer.reshapeOrtho(gl, width, height, 0.1f, 1000.0f);
+ renderer.reshapeOrtho(width, height, 0.1f, 1000.0f);
pixelScale = 1.0f;
} else {
- renderer.reshapeNotify(gl, width, height);
+ renderer.reshapeNotify(width, height);
}
- st.useProgram(gl, false);
+ renderer.enable(gl, false);
}
}
@@ -257,7 +253,7 @@ public abstract class TextRendererGLELBase implements GLEventListener {
dx += pixelScale * font.getAdvanceWidth('X', pixelSize) * column;
dy -= pixelScale * lineHeight * ( row + 1 );
- final PMVMatrix pmvMatrix = rs.pmvMatrix();
+ final PMVMatrix pmvMatrix = rs.getMatrixMutable();
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
if( !exclusivePMVMatrix ) {
pmvMatrix.glPushMatrix();
@@ -271,17 +267,17 @@ public abstract class TextRendererGLELBase implements GLEventListener {
pmvMatrix.glScalef(pixelScale, pixelScale, 1f);
}
renderer.enable(gl, true);
- renderer.updateMatrix(gl);
if( cacheRegion ) {
- textRenderUtil.drawString3D(gl, font, pixelSize, text, vbaaSampleCount);
+ textRenderUtil.drawString3D(gl, font, pixelSize, text, null, vbaaSampleCount);
} else if( null != region ) {
- TextRegionUtil.drawString3D(region, renderer, gl, font, pixelSize, text, vbaaSampleCount);
+ TextRegionUtil.drawString3D(region, renderer, gl, font, pixelSize, text, null, vbaaSampleCount);
} else {
- TextRegionUtil.drawString3D(renderer, gl, font, pixelSize, text, vbaaSampleCount);
+ TextRegionUtil.drawString3D(renderer, gl, font, pixelSize, text, null, vbaaSampleCount);
}
renderer.enable(gl, false);
if( !exclusivePMVMatrix ) {
+ rs.setMatrixDirty();
pmvMatrix.glPopMatrix();
}
lastRow = row + newLineCount;
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 f14da399e..b5ac6cdaa 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
@@ -91,7 +91,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
outlineShape.closeLastOutline(true);
region = GLRegion.create(getRenderModes());
- region.addOutlineShape(outlineShape, null);
+ region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null);
}
public void init(GLAutoDrawable drawable) {
@@ -99,13 +99,12 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final RegionRenderer regionRenderer = getRenderer();
+ final RenderState rs = getRenderer().getRenderState();
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);
+ rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f);
createTestOutline();
}
@@ -117,14 +116,13 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
final RegionRenderer regionRenderer = getRenderer();
- final PMVMatrix pmv = regionRenderer.getMatrix();
+ final PMVMatrix pmv = regionRenderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(getXTran(), getYTran(), getZTran());
pmv.glRotatef(getAngle(), 0, 1, 0);
- regionRenderer.updateMatrix(gl);
- if( weight != regionRenderer.getWeight()) {
- regionRenderer.setWeight(gl, weight);
+ if( weight != regionRenderer.getRenderState().getWeight() ) {
+ regionRenderer.getRenderState().setWeight(weight);
}
region.draw(gl, regionRenderer, getSampleCount());
}
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 23ccef640..d9e962ea6 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
@@ -93,7 +93,7 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
shape.closeLastOutline(true);
region = GLRegion.create(getRenderModes());
- region.addOutlineShapes(outlineShapes, null);
+ region.addOutlineShapes(outlineShapes, null, null);
}
public void init(GLAutoDrawable drawable) {
@@ -101,13 +101,12 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final RegionRenderer regionRenderer = getRenderer();
+ final RenderState rs = getRenderer().getRenderState();
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);
+ rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f);
createTestOutline();
}
@@ -120,14 +119,13 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
final RegionRenderer regionRenderer = getRenderer();
- final PMVMatrix pmv = regionRenderer.getMatrix();
+ final PMVMatrix pmv = regionRenderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(getXTran(), getYTran(), getZTran());
pmv.glRotatef(getAngle(), 0, 1, 0);
- regionRenderer.updateMatrix(gl);
- if( weight != regionRenderer.getWeight()) {
- regionRenderer.setWeight(gl, weight);
+ if( weight != regionRenderer.getRenderState().getWeight() ) {
+ regionRenderer.getRenderState().setWeight(weight);
}
region.draw(gl, regionRenderer, getSampleCount());
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
index 7bcbe0484..7897d0a00 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo.java
@@ -41,7 +41,6 @@ import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.glsl.ShaderState;
/** Demonstrate the rendering of multiple outlines into one region/OutlineShape
* These Outlines are not necessary connected or contained.
@@ -97,7 +96,7 @@ public class GPURegionNewtDemo {
}
System.out.println("Requested: " + caps);
- int rmode = GraphUseWeight ? Region.VARIABLE_CURVE_WEIGHT_BIT : 0;
+ int rmode = GraphUseWeight ? Region.VARWEIGHT_RENDERING_BIT : 0;
int sampleCount = 0;
if( GraphVBAASamples > 0 ) {
rmode |= Region.VBAA_RENDERING_BIT;
@@ -112,7 +111,7 @@ public class GPURegionNewtDemo {
window.setSize(800, 400);
window.setTitle("GPU Curve Region Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, rmode, sampleCount, DEBUG, TRACE);
regionGLListener.attachInputListenerTo(window);
window.addGLEventListener(regionGLListener);
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 30c6bdea5..65ed86947 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
@@ -46,6 +46,7 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
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.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -145,13 +146,10 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
@Override
public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- final PMVMatrix pmv = renderer.getMatrix();
- renderer.reshapePerspective(null, 45.0f, width, height, zNear, zFar);
+ final PMVMatrix pmv = renderer.getMatrixMutable();
+ renderer.reshapePerspective(45.0f, width, height, zNear, zFar);
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
- renderer.updateMatrix(gl);
System.err.printf("Reshape: zNear %f, zFar %f%n", zNear, zFar);
System.err.printf("Reshape: Frustum: %s%n", pmv.glGetFrustum());
{
@@ -207,7 +205,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
dumpMatrix();
}
public void editGlobalWeight(float delta) {
- if( !RegionRenderer.isWeightValid(weight+delta) ) {
+ if( !RenderState.isWeightValid(weight+delta) ) {
return;
}
weight += delta;
@@ -328,7 +326,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
public boolean run(GLAutoDrawable drawable) {
try {
final String modeS = Region.getRenderModeString(renderer.getRenderModes());
- final String type = modeS + ( Region.isNonUniformWeight(renderModes) ? "-vc" : "-uc" ) ;
+ final String type = modeS + ( Region.hasVariableWeight(renderModes) ? "-vc" : "-uc" ) ;
printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false);
screenshot_num++;
} catch (GLException e) {
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 a484c08ef..08d2f0d70 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
@@ -36,12 +36,11 @@ import com.jogamp.graph.curve.opengl.RenderState;
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;
public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 {
public GPUTextGLListener0A() {
- super(RenderState.createRenderState(new ShaderState(), SVertex.factory()), Region.VBAA_RENDERING_BIT, 4, true, false, false);
+ super(RenderState.createRenderState(SVertex.factory()), Region.VBAA_RENDERING_BIT, 4, true, false, false);
}
public GPUTextGLListener0A(RenderState rs, int renderModes, int sampleCount, boolean blending, boolean debug, boolean trace) {
@@ -57,13 +56,12 @@ public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 {
GL2ES2 gl = drawable.getGL().getGL2ES2();
- final RegionRenderer renderer = getRenderer();
+ final RenderState rs = getRenderer().getRenderState();
gl.setSwapInterval(1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
gl.glEnable(GL2ES2.GL_BLEND);
- renderer.setAlpha(gl, 1.0f);
- renderer.setColorStatic(gl, 0.1f, 0.1f, 0.1f);
+ rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
}
public void dispose(GLAutoDrawable drawable) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
index f63b9b70a..e6b1f9c9c 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java
@@ -40,7 +40,6 @@ import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.glsl.ShaderState;
public class GPUTextNewtDemo {
/**
@@ -110,7 +109,7 @@ public class GPUTextNewtDemo {
window.setSize(800, 400);
window.setTitle("GPU Text Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, rmode, sampleCount, true, DEBUG, TRACE);
// ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32);
window.addGLEventListener(textGLListener);
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 f187dcc6b..7372eb8f6 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
@@ -156,7 +156,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
headtext = text1;
}
if(null != headtext) {
- headbox = font.getStringBounds(headtext, font.getPixelSize(fontSizeHead, dpiH));
+ headbox = font.getMetricBounds(headtext, font.getPixelSize(fontSizeHead, dpiH));
}
}
@@ -169,7 +169,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
((Window)upObj).getMainMonitor().getPixelsPerMM(pixelsPerMM);
dpiH = pixelsPerMM[1]*25.4f;
}
- fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
+ fontNameBox = font.getMetricBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
switchHeadBox();
}
@@ -213,10 +213,11 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
// final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() };
final RegionRenderer renderer = getRenderer();
- final PMVMatrix pmv = renderer.getMatrix();
+ final RenderState rs = renderer.getRenderState();
+ final PMVMatrix pmv = renderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
- renderer.setColorStatic(gl, 0.1f, 0.1f, 0.1f);
+ rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
if( renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
@@ -245,45 +246,44 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
// bottom, half line up
pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0);
- renderer.updateMatrix(gl);
// No cache, keep region alive!
- TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, nearPlaneS * pixelSizeFPS, text, sampleCountFPS);
+ TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, nearPlaneS * pixelSizeFPS, text, null, sampleCountFPS);
}
float dx = width-fontNameBox.getWidth()-2f;
float dy = height - 10f;
+ renderer.setMatrixDirty();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
- renderer.updateMatrix(gl);
// System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeFName, fontName, getSampleCount());
+ textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeFName, fontName, null, getSampleCount());
dx = 10f;
dy += -fontNameBox.getHeight() - 10f;
if(null != headtext) {
+ renderer.setMatrixDirty();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
// System.err.printf("Head: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
// pmv.glTranslatef(x0, y1, z0);
- renderer.updateMatrix(gl);
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeHead, headtext, getSampleCount());
+ textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeHead, headtext, null, getSampleCount());
}
dy += -headbox.getHeight() - font.getLineHeight(pixelSizeBottom);
+ renderer.setMatrixDirty();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
// System.err.printf("Bottom: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
pmv.glTranslatef(getXTran(), getYTran(), getZTran());
pmv.glRotatef(getAngle(), 0, 1, 0);
- renderer.updateMatrix(gl);
- renderer.setColorStatic(gl, 0.9f, 0.0f, 0.0f);
+ rs.setColorStatic(0.9f, 0.0f, 0.0f, 1.0f);
if( renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
}
@@ -293,15 +293,15 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
}
if(!userInput) {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, text2, getSampleCount());
+ TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
} else {
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, text2, getSampleCount());
+ textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
}
} else {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), getSampleCount());
+ TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
} else {
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), getSampleCount());
+ textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
}
}
}
@@ -315,7 +315,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
public void fontHeadIncr(int v) {
fontSizeHead = Math.abs((fontSizeHead + v) % fontSizeModulo) ;
if(null != headtext) {
- headbox = font.getStringBounds(headtext, font.getPixelSize(fontSizeHead, dpiH));
+ headbox = font.getMetricBounds(headtext, font.getPixelSize(fontSizeHead, dpiH));
}
}
@@ -327,7 +327,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
fontSet = set;
font = _font;
fontName = font.getFullFamilyName(null).toString();
- fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
+ fontNameBox = font.getMetricBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
dumpFontNames();
return true;
}
@@ -344,7 +344,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
fontSet = set;
font = _font;
fontName = font.getFullFamilyName(null).toString();
- fontNameBox = font.getStringBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
+ fontNameBox = font.getMetricBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
dumpFontNames();
return true;
}
@@ -359,7 +359,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
void dumpMatrix(boolean bbox) {
System.err.println("Matrix: " + getXTran() + "/" + getYTran() + " x"+getZTran() + " @"+getAngle() +" fontSize "+fontSizeBottom);
if(bbox) {
- System.err.println("bbox: "+font.getStringBounds(text2, nearPlaneS * font.getPixelSize(fontSizeBottom, dpiH)));
+ System.err.println("bbox: "+font.getMetricBounds(text2, nearPlaneS * font.getPixelSize(fontSizeBottom, dpiH)));
}
}
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 f9becfaed..b3b17375d 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
@@ -33,7 +33,6 @@ import com.jogamp.opengl.test.junit.graph.demos.ui.RIButton;
import com.jogamp.opengl.test.junit.graph.demos.ui.SceneUIController;
import com.jogamp.opengl.test.junit.graph.demos.ui.UIShape;
import com.jogamp.opengl.util.GLReadBufferUtil;
-import com.jogamp.opengl.util.glsl.ShaderState;
public class GPUUISceneGLListener0A implements GLEventListener {
@@ -87,12 +86,12 @@ public class GPUUISceneGLListener0A implements GLEventListener {
}
public GPUUISceneGLListener0A(int renderModes) {
- this(RenderState.createRenderState(new ShaderState(), SVertex.factory()), renderModes, false, false);
+ this(RenderState.createRenderState(SVertex.factory()), renderModes, false, false);
}
public GPUUISceneGLListener0A(RenderState rs, int renderModes, boolean debug, boolean trace) {
this.rs = rs;
- this.renderModes = renderModes;
+ this.renderModes = renderModes | Region.COLORCHANNEL_RENDERING_BIT;
this.debug = debug;
this.trace = trace;
@@ -261,14 +260,41 @@ public class GPUUISceneGLListener0A implements GLEventListener {
} } );
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
+
+ button = new RIButton(SVertex.factory(), font, "< quality >", buttonXSize, buttonYSize);
+ button.translate(xstart,ystart - diffY*buttons.size(), 0f);
+ button.setLabelColor(1.0f, 1.0f, 1.0f);
+ button.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ final Object attachment = e.getAttachment();
+ if( attachment instanceof UIShape.EventDetails ) {
+ final UIShape.EventDetails shapeEvent = (UIShape.EventDetails)attachment;
+ int quality = shapeEvent.shape.getQuality();
+
+ if( shapeEvent.rotPosition[0] < shapeEvent.rotBounds.getCenter()[0] ) {
+ // left-half pressed
+ if( quality > 0 ) {
+ quality=0;
+ }
+ } else {
+ // right-half pressed
+ if( quality < 1 ) {
+ quality=1;
+ }
+ }
+ sceneUIController.setAllShapesQuality(quality);
+ }
+ } } );
+ button.addMouseListener(dragZoomRotateListener);
+ buttons.add(button);
}
button = new RIButton(SVertex.factory(), font, "Quit", buttonXSize, buttonYSize);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
- button.setColor(0.8f, 0.0f, 0.0f);
+ button.setColor(0.8f, 0.0f, 0.0f, 1.0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
- button.setSelectedColor(0.8f, 0.8f, 0.8f);
- button.setLabelSelectedColor(0.8f, 0.0f, 0.0f);
+ button.setSelectedColorMod(0.8f, 0.8f, 0.8f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@@ -511,7 +537,6 @@ public class GPUUISceneGLListener0A implements GLEventListener {
gl.glEnable(GL2ES2.GL_BLEND);
renderer.init(gl);
- renderer.setAlpha(gl, 1.0f);
initTexts();
@@ -529,7 +554,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
sceneUIController.addShape(truePtSizeLabel);
truePtSizeLabel.setEnabled(enableOthers);
truePtSizeLabel.translate(0, - 1.5f * jogampLabel.getLineHeight(), 0f);
- truePtSizeLabel.setColor(0.1f, 0.1f, 0.1f);
+ truePtSizeLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f);
/**
*
@@ -541,7 +566,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
fpsLabel.addMouseListener(dragZoomRotateListener);
sceneUIController.addShape(fpsLabel);
fpsLabel.setEnabled(enableOthers);
- fpsLabel.setColor(0.3f, 0.3f, 0.3f);
+ fpsLabel.setColor(0.3f, 0.3f, 0.3f, 1.0f);
crossHairCtr = new CrossHair(renderer.getRenderState().getVertexFactory(), 100f, 100f, 2f);
crossHairCtr.addMouseListener(dragZoomRotateListener);
@@ -603,7 +628,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
final float dyTop = drawable.getHeight() * relTop;
final float dxRight = drawable.getWidth() * relRight;
labels[currentText] = new Label(SVertex.factory(), font, pixelSizeFixed, strings[currentText]);
- labels[currentText].setColor(0.1f, 0.1f, 0.1f);
+ labels[currentText].setColor(0.1f, 0.1f, 0.1f, 1.0f);
labels[currentText].setEnabled(enableOthers);
labels[currentText].translate(dxRight,
dyTop - 1.5f * jogampLabel.getLineHeight()
@@ -627,8 +652,8 @@ public class GPUUISceneGLListener0A implements GLEventListener {
final String text;
if( null == actionText ) {
final String timePrec = gl.isGLES() ? "4.0" : "4.1";
- text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize %.1f, %s-samples %d, td %"+timePrec+"f, blend %b, alpha-bits %d, msaa-bits %d",
- lfps, tfps, gl.getSwapInterval(), fontSizeFixedPVP, modeS, sceneUIController.getSampleCount(), td,
+ text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize %.1f, %s-samples %d, q %d, td %"+timePrec+"f, blend %b, alpha-bits %d, msaa-bits %d",
+ lfps, tfps, gl.getSwapInterval(), fontSizeFixedPVP, modeS, sceneUIController.getSampleCount(), fpsLabel.getQuality(), td,
renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED),
drawable.getChosenGLCapabilities().getAlphaBits(),
drawable.getChosenGLCapabilities().getNumSamples());
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
index c59d85824..a4da58eac 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java
@@ -11,7 +11,6 @@ import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.glsl.ShaderState;
public class GPUUISceneNewtDemo {
static final boolean DEBUG = false;
@@ -68,14 +67,14 @@ public class GPUUISceneNewtDemo {
window.setSize(800, 400);
window.setTitle("GraphUI Newt Demo: graph["+Region.getRenderModeString(rmode)+"], msaa "+SceneMSAASamples);
- final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ final RenderState rs = RenderState.createRenderState(SVertex.factory());
GPUUISceneGLListener0A sceneGLListener = new GPUUISceneGLListener0A(rs, rmode, DEBUG, TRACE);
window.addGLEventListener(sceneGLListener);
sceneGLListener.attachInputListenerTo(window);
final Animator animator = new Animator();
- animator.setUpdateFPSFrames(60, null); // System.err);
+ animator.setUpdateFPSFrames(60, System.err);
animator.add(window);
window.addWindowListener(new WindowAdapter() {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java
index 75fc0eb8f..450d5743a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java
@@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.graph.demos.ui;
import javax.media.opengl.GL2ES2;
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.OutlineShapeXForm;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
@@ -56,7 +55,7 @@ public class CrossHair extends UIShape {
this.width = width;
this.height = height;
this.lineWidth = lineWidth;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
@Override
@@ -68,7 +67,7 @@ public class CrossHair extends UIShape {
}
@Override
- protected void createShape(GL2ES2 gl, RegionRenderer renderer) {
+ protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) {
final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
final float tw = getWidth();
@@ -97,7 +96,9 @@ public class CrossHair extends UIShape {
shape.addVertex(ctrX-twh, ctrY+lwh, ctrZ, true);
shape.closeLastOutline(true);
- shapes.add(new OutlineShapeXForm(shape, null));
+ shape.setIsQuadraticNurbs();
+ shape.setSharpness(shapesSharpness);
+ region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
}
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 78c42b2d0..2f942fd13 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
@@ -32,7 +32,6 @@ import javax.media.opengl.GL2ES2;
import jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.OutlineShapeXForm;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
import com.jogamp.graph.font.Font;
@@ -57,7 +56,7 @@ public class Label extends UIShape {
public void setText(String text) {
this.text = text;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
public Font getFont() {
@@ -66,7 +65,7 @@ public class Label extends UIShape {
public void setFont(Font font) {
this.font = font;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
public float getPixelSize() {
@@ -79,7 +78,7 @@ public class Label extends UIShape {
public void setPixelSize(float pixelSize) {
this.pixelSize = pixelSize;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
@Override
@@ -95,14 +94,15 @@ public class Label extends UIShape {
private final TextRegionUtil.ShapeVisitor shapeVisitor = new TextRegionUtil.ShapeVisitor() {
@Override
public void visit(OutlineShape shape, AffineTransform t) {
- shapes.add(new OutlineShapeXForm(shape, new AffineTransform(t)));
+ shape.setSharpness(shapesSharpness);
+ region.addOutlineShape(shape, t, rgbaColor);
box.resize(shape.getBounds(), t, tmpV3);
}
};
@Override
- protected void createShape(GL2ES2 gl, RegionRenderer renderer) {
- TextRegionUtil.processString(shapeVisitor, new AffineTransform(), font, pixelSize, text);
+ protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) {
+ TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text);
final float[] ctr = box.getCenter();
setRotationOrigin( ctr[0], ctr[1], ctr[2]);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java
new file mode 100644
index 000000000..dff9cd1c7
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java
@@ -0,0 +1,102 @@
+/**
+ * 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.opengl.test.junit.graph.demos.ui;
+
+import jogamp.graph.geom.plane.AffineTransform;
+
+import com.jogamp.graph.curve.OutlineShape;
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.TextRegionUtil;
+import com.jogamp.graph.font.Font;
+import com.jogamp.opengl.math.geom.AABBox;
+
+public class Label0 {
+ protected Font font;
+ protected String text;
+ protected final float[] rgbaColor;
+ protected final AABBox box;
+
+ public Label0(Font font, String text, float[] rgbaColor) {
+ this.font = font;
+ this.text = text;
+ this.rgbaColor = rgbaColor;
+ this.box = new AABBox();
+ }
+
+ public final String getText() { return text; }
+
+ public final float[] getColor() { return rgbaColor; }
+
+ public final void setColor(float r, float g, float b, float a) {
+ this.rgbaColor[0] = r;
+ this.rgbaColor[1] = g;
+ this.rgbaColor[2] = b;
+ this.rgbaColor[3] = a;
+ }
+
+ public final void setText(String text) {
+ this.text = text;
+ }
+
+ public final Font getFont() { return font; }
+
+ public final void setFont(Font font) {
+ this.font = font;
+ }
+
+ public final AABBox getBounds() { return box; }
+
+ private final float[] tmpV3 = new float[3];
+
+ private final TextRegionUtil.ShapeVisitor shapeVisitor = new TextRegionUtil.ShapeVisitor() {
+ @Override
+ public void visit(OutlineShape shape, AffineTransform t) {
+ final AffineTransform t1 = new AffineTransform(tLeft).concatenate( t );
+ region.addOutlineShape(shape, t1, rgbaColor);
+ box.resize(shape.getBounds(), t1, tmpV3);
+ }
+ };
+
+ private Region region;
+ private AffineTransform tLeft;
+
+ public final AABBox addShapeToRegion(final float pixelSize, final Region region, final AffineTransform tLeft) {
+ box.reset();
+ this.region = region;
+ this.tLeft = tLeft;
+ TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text);
+ this.region = null;
+ this.tLeft = null;
+ return box;
+ }
+
+ @Override
+ public final String toString(){
+ return "Label0 [" + font.toString() + ", " + getText() + "]";
+ }
+}
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 cfce04dd0..d46343f9d 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
@@ -29,8 +29,9 @@ package com.jogamp.opengl.test.junit.graph.demos.ui;
import javax.media.opengl.GL2ES2;
+import jogamp.graph.geom.plane.AffineTransform;
+
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.OutlineShapeXForm;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.Vertex;
@@ -49,7 +50,7 @@ public class RIButton extends UIShape {
public static final float DEFAULT_CORNER = 1f;
private float width, height;
- private final Label label;
+ private final Label0 label;
private float spacingX = DEFAULT_SPACING_X;
private float spacingY = DEFAULT_SPACING_Y;
private float corner = DEFAULT_CORNER;
@@ -58,13 +59,7 @@ public class RIButton extends UIShape {
public RIButton(Factory<? extends Vertex> factory, Font labelFont, String labelText, float width, float height) {
super(factory);
- final float pixelSize = height * ( 1f - spacingY ) ;
- System.err.printf("RIButton: height %f -> pixelSize %f%n", height, pixelSize);
- this.label = new Label(factory, labelFont, pixelSize, labelText);
- this.label.setSelectedColor(this.color[0], this.color[1], this.color[2]);
- this.label.setColor(0.9f, 0.9f, 0.9f);
- this.label.setSelectedColor(1f, 1f, 1f);
-
+ this.label = new Label0(labelFont, labelText, new float[] { 0.9f, 0.9f, 0.9f, 1.0f });
this.width = width;
this.height = height;
}
@@ -72,82 +67,73 @@ public class RIButton extends UIShape {
public final float getWidth() { return width; }
public final float getHeight() { return height; }
public final float getCorner() { return corner; }
- public final Label getLabel() { return label; }
public void setDimension(float width, float height) {
this.width = width;
this.height = height;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
@Override
protected void clearImpl(GL2ES2 gl, RegionRenderer renderer) {
- label.clear(gl, renderer);
}
@Override
protected void destroyImpl(GL2ES2 gl, RegionRenderer renderer) {
- label.destroy(gl, renderer);
}
@Override
public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) {
- gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL);
- gl.glPolygonOffset(0.0f, 1f);
+ // No need to setup an poly offset for z-fighting, using one region now
+ // gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL);
+ // gl.glPolygonOffset(0.0f, 1f);
super.drawShape(gl, renderer, sampleCount);
- gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
-
- label.drawShape(gl, renderer, sampleCount);
+ // gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
}
@Override
- protected void createShape(GL2ES2 gl, RegionRenderer renderer) {
- label.clear(gl, renderer);
-
+ protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) {
final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
if(corner == 0.0f) {
createSharpOutline(shape);
} else {
createCurvedOutline(shape);
}
+ shape.setIsQuadraticNurbs();
+ shape.setSharpness(shapesSharpness);
+ region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
// Precompute text-box size .. guessing pixelSize
final float lPixelSize0 = 10f;
final float lw = width * ( 1f - spacingX ) ;
final float lh = height * ( 1f - spacingY ) ;
- final AABBox lbox0 = label.font.getStringBounds(label.text, lPixelSize0);
+ final AABBox lbox0 = label.font.getMetricBounds(label.text, lPixelSize0);
final float lsx = lw / lbox0.getWidth();
final float lsy = lh / lbox0.getHeight();
final float lPixelSize1 = lsx < lsy ? lPixelSize0 * lsx : lPixelSize0 * lsy;
if( DRAW_DEBUG_BOX ) {
System.err.println("RIButton: spacing "+spacingX+", "+spacingY);
System.err.println("RIButton: bbox "+box);
- System.err.println("RIButton: lbox "+lbox0);
+ System.err.println("RIButton: lbox "+lbox0+", "+label.text);
System.err.println("RIButton: net-text "+lw+" x "+lh);
System.err.println("RIButton: lsx "+lsx+", lsy "+lsy+": pixelSize "+lPixelSize0+" -> "+lPixelSize1);
}
// Setting pixelSize based on actual text-box size
- label.setPixelSize(lPixelSize1);
- label.createShape(gl, renderer);
- final AABBox lbox1 = label.getBounds();
- if( DRAW_DEBUG_BOX ) {
- System.err.printf("RIButton: lbox1 %s .... %s%n", lbox1, this.label.text);
- }
-
+ final AABBox lbox1 = label.font.getPointsBounds(null, label.text, lPixelSize1);
// Center text .. (share same center w/ button)
final float[] lctr = lbox1.getCenter();
final float[] ctr = box.getCenter();
final float[] ltx = new float[] { ctr[0] - lctr[0], ctr[1] - lctr[1], 0f };
- label.translateShape( ltx[0], ltx[1] );
- lbox1.translate( ltx );
- // rotate center of button/label ..
- label.setRotationOrigin( ctr[0], ctr[1], ctr[2]);
- setRotationOrigin( ctr[0], ctr[1], ctr[2]);
+ final AABBox lbox2 = label.addShapeToRegion(lPixelSize1, region, AffineTransform.getTranslateInstance(ltx[0], ltx[1]));
+ if( DRAW_DEBUG_BOX ) {
+ System.err.printf("RIButton.0: lbox1 %s%n", lbox1);
+ System.err.printf("RIButton.0: lbox2 %s%n", lbox2);
+ }
- shapes.add(new OutlineShapeXForm(shape, null));
+ setRotationOrigin( ctr[0], ctr[1], ctr[2]);
if( DRAW_DEBUG_BOX ) {
System.err.println("XXX.UIShape.RIButton: Added Shape: "+shape+", "+box);
@@ -205,7 +191,7 @@ public class RIButton extends UIShape {
else{
this.corner = corner;
}
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
public float getLabelZOffset() {
@@ -214,7 +200,7 @@ public class RIButton extends UIShape {
public void setLabelZOffset(float labelZOffset) {
this.labelZOffset = -labelZOffset;
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
public final float getSpacingX() { return spacingX; }
public final float getSpacingY() { return spacingY; }
@@ -239,7 +225,7 @@ public class RIButton extends UIShape {
} else {
this.spacingY = spacingY;
}
- dirty |= DIRTY_SHAPE | DIRTY_REGION;
+ dirty |= DIRTY_SHAPE;
}
public float[] getLabelColor() {
@@ -247,17 +233,13 @@ public class RIButton extends UIShape {
}
public void setLabelColor(float r, float g, float b) {
- label.setColor(r, g, b);
- }
-
- public void setLabelSelectedColor(float r, float g, float b){
- label.setSelectedColor(r, g, b);
+ label.setColor(r, g, b, 1.0f);
}
@Override
public String toString() {
return "RIButton [" + translate[0]+getWidth()/2f+" / "+translate[1]+getHeight()/2f+" "+getWidth() + "x" + getHeight() + ", "
- + getLabel() + ", " + "spacing: " + spacingX+"/"+spacingY
+ + label + ", " + "spacing: " + spacingX+"/"+spacingY
+ ", " + "corner: " + corner + ", " + "shapeOffset: " + labelZOffset + ", "+box+" ]";
}
}
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 124729563..4f77ad3ad 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
@@ -82,6 +82,16 @@ public class SceneUIController implements GLEventListener{
public int getSampleCount() { return sampleCount[0]; }
public void setSampleCount(int v) { sampleCount[0]=v; markAllShapesDirty(); }
+ public void setAllShapesQuality(final int q) {
+ for(int i=0; i<shapes.size(); i++) {
+ shapes.get(i).setQuality(q);
+ }
+ }
+ public void setAllShapesSharpness(final float sharpness) {
+ for(int i=0; i<shapes.size(); i++) {
+ shapes.get(i).setSharpness(sharpness);
+ }
+ }
public void markAllShapesDirty() {
for(int i=0; i<shapes.size(); i++) {
shapes.get(i).markDirty();
@@ -168,7 +178,7 @@ public class SceneUIController implements GLEventListener{
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- final PMVMatrix pmv = renderer.getMatrix();
+ final PMVMatrix pmv = renderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
final int shapeCount = shapes.size();
@@ -178,8 +188,8 @@ public class SceneUIController implements GLEventListener{
uiShape.validate(gl, renderer);
pmv.glPushMatrix();
transformShape(pmv, uiShape);
- renderer.updateMatrix(gl);
uiShape.drawShape(gl, renderer, sampleCount);
+ renderer.setMatrixDirty();
pmv.glPopMatrix();
}
}
@@ -206,9 +216,8 @@ public class SceneUIController implements GLEventListener{
viewport[2] = width;
viewport[3] = height;
- final GL2ES2 gl = drawable.getGL().getGL2ES2();
- final PMVMatrix pmv = renderer.getMatrix();
- renderer.reshapePerspective(gl, 45.0f, width, height, zNear, zFar);
+ final PMVMatrix pmv = renderer.getMatrixMutable();
+ renderer.reshapePerspective(45.0f, width, height, zNear, zFar);
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
@@ -249,7 +258,6 @@ public class SceneUIController implements GLEventListener{
pmv.glTranslatef(scenePlaneOrigin[0], scenePlaneOrigin[1], scenePlaneOrigin[2]);
pmv.glScalef(sceneScale[0], sceneScale[1], sceneScale[2]);
- renderer.updateMatrix(gl);
}
public UIShape getActiveUI() {
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 d8b28c518..5010e2d94 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
@@ -89,13 +89,12 @@ public class UIGLListener01 extends UIListenerBase01 {
final float[] translate = button.getTranslate();
final RegionRenderer regionRenderer = getRegionRenderer();
- final PMVMatrix pmv = regionRenderer.getMatrix();
+ final PMVMatrix pmv = regionRenderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(getXTran(), getYTran(), getZoom());
pmv.glRotatef(getAngle(), 0, 1, 0);
pmv.glTranslatef(translate[0], translate[1], 0);
- regionRenderer.updateMatrix(gl);
button.drawShape(gl, regionRenderer, sampleCount);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
index 6c192e37d..21a2b079d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
@@ -119,7 +119,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
GL2ES2 gl = drawable.getGL().getGL2ES2();
gl.glViewport(xstart, ystart, width, height);
- rRenderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 7000.0f);
+ rRenderer.reshapePerspective(45.0f, width, height, 0.1f, 7000.0f);
dumpMatrix();
}
@@ -208,12 +208,12 @@ public abstract class UIListenerBase01 implements GLEventListener {
public void mousePressed(MouseEvent e) {
button.setLabelColor(0.8f,0.8f,0.8f);
- button.setColor(0.1f, 0.1f, 0.1f);
+ button.setColor(0.1f, 0.1f, 0.1f, 1.0f);
}
public void mouseReleased(MouseEvent e) {
button.setLabelColor(1.0f,1.0f,1.0f);
- button.setColor(0.6f,0.6f,0.6f);
+ button.setColor(0.6f,0.6f,0.6f, 1.0f);
}
public void mouseMoved(MouseEvent e) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
index 031d43e79..2c444d47e 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
@@ -39,7 +39,6 @@ import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.glsl.ShaderState;
/** Demonstrate the rendering of multiple outlines into one region/OutlineShape
* These Outlines are not necessary connected or contained.
@@ -64,7 +63,7 @@ public class UINewtDemo01 {
window.setPosition(10, 10);
window.setSize(800, 400);
window.setTitle("GPU UI Newt Demo 01");
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ RenderState rs = RenderState.createRenderState(SVertex.factory());
UIGLListener01 uiGLListener = new UIGLListener01 (rs, DEBUG, TRACE);
uiGLListener.attachInputListenerTo(window);
window.addGLEventListener(uiGLListener);
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 58c237e8c..bca60494b 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
@@ -32,10 +32,7 @@ import java.util.ArrayList;
import javax.media.nativewindow.NativeWindowException;
import javax.media.opengl.GL2ES2;
-import jogamp.graph.geom.plane.AffineTransform;
-
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.OutlineShapeXForm;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
@@ -54,11 +51,9 @@ public abstract class UIShape {
private final Factory<? extends Vertex> vertexFactory;
- protected final ArrayList<OutlineShapeXForm> shapes;
-
protected static final int DIRTY_SHAPE = 1 << 0 ;
- protected static final int DIRTY_REGION = 1 << 2 ;
- protected int dirty = DIRTY_SHAPE | DIRTY_REGION;
+ protected int dirty = DIRTY_SHAPE;
+ protected float shapesSharpness = OutlineShape.DEFAULT_SHARPNESS;
protected final AABBox box;
protected final float[] translate = new float[] { 0f, 0f, 0f };
@@ -66,12 +61,11 @@ public abstract class UIShape {
protected final float[] rotOrigin = new float[] { 0f, 0f, 0f };
protected final float[] scale = new float[] { 1f, 1f, 1f };
- protected final float[] shapeTranslate2D = new float[] { 0f, 0f };
- protected final float[] shapeScale2D = new float[] { 1f, 1f };
- private GLRegion region = null;
+ protected GLRegion region = null;
+ protected int regionQuality = 99;
- protected final float[] color = {0.6f, 0.6f, 0.6f};
- protected final float[] selectedColor = {0.8f, 0.8f, 0.8f};
+ protected final float[] rgbaColor = {0.6f, 0.6f, 0.6f, 1.0f};
+ protected final float[] selectedRGBAModulate = {1.4f, 1.4f, 1.4f, 1.0f};
private boolean down = false;
private boolean toggle =false;
@@ -81,7 +75,6 @@ public abstract class UIShape {
public UIShape(Factory<? extends Vertex> factory) {
this.vertexFactory = factory;
- this.shapes = new ArrayList<OutlineShapeXForm>();
this.box = new AABBox();
}
@@ -97,7 +90,6 @@ public abstract class UIShape {
*/
public void clear(GL2ES2 gl, RegionRenderer renderer) {
clearImpl(gl, renderer);
- shapes.clear();
translate[0] = 0f;
translate[1] = 0f;
translate[2] = 0f;
@@ -108,12 +100,8 @@ public abstract class UIShape {
scale[0] = 1f;
scale[1] = 1f;
scale[2] = 1f;
- shapeTranslate2D[0] = 0f;
- shapeTranslate2D[1] = 0f;
- shapeScale2D[0] = 1f;
- shapeScale2D[1] = 1f;
box.reset();
- dirty = DIRTY_SHAPE | DIRTY_REGION;
+ dirty = DIRTY_SHAPE;
}
/**
@@ -123,7 +111,6 @@ public abstract class UIShape {
*/
public void destroy(GL2ES2 gl, RegionRenderer renderer) {
destroyImpl(gl, renderer);
- shapes.clear();
translate[0] = 0f;
translate[1] = 0f;
translate[2] = 0f;
@@ -134,12 +121,8 @@ public abstract class UIShape {
scale[0] = 1f;
scale[1] = 1f;
scale[2] = 1f;
- shapeTranslate2D[0] = 0f;
- shapeTranslate2D[1] = 0f;
- shapeScale2D[0] = 1f;
- shapeScale2D[1] = 1f;
box.reset();
- dirty = DIRTY_SHAPE | DIRTY_REGION;
+ dirty = DIRTY_SHAPE;
}
public void setTranslate(float tx, float ty, float tz) {
@@ -174,42 +157,17 @@ public abstract class UIShape {
}
public final float[] getScale() { return scale; }
- public final void translateShape(float tx, float ty) {
- shapeTranslate2D[0] += tx;
- shapeTranslate2D[1] += ty;
- }
- public final void scaleShape(float sx, float sy) {
- shapeScale2D[0] *= sx;
- shapeScale2D[1] *= sy;
- }
-
public final void markDirty() {
- dirty = DIRTY_SHAPE | DIRTY_REGION;
+ dirty = DIRTY_SHAPE;
}
public final boolean isShapeDirty() {
return 0 != ( dirty & DIRTY_SHAPE ) ;
}
- public final boolean isRegionDirty() {
- return 0 != ( dirty & DIRTY_REGION ) ;
- }
-
- public ArrayList<OutlineShapeXForm> getShapes() { return shapes; }
-
public final AABBox getBounds() { return box; }
public GLRegion getRegion(GL2ES2 gl, RegionRenderer renderer) {
validate(gl, renderer);
- if( isRegionDirty() ) {
- if( null == region ) {
- region = GLRegion.create(renderer.getRenderModes());
- } else {
- region.clear(gl, renderer);
- }
- addToRegion(region);
- dirty &= ~DIRTY_REGION;
- // System.err.println("XXX.UIShape: updated: "+region);
- }
return region;
}
@@ -223,85 +181,93 @@ public abstract class UIShape {
* @param sampleCount
*/
public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) {
- final float[] _color;
+ final float r, g, b, a;
+ final boolean isSelect;
if( isPressed() || toggle ) {
- _color = selectedColor;
+ isSelect = true;
+ r = rgbaColor[0]*selectedRGBAModulate[0];
+ g = rgbaColor[1]*selectedRGBAModulate[1];
+ b = rgbaColor[2]*selectedRGBAModulate[2];
+ a = rgbaColor[3]*selectedRGBAModulate[3];
} else {
- _color = color;
-
+ isSelect = false;
+ r = rgbaColor[0];
+ g = rgbaColor[1];
+ b = rgbaColor[2];
+ a = rgbaColor[3];
}
+
if( renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
- gl.glClearColor(_color[0], _color[1], _color[2], 0.0f);
+ gl.glClearColor(r, g, b, 0.0f);
}
- renderer.setColorStatic(gl, _color[0], _color[1], _color[2]);
+ final RenderState rs = renderer.getRenderState();
+ if( Region.hasColorChannel( renderer.getRenderModes() ) ) {
+ if( isSelect ) {
+ rs.setColorStatic(selectedRGBAModulate[0], selectedRGBAModulate[1], selectedRGBAModulate[2], selectedRGBAModulate[3]);
+ } else {
+ rs.setColorStatic(1.0f, 1.0f, 1.0f, 1.0f);
+ }
+ } else {
+ rs.setColorStatic(r, g, b, a);
+ }
getRegion(gl, renderer).draw(gl, renderer, sampleCount);
}
public final boolean validate(GL2ES2 gl, RegionRenderer renderer) {
if( isShapeDirty() ) {
- shapes.clear();
box.reset();
- createShape(gl, renderer);
+ if( null == region ) {
+ region = GLRegion.create(renderer.getRenderModes());
+ } else {
+ region.clear(gl, renderer);
+ }
+ addShapeToRegion(gl, renderer);
if( DRAW_DEBUG_BOX ) {
- shapes.clear();
+ region.clear(gl, renderer);
final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
- shapes.add(new OutlineShapeXForm(createDebugOutline(shape, box), null));
+ shape.setSharpness(shapesSharpness);
+ shape.setIsQuadraticNurbs();
+ region.addOutlineShape(shape, null, rgbaColor);
}
+ region.setQuality(regionQuality);
dirty &= ~DIRTY_SHAPE;
- dirty |= DIRTY_REGION;
+ return true;
+ } else {
return false;
}
- return true;
}
- private final void addToRegion(Region region) {
- final boolean hasLocTrans = 0f != shapeTranslate2D[0] || 0f != shapeTranslate2D[1];
- final boolean hasLocScale = 1f != shapeScale2D[0] || 1f != shapeScale2D[1];
- final AffineTransform t;
- if( hasLocScale || hasLocTrans ) {
- // System.err.printf("UIShape.addToRegion: locTranslate %f x %f, locScale %f x %f%n",
- // shapeTranslate[0], shapeTranslate[1], shapeScale[0], shapeScale[1]);
- t = new AffineTransform();
- if( hasLocTrans ) {
- t.translate(shapeTranslate2D[0], shapeTranslate2D[1]);
- }
- if( hasLocScale ) {
- t.scale(shapeScale2D[0], shapeScale2D[1]);
- }
- } else {
- t = null;
- }
- final int shapeCount = shapes.size();
- for(int i=0; i<shapeCount; i++) {
- final OutlineShapeXForm tshape = shapes.get(i);
- final AffineTransform t2;
- if( null != tshape.t ) {
- if( null != t ) {
- t2 = new AffineTransform(t).concatenate(tshape.t);
- } else {
- t2 = tshape.t;
- }
- } else {
- t2 = t;
- }
- region.addOutlineShape(tshape.shape, t2);
- }
+ public float[] getColor() {
+ return rgbaColor;
}
- public float[] getColor() {
- return color;
+ public final int getQuality() { return regionQuality; }
+ public final void setQuality(final int q) {
+ this.regionQuality = q;
+ if( null != region ) {
+ region.setQuality(q);
+ }
+ }
+ public final void setSharpness(float sharpness) {
+ this.shapesSharpness = sharpness;
+ dirty = DIRTY_SHAPE;
+ }
+ public final float getSharpness() {
+ return shapesSharpness;
}
- public void setColor(float r, float g, float b) {
- this.color[0] = r;
- this.color[1] = g;
- this.color[2] = b;
+ public final void setColor(float r, float g, float b, float a) {
+ this.rgbaColor[0] = r;
+ this.rgbaColor[1] = g;
+ this.rgbaColor[2] = b;
+ this.rgbaColor[3] = a;
}
- public void setSelectedColor(float r, float g, float b){
- this.selectedColor[0] = r;
- this.selectedColor[1] = g;
- this.selectedColor[2] = b;
+ public final void setSelectedColorMod(float r, float g, float b, float a){
+ this.selectedRGBAModulate[0] = r;
+ this.selectedRGBAModulate[1] = g;
+ this.selectedRGBAModulate[2] = b;
+ this.selectedRGBAModulate[3] = a;
}
public String toString() {
@@ -443,7 +409,7 @@ public abstract class UIShape {
protected abstract void clearImpl(GL2ES2 gl, RegionRenderer renderer);
protected abstract void destroyImpl(GL2ES2 gl, RegionRenderer renderer);
- protected abstract void createShape(GL2ES2 gl, RegionRenderer renderer);
+ protected abstract void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer);
//
//