aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-02 04:41:48 +0200
committerSven Gothel <[email protected]>2014-04-02 04:41:48 +0200
commite8a5a1cbb988670ca206ab1ac633e19a91bfa478 (patch)
tree5b9f17a06ad350150375a2a0e38daa3d6dd11251 /src
parent6f5686696b1e9085a759774056c7be9887a9e34f (diff)
Bug 801: WIP 2/2 - Add color attribute; Switch Shader instead of branching in shader; Update attributes and uniforms manually, drop ShaderState;
- Due to shader-switching, 'renderModes' are now local to Region, e.g. UIShape etc - Remove RegionRenderer.renderModes - VBORegion2P*: - Use simple 2x float matrix for orthogonal P+Mv - Cleanup shader
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java18
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java24
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java41
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java25
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java38
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java162
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java81
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java17
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java3
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java113
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java54
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java25
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java2
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp23
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp23
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp35
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp36
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp44
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp47
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java22
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java94
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/CrossHair.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java30
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIGLListener01.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java6
40 files changed, 528 insertions, 603 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 2cd68a806..7edd2f572 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -51,7 +51,7 @@ public abstract class Region {
public static final boolean DEBUG_INSTANCE = Debug.debug("graph.curve.Instance");
/**
- * Rendering-Mode bit for {@link Region#getRenderModes() Region} and {@link com.jogamp.graph.curve.opengl.RegionRenderer#getRenderModes() RegionRenderer}.
+ * Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
* MSAA based Anti-Aliasing, a two pass region rendering, slower and more
* resource hungry (FBO), but providing fast MSAA in case
@@ -61,7 +61,7 @@ public abstract class Region {
public static final int MSAA_RENDERING_BIT = 1 << 0;
/**
- * Rendering-Mode bit for {@link Region#getRenderModes() Region} and {@link com.jogamp.graph.curve.opengl.RegionRenderer#getRenderModes() RegionRenderer}.
+ * Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
* View based Anti-Aliasing, a two pass region rendering, slower and more
* resource hungry (FBO), but AA is perfect. Otherwise the default fast one
@@ -71,7 +71,7 @@ public abstract class Region {
public static final int VBAA_RENDERING_BIT = 1 << 1;
/**
- * Rendering-Mode bit for {@link Region#getRenderModes() Region} and {@link com.jogamp.graph.curve.opengl.RegionRenderer#getRenderModes() RegionRenderer}.
+ * Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
* Use non uniform weights [0.0 .. 1.9] for curve region rendering.
* Otherwise the default weight 1.0 for uniform curve region rendering is
@@ -81,7 +81,7 @@ public abstract class Region {
public static final int VARWEIGHT_RENDERING_BIT = 1 << 8;
/**
- * Rendering-Mode bit for {@link Region#getRenderModes() Region} and {@link com.jogamp.graph.curve.opengl.RegionRenderer#getRenderModes() RegionRenderer}.
+ * Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
* If set, a color channel attribute per vertex is added to the stream,
* otherwise only the
@@ -92,13 +92,16 @@ public abstract class Region {
public static final int COLORCHANNEL_RENDERING_BIT = 1 << 9;
/**
- * Rendering-Mode bit for {@link Region#getRenderModes() Region} and {@link com.jogamp.graph.curve.opengl.RegionRenderer#getRenderModes() RegionRenderer}.
+ * Rendering-Mode bit for {@link #getRenderModes() Region}
* <p>
* If set, a color texture is used to determine the color.
* </p>
*/
public static final int COLORTEXTURE_RENDERING_BIT = 1 << 10;
+ /** Default maximum {@link #getQuality() quality}, {@value}. */
+ public static final int MAX_QUALITY = 1;
+
public static final int TWO_PASS_DEFAULT_TEXTURE_UNIT = 0;
private final int renderModes;
@@ -162,7 +165,7 @@ public abstract class Region {
protected Region(int regionRenderModes) {
this.renderModes = regionRenderModes;
- this.quality = 99;
+ this.quality = MAX_QUALITY;
}
// FIXME: Better handling of impl. buffer growth .. !
@@ -176,7 +179,10 @@ public abstract class Region {
*/
public final int getRenderModes() { return renderModes; }
+ /** See {@link #MAX_QUALITY} */
public final int getQuality() { return quality; }
+
+ /** See {@link #MAX_QUALITY} */
public final void setQuality(int q) { quality=q; }
protected void clearImpl() {
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 e305cc336..9505f2a9d 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -78,26 +78,26 @@ public abstract class GLRegion extends Region {
* <p>Allocates the ogl related data and initializes it the 1st time.<p>
* <p>Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.</p>
*/
- protected abstract void updateImpl(GL2ES2 gl, RegionRenderer renderer);
+ protected abstract void updateImpl(final GL2ES2 gl);
- protected abstract void destroyImpl(GL2ES2 gl, RegionRenderer renderer);
+ protected abstract void destroyImpl(final GL2ES2 gl);
- protected abstract void clearImpl(final GL2ES2 gl, final RegionRenderer renderer);
+ protected abstract void clearImpl(final GL2ES2 gl);
/**
* Clears all data, i.e. triangles, vertices etc.
*/
- public void clear(final GL2ES2 gl, final RegionRenderer renderer) {
- clearImpl(gl, renderer);
+ public void clear(final GL2ES2 gl) {
+ clearImpl(gl);
clearImpl();
}
/**
* Delete and clear the associated OGL objects.
*/
- public final void destroy(GL2ES2 gl, RegionRenderer renderer) {
- clear(gl, renderer);
- destroyImpl(gl, renderer);
+ public final void destroy(GL2ES2 gl) {
+ clear(gl);
+ destroyImpl(gl);
}
/**
@@ -120,7 +120,7 @@ public abstract class GLRegion extends Region {
* The <i>alpha</i> component shall be set to zero.
* Note: If {@link GL#GL_BLEND blending} is enabled, the
* {@link RegionRenderer} might need to be
- * {@link RegionRenderer#create(RenderState, int, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback) created}
+ * {@link RegionRenderer#create(RenderState, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback) created}
* with the appropriate {@link {@link RegionRenderer.GLCallback callbacks}.
* </p>
* @param matrix current {@link PMVMatrix}.
@@ -129,13 +129,13 @@ public abstract class GLRegion extends Region {
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @see RegionRenderer#enable(GL2ES2, boolean)
*/
- public final void draw(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] sampleCount) {
+ public final void draw(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
if(isDirty()) {
- updateImpl(gl, renderer);
+ updateImpl(gl);
setDirty(false);
}
drawImpl(gl, renderer, sampleCount);
}
- protected abstract void drawImpl(GL2ES2 gl, RegionRenderer renderer, int[/*1*/] sampleCount);
+ protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount);
}
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 8df34ead5..ade6098e1 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -70,7 +70,7 @@ public class RegionRenderer {
* <p>
* Implementation also sets {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
* </p>
- * @see #create(RenderState, int, GLCallback, GLCallback)
+ * @see #create(RenderState, GLCallback, GLCallback)
* @see #enable(GL2ES2, boolean)
*/
public static final GLCallback defaultBlendEnable = new GLCallback() {
@@ -89,7 +89,7 @@ public class RegionRenderer {
* <p>
* Implementation also clears {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
* </p>
- * @see #create(RenderState, int, GLCallback, GLCallback)
+ * @see #create(RenderState, GLCallback, GLCallback)
* @see #enable(GL2ES2, boolean)
*/
public static final GLCallback defaultBlendDisable = new GLCallback() {
@@ -109,20 +109,18 @@ public class RegionRenderer {
* can be utilized to enable and disable {@link GL#GL_BLEND}.
* </p>
* @param rs the used {@link RenderState}
- * @param renderModes bit-field of modes, e.g. {@link Region#VARWEIGHT_RENDERING_BIT}, {@link Region#VBAA_RENDERING_BIT}
* @param enableCallback optional {@link GLCallback}, if not <code>null</code> will be issued at
- * {@link #init(GL2ES2) init(gl)} and {@link #enable(GL2ES2, boolean) enable(gl, true)}.
+ * {@link #init(GL2ES2, int) init(gl)} and {@link #enable(GL2ES2, boolean) enable(gl, true)}.
* @param disableCallback optional {@link GLCallback}, if not <code>null</code> will be issued at
* {@link #enable(GL2ES2, boolean) enable(gl, false)}.
* @return an instance of Region Renderer
* @see #enable(GL2ES2, boolean)
*/
- public static RegionRenderer create(final RenderState rs, final int renderModes,
- final GLCallback enableCallback, final GLCallback disableCallback) {
- return new RegionRenderer(rs, renderModes, enableCallback, disableCallback);
+ public static RegionRenderer create(final RenderState rs, final GLCallback enableCallback,
+ final GLCallback disableCallback) {
+ return new RegionRenderer(rs, enableCallback, disableCallback);
}
- private final int renderModes;
private final RenderState rs;
private final GLCallback enableCallback;
@@ -149,30 +147,13 @@ public class RegionRenderer {
/**
* @param rs the used {@link RenderState}
- * @param renderModes bit-field of modes
*/
- protected RegionRenderer(final RenderState rs, final int renderModes, final GLCallback enableCallback, final GLCallback disableCallback) {
+ protected RegionRenderer(final RenderState rs, final GLCallback enableCallback, final GLCallback disableCallback) {
this.rs = rs;
- this.renderModes = renderModes;
this.enableCallback = enableCallback;
this.disableCallback = disableCallback;
}
- public final int getRenderModes() {
- return renderModes;
- }
-
- public final boolean usesVariableCurveWeight() { return Region.hasVariableWeight(renderModes); }
-
- /**
- * @return true if Region's renderModes contains all bits as this Renderer's renderModes
- * except {@link Region#VARWEIGHT_RENDERING_BIT}, otherwise false.
- */
- public final boolean areRenderModesCompatible(final Region region) {
- final int cleanRenderModes = getRenderModes() & ( Region.VARWEIGHT_RENDERING_BIT );
- return cleanRenderModes == ( region.getRenderModes() & cleanRenderModes );
- }
-
public final boolean isVBOSupported() { return vboSupported; }
/**
@@ -182,9 +163,10 @@ public class RegionRenderer {
* <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
+ * @param renderModes TODO
* @throws GLException if initialization failed
*/
- public final void init(GL2ES2 gl) throws GLException {
+ public final void init(final GL2ES2 gl, final int renderModes) throws GLException {
if(initialized){
return;
}
@@ -227,6 +209,7 @@ public class RegionRenderer {
final ShaderProgram sp = (ShaderProgram) i.next().getValue();
sp.destroy(gl);
}
+ shaderPrograms.clear();
rs.destroy(gl);
initialized = false;
}
@@ -237,10 +220,10 @@ public class RegionRenderer {
* Enabling or disabling the {@link #getRenderState() RenderState}'s
* {@link RenderState#getShaderProgram() shader program}.
* <p>
- * In case enable and disable {@link GLCallback}s are setup via {@link #create(RenderState, int, GLCallback, GLCallback)},
+ * In case enable and disable {@link GLCallback}s are setup via {@link #create(RenderState, GLCallback, GLCallback)},
* they will be called before toggling the shader program.
* </p>
- * @see #create(RenderState, int, GLCallback, GLCallback)
+ * @see #create(RenderState, GLCallback, GLCallback)
*/
public final void enable(GL2ES2 gl, boolean enable) {
if( enable ) {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
index f915b7d49..c7083a41b 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -104,17 +104,20 @@ public class RenderState {
* Set a {@link ShaderProgram} and enable it. If the given {@link ShaderProgram} is new,
* method returns true, otherwise false.
* @param gl
- * @param sp
+ * @param spNext
* @return true if a new shader program is being used and hence external uniform-data and -location,
* as well as the attribute-location must be updated, otherwise false.
*/
- public final boolean setShaderProgram(final GL2ES2 gl, final ShaderProgram sp) {
- if( sp.equals(this.sp) ) {
- sp.useProgram(gl, true);
+ public final boolean setShaderProgram(final GL2ES2 gl, final ShaderProgram spNext) {
+ if( spNext.equals(this.sp) ) {
+ spNext.useProgram(gl, true);
return false;
}
- this.sp = sp;
- sp.useProgram(gl, true);
+ if( null != this.sp ) {
+ this.sp.notifyNotInUse();
+ }
+ this.sp = spNext;
+ spNext.useProgram(gl, true);
return true;
}
@@ -129,13 +132,6 @@ public class RenderState {
public final void setMatrixDirty() { gcu_PMVMatrix01_dirty = true; }
public final boolean isMatrixDirty() { return gcu_PMVMatrix01_dirty;}
- public final void updateMatrix(GL2ES2 gl) {
- if( gcu_PMVMatrix01_dirty && sp.inUse() ) {
- gl.glUniform( gcu_PMVMatrix01 );
- gcu_PMVMatrix01_dirty = false;
- }
- }
-
public static boolean isWeightValid(float v) {
return 0.0f <= v && v <= 1.9f ;
}
@@ -179,20 +175,17 @@ public class RenderState {
if( null != sp && sp.inUse() ) {
if( ( !Region.isTwoPass(renderModes) || !pass1 ) && ( gcu_PMVMatrix01_dirty || updateLocation ) ) {
final boolean r0 = updateUniformDataLoc(gl, updateLocation, gcu_PMVMatrix01_dirty, gcu_PMVMatrix01);
- System.err.println("XXX gcu_PMVMatrix01.update: "+r0);
res = res && r0;
gcu_PMVMatrix01_dirty = !r0;
}
if( pass1 ) {
if( Region.hasVariableWeight( renderModes ) && ( gcu_Weight_dirty || updateLocation ) ) {
final boolean r0 = updateUniformDataLoc(gl, updateLocation, gcu_Weight_dirty, gcu_Weight);
- System.err.println("XXX gcu_Weight.update: "+r0);
res = res && r0;
gcu_Weight_dirty = !r0;
}
if( gcu_ColorStatic_dirty || updateLocation ) {
final boolean r0 = updateUniformDataLoc(gl, updateLocation, gcu_ColorStatic_dirty, gcu_ColorStatic);
- System.err.println("XXX gcu_ColorStatic.update: "+r0);
res = res && r0;
gcu_ColorStatic_dirty = false;
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
index 6d9fdab0b..16b1224bd 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -48,10 +48,10 @@ import com.jogamp.graph.geom.Vertex.Factory;
*/
public class TextRegionUtil {
- public final RegionRenderer renderer;
+ public final int renderModes;
- public TextRegionUtil(final RegionRenderer renderer) {
- this.renderer = renderer;
+ public TextRegionUtil(final int renderModes) {
+ this.renderModes = renderModes;
}
public static interface ShapeVisitor {
@@ -144,6 +144,7 @@ public class TextRegionUtil {
* Cached {@link GLRegion}s will be destroyed w/ {@link #clear(GL2ES2)} or to free memory.
* </p>
* @param gl the current GL state
+ * @param renderer TODO
* @param font {@link Font} to be used
* @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
* @param str text to be rendered
@@ -153,15 +154,15 @@ public class TextRegionUtil {
* @throws Exception if TextRenderer not initialized
*/
public void drawString3D(final GL2ES2 gl,
- final Font font, final float pixelSize, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ final RegionRenderer renderer, final Font font, final float pixelSize,
+ final CharSequence str, final float[] rgbaColor, final int[/*1*/] sampleCount) {
if( !renderer.isInitialized() ) {
throw new GLException("TextRendererImpl01: not initialized!");
}
final int special = 0;
GLRegion region = getCachedRegion(font, str, pixelSize, special);
if(null == region) {
- region = GLRegion.create(renderer.getRenderModes());
+ region = GLRegion.create(renderModes);
addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str, rgbaColor);
addCachedRegion(gl, font, str, pixelSize, special, region);
}
@@ -174,10 +175,11 @@ public class TextRegionUtil {
* <p>
* In case of a multisampling region renderer, i.e. {@link Region#VBAA_RENDERING_BIT}, recreating the {@link GLRegion}
* is a huge performance impact.
- * In such case better use {@link #drawString3D(GLRegion, RegionRenderer, GL2ES2, Font, float, CharSequence, float[], int[])}
+ * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, float, CharSequence, float[], int[])}
* instead.
* </p>
* @param gl the current GL state
+ * @param renderModes TODO
* @param font {@link Font} to be used
* @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
* @param str text to be rendered
@@ -186,21 +188,21 @@ public class TextRegionUtil {
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @throws Exception if TextRenderer not initialized
*/
- public static void drawString3D(final RegionRenderer renderer, final GL2ES2 gl,
- final Font font, final float pixelSize, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ public static void drawString3D(final GL2ES2 gl, final int renderModes,
+ final RegionRenderer renderer, final Font font, final float pixelSize,
+ final CharSequence str, final float[] rgbaColor, final int[/*1*/] sampleCount) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
- final GLRegion region = GLRegion.create(renderer.getRenderModes());
+ final GLRegion region = GLRegion.create(renderModes);
addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str, rgbaColor);
region.draw(gl, renderer, sampleCount);
- region.destroy(gl, renderer);
+ region.destroy(gl);
}
/**
* Render the string in 3D space w.r.t. the font and pixelSize
- * using the given {@link GLRegion}, which will {@link GLRegion#clear(GL2ES2, RegionRenderer) cleared} beforehand.
+ * using the given {@link GLRegion}, which will {@link GLRegion#clear(GL2ES2) cleared} beforehand.
* @param gl the current GL state
* @param font {@link Font} to be used
* @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
@@ -210,13 +212,13 @@ public class TextRegionUtil {
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @throws Exception if TextRenderer not initialized
*/
- public static void drawString3D(final GLRegion region, final RegionRenderer renderer, final GL2ES2 gl,
+ public static void drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
final Font font, final float pixelSize, final CharSequence str,
final float[] rgbaColor, final int[/*1*/] sampleCount) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
- region.clear(gl, renderer);
+ region.clear(gl);
addStringToRegion(region, renderer.getRenderState().getVertexFactory(), font, pixelSize, str, rgbaColor);
region.draw(gl, renderer, sampleCount);
}
@@ -229,7 +231,7 @@ public class TextRegionUtil {
final Iterator<GLRegion> iterator = stringCacheMap.values().iterator();
while(iterator.hasNext()){
final GLRegion region = iterator.next();
- region.destroy(gl, renderer);
+ region.destroy(gl);
}
stringCacheMap.clear();
stringCacheArray.clear();
@@ -295,7 +297,7 @@ public class TextRegionUtil {
final String key = getKey(font, str, pixelSize, special);
final GLRegion region = stringCacheMap.remove(key);
if(null != region) {
- region.destroy(gl, renderer);
+ region.destroy(gl);
}
stringCacheArray.remove(key);
}
@@ -305,7 +307,7 @@ public class TextRegionUtil {
if( null != key ) {
final GLRegion region = stringCacheMap.remove(key);
if(null != region) {
- region.destroy(gl, renderer);
+ region.destroy(gl);
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
index 9d3ee412b..cf56ff0a4 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
@@ -29,6 +29,8 @@ package com.jogamp.opengl.math;
import java.nio.FloatBuffer;
+import javax.media.opengl.GLException;
+
import jogamp.opengl.Debug;
import com.jogamp.common.os.Platform;
@@ -199,6 +201,123 @@ public class FloatUtil {
}
/**
+ * Make given matrix the orthogonal matrix based on given parameters.
+ *
+ * @param a 4x4 matrix in column-major order (also result)
+ * @param a_off
+ * @param initA if true, given matrix will be initialized w/ identity matrix.
+ * @param left
+ * @param right
+ * @param bottom
+ * @param top
+ * @param zNear
+ * @param zFar
+ * @return given matrix for chaining
+ */
+ public static final float[] makeOrthof(final float[] a, final int a_off, final boolean initA,
+ final float left, final float right,
+ final float bottom, final float top,
+ final float zNear, final float zFar) {
+ if( initA ) {
+ FloatUtil.makeIdentityf(a, a_off);
+ }
+ // Ortho matrix (Column Order):
+ // 2/dx 0 0 0
+ // 0 2/dy 0 0
+ // 0 0 2/dz 0
+ // tx ty tz 1
+ final float dx=right-left;
+ final float dy=top-bottom;
+ final float dz=zFar-zNear;
+ final float tx=-1.0f*(right+left)/dx;
+ final float ty=-1.0f*(top+bottom)/dy;
+ final float tz=-1.0f*(zFar+zNear)/dz;
+
+ a[a_off+0+4*0] = 2.0f/dx;
+ a[a_off+1+4*1] = 2.0f/dy;
+ a[a_off+2+4*2] = -2.0f/dz;
+ a[a_off+0+4*3] = tx;
+ a[a_off+1+4*3] = ty;
+ a[a_off+2+4*3] = tz;
+
+ return a;
+ }
+
+ /**
+ * Make given matrix the frustum matrix based on given parameters.
+ *
+ * @param a 4x4 matrix in column-major order (also result)
+ * @param a_off
+ * @param initA if true, given matrix will be initialized w/ identity matrix.
+ * @param left
+ * @param right
+ * @param bottom
+ * @param top
+ * @param zNear
+ * @param zFar
+ * @return given matrix for chaining
+ */
+ public static final float[] makeFrustumf(final float[] a, final int a_off, final boolean initA,
+ final float left, final float right,
+ final float bottom, final float top,
+ final float zNear, final float zFar) {
+ if(zNear<=0.0f||zFar<0.0f) {
+ throw new GLException("GL_INVALID_VALUE: zNear and zFar must be positive, and zNear>0");
+ }
+ if(left==right || top==bottom) {
+ throw new GLException("GL_INVALID_VALUE: top,bottom and left,right must not be equal");
+ }
+ if( initA ) {
+ FloatUtil.makeIdentityf(a, a_off);
+ }
+ // Frustum matrix (Column Order):
+ // 2*zNear/dx 0 0 0
+ // 0 2*zNear/dy 0 0
+ // A B C -1
+ // 0 0 D 0
+ final float zNear2 = 2.0f*zNear;
+ final float dx=right-left;
+ final float dy=top-bottom;
+ final float dz=zFar-zNear;
+ final float A=(right+left)/dx;
+ final float B=(top+bottom)/dy;
+ final float C=-1.0f*(zFar+zNear)/dz;
+ final float D=-2.0f*(zFar*zNear)/dz;
+
+ a[a_off+0+4*0] = zNear2/dx;
+ a[a_off+1+4*1] = zNear2/dy;
+ a[a_off+2+4*2] = C;
+
+ a[a_off+0+4*2] = A;
+ a[a_off+1+4*2] = B;
+
+ a[a_off+2+4*3] = D;
+ a[a_off+3+4*2] = -1.0f;
+ return a;
+ }
+
+ /**
+ * Make given matrix the perspective matrix based on given parameters.
+ *
+ * @param a 4x4 matrix in column-major order (also result)
+ * @param a_off
+ * @param initA if true, given matrix will be initialized w/ identity matrix.
+ * @param fovy angle in radians
+ * @param aspect
+ * @param zNear
+ * @param zFar
+ * @return given matrix for chaining
+ */
+ public static final float[] makePerspective(final float[] a, final int a_off, final boolean initA,
+ final float fovy, final float aspect, final float zNear, final float zFar) {
+ float top=(float)Math.tan(fovy)*zNear;
+ float bottom=-1.0f*top;
+ float left=aspect*bottom;
+ float right=aspect*top;
+ return makeFrustumf(a, a_off, initA, left, right, bottom, top, zNear, zFar);
+ }
+
+ /**
* Multiply matrix: [d] = [a] x [b]
* @param a 4x4 matrix in column-major order
* @param b 4x4 matrix in column-major order
@@ -840,4 +959,47 @@ public class FloatUtil {
public static float sqrt(final float a) { return (float) java.lang.Math.sqrt(a); }
+ /**
+ * Returns resolution of Z buffer of given parameter,
+ * see <a href="http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html">Love Your Z-Buffer</a>.
+ * <pre>
+ * return z * z / ( zNear * (1&lt;&lt;zBits) - z )
+ * </pre>
+ * @param zBits number of bits of Z precision, i.e. z-buffer depth
+ * @param z distance from the eye to the object
+ * @param zNear distance from eye to near clip plane
+ * @return smallest resolvable Z separation at this range.
+ */
+ public static float getZBufferEpsilon(final int zBits, final float z, final float zNear) {
+ return z * z / ( zNear * ( 1 << zBits ) - z );
+ }
+
+ /**
+ * Returns Z buffer value of given parameter,
+ * see <a href="http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html">Love Your Z-Buffer</a>.
+ * <pre>
+ * float a = zFar / ( zFar - zNear )
+ * float b = zFar * zNear / ( zNear - zFar )
+ * return (int) ( (1&lt;&lt;zBits) * ( a + b / z ) )
+ * </pre>
+ * @param zBits number of bits of Z precision, i.e. z-buffer depth
+ * @param z distance from the eye to the object
+ * @param zNear distance from eye to near clip plane
+ * @param zFar distance from eye to far clip plane
+ * @return z buffer value
+ */
+ public static int getZBufferValue(final int zBits, final float z, final float zNear, final float zFar) {
+ final float a = zFar / ( zFar - zNear );
+ final float b = zFar * zNear / ( zNear - zFar );
+ return (int) ( (1<<zBits) * ( a + b / z ) );
+ }
+
+ /**
+ * Returns orthogonal distance
+ * (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar);
+ */
+ public static float getOrthoWinZ(final float orthoZ, final float zNear, final float zFar) {
+ return (1f/zNear-1f/orthoZ)/(1f/zNear-1f/zFar);
+ }
+
} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
index 44288256a..8f5beeebe 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
@@ -686,61 +686,12 @@ public class PMVMatrix implements GLMatrixFunc {
@Override
public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
- // Ortho matrix (Column Order):
- // 2/dx 0 0 0
- // 0 2/dy 0 0
- // 0 0 2/dz 0
- // tx ty tz 1
- final float dx=right-left;
- final float dy=top-bottom;
- final float dz=zFar-zNear;
- final float tx=-1.0f*(right+left)/dx;
- final float ty=-1.0f*(top+bottom)/dy;
- final float tz=-1.0f*(zFar+zNear)/dz;
-
- matrixOrtho[0+4*0] = 2.0f/dx;
- matrixOrtho[1+4*1] = 2.0f/dy;
- matrixOrtho[2+4*2] = -2.0f/dz;
- matrixOrtho[0+4*3] = tx;
- matrixOrtho[1+4*3] = ty;
- matrixOrtho[2+4*3] = tz;
-
- glMultMatrixf(matrixOrtho, 0);
+ glMultMatrixf( FloatUtil.makeOrthof(matrixOrtho, 0, false, left, right, bottom, top, zNear, zFar), 0 );
}
@Override
public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) {
- if(zNear<=0.0f||zFar<0.0f) {
- throw new GLException("GL_INVALID_VALUE: zNear and zFar must be positive, and zNear>0");
- }
- if(left==right || top==bottom) {
- throw new GLException("GL_INVALID_VALUE: top,bottom and left,right must not be equal");
- }
- // Frustum matrix (Column Order):
- // 2*zNear/dx 0 0 0
- // 0 2*zNear/dy 0 0
- // A B C -1
- // 0 0 D 0
- final float zNear2 = 2.0f*zNear;
- final float dx=right-left;
- final float dy=top-bottom;
- final float dz=zFar-zNear;
- final float A=(right+left)/dx;
- final float B=(top+bottom)/dy;
- final float C=-1.0f*(zFar+zNear)/dz;
- final float D=-2.0f*(zFar*zNear)/dz;
-
- matrixFrustum[0+4*0] = zNear2/dx;
- matrixFrustum[1+4*1] = zNear2/dy;
- matrixFrustum[2+4*2] = C;
-
- matrixFrustum[0+4*2] = A;
- matrixFrustum[1+4*2] = B;
-
- matrixFrustum[2+4*3] = D;
- matrixFrustum[3+4*2] = -1.0f;
-
- glMultMatrixf(matrixFrustum, 0);
+ glMultMatrixf( FloatUtil.makeFrustumf(matrixFrustum, 0, false, left, right, bottom, top, zNear, zFar), 0 );
}
//
@@ -751,11 +702,7 @@ public class PMVMatrix implements GLMatrixFunc {
* {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} with the perspective/frustum matrix.
*/
public final void gluPerspective(final float fovy, final float aspect, final float zNear, final float zFar) {
- float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear;
- float bottom=-1.0f*top;
- float left=aspect*bottom;
- float right=aspect*top;
- glFrustumf(left, right, bottom, top, zNear, zFar);
+ glMultMatrixf( FloatUtil.makePerspective(matrixFrustum, 0, false, fovy*((float)Math.PI)/360.0f, aspect, zNear, zFar), 0 );
}
/**
@@ -840,24 +787,12 @@ public class PMVMatrix implements GLMatrixFunc {
* using a {@link AABBox#intersectsRay(Ray, float[]) bounding box}.
* <p>
* Notes for picking <i>winz0</i> and <i>winz1</i>:
+ * <ul>
+ * <li>see {@link FloatUtil#getZBufferEpsilon(int, float, float)}</li>
+ * <li>see {@link FloatUtil#getZBufferValue(int, float, float, float)}</li>
+ * <li>see {@link FloatUtil#getOrthoWinZ(float, float, float)}</li>
+ * </ul>
* </p>
- * <p>
- * <a href="http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html">Love Your Z-Buffer</a>
- * <pre>
- * delta = z * z / ( zNear * (1&lt;&lt;N) - z )
- *
- * Where:
- * N = number of bits of Z precision
- * zNear = distance from eye to near clip plane
- * z = distance from the eye to the object
- * delta = the smallest resolvable Z separation at this range.
- * </pre>
- * Another equation to determine winZ for 'orthoDist' > 0
- * <pre>
- * winZ = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar);
- * </pre>
- * </p>
- *
* @param winx
* @param winy
* @param winz0
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
index b289b41e2..6a4b13dfb 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
@@ -312,17 +312,20 @@ public class ShaderProgram {
gl.glUseProgram( on ? shaderProgram : 0 );
programInUse = on;
}
+ public synchronized void notifyNotInUse() {
+ programInUse = false;
+ }
- protected boolean programLinked = false;
- protected boolean programInUse = false;
- protected int shaderProgram = 0; // non zero is valid!
- protected HashSet<ShaderCode> allShaderCode = new HashSet<ShaderCode>();
- protected HashSet<ShaderCode> attachedShaderCode = new HashSet<ShaderCode>();
- protected int id = -1;
+ private boolean programLinked = false;
+ private boolean programInUse = false;
+ private int shaderProgram = 0; // non zero is valid!
+ private final HashSet<ShaderCode> allShaderCode = new HashSet<ShaderCode>();
+ private final HashSet<ShaderCode> attachedShaderCode = new HashSet<ShaderCode>();
+ private int id = -1;
private static synchronized int getNextID() {
return nextID++;
}
- protected static int nextID = 1;
+ private static int nextID = 1;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
index ce4c2615d..64dd589b8 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -176,8 +176,7 @@ public class ShaderState {
}
if(shaderProgram.inUse()) {
if(null != prog && enable) {
- // new program will issue glUseProgram(..)
- shaderProgram.programInUse = false;
+ shaderProgram.notifyNotInUse();
} else {
// no new 'enabled' program - disable
useProgram(gl, false);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index 4649a2714..172bd52c8 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -30,21 +30,21 @@ package jogamp.graph.curve.opengl;
import java.nio.FloatBuffer;
import javax.media.opengl.GL2ES2;
-// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER !
import javax.media.opengl.GL;
import javax.media.opengl.GLUniformData;
import jogamp.graph.curve.opengl.shader.AttributeNames;
import jogamp.graph.curve.opengl.shader.UniformNames;
+import com.jogamp.common.nio.Buffers;
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;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLArrayDataServer;
-import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderProgram;
public class VBORegion2PMSAAES2 extends GLRegion {
@@ -63,11 +63,9 @@ public class VBORegion2PMSAAES2 extends GLRegion {
private GLArrayDataServer gca_FboTexCoordsAttr;
private GLArrayDataServer indicesFbo;
private final GLUniformData gcu_FboTexUnit;
- private GLUniformData gcu_FboTexSize;
- private final PMVMatrix fboPMVMatrix;
+ private final GLUniformData gcu_FboTexSize;
+ private final float[] pmvMatrix02 = new float[2*16]; // P + Mv
private final GLUniformData gcu_PMVMatrix02;
- private boolean gcu_FboTexSize_dirty = true;
- private boolean gcu_PMVMatrix02_dirty = true;
private ShaderProgram spPass2 = null;
private FBObject fbo;
@@ -80,33 +78,27 @@ public class VBORegion2PMSAAES2 extends GLRegion {
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
final RenderState rs = renderer.getRenderState();
- final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
+ renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocation;
if( pass1 ) {
updateLocation = !sp.equals(spPass1);
spPass1 = sp;
rs.update(gl, updateLocation, renderModes, true);
- if( updateLocation ) {
- gcu_PMVMatrix02.setLocation(gl, sp.program());
- }
+ rs.updateUniformLoc(gl, updateLocation, gcu_PMVMatrix02);
rs.updateAttributeLoc(gl, updateLocation, gca_VerticesAttr);
rs.updateAttributeLoc(gl, updateLocation, gca_CurveParamsAttr);
if( null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr);
}
- System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0+", "+rs);
} else {
updateLocation = !sp.equals(spPass2);
spPass2 = sp;
rs.update(gl, updateLocation, renderModes, false);
rs.updateAttributeLoc(gl, updateLocation, gca_FboVerticesAttr);
rs.updateAttributeLoc(gl, updateLocation, gca_FboTexCoordsAttr);
- rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexSize);
- if( updateLocation ) {
- gcu_FboTexSize.setLocation(gl, sp.program());
- }
- System.err.println("XXX changedSP.p2 "+updateLocation+" / "+updateLocation0+", "+rs);
+ rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexUnit);
+ rs.updateUniformLoc(gl, updateLocation, gcu_FboTexSize);
}
}
@@ -130,30 +122,33 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_ColorsAttr = null;
}
+ FloatUtil.makeIdentityf(pmvMatrix02, 0);
+ FloatUtil.makeIdentityf(pmvMatrix02, 16);
+ gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02));
+
// Pass 2:
- fboPMVMatrix = new PMVMatrix();
- gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix01, 4, 4, fboPMVMatrix.glGetPMvMatrixf());
gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, textureUnit);
+ gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, Buffers.newDirectFloatBuffer(2));
indicesFbo = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3);
indicesFbo.seal(true);
- gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 2, GL2ES2.GL_FLOAT,
- false, 4, GL.GL_STATIC_DRAW);
+ gca_FboTexCoordsAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_TEXCOORDS_ATTR_NAME, 2, GL2ES2.GL_FLOAT,
+ false, 4, GL.GL_STATIC_DRAW);
gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(0);
gca_FboTexCoordsAttr.putf(0); gca_FboTexCoordsAttr.putf(1);
gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(1);
gca_FboTexCoordsAttr.putf(1); gca_FboTexCoordsAttr.putf(0);
gca_FboTexCoordsAttr.seal(true);
- gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT,
- false, 4, GL.GL_STATIC_DRAW);
+ gca_FboVerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.FBO_VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT,
+ false, 4, GL.GL_STATIC_DRAW);
}
@Override
- protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected final void clearImpl(final GL2ES2 gl) {
if( null != indicesBuffer ) {
indicesBuffer.seal(gl, false);
indicesBuffer.rewind();
@@ -166,11 +161,15 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_CurveParamsAttr.seal(gl, false);
gca_CurveParamsAttr.rewind();
}
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.seal(gl, false);
+ gca_ColorsAttr.rewind();
+ }
fboDirty = true;
}
@Override
- protected final void pushVertex(float[] coords, float[] texParams, float[] color) {
+ protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) {
gca_VerticesAttr.putf(coords[0]);
gca_VerticesAttr.putf(coords[1]);
gca_VerticesAttr.putf(coords[2]);
@@ -178,6 +177,17 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_CurveParamsAttr.putf(texParams[0]);
gca_CurveParamsAttr.putf(texParams[1]);
gca_CurveParamsAttr.putf(texParams[2]);
+
+ if( null != gca_ColorsAttr ) {
+ if( null != rgba ) {
+ gca_ColorsAttr.putf(rgba[0]);
+ gca_ColorsAttr.putf(rgba[1]);
+ gca_ColorsAttr.putf(rgba[2]);
+ gca_ColorsAttr.putf(rgba[3]);
+ } else {
+ throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
+ }
+ }
}
@Override
@@ -186,7 +196,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
}
@Override
- protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void updateImpl(final GL2ES2 gl) {
// seal buffers
indicesBuffer.seal(gl, true);
indicesBuffer.enableBuffer(gl, false);
@@ -194,6 +204,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_CurveParamsAttr.enableBuffer(gl, false);
gca_VerticesAttr.seal(gl, true);
gca_VerticesAttr.enableBuffer(gl, false);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.seal(gl, true);
+ gca_ColorsAttr.enableBuffer(gl, false);
+ }
// update all bbox related data
gca_FboVerticesAttr.seal(gl, false);
@@ -204,18 +218,12 @@ public class VBORegion2PMSAAES2 extends GLRegion {
fb.put( 8, box.getMinZ());
fb.put(11, box.getMinZ());
}
- // Pending .. (follow fboDirty)
- // gca_FboVerticesAttr.seal(gl, true);
- // gca_FboVerticesAttr.enableBuffer(gl, false);
- // fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- // fboPMVMatrix.glLoadIdentity();
- // fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1);
+ // Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
// push data 2 GPU ..
indicesFbo.seal(gl, true);
indicesFbo.enableBuffer(gl, false);
- // trigger renderRegion2FBO !
fboDirty = true;
// the buffers were disabled, since due to real/fbo switching and other vbo usage
}
@@ -324,16 +332,17 @@ public class VBORegion2PMSAAES2 extends GLRegion {
fb.put(3, minX); fb.put( 4, maxY);
fb.put(6, maxX); fb.put( 7, maxY);
fb.put(9, maxX); fb.put(10, minY);
+ fb.position(12);
}
gca_FboVerticesAttr.seal(true);
- fboPMVMatrix.glLoadIdentity();
- fboPMVMatrix.glOrthof(minX, maxX, minY, maxY, -1, 1);
- gcu_PMVMatrix02_dirty = true;
+ FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
+ useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount);
} else {
gca_FboTexCoordsAttr.setVBOWritten(false);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
+ useShaderProgram(gl, renderer, getRenderModes(), false, getQuality(), sampleCount[0]);
renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]);
}
}
@@ -341,14 +350,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, final int sampleCount) {
gl.glViewport(0, 0, width, height);
- if( gcu_FboTexSize_dirty ) {
- gl.glUniform(gcu_FboTexSize);
- gcu_FboTexSize_dirty = false;
- }
- if( gcu_PMVMatrix02_dirty ) {
- gl.glUniform(gcu_PMVMatrix02);
- gcu_PMVMatrix02_dirty = false;
- }
+ gl.glUniform(gcu_FboTexSize);
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
@@ -376,6 +378,11 @@ public class VBORegion2PMSAAES2 extends GLRegion {
if(null == fbo) {
fboWidth = targetFboWidth;
fboHeight = targetFboHeight;
+ final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer();
+ {
+ fboTexSize.put(0, fboWidth);
+ fboTexSize.put(1, fboHeight);
+ }
fbo = new FBObject();
fbo.reset(gl, fboWidth, fboHeight, sampleCount[0], false);
sampleCount[0] = fbo.getNumSamples();
@@ -402,6 +409,11 @@ public class VBORegion2PMSAAES2 extends GLRegion {
}
fboWidth = targetFboWidth;
fboHeight = targetFboHeight;
+ final FloatBuffer fboTexSize = (FloatBuffer) gcu_FboTexSize.getBuffer();
+ {
+ fboTexSize.put(0, fboWidth);
+ fboTexSize.put(1, fboHeight);
+ }
}
fbo.bind(gl);
@@ -415,19 +427,26 @@ public class VBORegion2PMSAAES2 extends GLRegion {
}
private void renderRegion(final GL2ES2 gl) {
+ gl.glUniform(gcu_PMVMatrix02);
gca_VerticesAttr.enableBuffer(gl, true);
gca_CurveParamsAttr.enableBuffer(gl, true);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.enableBuffer(gl, true);
+ }
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
indicesBuffer.bindBuffer(gl, false);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.enableBuffer(gl, false);
+ }
gca_CurveParamsAttr.enableBuffer(gl, false);
gca_VerticesAttr.enableBuffer(gl, false);
}
@Override
- protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void destroyImpl(final GL2ES2 gl) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegion2PES2 Destroy: " + this);
}
@@ -443,6 +462,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_CurveParamsAttr.destroy(gl);
gca_CurveParamsAttr = null;
}
+ if(null != gca_ColorsAttr) {
+ gca_ColorsAttr.destroy(gl);
+ gca_ColorsAttr = null;
+ }
if(null != indicesBuffer) {
indicesBuffer.destroy(gl);
indicesBuffer = null;
@@ -459,5 +482,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
indicesFbo.destroy(gl);
indicesFbo = null;
}
+ spPass1 = null;
+ spPass2 = null;
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index afaae3679..a701a4b19 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -45,9 +45,9 @@ import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Attachment;
import com.jogamp.opengl.FBObject.TextureAttachment;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.GLArrayDataServer;
-import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderProgram;
public class VBORegion2PVBAAES2 extends GLRegion {
@@ -97,10 +97,8 @@ public class VBORegion2PVBAAES2 extends GLRegion {
private GLArrayDataServer indicesFbo;
private final GLUniformData gcu_FboTexUnit;
private final GLUniformData gcu_FboTexSize;
- private final PMVMatrix fboPMVMatrix;
+ private final float[] pmvMatrix02 = new float[2*16]; // P + Mv
private final GLUniformData gcu_PMVMatrix02;
- private boolean gcu_FboTexSize_dirty = true;
- private boolean gcu_PMVMatrix02_dirty = true;
private ShaderProgram spPass2 = null;
private FBObject fbo;
@@ -114,7 +112,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
final RenderState rs = renderer.getRenderState();
- final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
+ renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount);
final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
final boolean updateLocation;
if( pass1 ) {
@@ -127,7 +125,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
if( null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr);
}
- System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0+", "+rs);
} else {
updateLocation = !sp.equals(spPass2);
spPass2 = sp;
@@ -136,7 +133,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
rs.updateAttributeLoc(gl, updateLocation, gca_FboTexCoordsAttr);
rs.updateUniformDataLoc(gl, updateLocation, true, gcu_FboTexUnit);
rs.updateUniformLoc(gl, updateLocation, gcu_FboTexSize);
- System.err.println("XXX changedSP.p2 "+updateLocation+" / "+updateLocation0+", "+rs);
}
}
@@ -159,9 +155,11 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gca_ColorsAttr = null;
}
+ FloatUtil.makeIdentityf(pmvMatrix02, 0);
+ FloatUtil.makeIdentityf(pmvMatrix02, 16);
+ gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, FloatBuffer.wrap(pmvMatrix02));
+
// Pass 2:
- fboPMVMatrix = new PMVMatrix();
- gcu_PMVMatrix02 = new GLUniformData(UniformNames.gcu_PMVMatrix02, 4, 4, fboPMVMatrix.glGetPMvMatrixf());
gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, textureUnit);
gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, Buffers.newDirectFloatBuffer(2));
@@ -183,7 +181,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
}
@Override
- protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected final void clearImpl(final GL2ES2 gl) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegion2PES2 Clear: " + this);
// Thread.dumpStack();
@@ -208,7 +206,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
}
@Override
- protected final void pushVertex(final float[] coords, final float[] texParams, float[] rgba) {
+ protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) {
gca_VerticesAttr.putf(coords[0]);
gca_VerticesAttr.putf(coords[1]);
gca_VerticesAttr.putf(coords[2]);
@@ -235,7 +233,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
}
@Override
- protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void updateImpl(final GL2ES2 gl) {
if(null == indicesFbo) {
if(Region.DEBUG_INSTANCE) {
System.err.println("VBORegion2PVBAAES2 Create: " + this);
@@ -262,12 +260,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
fb.put( 8, box.getMinZ());
fb.put(11, box.getMinZ());
}
- // Pending .. (follow fboDirty)
- // gca_FboVerticesAttr.seal(gl, true);
- // gca_FboVerticesAttr.enableBuffer(gl, false);
- // fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- // fboPMVMatrix.glLoadIdentity();
- // fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1);
+ // Pending gca_FboVerticesAttr-seal and fboPMVMatrix-setup, follow fboDirty
// push data 2 GPU ..
indicesFbo.seal(gl, true);
@@ -455,11 +448,10 @@ public class VBORegion2PVBAAES2 extends GLRegion {
fb.put(3, minX); fb.put( 4, maxY);
fb.put(6, maxX); fb.put( 7, maxY);
fb.put(9, maxX); fb.put(10, minY);
+ fb.position(12);
}
gca_FboVerticesAttr.seal(true);
- fboPMVMatrix.glLoadIdentity();
- fboPMVMatrix.glOrthof(minX, maxX, minY, maxY, -1, 1);
- gcu_PMVMatrix02_dirty = true;
+ FloatUtil.makeOrthof(pmvMatrix02, 0, true, minX, maxX, minY, maxY, -1, 1);
useShaderProgram(gl, renderer, getRenderModes(), true, getQuality(), sampleCount[0]);
renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, newFboWidth, newFboHeight, vpWidth, vpHeight, sampleCount[0]);
}
@@ -472,10 +464,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
final int vpWidth, final int vpHeight, final int sampleCount) {
gl.glViewport(0, 0, vpWidth, vpHeight);
- if( gcu_FboTexSize_dirty ) {
- gl.glUniform(gcu_FboTexSize);
- gcu_FboTexSize_dirty = false;
- }
+ gl.glUniform(gcu_FboTexSize);
gl.glActiveTexture(GL.GL_TEXTURE0 + gcu_FboTexUnit.intValue());
@@ -508,7 +497,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
{
fboTexSize.put(0, fboWidth);
fboTexSize.put(1, fboHeight);
- gcu_FboTexSize_dirty=true;
}
fbo = new FBObject();
fbo.reset(gl, fboWidth, fboHeight);
@@ -532,7 +520,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
{
fboTexSize.put(0, fboWidth);
fboTexSize.put(1, fboHeight);
- gcu_FboTexSize_dirty=true;
}
} else {
fbo.bind(gl);
@@ -540,19 +527,16 @@ public class VBORegion2PVBAAES2 extends GLRegion {
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
-
- if( gcu_PMVMatrix02_dirty ) {
- gl.glUniform(gcu_PMVMatrix02);
- gcu_PMVMatrix02_dirty = false;
- }
-
gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+
renderRegion(gl);
+
fbo.unbind(gl);
fboDirty = false;
}
private void renderRegion(final GL2ES2 gl) {
+ gl.glUniform(gcu_PMVMatrix02);
gca_VerticesAttr.enableBuffer(gl, true);
gca_CurveParamsAttr.enableBuffer(gl, true);
if( null != gca_ColorsAttr ) {
@@ -571,7 +555,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
}
@Override
- protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void destroyImpl(final GL2ES2 gl) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegion2PES2 Destroy: " + this);
// Thread.dumpStack();
@@ -610,5 +594,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
indicesFbo.destroy(gl);
indicesFbo = null;
}
+ spPass1 = null;
+ spPass2 = null;
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 659f64847..8268394dd 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -43,6 +43,7 @@ public class VBORegionSPES2 extends GLRegion {
private GLArrayDataServer gca_CurveParamsAttr = null;
private GLArrayDataServer gca_ColorsAttr;
private GLArrayDataServer indicesBuffer = null;
+ private ShaderProgram spPass1 = null;
public VBORegionSPES2(final int renderModes) {
super(renderModes);
@@ -64,7 +65,7 @@ public class VBORegionSPES2 extends GLRegion {
}
@Override
- protected final void clearImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected final void clearImpl(final GL2ES2 gl) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegionSPES2 Clear: " + this);
}
@@ -87,7 +88,7 @@ public class VBORegionSPES2 extends GLRegion {
}
@Override
- protected final void pushVertex(float[] coords, float[] texParams, float[] rgba) {
+ protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) {
gca_VerticesAttr.putf(coords[0]);
gca_VerticesAttr.putf(coords[1]);
gca_VerticesAttr.putf(coords[2]);
@@ -114,7 +115,7 @@ public class VBORegionSPES2 extends GLRegion {
}
@Override
- protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void updateImpl(final GL2ES2 gl) {
// seal buffers
indicesBuffer.seal(gl, true);
indicesBuffer.enableBuffer(gl, false);
@@ -133,8 +134,6 @@ public class VBORegionSPES2 extends GLRegion {
}
}
- private ShaderProgram spPass1 = null;
-
public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final int quality) {
final RenderState rs = renderer.getRenderState();
final boolean updateLocation0 = renderer.useShaderProgram(gl, renderModes, true, quality, 0);
@@ -149,10 +148,9 @@ public class VBORegionSPES2 extends GLRegion {
if( null != gca_ColorsAttr ) {
rs.updateAttributeLoc(gl, updateLocation, gca_ColorsAttr);
}
- System.err.println("XXX changedSP "+updateLocation+", "+rs);
- System.err.println("XXX gca_VerticesAttr "+gca_VerticesAttr);
- System.err.println("XXX gca_CurveParamsAttr "+gca_CurveParamsAttr);
- System.err.println("XXX gca_ColorsAttr "+gca_ColorsAttr);
+ if( DEBUG ) {
+ System.err.println("XXX changedSP.p1 "+updateLocation+" / "+updateLocation0);
+ }
}
@@ -169,17 +167,23 @@ public class VBORegionSPES2 extends GLRegion {
}
gca_VerticesAttr.enableBuffer(gl, true);
gca_CurveParamsAttr.enableBuffer(gl, true);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.enableBuffer(gl, true);
+ }
indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
indicesBuffer.bindBuffer(gl, false);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.enableBuffer(gl, false);
+ }
gca_CurveParamsAttr.enableBuffer(gl, false);
gca_VerticesAttr.enableBuffer(gl, false);
}
@Override
- protected void destroyImpl(final GL2ES2 gl, final RegionRenderer renderer) {
+ protected void destroyImpl(final GL2ES2 gl) {
if(DEBUG_INSTANCE) {
System.err.println("VBORegionSPES2 Destroy: " + this);
}
@@ -199,5 +203,6 @@ public class VBORegionSPES2 extends GLRegion {
indicesBuffer.destroy(gl);
indicesBuffer = null;
}
+ spPass1 = null;
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java
index df5ba35f2..f37025516 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/UniformNames.java
@@ -5,7 +5,7 @@ public class UniformNames {
public static final String gcu_ColorStatic = "gcu_ColorStatic";
public static final String gcu_Weight = "gcu_Weight";
- public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix01"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi
+ public static final String gcu_PMVMatrix02 = "gcu_PMVMatrix02"; // gcu_PMVMatrix[3]; // P, Mv, and Mvi
public static final String gcu_FboTexUnit = "gcu_FboTexUnit";
public static final String gcu_FboTexSize = "gcu_FboTexSize";
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp
deleted file mode 100644
index 6e60fc044..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm-weight.fp
+++ /dev/null
@@ -1,23 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 1-pass shader w/o weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-void main (void)
-{
-
-// #include curverenderer01-pass1-curve-lineAA.glsl
-#include curverenderer01-pass1-curve-weight.glsl
-
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp
deleted file mode 100644
index 18f06fff0..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass_norm.fp
+++ /dev/null
@@ -1,23 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 1-pass shader w/o weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-void main (void)
-{
-
-// #include curverenderer01-pass1-curve-lineAA.glsl
-#include curverenderer01-pass1-curve-simple.glsl
-
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp
deleted file mode 100644
index 0a4f7b331..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa-weight.fp
+++ /dev/null
@@ -1,35 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/ weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-void main (void)
-{
- if( 0.0 < gcu_FboTexSize.z ) {
- // Pass-2: Dump Texture
- vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st);
- #if 0
- if( 0.0 == t.a ) {
- discard; // discard freezes NV tegra2 compiler
- }
- #endif
-
- mgl_FragColor = t;
- } else {
-
-#include curverenderer01-pass1-curve-weight.glsl
-
- }
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp
deleted file mode 100644
index c5cbb99b0..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_msaa.fp
+++ /dev/null
@@ -1,36 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/o weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-void main (void)
-{
- if( 0.0 < gcu_FboTexSize.z ) {
- // Pass-2: Dump Texture
- vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st);
- #if 0
- if( 0.0 == t.a ) {
- discard; // discard freezes NV tegra2 compiler
- }
- #endif
-
- mgl_FragColor = t;
- } else {
-
-#include curverenderer01-pass1-curve-simple.glsl
-
- }
-}
-
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp
deleted file mode 100644
index e3bcd20ae..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa-weight.fp
+++ /dev/null
@@ -1,44 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/ weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY))
-
-void main (void)
-{
- if( 0.0 < gcu_FboTexSize.z ) {
-
-// Quality: allsamples > [flipquad,rgss, quincunx] > poles
-#include curverenderer01-pass2-vbaa_allsamples_equal.glsl
-
-// #include curverenderer01-pass2-vbaa_flipquad3.glsl
-// #include curverenderer01-pass2-vbaa_flipquad2.glsl
-// #include curverenderer01-pass2-vbaa_flipquad.glsl
-// #include curverenderer01-pass2-vbaa_rgss.glsl
-// #include curverenderer01-pass2-vbaa_quincunx.glsl
-
-// #include curverenderer01-pass2-vbaa_poles_equalweight.glsl
-// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl
-// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl
-// #include curverenderer01-pass2-vbaa_allsamples_prop01.glsl
-// #include curverenderer01-pass2-vbaa_fxaa3.glsl
-
- } else {
-
-#include curverenderer01-pass1-curve-weight.glsl
-
- }
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp
deleted file mode 100644
index 52c719e46..000000000
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass_vbaa.fp
+++ /dev/null
@@ -1,47 +0,0 @@
-//Copyright 2010 JogAmp Community. All rights reserved.
-
-//
-// 2-pass shader w/o weight
-//
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
- #define texture2D texture
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-#include uniforms.glsl
-#include varyings.glsl
-
-#define GetSample(texUnit, texCoord, psize, cx, cy, offX, offY) texture2D(texUnit, texCoord + psize * vec2(cx+offX, cy+offY))
-
-void main (void)
-{
- if( 0.0 < gcu_FboTexSize.z ) {
-
-// Quality: allsamples > [flipquad,rgss, quincunx] > poles
-
- if( 0.0 >= gcu_FboTexSize.w ) {
-#include curverenderer01-pass2-vbaa_flipquad3.glsl
- } else {
-#include curverenderer01-pass2-vbaa_allsamples_equal.glsl
- }
-// #include curverenderer01-pass2-vbaa_flipquad2.glsl
-// #include curverenderer01-pass2-vbaa_flipquad.glsl
-// #include curverenderer01-pass2-vbaa_rgss.glsl
-// #include curverenderer01-pass2-vbaa_quincunx.glsl
-
-// #include curverenderer01-pass2-vbaa_poles_equalweight.glsl
-// #include curverenderer01-pass2-vbaa_poles_bilin1.glsl
-// #include curverenderer01-pass2-vbaa_poles_propweight1.glsl
-// #include curverenderer01-pass2-vbaa_allsamples_prop01.glsl
-// #include curverenderer01-pass2-vbaa_fxaa3.glsl
-
- } else {
-
-#include curverenderer01-pass1-curve-simple.glsl
-
- }
-}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl
new file mode 100644
index 000000000..1872af67f
--- /dev/null
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass2-msaa.glsl
@@ -0,0 +1,10 @@
+ // Pass-2: Dump Texture
+ vec4 t = texture2D(gcu_FboTexUnit, gcv_FboTexCoord.st);
+ #if 0
+ if( 0.0 == t.a ) {
+ discard; // discard freezes NV tegra2 compiler
+ }
+ #endif
+
+ mgl_FragColor = t;
+
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 b5d52739e..27e5ad90f 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
@@ -210,18 +210,18 @@ public class TestTextRendererNEWT00 extends UITestCase {
}
final RenderState rs = RenderState.createRenderState(SVertex.factory());
- final int rendererMode, sampleCount;
+ final int renderModes, sampleCount;
if( graphVBAASamples > 0 ) {
- rendererMode = Region.VBAA_RENDERING_BIT;
+ renderModes = Region.VBAA_RENDERING_BIT;
sampleCount = graphVBAASamples;
} else if ( graphMSAASamples > 0 ) {
- rendererMode = Region.MSAA_RENDERING_BIT;
+ renderModes = Region.MSAA_RENDERING_BIT;
sampleCount = graphMSAASamples;
} else {
- rendererMode = 0;
+ renderModes = 0;
sampleCount = 0;
}
- final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, rendererMode, sampleCount);
+ final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, renderModes, sampleCount);
System.err.println(textGLListener.getFontInfo());
window.addGLEventListener(textGLListener);
@@ -235,7 +235,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
@Override
public boolean run(GLAutoDrawable drawable) {
try {
- textGLListener.printScreen(drawable, "./", "TestTextRendererNEWT00-snap"+screenshot_num, false);
+ textGLListener.printScreen(renderModes, drawable, "./", "TestTextRendererNEWT00-snap"+screenshot_num, false);
screenshot_num++;
} catch (Exception e) {
e.printStackTrace();
@@ -322,13 +322,13 @@ public class TestTextRendererNEWT00 extends UITestCase {
public void dispose(GLAutoDrawable drawable) {
final GL2ES2 gl = drawable.getGL().getGL2ES2();
screenshot.dispose(gl);
- regionFPS.destroy(gl, renderer);
- regionFPSAnim.destroy(gl, renderer);
+ regionFPS.destroy(gl);
+ regionFPSAnim.destroy(gl);
super.dispose(drawable);
}
- public void printScreen(GLAutoDrawable drawable, String dir, String objName, boolean exportAlpha) throws GLException, IOException {
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ public void printScreen(int renderModes, GLAutoDrawable drawable, String dir, String objName, boolean exportAlpha) throws GLException, IOException {
+ final String modeS = Region.getRenderModeString(renderModes);
final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
drawable.getChosenGLCapabilities().getNumSamples(),
TestTextRendererNEWT00.fontSizeFixed, drawable.getWidth(), drawable.getHeight(), modeS, vbaaSampleCount[0]);
@@ -372,7 +372,7 @@ public class TestTextRendererNEWT00 extends UITestCase {
final float pixelSize = font.getPixelSize(fontSizeFixed, dpiH);
final float pixelSizeAnim = font.getPixelSize(fontSizeAnim, dpiH);
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ final String modeS = Region.getRenderModeString(renderModes);
final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d",
lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeFixed,
drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]);
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 c1c1dc18e..247ba69b3 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,6 @@ 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.RegionRenderer;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.newt.opengl.GLWindow;
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 ebb897484..b04808300 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -140,12 +140,12 @@ public class TestTextRendererNEWT10 extends UITestCase {
System.err.println("Chosen: "+winctx.window.getChosenCapabilities());
final RenderState rs = RenderState.createRenderState(SVertex.factory());
- final RegionRenderer renderer = RegionRenderer.create(rs, 0, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
- final TextRegionUtil textRenderUtil = new TextRegionUtil(renderer);
+ final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
+ final TextRegionUtil textRenderUtil = new TextRegionUtil(0);
// init
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- renderer.init(gl);
+ renderer.init(gl, 0);
rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
// reshape
@@ -156,17 +156,17 @@ public class TestTextRendererNEWT10 extends UITestCase {
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderString(drawable, gl, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000);
- renderString(drawable, gl, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "Hello World", 0, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "4567890123456", 4, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "I like JogAmp", 4, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000);
int c = 0;
- renderString(drawable, gl, textRenderUtil, "GlueGen", c++, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "JOAL", c++, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "JOGL", c++, -1, -1000);
- renderString(drawable, gl, textRenderUtil, "JOCL", c++, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000);
drawable.swapBuffers();
sleep();
@@ -179,7 +179,7 @@ public class TestTextRendererNEWT10 extends UITestCase {
int lastRow = -1;
- void renderString(GLDrawable drawable, GL2ES2 gl, TextRegionUtil textRenderUtil, String text, int column, int row, int z0) {
+ void renderString(GLDrawable drawable, GL2ES2 gl, RegionRenderer renderer, TextRegionUtil textRenderUtil, String text, int column, int row, int z0) {
final int height = drawable.getHeight();
int dx = 0;
@@ -191,11 +191,11 @@ public class TestTextRendererNEWT10 extends UITestCase {
dx += font.getAdvanceWidth('X', fontSize) * column;
dy -= (int)textBox.getHeight() * ( row + 1 );
- final PMVMatrix pmv = textRenderUtil.renderer.getMatrixMutable();
+ final PMVMatrix pmv = renderer.getMatrixMutable();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- textRenderUtil.drawString3D(gl, font, fontSize, text, null, texSize);
+ textRenderUtil.drawString3D(gl, renderer, 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 fb4d0baf4..05e090886 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -46,7 +46,7 @@ import com.jogamp.newt.Window;
import com.jogamp.opengl.util.PMVMatrix;
public abstract class TextRendererGLELBase implements GLEventListener {
- public final int usrRenderModes;
+ public final int renderModes;
protected final int[] vbaaSampleCount;
protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f };
@@ -87,7 +87,7 @@ public abstract class TextRendererGLELBase implements GLEventListener {
* @see #setRendererCallbacks(com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback)
*/
public TextRendererGLELBase(final int renderModes, int[] sampleCount) {
- this.usrRenderModes = renderModes;
+ this.renderModes = renderModes;
this.vbaaSampleCount = sampleCount;
}
@@ -115,7 +115,7 @@ public abstract class TextRendererGLELBase implements GLEventListener {
}
/**
- * See {@link RegionRenderer#create(RenderState, int, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback)}.
+ * See {@link RegionRenderer#create(RenderState, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback)}.
* <p>
* Must be called before {@link #init(GLAutoDrawable)}.
* </p>
@@ -135,10 +135,10 @@ public abstract class TextRendererGLELBase implements GLEventListener {
exclusivePMVMatrix = null == sharedPMVMatrix;
this.rs = RenderState.createRenderState(SVertex.factory(), sharedPMVMatrix);
}
- this.renderer = RegionRenderer.create(rs, usrRenderModes, enableCallback, disableCallback);
- this.textRenderUtil = new TextRegionUtil(renderer);
+ this.renderer = RegionRenderer.create(rs, enableCallback, disableCallback);
+ this.textRenderUtil = new TextRegionUtil(renderModes);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
- renderer.init(gl);
+ renderer.init(gl, renderModes);
rs.setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
renderer.enable(gl, false);
@@ -268,11 +268,11 @@ public abstract class TextRendererGLELBase implements GLEventListener {
}
renderer.enable(gl, true);
if( cacheRegion ) {
- textRenderUtil.drawString3D(gl, font, pixelSize, text, null, vbaaSampleCount);
+ textRenderUtil.drawString3D(gl, renderer, font, pixelSize, text, null, vbaaSampleCount);
} else if( null != region ) {
- TextRegionUtil.drawString3D(region, renderer, gl, font, pixelSize, text, null, vbaaSampleCount);
+ TextRegionUtil.drawString3D(gl, region, renderer, font, pixelSize, text, null, vbaaSampleCount);
} else {
- TextRegionUtil.drawString3D(renderer, gl, font, pixelSize, text, null, vbaaSampleCount);
+ TextRegionUtil.drawString3D(gl, renderModes, renderer, font, pixelSize, text, null, vbaaSampleCount);
}
renderer.enable(gl, false);
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 b5ac6cdaa..2b3b2e7d9 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
@@ -50,7 +50,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
OutlineShape outlineShape = null;
public GPURegionGLListener01 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) {
- super(RegionRenderer.create(rs, renderModes, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
setMatrix(-20, 00, -50, 0f, sampleCount);
}
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 d9e962ea6..fbf110809 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
@@ -50,7 +50,7 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
List<OutlineShape> outlineShapes = new ArrayList<OutlineShape>();
public GPURegionGLListener02 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) {
- super(RegionRenderer.create(rs, renderModes, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
setMatrix(-20, 00, -50, 0f, sampleCount);
}
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 65ed86947..420e23f4d 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
@@ -133,7 +133,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
System.err.println("*** GLDebugMessage "+gl.getContext().isGLDebugMessageEnabled());
MSAATool.dump(drawable);
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- getRenderer().init(gl);
+ getRenderer().init(gl, renderModes);
}
public static void mapWin2ObjectCoords(final PMVMatrix pmv, final int[] view,
@@ -183,7 +183,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
autoDrawable = null;
GL2ES2 gl = drawable.getGL().getGL2ES2();
if(null != region) {
- region.destroy(gl, renderer);
+ region.destroy(gl);
}
screenshot.dispose(gl);
renderer.destroy(gl);
@@ -325,7 +325,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
@Override
public boolean run(GLAutoDrawable drawable) {
try {
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ final String modeS = Region.getRenderModeString(renderModes);
final String type = modeS + ( Region.hasVariableWeight(renderModes) ? "-vc" : "-uc" ) ;
printScreen(drawable, "./", "demo-"+type, "snap"+screenshot_num, false);
screenshot_num++;
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 7372eb8f6..5dcfea4a9 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
@@ -113,11 +113,10 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
boolean userInput = false;
public GPUTextRendererListenerBase01(RenderState rs, int renderModes, int sampleCount, boolean blending, boolean debug, boolean trace) {
// NOTE_ALPHA_BLENDING: We use alpha-blending
- super(RegionRenderer.create(rs, renderModes,
- blending ? RegionRenderer.defaultBlendEnable : null,
+ super(RegionRenderer.create(rs, blending ? RegionRenderer.defaultBlendEnable : null,
blending ? RegionRenderer.defaultBlendDisable : null),
renderModes, debug, trace);
- this.textRegionUtil = new TextRegionUtil(this.getRenderer());
+ this.textRegionUtil = new TextRegionUtil(renderModes);
this.regionFPS = GLRegion.create(renderModes);
this.regionBottom = GLRegion.create(renderModes);
try {
@@ -192,8 +191,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
@Override
public void dispose(GLAutoDrawable drawable) {
- regionFPS.destroy(drawable.getGL().getGL2ES2(), getRenderer());
- regionBottom.destroy(drawable.getGL().getGL2ES2(), getRenderer());
+ regionFPS.destroy(drawable.getGL().getGL2ES2());
+ regionBottom.destroy(drawable.getGL().getGL2ES2());
super.dispose(drawable);
}
@@ -238,7 +237,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
tfps = 0f;
td = 0f;
}
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ final String modeS = Region.getRenderModeString(regionFPS.getRenderModes());
final String text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize [head %.1f, bottom %.1f], %s-samples [%d, this %d], td %4.1f, blend %b, alpha-bits %d",
lfps, tfps, gl.getSwapInterval(), fontSizeHead, fontSizeBottom, modeS, getSampleCount()[0], sampleCountFPS[0], td,
renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED),
@@ -248,7 +247,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0);
// No cache, keep region alive!
- TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, nearPlaneS * pixelSizeFPS, text, null, sampleCountFPS);
+ TextRegionUtil.drawString3D(gl, regionFPS, renderer, font, nearPlaneS * pixelSizeFPS, text, null, sampleCountFPS);
}
float dx = width-fontNameBox.getWidth()-2f;
@@ -259,7 +258,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
pmv.glLoadIdentity();
pmv.glTranslatef(nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy), nearPlaneZ0);
// System.err.printf("FontN: [%f %f] -> [%f %f]%n", dx, dy, nearPlaneX0+(dx*nearPlaneSx), nearPlaneY0+(dy*nearPlaneSy));
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeFName, fontName, null, getSampleCount());
+ textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeFName, fontName, null, getSampleCount());
dx = 10f;
dy += -fontNameBox.getHeight() - 10f;
@@ -271,7 +270,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
// 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);
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeHead, headtext, null, getSampleCount());
+ textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeHead, headtext, null, getSampleCount());
}
dy += -headbox.getHeight() - font.getLineHeight(pixelSizeBottom);
@@ -293,15 +292,15 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
}
if(!userInput) {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
+ TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
} else {
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
+ textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount());
}
} else {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(regionBottom, renderer, gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
+ TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
} else {
- textRegionUtil.drawString3D(gl, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
+ textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount());
}
}
}
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 b3b17375d..e93d6607e 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
@@ -45,22 +45,25 @@ public class GPUUISceneGLListener0A implements GLEventListener {
private RegionRenderer renderer;
- int fontSet = FontFactory.UBUNTU;
- Font font;
+ private final int fontSet = FontFactory.UBUNTU;
+ private Font font;
- final float relTop = 5f/6f;
- final float relRight = 2f/6f;
- final float relLeft = 1f/6f;
+ private final float sceneDist = 3000f;
+ private final float zNear = 0.1f, zFar = 7000f;
+
+ private final float relTop = 5f/6f;
+ private final float relRight = 2f/6f;
+ private final float relLeft = 1f/6f;
/** Proportional Button Size to Window Height, per-vertical-pixels [PVP] */
- final float buttonYSizePVP = 0.084f;
- final float buttonXSizePVP = 0.105f;
- final float fontSizePt = 10f;
+ private final float buttonYSizePVP = 0.084f;
+ private final float buttonXSizePVP = 0.105f;
+ private final float fontSizePt = 10f;
/** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */
- final float fontSizeFixedPVP = 0.046f;
+ private final float fontSizeFixedPVP = 0.046f;
/** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */
- final float fontSizeFpsPVP = 0.038f;
- float dpiH = 96;
+ private final float fontSizeFpsPVP = 0.038f;
+ private float dpiH = 96;
private int currentText = 0;
@@ -91,7 +94,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
public GPUUISceneGLListener0A(RenderState rs, int renderModes, boolean debug, boolean trace) {
this.rs = rs;
- this.renderModes = renderModes | Region.COLORCHANNEL_RENDERING_BIT;
+ this.renderModes = renderModes;
this.debug = debug;
this.trace = trace;
@@ -101,7 +104,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
System.err.println("Catched: "+ioe.getMessage());
ioe.printStackTrace();
}
- sceneUIController = new SceneUIController();
+ sceneUIController = new SceneUIController(sceneDist, zNear, zFar);
screenshot = new GLReadBufferUtil(false, false);
}
@@ -141,8 +144,8 @@ public class GPUUISceneGLListener0A implements GLEventListener {
}
}
- private void initButtons(final GL gl, final int width, final int height, final RegionRenderer renderer) {
- final boolean pass2Mode = 0 != ( renderer.getRenderModes() & ( Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT ) ) ;
+ private void initButtons(final GL gl, final int width, final int height, final float labelZOffset, final RegionRenderer renderer) {
+ final boolean pass2Mode = Region.isTwoPass( renderModes ) ;
buttons.clear();
final float buttonXSize = buttonXSizePVP * width;
@@ -153,7 +156,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
final float diffX = 1.2f * buttonXSize;
final float diffY = 1.5f * buttonYSize;
- RIButton button = new RIButton(SVertex.factory(), font, "Next Text", buttonXSize, buttonYSize);
+ RIButton button = new RIButton(SVertex.factory(), renderModes, font, "Next Text", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart-diffY*buttons.size(), 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -170,7 +173,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
- button = new RIButton(SVertex.factory(), font, "Show FPS", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "Show FPS", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setToggleable(true);
button.setPressed(fpsLabel.isEnabled());
@@ -187,7 +190,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
- button = new RIButton(SVertex.factory(), font, "v-sync", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "v-sync", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setToggleable(true);
button.setPressed(gl.getSwapInterval()>0);
@@ -211,7 +214,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
- button = new RIButton(SVertex.factory(), font, "< tilt >", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "< tilt >", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -234,7 +237,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
if( pass2Mode ) { // second column to the left
- button = new RIButton(SVertex.factory(), font, "< samples >", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "< samples >", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -261,7 +264,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
button.addMouseListener(dragZoomRotateListener);
buttons.add(button);
- button = new RIButton(SVertex.factory(), font, "< quality >", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "< quality >", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -275,12 +278,12 @@ public class GPUUISceneGLListener0A implements GLEventListener {
if( shapeEvent.rotPosition[0] < shapeEvent.rotBounds.getCenter()[0] ) {
// left-half pressed
if( quality > 0 ) {
- quality=0;
+ quality--;
}
} else {
// right-half pressed
- if( quality < 1 ) {
- quality=1;
+ if( quality < Region.MAX_QUALITY ) {
+ quality++;
}
}
sceneUIController.setAllShapesQuality(quality);
@@ -290,7 +293,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
}
- button = new RIButton(SVertex.factory(), font, "Quit", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "Quit", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart,ystart - diffY*buttons.size(), 0f);
button.setColor(0.8f, 0.0f, 0.0f, 1.0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
@@ -316,7 +319,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
{
int j = 1; // column
int k = 0; // row
- button = new RIButton(SVertex.factory(), font, "y flip", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "y flip", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -328,7 +331,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "x flip", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "x flip", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -340,7 +343,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "+", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "+", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -368,7 +371,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "< space >", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "< space >", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -393,7 +396,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "< corner >", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "< corner >", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -419,7 +422,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "reset", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "reset", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -431,7 +434,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
buttons.add(button);
k++;
- button = new RIButton(SVertex.factory(), font, "screenshot", buttonXSize, buttonYSize);
+ button = new RIButton(SVertex.factory(), renderModes, font, "screenshot", buttonXSize, buttonYSize, labelZOffset);
button.translate(xstart - diffX*j,ystart - diffY*k, 0f);
button.setLabelColor(1.0f, 1.0f, 1.0f);
button.addMouseListener(new MouseAdapter() {
@@ -529,28 +532,33 @@ public class GPUUISceneGLListener0A implements GLEventListener {
ioe.printStackTrace();
}
- renderer = RegionRenderer.create(rs, renderModes, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
- // renderer = RegionRenderer.create(rs, renderModes, null, null);
+ renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
+ // renderer = RegionRenderer.create(rs, null, null);
gl.setSwapInterval(1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
gl.glEnable(GL2ES2.GL_BLEND);
- renderer.init(gl);
+ final int zBits = drawable.getChosenGLCapabilities().getDepthBits();
+ final float zEpsilon = FloatUtil.getZBufferEpsilon(zBits, sceneDist, zNear);
+ final float labelZOffset = Region.isTwoPass(renderModes) ? RIButton.DEFAULT_2PASS_LABEL_ZOFFSET : -2f*zEpsilon;
+ System.err.println("zEpsilon "+zEpsilon+" ( zBits "+zBits+") -> labelZOffset "+labelZOffset);
+
+ renderer.init(gl, renderModes);
initTexts();
sceneUIController.setRenderer(renderer);
final float pixelSizeFixed = fontSizeFixedPVP * drawable.getHeight();
- jogampLabel = new Label(SVertex.factory(), font, pixelSizeFixed, jogamp);
+ jogampLabel = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSizeFixed, jogamp);
jogampLabel.addMouseListener(dragZoomRotateListener);
sceneUIController.addShape(jogampLabel);
jogampLabel.setEnabled(enableOthers);
final float pixelSize10Pt = font.getPixelSize(fontSizePt, dpiH);
System.err.println("10Pt PixelSize: Display "+dpiH+" dpi, fontSize "+fontSizePt+" ppi -> "+pixelSize10Pt+" pixel-size");
- truePtSizeLabel = new Label(SVertex.factory(), font, pixelSize10Pt, truePtSize);
+ truePtSizeLabel = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSize10Pt, truePtSize);
sceneUIController.addShape(truePtSizeLabel);
truePtSizeLabel.setEnabled(enableOthers);
truePtSizeLabel.translate(0, - 1.5f * jogampLabel.getLineHeight(), 0f);
@@ -562,19 +570,19 @@ public class GPUUISceneGLListener0A implements GLEventListener {
* [FPS] Display 112.88889 dpi, fontSize 12.0 ppi -> pixelSize 15.679012
*/
final float pixelSizeFPS = fontSizeFpsPVP * drawable.getHeight();
- fpsLabel = new Label(renderer.getRenderState().getVertexFactory(), font, pixelSizeFPS, "Nothing there yet");
+ fpsLabel = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSizeFPS, "Nothing there yet");
fpsLabel.addMouseListener(dragZoomRotateListener);
sceneUIController.addShape(fpsLabel);
fpsLabel.setEnabled(enableOthers);
fpsLabel.setColor(0.3f, 0.3f, 0.3f, 1.0f);
- crossHairCtr = new CrossHair(renderer.getRenderState().getVertexFactory(), 100f, 100f, 2f);
+ crossHairCtr = new CrossHair(renderer.getRenderState().getVertexFactory(), 0, 100f, 100f, 2f);
crossHairCtr.addMouseListener(dragZoomRotateListener);
sceneUIController.addShape(crossHairCtr);
crossHairCtr.setEnabled(true);
crossHairCtr.translate(0f, 0f, -1f);
- initButtons(gl, drawable.getWidth(), drawable.getHeight(), renderer);
+ initButtons(gl, drawable.getWidth(), drawable.getHeight(), labelZOffset, renderer);
for(int i=0; i<buttons.size(); i++) {
sceneUIController.addShape(buttons.get(i));
}
@@ -607,7 +615,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
private int shotCount = 0;
public void printScreen(final GL gl) {
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ final String modeS = Region.getRenderModeString(jogampLabel.getRenderModes());
final String filename = String.format("GraphUIDemo-shot%03d-%03dx%03d-S_%s_%02d.png",
shotCount++, renderer.getWidth(), renderer.getHeight(),
modeS, sceneUIController.getSampleCount());
@@ -627,7 +635,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
final float pixelSizeFixed = fontSizeFixedPVP * drawable.getHeight();
final float dyTop = drawable.getHeight() * relTop;
final float dxRight = drawable.getWidth() * relRight;
- labels[currentText] = new Label(SVertex.factory(), font, pixelSizeFixed, strings[currentText]);
+ labels[currentText] = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSizeFixed, strings[currentText]);
labels[currentText].setColor(0.1f, 0.1f, 0.1f, 1.0f);
labels[currentText].setEnabled(enableOthers);
labels[currentText].translate(dxRight,
@@ -648,7 +656,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
tfps = 0f;
td = 0f;
}
- final String modeS = Region.getRenderModeString(renderer.getRenderModes());
+ final String modeS = Region.getRenderModeString(jogampLabel.getRenderModes());
final String text;
if( null == actionText ) {
final String timePrec = gl.isGLES() ? "4.0" : "4.1";
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 450d5743a..a0842b142 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
@@ -40,8 +40,8 @@ import com.jogamp.graph.geom.Vertex.Factory;
public class CrossHair extends UIShape {
private float width, height, lineWidth;
- public CrossHair(Factory<? extends Vertex> factory, float width, float height, float linewidth) {
- super(factory);
+ public CrossHair(Factory<? extends Vertex> factory, int renderModes, float width, float height, float linewidth) {
+ super(factory, renderModes);
this.width = width;
this.height = height;
this.lineWidth = linewidth;
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 2f942fd13..6209bd975 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
@@ -43,8 +43,8 @@ public class Label extends UIShape {
protected float pixelSize;
protected String text;
- public Label(Factory<? extends Vertex> factory, Font font, float pixelSize, String text) {
- super(factory);
+ public Label(Factory<? extends Vertex> factory, int renderModes, Font font, float pixelSize, String text) {
+ super(factory, renderModes);
this.font = font;
this.pixelSize = pixelSize;
this.text = text;
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 d46343f9d..e83097488 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
@@ -32,10 +32,12 @@ import javax.media.opengl.GL2ES2;
import jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.curve.OutlineShape;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
+import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.geom.AABBox;
/**
@@ -49,19 +51,21 @@ public class RIButton extends UIShape {
/** {@value} */
public static final float DEFAULT_CORNER = 1f;
- private float width, height;
+ public static final float DEFAULT_2PASS_LABEL_ZOFFSET = -0.05f;
+
+ private float width, height, labelZOffset;
private final Label0 label;
private float spacingX = DEFAULT_SPACING_X;
private float spacingY = DEFAULT_SPACING_Y;
private float corner = DEFAULT_CORNER;
- private float labelZOffset = -0.05f;
- public RIButton(Factory<? extends Vertex> factory, Font labelFont, String labelText, float width, float height) {
- super(factory);
+ public RIButton(Factory<? extends Vertex> factory, int renderModes, Font labelFont, String labelText, float width, float height, float labelZOffset) {
+ super(factory, renderModes | Region.COLORCHANNEL_RENDERING_BIT);
this.label = new Label0(labelFont, labelText, new float[] { 0.9f, 0.9f, 0.9f, 1.0f });
this.width = width;
this.height = height;
+ this.labelZOffset = labelZOffset;
}
public final float getWidth() { return width; }
@@ -84,11 +88,15 @@ public class RIButton extends UIShape {
@Override
public void drawShape(GL2ES2 gl, RegionRenderer renderer, int[] sampleCount) {
- // 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);
+ if( false ) {
+ // Setup poly offset for z-fighting
+ gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL);
+ gl.glPolygonOffset(0f, 1f);
+ super.drawShape(gl, renderer, sampleCount);
+ gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
+ } else {
+ super.drawShape(gl, renderer, sampleCount);
+ }
}
@Override
@@ -198,8 +206,8 @@ public class RIButton extends UIShape {
return labelZOffset;
}
- public void setLabelZOffset(float labelZOffset) {
- this.labelZOffset = -labelZOffset;
+ public void setLabelZOffset(final float labelZOffset) {
+ this.labelZOffset = labelZOffset;
dirty |= DIRTY_SHAPE;
}
public final float getSpacingX() { return spacingX; }
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 4f77ad3ad..62e82a038 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
@@ -23,13 +23,12 @@ import com.jogamp.opengl.util.PMVMatrix;
public class SceneUIController implements GLEventListener{
private final ArrayList<UIShape> shapes = new ArrayList<UIShape>();
- private final float sceneDist = 1000f;
+ private final float sceneDist, zNear, zFar;
private RegionRenderer renderer;
private final int[] sampleCount = new int[1];
- private final float zNear = 0.1f, zFar = 7000f;
/** Describing the bounding box in model-coordinates of the near-plane parallel at distance one. */
private final AABBox nearPlane1Box = new AABBox();
private final int[] viewport = new int[] { 0, 0, 0, 0 };
@@ -42,12 +41,15 @@ public class SceneUIController implements GLEventListener{
private GLAutoDrawable cDrawable = null;
- public SceneUIController() {
- this(null);
+ public SceneUIController(final float sceneDist, final float zNear, final float zFar) {
+ this(null, sceneDist, zNear, zFar);
}
- public SceneUIController(RegionRenderer renderer) {
+ public SceneUIController(RegionRenderer renderer, float sceneDist, float zNear, float zFar) {
this.renderer = renderer;
+ this.sceneDist = sceneDist;
+ this.zFar = zFar;
+ this.zNear = zNear;
this.sampleCount[0] = 4;
}
@@ -205,7 +207,7 @@ public class SceneUIController implements GLEventListener{
final float zNear, final float zFar,
float orthoX, float orthoY, float orthoDist,
final float[] winZ, final float[] objPos) {
- winZ[0] = (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar);
+ winZ[0] = FloatUtil.getOrthoWinZ(orthoDist, zNear, zFar);
pmv.gluUnProject(orthoX, orthoY, winZ[0], view, 0, objPos, 0);
}
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 5010e2d94..4bab03088 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
@@ -45,12 +45,12 @@ import com.jogamp.opengl.util.PMVMatrix;
public class UIGLListener01 extends UIListenerBase01 {
- public UIGLListener01 (RenderState rs, boolean debug, boolean trace) {
- super(RegionRenderer.create(rs, 0, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), debug, trace);
+ public UIGLListener01 (int renderModes, RenderState rs, boolean debug, boolean trace) {
+ super(renderModes, RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), debug, trace);
setMatrix(-20, 00, 0f, -50);
try {
final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault();
- button = new RIButton(SVertex.factory(), font, "Click me!", 4f, 3f);
+ button = new RIButton(SVertex.factory(), 0, font, "Click me!", 4f, 3f, -0.05f);
button.translate(2,1,0);
/** Button defaults !
button.setLabelColor(1.0f,1.0f,1.0f);
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 21a2b079d..5445c6145 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
@@ -41,6 +41,7 @@ import javax.media.opengl.GLException;
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.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
@@ -61,6 +62,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
*/
public abstract class UIListenerBase01 implements GLEventListener {
private final GLReadBufferUtil screenshot;
+ private final int renderModes;
private final RegionRenderer rRenderer;
private final boolean debug;
private final boolean trace;
@@ -81,7 +83,8 @@ public abstract class UIListenerBase01 implements GLEventListener {
boolean ignoreInput = false;
- public UIListenerBase01(RegionRenderer rRenderer, boolean debug, boolean trace) {
+ public UIListenerBase01(int renderModes, RegionRenderer rRenderer, boolean debug, boolean trace) {
+ this.renderModes = renderModes;
this.rRenderer = rRenderer;
this.debug = debug;
this.trace = trace;
@@ -112,7 +115,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
}
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- getRegionRenderer().init(gl);
+ getRegionRenderer().init(gl, renderModes);
}
public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
@@ -303,7 +306,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
autoDrawable.invoke(false, new GLRunnable() {
public boolean run(GLAutoDrawable drawable) {
try {
- final String type = ( 1 == rRenderer.getRenderModes() ) ? "r2t0-msaa1" : "r2t1-msaa0" ;
+ final String type = Region.getRenderModeString(renderModes);
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/ui/UINewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UINewtDemo01.java
index 2c444d47e..27a91befc 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
@@ -64,7 +64,7 @@ public class UINewtDemo01 {
window.setSize(800, 400);
window.setTitle("GPU UI Newt Demo 01");
RenderState rs = RenderState.createRenderState(SVertex.factory());
- UIGLListener01 uiGLListener = new UIGLListener01 (rs, DEBUG, TRACE);
+ UIGLListener01 uiGLListener = new UIGLListener01 (0, rs, DEBUG, TRACE);
uiGLListener.attachInputListenerTo(window);
window.addGLEventListener(uiGLListener);
window.setVisible(true);
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 bca60494b..554398435 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
@@ -49,20 +49,22 @@ import com.jogamp.opengl.math.geom.AABBox;
public abstract class UIShape {
public static final boolean DRAW_DEBUG_BOX = false;
- private final Factory<? extends Vertex> vertexFactory;
-
protected static final int DIRTY_SHAPE = 1 << 0 ;
- protected int dirty = DIRTY_SHAPE;
- protected float shapesSharpness = OutlineShape.DEFAULT_SHARPNESS;
+ private final Factory<? extends Vertex> vertexFactory;
+ private final int renderModes;
protected final AABBox box;
+
protected final float[] translate = new float[] { 0f, 0f, 0f };
protected final Quaternion rotation = new Quaternion();
protected final float[] rotOrigin = new float[] { 0f, 0f, 0f };
protected final float[] scale = new float[] { 1f, 1f, 1f };
protected GLRegion region = null;
- protected int regionQuality = 99;
+ protected int regionQuality = Region.MAX_QUALITY;
+
+ protected int dirty = DIRTY_SHAPE;
+ protected float shapesSharpness = OutlineShape.DEFAULT_SHARPNESS;
protected final float[] rgbaColor = {0.6f, 0.6f, 0.6f, 1.0f};
protected final float[] selectedRGBAModulate = {1.4f, 1.4f, 1.4f, 1.0f};
@@ -73,8 +75,9 @@ public abstract class UIShape {
private boolean enabled = true;
private ArrayList<MouseListener> mouseListeners = new ArrayList<MouseListener>();
- public UIShape(Factory<? extends Vertex> factory) {
+ public UIShape(final Factory<? extends Vertex> factory, final int renderModes) {
this.vertexFactory = factory;
+ this.renderModes = renderModes;
this.box = new AABBox();
}
@@ -166,6 +169,8 @@ public abstract class UIShape {
public final AABBox getBounds() { return box; }
+ public final int getRenderModes() { return renderModes; }
+
public GLRegion getRegion(GL2ES2 gl, RegionRenderer renderer) {
validate(gl, renderer);
return region;
@@ -202,7 +207,7 @@ public abstract class UIShape {
}
final RenderState rs = renderer.getRenderState();
- if( Region.hasColorChannel( renderer.getRenderModes() ) ) {
+ if( Region.hasColorChannel( renderModes ) ) {
if( isSelect ) {
rs.setColorStatic(selectedRGBAModulate[0], selectedRGBAModulate[1], selectedRGBAModulate[2], selectedRGBAModulate[3]);
} else {
@@ -218,13 +223,13 @@ public abstract class UIShape {
if( isShapeDirty() ) {
box.reset();
if( null == region ) {
- region = GLRegion.create(renderer.getRenderModes());
+ region = GLRegion.create(renderModes);
} else {
- region.clear(gl, renderer);
+ region.clear(gl);
}
addShapeToRegion(gl, renderer);
if( DRAW_DEBUG_BOX ) {
- region.clear(gl, renderer);
+ region.clear(gl);
final OutlineShape shape = new OutlineShape(renderer.getRenderState().getVertexFactory());
shape.setSharpness(shapesSharpness);
shape.setIsQuadraticNurbs();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
index 2e13f22e2..b96ef21a9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
@@ -63,7 +63,7 @@ public abstract class GLReadBuffer00Base extends UITestCase {
// FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO
super(Region.VBAA_RENDERING_BIT, new int[] { 4 });
this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
- regionFPS = GLRegion.create(usrRenderModes);
+ regionFPS = GLRegion.create(renderModes);
staticRGBAColor[0] = 0.9f;
staticRGBAColor[1] = 0.9f;
@@ -73,7 +73,7 @@ public abstract class GLReadBuffer00Base extends UITestCase {
@Override
public void dispose(GLAutoDrawable drawable) {
- regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer);
+ regionFPS.destroy(drawable.getGL().getGL2ES2());
super.dispose(drawable);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
index 62977f5ec..2abf083b1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
@@ -180,8 +180,8 @@ public class MovieCube implements GLEventListener {
if( lowPerfDevice ) {
regionFPS = null;
} else {
- regionFPS = GLRegion.create(usrRenderModes);
- System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName());
+ regionFPS = GLRegion.create(renderModes);
+ System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName());
}
staticRGBAColor[0] = 0.1f;
staticRGBAColor[1] = 0.1f;
@@ -208,7 +208,7 @@ public class MovieCube implements GLEventListener {
@Override
public void dispose(GLAutoDrawable drawable) {
if( null != regionFPS ) {
- regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer);
+ regionFPS.destroy(drawable.getGL().getGL2ES2());
}
super.dispose(drawable);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index 7dbe68f84..f76859a9e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
@@ -149,8 +149,8 @@ public class MovieSimple implements GLEventListener {
if( lowPerfDevice ) {
regionFPS = null;
} else {
- regionFPS = GLRegion.create(usrRenderModes);
- System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName());
+ regionFPS = GLRegion.create(renderModes);
+ System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName());
}
staticRGBAColor[0] = 0.9f;
staticRGBAColor[1] = 0.9f;
@@ -166,7 +166,7 @@ public class MovieSimple implements GLEventListener {
@Override
public void dispose(GLAutoDrawable drawable) {
if( null != regionFPS ) {
- regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer);
+ regionFPS.destroy(drawable.getGL().getGL2ES2());
}
super.dispose(drawable);
}