diff options
Diffstat (limited to 'src/jogl/classes')
8 files changed, 136 insertions, 101 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 389af2a8b..2cbbd5f48 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -186,6 +186,8 @@ public abstract class Region { public static final int MIN_AA_SAMPLE_COUNT = 1; /** Maximum pass2 AA sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ public static final int MAX_AA_SAMPLE_COUNT = 8; + /** Default pass2 AA sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + public static final int DEFAULT_AA_SAMPLE_COUNT = 4; /** Returns clipped AA sample-count to [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}] */ public static final int clipAASampleCount(final int v) { return Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(v, Region.MIN_AA_SAMPLE_COUNT)); } @@ -801,7 +803,7 @@ public abstract class Region { * Mark this region's shape dirty, * i.e. its vertices, triangles, lines and/or color-texture coordinates changed. * <p> - * The data will be re-uploaded to the GPU at next {@link GLRegion#draw(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer, int, int[]) draw(..)}. + * The data will be re-uploaded to the GPU at next {@link GLRegion#draw(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) draw(..)}. * </p> * <p> * In 2-pass mode, this implies updating the FBO itself as well. 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 dfc7d3921..8b45910c8 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -488,8 +488,7 @@ public abstract class GLRegion extends Region { /**
* Renders the associated OGL objects specifying
- * current width/hight of window for multi pass rendering
- * of the region.
+ * current width/hight of window for optional 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}
@@ -511,18 +510,19 @@ public abstract class GLRegion extends Region { * </p>
* @param gl current {@link GL2ES2}.
* @param renderer the {@link RegionRenderer} to be used
- * @param pass2Quality pass2 AA-quality selector in the range [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}
- * @param sampleCount desired pass2 AA-multisampling sample count in the typical range [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}, {@link Region#MSAA_RENDERING_BIT}
- * Use -1 for glSelect mode, pass1 w/o any color texture nor channel, use static select color only.
- * The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
* @see RegionRenderer#enable(GL2ES2, boolean)
+ * @see RegionRenderer#setAAQuality(int)
+ * @see RegionRenderer#setSampleCount(int)
+ * @see RegionRenderer#setClipBBox(com.jogamp.math.geom.AABBox)
*/
- public final void draw(final GL2ES2 gl, final RegionRenderer renderer, final int pass2Quality, final int[/*1*/] sampleCount) {
+ public final void draw(final GL2ES2 gl, final RegionRenderer renderer) {
+ final int pass2Quality = renderer.getAAQuality();
+ final int pass2SampleCount = renderer.getSampleCount();
final int curRenderModes;
- if( 0 == sampleCount[0] ) {
+ if( 0 == pass2SampleCount ) {
// no sampling, reduce to pass1
curRenderModes = getRenderModes() & ~( VBAA_RENDERING_BIT | MSAA_RENDERING_BIT );
- } else if( 0 > sampleCount[0] ) {
+ } else if( 0 > pass2SampleCount ) {
// negative sampling, hint we perform glSelect: pass1 w/o any color texture nor channel, use static select color only
curRenderModes = getRenderModes() & ~( VBAA_RENDERING_BIT | MSAA_RENDERING_BIT | COLORCHANNEL_RENDERING_BIT | COLORTEXTURE_RENDERING_BIT );
} else {
@@ -535,15 +535,38 @@ public abstract class GLRegion extends Region { if( lastRenderModes != curRenderModes ) {
markShapeDirty();
markStateDirty();
+ } else if( Region.isGraphAA(curRenderModes) &&
+ ( lastPass2Quality != pass2Quality || lastPass2SampleCount != pass2SampleCount ) ) {
+ markStateDirty();
}
if( isShapeDirty() ) {
updateImpl(gl, renderer, curRenderModes);
}
- drawImpl(gl, renderer, curRenderModes, Region.clipAAQuality(pass2Quality), sampleCount);
+ drawImpl(gl, renderer, curRenderModes);
clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
lastRenderModes = curRenderModes;
+ lastPass2Quality = pass2Quality;
+ lastPass2SampleCount = pass2SampleCount;
}
+
+ /** Perform glSelect false color rendering: pass1 w/o any color texture nor channel, use static select color only */
+ public final void drawToSelect(final GL2ES2 gl, final RegionRenderer renderer) {
+ final int curRenderModes = getRenderModes() & ~( VBAA_RENDERING_BIT | MSAA_RENDERING_BIT | COLORCHANNEL_RENDERING_BIT | COLORTEXTURE_RENDERING_BIT );
+ if( lastRenderModes != curRenderModes ) {
+ markShapeDirty();
+ markStateDirty();
+ }
+ if( isShapeDirty() ) {
+ updateImpl(gl, renderer, curRenderModes);
+ }
+ drawImpl(gl, renderer, curRenderModes);
+ clearDirtyBits(DIRTY_SHAPE|DIRTY_STATE);
+ lastRenderModes = curRenderModes;
+ }
+
private int lastRenderModes = 0;
+ private int lastPass2Quality = -1;
+ private int lastPass2SampleCount = -1;
/**
* Updates a graph region by updating the ogl related
@@ -553,5 +576,5 @@ public abstract class GLRegion extends Region { */
protected abstract void updateImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes);
- protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, int pass2Quality, final int[/*1*/] sampleCount);
+ protected abstract void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes);
}
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 ba9606064..50fae4907 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -92,7 +92,7 @@ public final class RegionRenderer { * 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, int[]) GLRegion's draw-method} + * which will cause {@link GLRegion#draw(GL2ES2, RegionRenderer) GLRegion's draw-method} * to set the proper {@link GL#glBlendFuncSeparate(int, int, int, int) blend-function} * and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering. * </p> @@ -236,7 +236,7 @@ public final class RegionRenderer { * Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext * if not initialized yet. * <p>Disables the renderer via {@link #enable(GL2ES2, boolean)} to remove any side-effects, ie ShaderState incl. shader program.</p> - * <p>Shall be called once before at initialization before a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, int, int)}</p> + * <p>Shall be called once before at initialization before a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region)}</p> * * @param gl referencing the current GLContext to which the ShaderState is bound to * @throws GLException if initialization failed @@ -304,6 +304,16 @@ public final class RegionRenderer { public final void setColorStatic(final float r, final float g, final float b, final float a){ rs.setColorStatic(r, g, b, a); } + /** Sets pass2 AA-quality rendering value clipped to the range [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}. */ + public final int setAAQuality(final int v) { return rs.setAAQuality(v); } + /** Returns pass2 AA-quality rendering value for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}. */ + public final int getAAQuality() { return rs.getAAQuality(); } + + /** Sets pass2 AA sample count clipped to the range [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + public final int setSampleCount(final int v) { return rs.setSampleCount(v); } + /** Returns pass2 AA sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + public final int getSampleCount() { return rs.getSampleCount(); } + /** Set the optional clipping {@link AABBox}, which shall be pre-multiplied with the Mv-matrix or null to disable. */ public final void setClipBBox(final AABBox clipBBox) { rs.setClipBBox(clipBBox); } /** Returns the optional Mv-premultiplied clipping {@link AABBox} or null if unused. */ @@ -319,7 +329,7 @@ public final class RegionRenderer { * Enabling or disabling the {@link #getRenderState() RenderState}'s * current {@link RenderState#getShaderProgram() shader program}. * <p> - * {@link #useShaderProgram(GL2ES2, int, boolean, int, int, TextureSequence)} + * {@link #useShaderProgram(GL2ES2, int, boolean, TextureSequence)} * generates, selects and caches the desired Curve-Graph {@link ShaderProgram} * and {@link RenderState#setShaderProgram(GL2ES2, ShaderProgram) sets it current} in the {@link RenderState} composition. * </p> @@ -330,7 +340,7 @@ public final class RegionRenderer { * @param gl current GL object * @param enable if true enable the current {@link ShaderProgram}, otherwise disable. * @see #create(Vertex.Factory<? extends Vertex>, RenderState, GLCallback, GLCallback) - * @see #useShaderProgram(GL2ES2, int, boolean, int, int, TextureSequence) + * @see #useShaderProgram(GL2ES2, int, boolean, TextureSequence) * @see RenderState#setShaderProgram(GL2ES2, ShaderProgram) * @see RenderState#getShaderProgram() */ @@ -591,8 +601,6 @@ public final class RegionRenderer { * @param gl * @param renderModes * @param pass1 - * @param pass2Quality - * @param sampleCount * @param colorTexSeq * @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. @@ -600,9 +608,8 @@ public final class RegionRenderer { * @see RenderState#setShaderProgram(GL2ES2, ShaderProgram) * @see RenderState#getShaderProgram() */ - public final boolean useShaderProgram(final GL2ES2 gl, final int renderModes, - final boolean pass1, final int pass2Quality, final int sampleCount, final TextureSequence colorTexSeq) { - final ShaderKey shaderKey = new ShaderKey(renderModes, pass1, pass2Quality, sampleCount, colorTexSeq, null != getClipBBox()); + public final boolean useShaderProgram(final GL2ES2 gl, final int renderModes, final boolean pass1, final TextureSequence colorTexSeq) { + final ShaderKey shaderKey = new ShaderKey(renderModes, pass1, getAAQuality(), getSampleCount(), colorTexSeq, null != getClipBBox()); /** if(DEBUG) { 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 88392ea04..ed5bcb110 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -60,7 +60,7 @@ public class RenderState { * Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}. * </p> * <p> - * If set, {@link GLRegion#draw(GL2ES2, RegionRenderer, int, int[]) GLRegion's draw-method} + * If set, {@link GLRegion#draw(GL2ES2, RegionRenderer) GLRegion's draw-method} * will set the proper {@link GL#glBlendFuncSeparate(int, int, int, int) blend-function} * and the clear-color to <i>transparent-black</i> in case of {@link Region#isTwoPass(int) multipass} FBO rendering. * </p> @@ -79,7 +79,7 @@ public class RenderState { * Shall be set via {@link #setHintMask(int)} and cleared via {@link #clearHintMask(int)}. * </p> * <p> - * {@link GLRegion#draw(GL2ES2, RegionRenderer, int, int[]) GLRegion's draw-method} + * {@link GLRegion#draw(GL2ES2, RegionRenderer) GLRegion's draw-method} * may toggle depth test, and reset it's state according to this hint. * </p> * <p> @@ -98,6 +98,10 @@ public class RenderState { private final FloatBuffer weightBuffer; private final float[] colorStatic; private final FloatBuffer colorStaticBuffer; + /** Pass2 AA-quality rendering {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}. */ + private int aaQuality; + /** Default pass2 AA sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + private int sampleCount; /** Optional clipping {@link AABBox}, which shall be pre-multiplied with the Mv-matrix. Null if unused. */ private AABBox clipBBox; private int hintBitfield; @@ -199,6 +203,8 @@ public class RenderState { this.weightBuffer = FloatBuffer.wrap(weight); this.colorStatic = new float[] { 1, 1, 1, 1 }; this.colorStaticBuffer = FloatBuffer.wrap(colorStatic); + this.aaQuality = Region.DEFAULT_AA_QUALITY; + this.sampleCount = Region.DEFAULT_AA_SAMPLE_COUNT; this.clipBBox = null; this.hintBitfield = 0; this.sp = null; @@ -265,6 +271,16 @@ public class RenderState { colorStatic[3] = a; } + /** Sets pass2 AA-quality rendering value clipped to the range [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}. */ + public final int setAAQuality(final int v) { final int q=Region.clipAAQuality(v); this.aaQuality=q; return q;} + /** Returns pass2 AA-quality rendering value for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}. */ + public final int getAAQuality() { return this.aaQuality; } + + /** Sets pass2 AA sample count clipped to the range [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}] for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + public final int setSampleCount(final int v) { final int s=Region.clipAASampleCount(v); this.sampleCount=s; return s;} + /** Returns pass2 AA sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link #VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */ + public final int getSampleCount() { return this.sampleCount; } + /** Set the optional clipping {@link AABBox}, which shall be pre-multiplied with the Mv-matrix or null to disable. */ public final void setClipBBox(final AABBox clipBBox) { this.clipBBox = clipBBox; } /** Returns the optional Mv-premultiplied clipping {@link AABBox} or null if unused. */ 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 633bc38af..5d60e2686 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -168,7 +168,7 @@ public class TextRegionUtil { * @return the given int[2] storage for chaining * @see Region#setBufferCapacity(int, int) * @see Region#growBuffer(int, int) - * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform) + * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, AffineTransform, AffineTransform) */ public static int[] countStringRegion(final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) { final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { @@ -203,15 +203,11 @@ public class TextRegionUtil { * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}. - * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] - * @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. * @return the bounding box of the given string from the produced and rendered GLRegion * @throws Exception if TextRenderer not initialized */ - public AABBox drawString3D(final GL2ES2 gl, - final RegionRenderer renderer, final Font font, final CharSequence str, - final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) { + public AABBox drawString3D(final GL2ES2 gl, final RegionRenderer renderer, + final Font font, final CharSequence str, final Vec4f rgbaColor) { if( !renderer.isInitialized() ) { throw new GLException("TextRendererImpl01: not initialized!"); } @@ -232,20 +228,19 @@ public class TextRegionUtil { } else { renderer.setColorStatic(1, 1, 1, 1); } - region.draw(gl, renderer, aaQuality, sampleCount); + region.draw(gl, renderer); return res; } /** - * Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances. + * Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, Vec4f, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances. * <p> * The region's buffer size is pre-calculated via {@link GLRegion#create(com.jogamp.opengl.GLProfile, int, com.jogamp.opengl.util.texture.TextureSequence, Font, CharSequence)} * </p> */ - public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, - final RegionRenderer renderer, final Font font, final CharSequence str, - final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) { - return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, aaQuality, sampleCount, new AffineTransform(), new AffineTransform()); + public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, final RegionRenderer renderer, + final Font font, final CharSequence str, final Vec4f rgbaColor) { + return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, new AffineTransform(), new AffineTransform()); } /** @@ -262,7 +257,7 @@ 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(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)} + * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, AffineTransform, AffineTransform)} * instead. * </p> * @param gl the current GL state @@ -272,17 +267,14 @@ public class TextRegionUtil { * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}. - * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] - * @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. * @param tmp1 temp {@link AffineTransform} to be reused * @param tmp2 temp {@link AffineTransform} to be reused * @throws Exception if TextRenderer not initialized * @return the bounding box of the given string from the produced and rendered GLRegion */ - public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, - final RegionRenderer renderer, final Font font, final CharSequence str, - final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) { + public static AABBox drawString3D(final GL2ES2 gl, final int renderModes, final RegionRenderer renderer, + final Font font, final CharSequence str, final Vec4f rgbaColor, + final AffineTransform tmp1, final AffineTransform tmp2) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } @@ -295,20 +287,20 @@ public class TextRegionUtil { } else { renderer.setColorStatic(1, 1, 1, 1); } - region.draw(gl, renderer, aaQuality, sampleCount); + region.draw(gl, renderer); region.destroy(gl); return res; } /** - * Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, int, int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances. + * Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, Vec4f, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances. * <p> * The region buffer's size is grown by pre-calculating required size via {@link #countStringRegion(Font, CharSequence, int[])}. * </p> */ public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer, - final Font font, final CharSequence str, final Vec4f rgbaColor, final int aaQuality, final int[/*1*/] sampleCount) { - return drawString3D(gl, region, renderer, font, str, rgbaColor, aaQuality, sampleCount, new AffineTransform(), new AffineTransform()); + final Font font, final CharSequence str, final Vec4f rgbaColor) { + return drawString3D(gl, region, renderer, font, str, rgbaColor, new AffineTransform(), new AffineTransform()); } /** @@ -333,9 +325,6 @@ public class TextRegionUtil { * @param rgbaColor used to fill the {@link Region#hasColorChannel() region's color-channel} if used * and set {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} to white. * Otherwise used to set the {@link RegionRenderer#setColorStatic(Vec4f) renderer's static-color} only, if not {@code null}. - * @param aaQuality pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}] - * @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. * @param tmp1 temp {@link AffineTransform} to be reused * @param tmp2 temp {@link AffineTransform} to be reused * @return the bounding box of the given string from the produced and rendered GLRegion @@ -343,7 +332,7 @@ public class TextRegionUtil { */ public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer, final Font font, final CharSequence str, final Vec4f rgbaColor, - final int aaQuality, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) { + final AffineTransform tmp1, final AffineTransform tmp2) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } @@ -355,7 +344,7 @@ public class TextRegionUtil { } else { renderer.setColorStatic(1, 1, 1, 1); } - region.draw(gl, renderer, aaQuality, sampleCount); + region.draw(gl, renderer); return res; } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index e3d2b8629..ae4a734be 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -176,12 +176,10 @@ public final class VBORegion2PMSAAES2 extends GLRegion { * * @param gl * @param renderer - * @param renderModes * @param pass1 - * @param pass2Quality - * @param sampleCount + * @param renderModes */ - public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int pass2Quality, final int sampleCount) { + public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1) { final boolean isTwoPass = Region.isTwoPass( curRenderModes ); final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq; @@ -189,7 +187,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { final RenderState rs = renderer.getRenderState(); final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) ); - final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, pass2Quality, sampleCount, colorTexSeq); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal; if( pass1 ) { @@ -243,7 +241,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border @Override - protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) { + protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { if( 0 >= indicesBuffer.getElemCount() ) { if(DEBUG_INSTANCE) { System.err.printf("VBORegion2PMSAAES2.drawImpl: Empty%n"); @@ -259,8 +257,8 @@ public final class VBORegion2PMSAAES2 extends GLRegion { final RenderState rs = renderer.getRenderState(); final int vpWidth = renderer.getWidth(); final int vpHeight = renderer.getHeight(); - if(vpWidth <=0 || vpHeight <= 0 || sampleCount[0] < 0) { - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + if(vpWidth <=0 || vpHeight <= 0 || rs.getSampleCount() < 0) { + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion(gl, rs, curRenderModes); } else { if(0 > maxTexSize[0]) { @@ -314,7 +312,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { winWidth, winHeight, targetWinWidth, targetWinHeight, diffWinWidth, diffWinHeight, ratioWinWidth, ratioWinHeight, targetFboWidth, targetFboHeight, - sampleCount[0]); + rs.getSampleCount()); } } if( 0 >= targetFboWidth || 0 >= targetFboHeight ) { @@ -328,7 +326,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { System.err.printf("XXX.maxDelta: hasDelta %b: %d / %d, %.3f, %.3f%n", hasDelta, deltaFboWidth, deltaFboHeight, (float)deltaFboWidth/fboWidth, (float)deltaFboHeight/fboHeight); System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n", - sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight); + rs.getSampleCount(), winWidth, winHeight, targetFboWidth, targetFboHeight); } if( hasDelta || fboDirty || isShapeDirty() || null == fbo ) { // FIXME: rescale @@ -348,24 +346,24 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } gca_FboVerticesAttr.seal(true); matP.setToOrtho(minX, maxX, minY, maxY, -1, 1); - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion2FBO(gl, rs, curRenderModes, // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight, 0, 0, targetFboWidth, targetFboHeight, - vpWidth, vpHeight, sampleCount); + vpWidth, vpHeight); } else if( isStateDirty() ) { - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion2FBO(gl, rs, curRenderModes, // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight, 0, 0, targetFboWidth, targetFboHeight, - vpWidth, vpHeight, sampleCount); + vpWidth, vpHeight); } - useShaderProgram(gl, renderer, curRenderModes, false, pass2Quality, sampleCount[0]); - renderFBO(gl, rs, vpWidth, vpHeight, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, false); + renderFBO(gl, rs, vpWidth, vpHeight); } } - private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, final int sampleCount) { + private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height) { gl.glViewport(0, 0, width, height); if( rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED | RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED) ) { @@ -410,12 +408,12 @@ public final class VBORegion2PMSAAES2 extends GLRegion { private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int curRenderModes, final int fboX, final int fboY, final int targetFboWidth, final int targetFboHeight, - final int vpWidth, final int vpHeight, final int[] sampleCount) { + final int vpWidth, final int vpHeight) { if( 0 >= targetFboWidth || 0 >= targetFboHeight ) { throw new IllegalArgumentException("targetFBOSize "+targetFboWidth+"x"+targetFboHeight+" must be greater than 0"); } final boolean blendingEnabled = rs.isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED); - final int targetFboSamples = sampleCount[0] > 1 ? sampleCount[0] : 0; + final int targetFboSamples = rs.getSampleCount() > 1 ? rs.getSampleCount() : 0; final boolean fboSampleTypeMatch; { final int oldSampleCount = null != fbo ? fbo.getNumSamples() : 0; @@ -430,7 +428,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { fboHeight = targetFboHeight; fbo = new FBObject(); fbo.init(gl, targetFboWidth, targetFboHeight, targetFboSamples); - sampleCount[0] = Math.max(1, fbo.getNumSamples()); + rs.setSampleCount( Math.max(1, fbo.getNumSamples()) ); if( 0 == targetFboSamples ) { texA = fbo.attachTexture2D(gl, 0, true, GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); if( !blendingEnabled ) { @@ -460,7 +458,7 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } } else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight || fbo.getNumSamples() != targetFboSamples ) { fbo.reset(gl, targetFboWidth, targetFboHeight, targetFboSamples); - sampleCount[0] = Math.max(1, fbo.getNumSamples()); + rs.setSampleCount( Math.max(1, fbo.getNumSamples()) ); if( DEBUG_FBO_1 ) { System.err.printf("XXX.resetFBO: %dx%d -> %dx%d%n%s%n", fboWidth, fboHeight, targetFboWidth, targetFboHeight, fbo ); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index 7c6ea9d3b..bf23f33e9 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -106,10 +106,8 @@ public final class VBORegion2PVBAAES2 extends GLRegion { * @param renderer * @param curRenderModes * @param pass1 - * @param pass2Quality - * @param sampleCount */ - public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1, final int pass2Quality, final int sampleCount) { + public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final boolean pass1) { final boolean isTwoPass = Region.isTwoPass( curRenderModes ); final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ) && null != colorTexSeq; @@ -117,7 +115,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { final RenderState rs = renderer.getRenderState(); final boolean hasAABBoxClipping = null != rs.getClipBBox() && ( ( !isTwoPass && pass1 ) || ( isTwoPass && !pass1 ) ); - final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, pass2Quality, sampleCount, colorTexSeq); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, pass1, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal; if( pass1 ) { @@ -159,7 +157,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } rsLocal.update(gl, rs, updateLocLocal, curRenderModes, true, false, true); rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit - rs.updateUniformLoc(gl, updateLocLocal, gcu_FboTexSize, sampleCount > 1); // maybe optimized away for sampleCount <= 1 + rs.updateUniformLoc(gl, updateLocLocal, gcu_FboTexSize, rs.getSampleCount() > 1); // maybe optimized away for sampleCount <= 1 } if( hasAABBoxClipping && updateLocLocal ) { rs.updateUniformLoc(gl, true, gcu_ClipBBox, true); @@ -249,7 +247,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { private static final int border = 2; // surrounding border, i.e. width += 2*border, height +=2*border @Override - protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) { + protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { if( 0 >= indicesBuffer.getElemCount() ) { if(DEBUG_INSTANCE) { System.err.printf("VBORegion2PVBAAES2.drawImpl: Empty%n"); @@ -265,8 +263,9 @@ public final class VBORegion2PVBAAES2 extends GLRegion { final RenderState rs = renderer.getRenderState(); final int vpWidth = renderer.getWidth(); final int vpHeight = renderer.getHeight(); - if(vpWidth <=0 || vpHeight <= 0 || sampleCount[0] < 0) { - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + int pass2SampleCount = rs.getSampleCount(); + if(vpWidth <=0 || vpHeight <= 0 || pass2SampleCount < 0) { + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion(gl, rs, curRenderModes); } else { if(0 > maxTexSize[0]) { @@ -303,16 +302,16 @@ public final class VBORegion2PVBAAES2 extends GLRegion { diffObjBorderWidth = border * ratioObjWinWidth; diffObjBorderHeight = border * ratioObjWinHeight; - targetFboWidth = (targetWinWidth+2*border)*sampleCount[0]; - targetFboHeight = (targetWinHeight+2*border)*sampleCount[0]; + targetFboWidth = (targetWinWidth+2*border)*pass2SampleCount; + targetFboHeight = (targetWinHeight+2*border)*pass2SampleCount; if( DEBUG_FBO_2 ) { final float ratioWinWidth, ratioWinHeight; ratioWinWidth = winWidth/targetWinWidth; ratioWinHeight = winHeight/targetWinHeight; final float renderFboWidth, renderFboHeight; - renderFboWidth = (winWidth+2*border)*sampleCount[0]; - renderFboHeight = (winHeight+2*border)*sampleCount[0]; + renderFboWidth = (winWidth+2*border)*pass2SampleCount; + renderFboHeight = (winHeight+2*border)*pass2SampleCount; final float ratioFboWidth, ratioFboHeight; ratioFboWidth = renderFboWidth/targetFboWidth; ratioFboHeight = renderFboHeight/targetFboHeight; @@ -330,7 +329,7 @@ public final class VBORegion2PVBAAES2 extends GLRegion { diffWinWidth, diffWinHeight, ratioWinWidth, ratioWinHeight, renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight, diffFboWidth, diffFboHeight, ratioFboWidth, ratioFboHeight, - sampleCount[0]); + pass2SampleCount); } } if( 0 >= targetFboWidth || 0 >= targetFboHeight ) { @@ -344,27 +343,28 @@ public final class VBORegion2PVBAAES2 extends GLRegion { System.err.printf("XXX.maxDelta: hasDelta %b: %d / %d, %.3f, %.3f%n", hasDelta, deltaFboWidth, deltaFboHeight, (float)deltaFboWidth/fboWidth, (float)deltaFboHeight/fboHeight); System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n", - sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight); + pass2SampleCount, winWidth, winHeight, targetFboWidth, targetFboHeight); } if( hasDelta || fboDirty || isShapeDirty() || null == fbo ) { final int maxLength = Math.max(targetFboWidth, targetFboHeight); if( maxLength > maxTexSize[0] ) { if( targetFboWidth > targetFboHeight ) { - sampleCount[0] = (int)Math.floor(maxTexSize[0] / (winWidth+2*border)); + pass2SampleCount = (int)Math.floor(maxTexSize[0] / (winWidth+2*border)); } else { - sampleCount[0] = (int)Math.floor(maxTexSize[0] / (winHeight+2*border)); + pass2SampleCount = (int)Math.floor(maxTexSize[0] / (winHeight+2*border)); } + rs.setSampleCount(pass2SampleCount); final float renderFboWidth, renderFboHeight; - renderFboWidth = (winWidth+2*border)*sampleCount[0]; - renderFboHeight = (winHeight+2*border)*sampleCount[0]; + renderFboWidth = (winWidth+2*border)*pass2SampleCount; + renderFboHeight = (winHeight+2*border)*pass2SampleCount; targetFboWidth = (int)Math.ceil(renderFboWidth); targetFboHeight = (int)Math.ceil(renderFboHeight); if( DEBUG_FBO_1 ) { System.err.printf("XXX.Rescale (MAX): win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], msaa %d%n", winWidth, winHeight, - renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight, sampleCount[0]); + renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight, pass2SampleCount); } - if( sampleCount[0] <= 0 ) { + if( pass2SampleCount <= 0 ) { // Last way out! renderRegion(gl, rs, curRenderModes); return; @@ -387,20 +387,20 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } gca_FboVerticesAttr.seal(true); matP.setToOrtho(minX, maxX, minY, maxY, -1, 1); - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion2FBO(gl, rs, curRenderModes, // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight, 0, 0, targetFboWidth, targetFboHeight, - vpWidth, vpHeight, sampleCount[0]); + vpWidth, vpHeight, pass2SampleCount); } else if( isStateDirty() ) { - useShaderProgram(gl, renderer, curRenderModes, true, pass2Quality, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, true); renderRegion2FBO(gl, rs, curRenderModes, // (int)drawWinBox.getMinX(), (int)drawWinBox.getMinY(), targetFboWidth, targetFboHeight, 0, 0, targetFboWidth, targetFboHeight, - vpWidth, vpHeight, sampleCount[0]); + vpWidth, vpHeight, pass2SampleCount); } - useShaderProgram(gl, renderer, curRenderModes, false, pass2Quality, sampleCount[0]); - renderFBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, sampleCount[0]); + useShaderProgram(gl, renderer, curRenderModes, false); + renderFBO(gl, rs, targetFboWidth, targetFboHeight, vpWidth, vpHeight, pass2SampleCount); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 80795e8f1..3a568758c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -124,7 +124,7 @@ public final class VBORegionSPES2 extends GLRegion { final RenderState rs = renderer.getRenderState(); final boolean hasAABBoxClipping = null != rs.getClipBBox(); - final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, 0 /* pass2Quality */, 0 /* sampleCount */, colorTexSeq); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, curRenderModes, true, colorTexSeq); final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); final boolean updateLocLocal = !sp.equals(spPass1); spPass1 = sp; @@ -152,7 +152,7 @@ public final class VBORegionSPES2 extends GLRegion { @Override - protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes, final int pass2Quality, final int[/*1*/] sampleCount) { + protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int curRenderModes) { // final boolean hasColorChannel = Region.hasColorChannel( curRenderModes ); final boolean hasColorTexture = Region.hasColorTexture( curRenderModes ); |