summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-10 00:31:52 +0200
committerSven Gothel <[email protected]>2014-04-10 00:31:52 +0200
commit45395696c252c215a8a22d05e5da7e98c662d07e (patch)
tree952c132450f7cc56aeed0bb1fc040bde5f3ba96a /src
parent16324b8f8369379ab4db013c4785a496b25c7094 (diff)
Bug 801: Introd. RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED hinting to deal w/ GL_DEPTH_TEST accordingly
Fixes VBORegion2PMSAAES2 no-depth-buffer usage and allows user to control behavior w/o quering GL state. If BITHINT_GLOBAL_DEPTH_TEST_ENABLED set: - RegionRenderer.defaultBlendEnable: glDepthMask(false) - RegionRenderer.defaultBlendDisable: glDepthMask(true) - VBORegion2PMSAAES2 enables/disables GL_DEPTH_TEST, otherwise MSAA is corrupt.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java17
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java18
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener01.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener02.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java1
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java1
9 files changed, 47 insertions, 7 deletions
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 a0a318a49..272099385 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -69,7 +69,8 @@ public class RegionRenderer {
/**
* Default {@link GL#GL_BLEND} <i>enable</i> {@link GLCallback},
- * turning-off depth writing via {@link GL#glDepthMask(boolean)} and turning-on the {@link GL#GL_BLEND} state.
+ * turning-off depth writing via {@link GL#glDepthMask(boolean)} if {@link RenderState#BITHINT_GLOBAL_DEPTH_TEST_ENABLED} is set
+ * and turning-on the {@link GL#GL_BLEND} state.
* <p>
* Implementation also sets {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint},
* which will cause {@link GLRegion#draw(GL2ES2, RegionRenderer, int[]) GLRegion's draw-method}
@@ -82,7 +83,11 @@ public class RegionRenderer {
public static final GLCallback defaultBlendEnable = new GLCallback() {
@Override
public void run(final GL gl, final RegionRenderer renderer) {
- gl.glDepthMask(false);
+ if( renderer.rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) {
+ gl.glDepthMask(false);
+ // gl.glDisable(GL.GL_DEPTH_TEST);
+ // gl.glDepthFunc(GL.GL_ALWAYS);
+ }
gl.glEnable(GL.GL_BLEND);
gl.glBlendEquation(GL.GL_FUNC_ADD); // default
renderer.rs.setHintMask(RenderState.BITHINT_BLENDING_ENABLED);
@@ -92,7 +97,7 @@ public class RegionRenderer {
/**
* Default {@link GL#GL_BLEND} <i>disable</i> {@link GLCallback},
* simply turning-off the {@link GL#GL_BLEND} state
- * and turning-on depth writing via {@link GL#glDepthMask(boolean)}.
+ * and turning-on depth writing via {@link GL#glDepthMask(boolean)} if {@link RenderState#BITHINT_GLOBAL_DEPTH_TEST_ENABLED} is set.
* <p>
* Implementation also clears {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
* </p>
@@ -104,7 +109,11 @@ public class RegionRenderer {
public void run(final GL gl, final RegionRenderer renderer) {
renderer.rs.clearHintMask(RenderState.BITHINT_BLENDING_ENABLED);
gl.glDisable(GL.GL_BLEND);
- gl.glDepthMask(true);
+ if( renderer.rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) {
+ // gl.glEnable(GL.GL_DEPTH_TEST);
+ // gl.glDepthFunc(GL.GL_LESS);
+ gl.glDepthMask(true);
+ }
}
};
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 7eb34a62d..f991855c0 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -58,12 +58,28 @@ public class RenderState {
* and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering.
* </p>
* <p>
- * Shall be called by custom code, e.g. via {@link RegionRenderer}'s
+ * Shall be set by custom code, e.g. via {@link RegionRenderer}'s
* enable and disable {@link RegionRenderer.GLCallback} as done in
* {@link RegionRenderer#defaultBlendEnable} and {@link RegionRenderer#defaultBlendDisable}.
* </p>
*/
public static final int BITHINT_BLENDING_ENABLED = 1 << 0 ;
+
+ /**
+ * Bitfield hint, {@link #isHintMaskSet(int) if set}
+ * stating globally <i>enabled</i> {@link GL#GL_DEPTH_TEST}, otherwise <i>disabled</i>.
+ * <p>
+ * Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}.
+ * </p>
+ * <p>
+ * {@link GLRegion#draw(GL2ES2, RegionRenderer, int[]) GLRegion's draw-method}
+ * may toggle depth test, and reset it's state according to this hint.
+ * </p>
+ * <p>
+ * Shall be set by custom code, e.g. after {@link RenderState} or {@link RegionRenderer} construction.
+ * </p>
+ */
+ public static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED = 1 << 1 ;
public static RenderState createRenderState(Vertex.Factory<? extends Vertex> pointFactory) {
return new RenderState(pointFactory, null);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index b52308e05..d870644f3 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -407,7 +407,12 @@ 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( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
+ if( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED | RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) {
+ // RGB is already multiplied w/ alpha via renderRegion2FBO(..)
+ gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+
+ } else if( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) {
// RGB is already multiplied w/ alpha via renderRegion2FBO(..)
gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
}
@@ -459,7 +464,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
fbo.setSamplingSink(ssink);
fbo.resetSamplingSink(gl); // validate
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.createFBO: %dx%d%n%s%n", fboWidth, fboHeight, fbo.toString());
+ System.err.printf("XXX.createFBO: blending %b, %dx%d%n%s%n", blendingEnabled, fboWidth, fboHeight, fbo.toString());
}
} else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight || fbo.getNumSamples() != sampleCount[0] ) {
fbo.reset(gl, targetFboWidth, targetFboHeight, sampleCount[0], true /* resetSamplingSink */);
@@ -482,6 +487,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
// Multiply RGB w/ Alpha, preserve alpha for renderFBO(..)
gl.glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA);
+
+ if( rs.isHintMaskSet(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) {
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ }
} else {
gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
}
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 ad794b646..0235a78c2 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -141,6 +141,7 @@ public class TestTextRendererNEWT10 extends UITestCase {
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
final TextRegionUtil textRenderUtil = new TextRegionUtil(0);
// 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 127cf3fc3..ebd526899 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -136,6 +136,7 @@ public abstract class TextRendererGLELBase implements GLEventListener {
this.rs = RenderState.createRenderState(SVertex.factory(), sharedPMVMatrix);
}
this.renderer = RegionRenderer.create(rs, enableCallback, disableCallback);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
this.textRenderUtil = new TextRegionUtil(renderModes);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
renderer.init(gl, renderModes);
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 48ba148a9..4bcbdb380 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
@@ -51,6 +51,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 {
public GPURegionGLListener01 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) {
super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
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 374f2928c..ca9f4fda7 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
@@ -51,6 +51,7 @@ public class GPURegionGLListener02 extends GPURendererListenerBase01 {
public GPURegionGLListener02 (RenderState rs, int renderModes, int sampleCount, boolean debug, boolean trace) {
super(RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable), renderModes, debug, trace);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
setMatrix(-20, 00, -50, 0f, sampleCount);
}
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 ad12e11e1..891151e38 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
@@ -116,6 +116,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
super(RegionRenderer.create(rs, blending ? RegionRenderer.defaultBlendEnable : null,
blending ? RegionRenderer.defaultBlendDisable : null),
renderModes, debug, trace);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
this.textRegionUtil = new TextRegionUtil(renderModes);
this.regionFPS = GLRegion.create(renderModes, null);
this.regionBottom = GLRegion.create(renderModes, null);
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 2dcad1e86..df9c6381f 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
@@ -615,6 +615,7 @@ public class GPUUISceneGLListener0A implements GLEventListener {
}
renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
+ rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
// renderer = RegionRenderer.create(rs, null, null);
gl.setSwapInterval(1);