From 45395696c252c215a8a22d05e5da7e98c662d07e Mon Sep 17 00:00:00 2001
From: Sven Gothel
* 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} disable {@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.
*
* Implementation also clears {@link RegionRenderer#getRenderState() RenderState}'s {@link RenderState#BITHINT_BLENDING_ENABLED blending bit-hint}.
*
- * 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}. *
*/ public static final int BITHINT_BLENDING_ENABLED = 1 << 0 ; + + /** + * Bitfield hint, {@link #isHintMaskSet(int) if set} + * stating globally enabled {@link GL#GL_DEPTH_TEST}, otherwise disabled. + *+ * Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}. + *
+ *+ * {@link GLRegion#draw(GL2ES2, RegionRenderer, int[]) GLRegion's draw-method} + * may toggle depth test, and reset it's state according to this hint. + *
+ *+ * Shall be set by custom code, e.g. after {@link RenderState} or {@link RegionRenderer} construction. + *
+ */ + 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); } -- cgit v1.2.3