diff options
author | Sven Gothel <[email protected]> | 2014-03-05 00:14:47 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-03-05 00:14:47 +0100 |
commit | fe3daea00da48c90a4e0c90cf37514a3ab7093d6 (patch) | |
tree | d1265ae31e9a58ca47e2bab8f64e6b476f120bc9 /src | |
parent | 8bab15934fe63e44084294e315492420e07a902b (diff) |
Bug 801: Refine 'blend' usage and modes (API-doc and demo-code)
- RegionRenderer: Make 'blend' setup pluggable via new GLCallbacks
- 'GLCallback's for enable/disable, passed via 'create' method.
Add 'defaultBlendEnable' and 'defaultBlendDisable',
replacing previos fixed calls.
- GLRegion.draw(..) added API-doc notes about:
- Decorating call with RegionRenderer.enable(..)
- glClearColor impact and blending
- VBORegion2P*: Remove fixed glClearColor(..) call
Diffstat (limited to 'src')
22 files changed, 283 insertions, 116 deletions
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 014b1641a..defb7722a 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -27,6 +27,7 @@ */
package com.jogamp.graph.curve.opengl;
+import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import com.jogamp.opengl.util.PMVMatrix;
@@ -93,10 +94,30 @@ public abstract class GLRegion extends Region { * Renders the associated OGL objects specifying
* current width/hight of window for multi pass rendering
* of the region.
+ * <p>
+ * User shall consider {@link RegionRenderer#enable(GL2ES2, boolean) enabling}
+ * the renderer beforehand and {@link RegionRenderer#enable(GL2ES2, boolean) disabling}
+ * it afterwards when used in conjunction with other renderer.
+ * </p>
+ * <p>
+ * Users shall also consider setting the {@link GL#glClearColor(float, float, float, float) Clear Color}
+ * appropriately:
+ * <ul>
+ * <li>If {@link GL#GL_BLEND blending} is enabled, <i>RGB</i> shall be set to text color, otherwise
+ * blending will reduce the alpha seam's contrast and the font will appear thinner.</li>
+ * <li>If {@link GL#GL_BLEND blending} is disabled, <i>RGB</i> shall be set to the actual desired background.</li>
+ * </ul>
+ * 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}
+ * with the appropriate {@link {@link RegionRenderer.GLCallback callbacks}.
+ * </p>
* @param matrix current {@link PMVMatrix}.
* @param renderer the {@link RegionRenderer} to be used
* @param sampleCount desired multisampling sample count for msaa-rendering.
* 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) {
if(isDirty()) {
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 7e0c17eb9..1f6e532d3 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -29,6 +29,7 @@ package com.jogamp.graph.curve.opengl; import java.nio.FloatBuffer; +import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; @@ -49,23 +50,75 @@ public abstract class RegionRenderer { protected static final boolean DEBUG = Region.DEBUG; protected static final boolean DEBUG_INSTANCE = Region.DEBUG_INSTANCE; + public interface GLCallback { + /** + * @param gl a current GL object + * @param renderer {@link RegionRenderer} calling this method. + */ + void run(GL gl, RegionRenderer renderer); + } + + /** + * Default {@link GL#GL_BLEND} <i>enable</i> {@link GLCallback}, + * turning on the {@link GL#GL_BLEND} state and setting up + * {@link GL#glBlendFunc(int, int) glBlendFunc}({@link GL#GL_SRC_ALPHA}, {@link GL#GL_ONE_MINUS_SRC_ALPHA}). + * @see #setEnableCallback(GLCallback, GLCallback) + * @see #enable(GL2ES2, boolean) + */ + public static final GLCallback defaultBlendEnable = new GLCallback() { + @Override + public void run(final GL gl, final RegionRenderer args) { + gl.glEnable(GL.GL_BLEND); + gl.glBlendEquation(GL.GL_FUNC_ADD); // default + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + } + }; + + /** + * Default {@link GL#GL_BLEND} <i>disable</i> {@link GLCallback}, + * simply turning off the {@link GL#GL_BLEND} state. + * @see #setEnableCallback(GLCallback, GLCallback) + * @see #enable(GL2ES2, boolean) + */ + public static final GLCallback defaultBlendDisable = new GLCallback() { + @Override + public void run(final GL gl, final RegionRenderer args) { + gl.glDisable(GL.GL_BLEND); + } + }; + public static boolean isWeightValid(float v) { return 0.0f <= v && v <= 1.9f ; } /** * Create a Hardware accelerated Region Renderer. + * <p> + * The optional {@link GLCallback}s <code>enableCallback</code> and <code>disableCallback</code> + * maybe used to issue certain tasks at {@link #enable(GL2ES2, boolean)}.<br/> + * For example, instances {@link #defaultBlendEnable} and {@link #defaultBlendDisable} + * 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#VARIABLE_CURVE_WEIGHT_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)}. + * @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(RenderState rs, int renderModes) { - return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, renderModes); + public static RegionRenderer create(final RenderState rs, final int renderModes, + final GLCallback enableCallback, final GLCallback disableCallback) { + return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, renderModes, enableCallback, disableCallback); } protected final int renderModes; protected final RenderState rs; + protected final GLCallback enableCallback; + protected final GLCallback disableCallback; + protected int vp_width; protected int vp_height; protected boolean initialized; @@ -96,9 +149,11 @@ public abstract class RegionRenderer { * @param rs the used {@link RenderState} * @param renderModes bit-field of modes */ - protected RegionRenderer(RenderState rs, int renderModes) { + protected RegionRenderer(final RenderState rs, final int renderModes, final GLCallback enableCallback, final GLCallback disableCallback) { this.rs = rs; this.renderModes = renderModes; + this.enableCallback = enableCallback; + this.disableCallback = disableCallback; } public final int getRenderModes() { @@ -148,8 +203,9 @@ public abstract class RegionRenderer { rs.attachTo(gl); - gl.glEnable(GL2ES2.GL_BLEND); - gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA); // FIXME: alpha blending stage ? + if( null != enableCallback ) { + enableCallback.run(gl, this); + } initialized = initImpl(gl); if(!initialized) { @@ -191,7 +247,25 @@ public abstract class RegionRenderer { public final RenderState getRenderState() { return rs; } public final ShaderState getShaderState() { return rs.getShaderState(); } + /** + * Enabling or disabling the {@link RenderState#getShaderState() RenderState}'s + * {@link ShaderState#useProgram(GL2ES2, boolean) ShaderState program}. + * <p> + * In case enable and disable {@link GLCallback}s are setup via {@link #create(RenderState, int, GLCallback, GLCallback)}, + * they will be called before toggling the shader program. + * </p> + * @see #create(RenderState, int, GLCallback, GLCallback) + */ public final void enable(GL2ES2 gl, boolean enable) { + if( enable ) { + if( null != enableCallback ) { + enableCallback.run(gl, this); + } + } else { + if( null != disableCallback ) { + disableCallback.run(gl, this); + } + } rs.getShaderState().useProgram(gl, enable); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index c2762591a..e50caa663 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -41,8 +41,8 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class RegionRendererImpl01 extends RegionRenderer { - public RegionRendererImpl01(RenderState rs, int renderModes) { - super(rs, renderModes); + public RegionRendererImpl01(final RenderState rs, final int renderModes, final GLCallback enableCallback, final GLCallback disableCallback) { + super(rs, renderModes, enableCallback, disableCallback); } @Override diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 9b15ba319..4d653af12 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -353,7 +353,6 @@ public class VBORegion2PMSAAES2 extends GLRegion { gl.glViewport(0, 0, fboWidth, fboHeight); st.uniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix - gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); renderRegion(gl); fbo.unbind(gl); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index cac39fb21..07a774d51 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -349,7 +349,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { gl.glViewport(0, 0, fboWidth, fboHeight); st.uniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix - gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); renderRegion(gl); fbo.unbind(gl); 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 0a1fa7ec9..905483e7f 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -48,6 +48,7 @@ import org.junit.runners.MethodSorters; import com.jogamp.common.os.Platform; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; +import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; @@ -263,7 +264,10 @@ public class TestTextRendererNEWT00 extends UITestCase { float dpiH; TextRendererGLEL(final RenderState rs, final int renderModes, final int sampleCount) { - super(rs, true /* exclusivePMV */, renderModes, new int[] { sampleCount }); // Region.VBAA_RENDERING_BIT); + super(renderModes, new int[] { sampleCount }); + setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); + setRenderState(rs); + regionFPS = GLRegion.create(renderModes); regionFPSAnim = GLRegion.create(renderModes); if( null != fontFileName ) { 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 a0bebeae6..a8044463d 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java @@ -209,7 +209,7 @@ public class TestTextRendererNEWT01 extends UITestCase { String winTitle; public TextGLListener(RenderState rs, int type, boolean debug, boolean trace) { - super(rs, type, 4, debug, trace); + super(rs, type, 4, true, debug, trace); } public void attachInputListenerTo(GLWindow window) { 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 def46a899..d109ba1cc 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -139,7 +139,7 @@ public class TestTextRendererNEWT10 extends UITestCase { System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - final RegionRenderer renderer = RegionRenderer.create(rs, 0); + final RegionRenderer renderer = RegionRenderer.create(rs, 0, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); final TextRegionUtil textRenderUtil = new TextRegionUtil(renderer); // init 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 075d8c5e8..4b89a85fb 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -52,17 +52,10 @@ public abstract class TextRendererGLELBase implements GLEventListener { protected final int[] vbaaSampleCount; protected final float[] staticRGBAColor = new float[] { 1f, 1f, 1f, 1f }; - /** - * In exclusive mode, impl. uses a pixelScale of 1f and orthogonal PMV on window dimensions - * and renderString uses 'height' for '1'. - * <p> - * In non-exclusive mode, i.e. shared w/ custom PMV (within another 3d scene), - * it uses the custom pixelScale and renderString uses normalized 'height', i.e. '1'. - * </p> - */ - protected boolean exclusivePMVMatrix = true; - protected PMVMatrix usrPMVMatrix = null; - protected RenderState rs = null; + private boolean exclusivePMVMatrix = true; + private PMVMatrix sharedPMVMatrix = null; + private RenderState rs = null; + private RegionRenderer.GLCallback enableCallback=null, disableCallback=null; protected RegionRenderer renderer = null; protected TextRegionUtil textRenderUtil = null; @@ -90,9 +83,9 @@ public abstract class TextRendererGLELBase implements GLEventListener { } /** - * * @param renderModes * @param sampleCount desired multisampling sample count for msaa-rendering. + * @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; @@ -100,16 +93,37 @@ public abstract class TextRendererGLELBase implements GLEventListener { } /** - * + * <p> + * Must be called before {@link #init(GLAutoDrawable)}. + * </p> * @param rs - * @param exclusivePMVMatrix - * @param renderModes - * @param sampleCount desired multisampling sample count for msaa-rendering. */ - public TextRendererGLELBase(final RenderState rs, final boolean exclusivePMVMatrix, final int renderModes, int[] sampleCount) { - this(renderModes, sampleCount); - this.rs = rs; - this.exclusivePMVMatrix = exclusivePMVMatrix; + public void setRenderState(RenderState rs) { this.rs = rs; } + + /** + * In exclusive mode, impl. uses a pixelScale of 1f and orthogonal PMV on window dimensions + * and renderString uses 'height' for '1'. + * <p> + * In non-exclusive mode, i.e. shared w/ custom PMV (within another 3d scene), + * it uses the custom pixelScale and renderString uses normalized 'height', i.e. '1'. + * </p> + * <p> + * Must be called before {@link #init(GLAutoDrawable)}. + * </p> + */ + public void setSharedPMVMatrix(PMVMatrix pmv) { + this.sharedPMVMatrix = pmv; + } + + /** + * See {@link RegionRenderer#create(RenderState, int, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback)}. + * <p> + * Must be called before {@link #init(GLAutoDrawable)}. + * </p> + */ + public void setRendererCallbacks(RegionRenderer.GLCallback enable, RegionRenderer.GLCallback disable) { + this.enableCallback = enable; + this.disableCallback = disable; } public void setFlipVerticalInGLOrientation(boolean v) { flipVerticalInGLOrientation=v; } @@ -119,10 +133,10 @@ public abstract class TextRendererGLELBase implements GLEventListener { @Override public void init(GLAutoDrawable drawable) { if( null == this.rs ) { - exclusivePMVMatrix = null == usrPMVMatrix; - this.rs = RenderState.createRenderState(new ShaderState(), SVertex.factory(), usrPMVMatrix); + exclusivePMVMatrix = null == sharedPMVMatrix; + this.rs = RenderState.createRenderState(new ShaderState(), SVertex.factory(), sharedPMVMatrix); } - this.renderer = RegionRenderer.create(rs, usrRenderModes); + this.renderer = RegionRenderer.create(rs, usrRenderModes, enableCallback, disableCallback); this.textRenderUtil = new TextRegionUtil(renderer); final GL2ES2 gl = drawable.getGL().getGL2ES2(); renderer.init(gl); @@ -243,7 +257,6 @@ public abstract class TextRendererGLELBase implements GLEventListener { dx += pixelScale * font.getAdvanceWidth('X', pixelSize) * column; dy -= pixelScale * lineHeight * ( row + 1 ); - final ShaderState st = rs.getShaderState(); final PMVMatrix pmvMatrix = rs.pmvMatrix(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); if( !exclusivePMVMatrix ) { @@ -251,15 +264,13 @@ public abstract class TextRendererGLELBase implements GLEventListener { } else { pmvMatrix.glLoadIdentity(); } - - st.useProgram(gl, true); - gl.glEnable(GL2ES2.GL_BLEND); pmvMatrix.glTranslatef(dx, dy, tz); if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { pmvMatrix.glScalef(pixelScale, -1f*pixelScale, 1f); } else if( 1f != pixelScale ) { pmvMatrix.glScalef(pixelScale, pixelScale, 1f); } + renderer.enable(gl, true); renderer.updateMatrix(gl); if( cacheRegion ) { textRenderUtil.drawString3D(gl, font, pixelSize, text, vbaaSampleCount); @@ -268,8 +279,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { } else { TextRegionUtil.drawString3D(renderer, gl, font, pixelSize, text, vbaaSampleCount); } - st.useProgram(gl, false); - gl.glDisable(GL2ES2.GL_BLEND); + renderer.enable(gl, false); if( !exclusivePMVMatrix ) { pmvMatrix.glPopMatrix(); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java index 1ec69878a..9ececa082 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionRendererListenerBase01.java @@ -47,6 +47,6 @@ public abstract class GPURegionRendererListenerBase01 extends GPURendererListene OutlineShape outlineShape = null; public GPURegionRendererListenerBase01(RenderState rs, int renderModes, boolean debug, boolean trace) { - super(RegionRenderer.create(rs, renderModes), renderModes, debug, trace); + super(RegionRenderer.create(rs, renderModes, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java index 04920b579..29b897d0e 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextGLListener0A.java @@ -33,18 +33,12 @@ import javax.media.opengl.GLAutoDrawable; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; -import com.jogamp.graph.geom.SVertex; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.glsl.ShaderState; public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { - public GPUTextGLListener0A() { - this( RenderState.createRenderState(new ShaderState(), SVertex.factory()), 0, 4, false, false ) ; - } - - public GPUTextGLListener0A(RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { - super(rs, renderModes, sampleCount, debug, trace); + public GPUTextGLListener0A(RenderState rs, int renderModes, int sampleCount, boolean blending, boolean debug, boolean trace) { + super(rs, renderModes, sampleCount, blending, debug, trace); } public void init(GLAutoDrawable drawable) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java index d39a80eb9..de06310d7 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo01.java @@ -59,7 +59,7 @@ public class GPUTextNewtDemo01 { window.setTitle("GPU Text Newt Demo 01 - smsaa1"); final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, 0, 0, DEBUG, TRACE); + GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, 0, 0, true, DEBUG, TRACE); window.addGLEventListener(textGLListener); final Animator animator = new Animator(); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java index 25635314f..3dc03788b 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo02.java @@ -56,10 +56,20 @@ public class GPUTextNewtDemo02 { static final boolean TRACE = false; public static void main(String[] args) { - GLProfile glp = GLProfile.getGL2ES2(); + boolean alpha = true; + boolean blending = true; + for(int i=0; i<args.length; i++) { + if(args[i].equals("-noblend")) { + blending = false; + } else if(args[i].equals("-noalpha")) { + alpha = false; + } + } + + final GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); - caps.setAlphaBits(4); + caps.setAlphaBits( alpha ? 4 : 0 ); System.out.println("Requested: "+caps); final GLWindow window = GLWindow.create(caps); @@ -69,7 +79,7 @@ public class GPUTextNewtDemo02 { window.setTitle("GPU Text Newt Demo 02 - gvbaa4 gmsaa0"); RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.VBAA_RENDERING_BIT, 4, DEBUG, TRACE); + GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.VBAA_RENDERING_BIT, 4, blending, DEBUG, TRACE); // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32); window.addGLEventListener(textGLListener); window.setVisible(true); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo03.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo03.java index 97334311a..b050a0b7c 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo03.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo03.java @@ -69,7 +69,7 @@ public class GPUTextNewtDemo03 { window.setTitle("GPU Text Newt Demo 02 - gvbaa0 gmsaa4"); RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); - GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.MSAA_RENDERING_BIT, 4, DEBUG, TRACE); + GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, Region.MSAA_RENDERING_BIT, 4, true, DEBUG, TRACE); // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32); window.addGLEventListener(textGLListener); window.setVisible(true); 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 e5eca2360..821f6835e 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 @@ -67,14 +67,16 @@ import com.jogamp.opengl.util.PMVMatrix; */ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerBase01 { public final TextRegionUtil textRegionUtil; - final GLRegion regionFPS; + private final GLRegion regionFPS; + private final boolean useBlending; int fontSet = FontFactory.UBUNTU; Font font; int headType = 0; boolean drawFPS = true; final float fontSizeFName = 8f; - final float fontSizeFPS = 12f; + final float fontSizeFPS = 10f; + final int[] sampleCountFPS = new int[] { 8 }; float fontSizeHead = 12f; float fontSizeBottom = 16f; float dpiH = 96; @@ -109,9 +111,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB StringBuilder userString = new StringBuilder(); boolean userInput = false; - - public GPUTextRendererListenerBase01(RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) { - super(RegionRenderer.create(rs, renderModes), renderModes, debug, trace); + 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, + blending ? RegionRenderer.defaultBlendDisable : null), + renderModes, debug, trace); + this.useBlending = blending; this.textRegionUtil = new TextRegionUtil(this.getRenderer()); this.regionFPS = GLRegion.create(renderModes); try { @@ -174,18 +180,52 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB super.dispose(drawable); } + public static void mapWin2ObjectCoords(final PMVMatrix pmv, final int[] view, + 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); + pmv.gluUnProject(orthoX, orthoY, winZ[0], view, 0, objPos, 0); + } + public static void translateOrtho(final String msg, + final PMVMatrix pmv, final int[] view, + final float zNear, final float zFar, + float orthoX, float orthoY, float orthoDist, + final float[] winZ, final float[] objPos) { + mapWin2ObjectCoords(pmv, view, zNear, zFar, orthoX, orthoY, orthoDist, winZ, objPos); + pmv.glTranslatef(objPos[0], objPos[1], objPos[2]); + /** + System.err.printf("XXX %7s: [%5.1f, %5.1f, [%5.1f -> %5.1f]] --> [%8.3f, %8.3f, %8.3f]%n", + msg, orthoX, orthoY, orthoDist, winZ[0], objPos[0], objPos[1], objPos[2]); */ + } + @Override public void display(GLAutoDrawable drawable) { final int width = drawable.getWidth(); final int height = drawable.getHeight(); GL2ES2 gl = drawable.getGL().getGL2ES2(); - gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Demo02 needs to have this set here as well .. hmm ? + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + final float zNear = 0.1f, zFar = 7000f; + final float zDistance0 = 500f; + final float zDistance1 = 400f; + final float[] objPos = new float[3]; + final float[] winZ = new float[1]; + final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; + final RegionRenderer renderer = getRenderer(); - renderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f); + final PMVMatrix pmv = renderer.getMatrix(); + renderer.reshapePerspective(null, 45.0f, width, height, zNear, zFar); + renderer.resetModelview(null); renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f); + if( useBlending ) { + // NOTE_ALPHA_BLENDING: + // Due to alpha blending and VBAA, we need a black background (== text color) + // otherwise blending will amplify 'white'! + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + } final float pixelSizeFName = font.getPixelSize(fontSizeFName, dpiH); final float pixelSizeHead = font.getPixelSize(fontSizeHead, dpiH); @@ -205,20 +245,25 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB td = 0f; } final String modeS = Region.getRenderModeString(renderer.getRenderModes()); - final String text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize [head %.1f, bottom %.1f], %s-samples %d, td %4.1f", - lfps, tfps, gl.getSwapInterval(), fontSizeHead, fontSizeBottom, modeS, getSampleCount()[0], td); + 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, + useBlending, drawable.getChosenGLCapabilities().getAlphaBits()); + + // bottom, half line up renderer.resetModelview(null); - renderer.translate(gl, 0, pixelSizeFPS/2, -6000); // bottom, half line up + translateOrtho("fpstxt", pmv, view, zNear, zFar, 0, pixelSizeFPS/2, zDistance0, winZ, objPos); + renderer.updateMatrix(gl); // No cache, keep region alive! - TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, pixelSizeFPS, text, getSampleCount()); + TextRegionUtil.drawString3D(regionFPS, renderer, gl, font, pixelSizeFPS, text, sampleCountFPS); } float dx = width-fontNameBox.getWidth()-2f; float dy = height - 10f; renderer.resetModelview(null); - renderer.translate(gl, dx, dy, -6000); + translateOrtho("fontxt", pmv, view, zNear, zFar, dx, dy, zDistance0, winZ, objPos); + renderer.updateMatrix(gl); textRegionUtil.drawString3D(gl, font, pixelSizeFName, fontName, getSampleCount()); dx = 10f; @@ -226,45 +271,30 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB if(null != headtext) { renderer.resetModelview(null); - renderer.translate(gl, dx, dy, -6000); + translateOrtho("headtx", pmv, view, zNear, zFar, dx, dy, zDistance0, winZ, objPos); + renderer.updateMatrix(gl); textRegionUtil.drawString3D(gl, font, pixelSizeHead, headtext, getSampleCount()); } dy += -headbox.getHeight() - font.getLineHeight(pixelSizeBottom); - final float zNear = 0.1f, zFar = 7000f; - renderer.reshapePerspective(null, 45.0f, width, height, zNear, zFar); renderer.resetModelview(null); - - final float[] objPos = new float[3]; - { - // Dynamic layout between two projection matrices: - // Calculate object-position for perspective projection-matrix, - // to place the perspective bottom text below head. - final PMVMatrix pmv = renderer.getMatrix(); - final int[] view = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight() }; - final float zDistance = 500f; - final float winZ = (1f/zNear-1f/zDistance)/(1f/zNear-1f/zFar); - pmv.gluUnProject(dx, dy, winZ, view, 0, objPos, 0); - /** - System.err.printf("XXX %.1f/%.1f/%.1f --> [%.3f, %.3f, %.3f] + %.3f, %.3f %.3f -> %.3f, %.3f, %.3f%n", - dx, dy, winZ, objPos[0], objPos[1], objPos[2], - getXTran(), getYTran(), getZTran(), - objPos[0]+getXTran(), objPos[1]+getYTran(), objPos[2]+getZTran()); - */ - } - - // renderer.translate(null, objPos[0], objPos[1], objPos[2]); - renderer.translate(null, objPos[0]+getXTran(), objPos[1]+getYTran(), objPos[2]+getZTran()); - // renderer.translate(null, getXTran(), getYTran(), getZTran()); + translateOrtho("Bottom", pmv, view, zNear, zFar, dx, dy, zDistance1, winZ, objPos); + renderer.translate(null, getXTran(), getYTran(), getZTran()); renderer.rotate(gl, getAngle(), 0, 1, 0); renderer.setColorStatic(gl, 1.0f, 0.0f, 0.0f); + if( useBlending ) { + // NOTE_ALPHA_BLENDING: + // Due to alpha blending and VBAA, we need a black background (== text color) + // otherwise blending will amplify 'white'! + gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f); + } + if(!userInput) { textRegionUtil.drawString3D(gl, font, pixelSizeBottom, text2, getSampleCount()); } else { textRegionUtil.drawString3D(gl, font, pixelSizeBottom, userString.toString(), getSampleCount()); } - } public void fontBottomIncr(int v) { 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 1a81204d6..7587295aa 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 @@ -225,7 +225,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { ioe.printStackTrace(); } - regionRenderer = RegionRenderer.create(rs, renderModes); + regionRenderer = RegionRenderer.create(rs, renderModes, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); gl.glEnable(GL2ES2.GL_DEPTH_TEST); gl.glEnable(GL2ES2.GL_BLEND); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java index 4cddb1340..ea593ec7d 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/MSAATool.java @@ -45,27 +45,27 @@ public class MSAATool { } catch (Exception e) { System.err.println("Catched Exception: "+e.getMessage()); // e.printStackTrace(); - } + } return isEnabled; } public static void dump(GLAutoDrawable drawable) { float[] vf = new float[] { 0f }; byte[] vb = new byte[] { 0 }; int[] vi = new int[] { 0, 0 }; - + System.out.println("GL MSAA SETUP:"); GL2ES2 gl = drawable.getGL().getGL2ES2(); GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); - System.out.println(" Caps realised "+caps); + System.out.println(" Caps realised "+caps); System.out.println(" Caps sample buffers "+caps.getSampleBuffers()+", samples "+caps.getNumSamples()); - + System.out.println(" GL MULTISAMPLE "+glIsEnabled(gl, GL2ES2.GL_MULTISAMPLE)); - // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB + // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB gl.glGetIntegerv(GL2GL3.GL_SAMPLE_BUFFERS, vi, 0); // samples min 0 gl.glGetIntegerv(GL2GL3.GL_SAMPLES, vi, 1); System.out.println(" GL SAMPLE_BUFFERS "+vi[0]+", SAMPLES "+vi[1]); - + System.out.println("GL CSAA SETUP:"); // default FALSE System.out.println(" GL SAMPLE COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_COVERAGE)); @@ -76,8 +76,21 @@ public class MSAATool { // default FALSE, value 1, invert false gl.glGetFloatv(GL2GL3.GL_SAMPLE_COVERAGE_VALUE, vf, 0); gl.glGetBooleanv(GL2GL3.GL_SAMPLE_COVERAGE_INVERT, vb, 0); - System.out.println(" GL SAMPLE_COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_COVERAGE) + + System.out.println(" GL SAMPLE_COVERAGE "+glIsEnabled(gl, GL2GL3.GL_SAMPLE_COVERAGE) + ": SAMPLE_COVERAGE_VALUE "+vf[0]+ - ", SAMPLE_COVERAGE_INVERT "+vb[0]); + ", SAMPLE_COVERAGE_INVERT "+vb[0]); + dumpBlend(gl); + } + public static void dumpBlend(GL gl) { + int[] vi = new int[] { 0, 0, 0, 0 }; + gl.glGetIntegerv(GL.GL_BLEND, vi, 0); + gl.glGetIntegerv(GL.GL_BLEND_SRC_ALPHA, vi, 1); + gl.glGetIntegerv(GL.GL_BLEND_SRC_RGB, vi, 2); + gl.glGetIntegerv(GL.GL_BLEND_DST_RGB, vi, 3); + final boolean blendEnabled = vi[0] == GL.GL_TRUE; + System.out.println("GL_BLEND "+blendEnabled+"/"+glIsEnabled(gl, GL.GL_BLEND) + + " GL_SRC_ALPHA 0x"+Integer.toHexString(vi[1])+ + " GL_SRC_RGB 0x"+Integer.toHexString(vi[2])+ + " GL_DST_RGB 0x"+Integer.toHexString(vi[3])); } } 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 fa3817de8..b646c8023 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,7 +45,7 @@ import com.jogamp.opengl.test.junit.graph.demos.ui.opengl.UIRegion; public class UIGLListener01 extends UIListenerBase01 { public UIGLListener01 (RenderState rs, boolean debug, boolean trace) { - super(RegionRenderer.create(rs, 0), debug, trace); + super(RegionRenderer.create(rs, 0, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), debug, trace); setMatrix(-20, 00, 0f, -50); try { final Font font = FontFactory.get(FontFactory.UBUNTU).getDefault(); 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 8c4cfd4b3..d556f2963 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 @@ -42,6 +42,7 @@ import org.junit.runners.MethodSorters; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; +import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -61,6 +62,7 @@ public abstract class GLReadBuffer00Base extends UITestCase { public TextRendererGLEL() { // 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); staticRGBAColor[0] = 1.0f; @@ -80,7 +82,9 @@ public abstract class GLReadBuffer00Base extends UITestCase { final String text = String.format("Frame %04d (%03d): %04dx%04d", frameNo, userCounter, drawable.getWidth(), drawable.getHeight()); System.err.println("TextRendererGLEL.display: "+text); if( null != renderer ) { - renderString(drawable, font, 24f, text, 0 /* col */, 0 /* row */, 0, 0, -1, regionFPS); + final float pixelSize = font.getPixelSize(14f, dpiH); + drawable.getGL().glClearColor(1f, 1f, 1f, 0f); + renderString(drawable, font, pixelSize, text, 0 /* col */, 0 /* row */, 0, 0, -1, regionFPS); } else { System.err.println(text); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index b02238c2b..79e0655e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -305,14 +305,6 @@ public class TextureSequenceCubeES2 implements GLEventListener { gl.glViewport(0, 0, width, height); - if(innerCube) { - // Clear background to white - gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); - } else { - // Clear background to blue - gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f); - } - if(!innerCube) { // lights on } else { @@ -370,6 +362,13 @@ public class TextureSequenceCubeES2 implements GLEventListener { public void display(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); + if(innerCube) { + // Clear background to white + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); + } else { + // Clear background to blue + gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f); + } gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); if( null == st ) { 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 bc3786b81..3aa400232 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 @@ -169,6 +169,8 @@ public class MovieCube implements GLEventListener { InfoTextRendererGLELBase() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(Region.VBAA_RENDERING_BIT, MovieCube.this.textSampleCount); + // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! + // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); regionFPS = GLRegion.create(usrRenderModes); System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); @@ -181,7 +183,7 @@ public class MovieCube implements GLEventListener { @Override public void init(GLAutoDrawable drawable) { // non-exclusive mode! - this.usrPMVMatrix = cube.pmvMatrix; + this.setSharedPMVMatrix(cube.pmvMatrix); super.init(drawable); pixelSize = font.getPixelSize(fontSize, dpiH); @@ -237,6 +239,7 @@ public class MovieCube implements GLEventListener { mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); final String text4 = mPlayer.getURI().getRawPath(); if( displayOSD && null != renderer ) { + drawable.getGL().glClearColor(1.0f, 1.0f, 1.0f, 0.0f); renderString(drawable, font, pixelSize, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS); // no-cache renderString(drawable, font, pixelSize, text2, 1 /* col */, 0 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); renderString(drawable, font, pixelSize, text3, 1 /* col */, 1 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); @@ -520,7 +523,9 @@ public class MovieCube implements GLEventListener { glp = GLProfile.getGL2ES2(); } System.err.println("GLProfile: "+glp); - final GLWindow window = GLWindow.create(new GLCapabilities(glp)); + final GLCapabilities caps = new GLCapabilities(glp); + // caps.setAlphaBits(4); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! + final GLWindow window = GLWindow.create(caps); final Animator anim = new Animator(window); window.addWindowListener(new WindowAdapter() { public void windowDestroyed(WindowEvent e) { @@ -529,6 +534,7 @@ public class MovieCube implements GLEventListener { }); window.setSize(width, height); window.setVisible(true); + System.err.println("Chosen: "+window.getChosenGLCapabilities()); anim.start(); mc.mPlayer.addEventListener(new GLMediaEventListener() { 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 ab159fb85..6cee4066b 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 @@ -136,12 +136,14 @@ public class MovieSimple implements GLEventListener { private final class InfoTextRendererGLELBase extends TextRendererGLELBase { private final Font font = getFont(0, 0, 0); - private final float fontSize = 12f; + private final float fontSize = 10f; private final GLRegion regionFPS; InfoTextRendererGLELBase() { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(Region.VBAA_RENDERING_BIT, textSampleCount); + // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! + // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); regionFPS = GLRegion.create(usrRenderModes); System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); @@ -186,6 +188,7 @@ public class MovieSimple implements GLEventListener { mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); final String text4 = mPlayer.getURI().getRawPath(); if( displayOSD && null != renderer ) { + // We share ClearColor w/ MovieSimple's init ! final float pixelSize = font.getPixelSize(fontSize, dpiH); renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS); // no-cache renderString(drawable, font, pixelSize, text2, 1 /* col */, -4 /* row */, 0, height, -1, true); @@ -1010,7 +1013,8 @@ public class MovieSimple implements GLEventListener { glp = GLProfile.getGL2ES2(); } System.err.println("GLProfile: "+glp); - GLCapabilities caps = new GLCapabilities(glp); + final GLCapabilities caps = new GLCapabilities(glp); + // caps.setAlphaBits(4); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! final MovieSimple[] mss = new MovieSimple[windowCount]; final GLWindow[] windows = new GLWindow[windowCount]; |