diff options
author | Sven Gothel <[email protected]> | 2023-02-24 22:15:20 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-02-24 22:15:20 +0100 |
commit | 307479391f955a5bd611b4ad4db6f53e097d15c5 (patch) | |
tree | 90b1e4179caf24a4bb9cead9d5db0cfc43dab771 | |
parent | 6ac71d7fee514f1bf388990b9373d190424699d9 (diff) |
Graph Region: Address overflow issue using GL2ES3 integer indices (WIP...); Ease GLArrayData* buffer growth.
Using integer indices, i.e. GL_UNSIGNED_INT, requires us to pass a GLProfile 'hint' to the GLRegion ctor.
Region.max_indices is computed in this regard and used in Region.addOutlineShape().
TODO: If exceeding max_indices, the code path needs some work.
Buffer growth is eased via GLArrayData using its golden growth ratio
and manually triggering growth before processing all triangles in Region.addOutlineShape().
+++
TextRegionUtil static drawText() won't clear passed Region anymore, caller has to do this if so intended.
30 files changed, 354 insertions, 175 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6bc229c64..6862884b4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -525,7 +525,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.CrossFadePlayer $* # @@ -940,7 +940,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT20 $* -#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo $* +testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.UIShapeDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.UITypeDemo01 $* diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 264b00b92..8843188b4 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -27,6 +27,7 @@ */ package com.jogamp.graph.curve; +import java.io.PrintStream; import java.util.ArrayList; import java.util.List; @@ -35,7 +36,9 @@ import jogamp.opengl.Debug; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.common.nio.Buffers; import com.jogamp.graph.curve.opengl.GLRegion; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.math.geom.Frustum; import com.jogamp.opengl.util.texture.TextureSequence; @@ -110,6 +113,8 @@ public abstract class Region { protected static final int DIRTY_STATE = 1 << 1 ; private final int renderModes; + private final boolean use_int32_idx; + private final int max_indices; private int quality; private int dirty = DIRTY_SHAPE | DIRTY_STATE; private int numVertices = 0; @@ -168,19 +173,33 @@ public abstract class Region { } } - protected Region(final int regionRenderModes) { + protected Region(final int regionRenderModes, final boolean use_int32_idx) { this.renderModes = regionRenderModes; + this.use_int32_idx = use_int32_idx; + if( use_int32_idx ) { + this.max_indices = GL_INT32_MAX / Buffers.SIZEOF_INT; // byte-size int32_t limit + } else { + this.max_indices = GL_UINT16_MAX; + } this.quality = MAX_QUALITY; } - // FIXME: Better handling of impl. buffer growth .. ! - // protected abstract void setupInitialComponentCount(int attributeCount, int indexCount); + /** Print implementation buffer stats like detailed and total size and capacity in bytes etc */ + public abstract void printBufferStats(PrintStream out); + + /** + * Returns true if implementation uses `int32_t` sized indices implying at least a {@link GLProfile#isGL2ES3()} alike context. + * Otherwise method returns false on {@link GLProfile#isGLES2()} using `uint16_t` sized indices. + */ + public final boolean usesI32Idx() { return this.use_int32_idx; } + + protected abstract void growBufferSize(int verticeCount, int indexCount); protected abstract void pushVertex(final float[] coords, final float[] texParams, float[] rgba); protected abstract void pushIndex(int idx); /** - * Return bit-field of render modes, see {@link GLRegion#create(int, TextureSequence)}. + * Return bit-field of render modes, see {@link GLRegion#create(GLProfile, int, TextureSequence)}. */ public final int getRenderModes() { return renderModes; } @@ -269,6 +288,9 @@ public abstract class Region { private final AABBox tmpBox = new AABBox(); + protected static final int GL_UINT16_MAX = 0xffff; // 65,535 + protected static final int GL_INT32_MAX = 0x7fffffff; // 2,147,483,647 + /** * Add the given {@link OutlineShape} to this region with the given optional {@link AffineTransform}. * <p> @@ -297,15 +319,17 @@ public abstract class Region { } final List<Triangle> trisIn = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS); final ArrayList<Vertex> vertsIn = shape.getVertices(); - if(DEBUG_INSTANCE) { + { final int addedVerticeCount = shape.getAddedVerticeCount(); final int verticeCount = vertsIn.size() + addedVerticeCount; final int indexCount = trisIn.size() * 3; - System.err.println("Region.addOutlineShape().0: tris: "+trisIn.size()+", verts "+vertsIn.size()+", transform "+t); - System.err.println("Region.addOutlineShape().0: VerticeCount "+vertsIn.size()+" + "+addedVerticeCount+" = "+verticeCount); - System.err.println("Region.addOutlineShape().0: IndexCount "+indexCount); + if(DEBUG_INSTANCE) { + System.err.println("Region.addOutlineShape().0: tris: "+trisIn.size()+", verts "+vertsIn.size()+", transform "+t); + System.err.println("Region.addOutlineShape().0: VerticeCount "+vertsIn.size()+" + "+addedVerticeCount+" = "+verticeCount); + System.err.println("Region.addOutlineShape().0: IndexCount "+indexCount); + } + growBufferSize(verticeCount, indexCount); } - // setupInitialComponentCount(verticeCount, indexCount); // FIXME: Use it ? final int idxOffset = numVertices; int vertsVNewIdxCount = 0, vertsTMovIdxCount = 0, vertsTNewIdxCount = 0, tris = 0; @@ -330,7 +354,7 @@ public abstract class Region { // triangles.add( triEx ); final Vertex[] triInVertices = triIn.getVertices(); final int tv0Idx = triInVertices[0].getId(); - if( Integer.MAX_VALUE-idxOffset > tv0Idx ) { // Integer.MAX_VALUE != i0 // FIXME: renderer uses SHORT! + if ( max_indices - idxOffset > tv0Idx ) { // valid 'known' idx - move by offset if(Region.DEBUG_INSTANCE) { System.err.println("T["+i+"]: Moved "+tv0Idx+" + "+idxOffset+" -> "+(tv0Idx+idxOffset)); @@ -340,7 +364,7 @@ public abstract class Region { pushIndex(triInVertices[2].getId()+idxOffset); vertsTMovIdxCount+=3; } else { - // invalid idx - generate new one + // FIXME: Invalid idx - generate new one if(Region.DEBUG_INSTANCE) { System.err.println("T["+i+"]: New Idx "+numVertices); } @@ -353,12 +377,13 @@ public abstract class Region { } } if(DEBUG_INSTANCE) { - System.err.println("Region.addOutlineShape().X: idxOffset "+idxOffset+", tris: "+tris+", verts [idx "+vertsTNewIdxCount+", add "+vertsTNewIdxCount+" = "+(vertsVNewIdxCount+vertsTNewIdxCount)+"]"); + System.err.println("Region.addOutlineShape().X: idx[ui32 "+usesI32Idx()+", offset "+idxOffset+"], tris: "+tris+", verts [idx "+vertsTNewIdxCount+", add "+vertsTNewIdxCount+" = "+(vertsVNewIdxCount+vertsTNewIdxCount)+"]"); System.err.println("Region.addOutlineShape().X: verts: idx[v-new "+vertsVNewIdxCount+", t-new "+vertsTNewIdxCount+" = "+(vertsVNewIdxCount+vertsTNewIdxCount)+"]"); System.err.println("Region.addOutlineShape().X: verts: idx t-moved "+vertsTMovIdxCount+", numVertices "+numVertices); System.err.println("Region.addOutlineShape().X: verts: v-dups "+vertsDupCountV+", t-dups "+vertsDupCountT+", t-known "+vertsKnownMovedT); // int vertsDupCountV = 0, vertsDupCountT = 0; System.err.println("Region.addOutlineShape().X: box "+box); + printBufferStats(System.err); } markShapeDirty(); } @@ -405,6 +430,7 @@ public abstract class Region { } protected final int getDirtyBits() { return dirty; } + @Override public String toString() { return "Region["+getRenderModeString(this.renderModes)+", q "+quality+", dirty "+dirty+", vertices "+numVertices+", box "+box+"]"; } 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 d924fa9c8..69638f60e 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -29,6 +29,8 @@ package com.jogamp.graph.curve.opengl; import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLArrayData;
+import com.jogamp.opengl.GLProfile;
import jogamp.graph.curve.opengl.VBORegion2PMSAAES2;
import jogamp.graph.curve.opengl.VBORegion2PVBAAES2;
@@ -37,6 +39,10 @@ import jogamp.graph.curve.opengl.VBORegionSPES2; import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.texture.TextureSequence;
import com.jogamp.graph.curve.Region;
+
+import java.io.PrintStream;
+
+import com.jogamp.common.nio.Buffers;
import com.jogamp.graph.curve.OutlineShape;
/** A GLRegion is the OGL binding of one or more OutlineShapes
@@ -57,31 +63,36 @@ public abstract class GLRegion extends Region { *
* <p> In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit
* {@link Region#DEFAULT_TWO_PASS_TEXTURE_UNIT} is being used.</p>
+ * @param glp intended GLProfile to use. Instance may use higher OpenGL features if indicated by GLProfile.
* @param renderModes bit-field of modes, e.g. {@link Region#VARWEIGHT_RENDERING_BIT}, {@link Region#VBAA_RENDERING_BIT}
* @param colorTexSeq optional {@link TextureSequence} for {@link Region#COLORTEXTURE_RENDERING_BIT} rendering mode.
*/
- public static GLRegion create(int renderModes, final TextureSequence colorTexSeq) {
+ public static GLRegion create(final GLProfile glp, int renderModes, final TextureSequence colorTexSeq) {
if( null != colorTexSeq ) {
renderModes |= Region.COLORTEXTURE_RENDERING_BIT;
} else if( Region.hasColorTexture(renderModes) ) {
throw new IllegalArgumentException("COLORTEXTURE_RENDERING_BIT set but null TextureSequence");
}
if( isVBAA(renderModes) ) {
- return new VBORegion2PVBAAES2(renderModes, colorTexSeq, Region.DEFAULT_TWO_PASS_TEXTURE_UNIT);
+ return new VBORegion2PVBAAES2(glp, renderModes, colorTexSeq, Region.DEFAULT_TWO_PASS_TEXTURE_UNIT);
} else if( isMSAA(renderModes) ) {
- return new VBORegion2PMSAAES2(renderModes, colorTexSeq, Region.DEFAULT_TWO_PASS_TEXTURE_UNIT);
+ return new VBORegion2PMSAAES2(glp, renderModes, colorTexSeq, Region.DEFAULT_TWO_PASS_TEXTURE_UNIT);
} else {
- return new VBORegionSPES2(renderModes, colorTexSeq);
+ return new VBORegionSPES2(glp, renderModes, colorTexSeq);
}
}
+ private final int gl_idx_type;
protected final TextureSequence colorTexSeq;
- protected GLRegion(final int renderModes, final TextureSequence colorTexSeq) {
- super(renderModes);
+ protected GLRegion(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq) {
+ super(renderModes, glp.isGL2ES3() /* use_int32_idx */);
+ this.gl_idx_type = usesI32Idx() ? GL.GL_UNSIGNED_INT : GL.GL_UNSIGNED_SHORT;
this.colorTexSeq = colorTexSeq;
}
+ protected final int glIdxType() { return this.gl_idx_type; }
+
/**
* Updates a graph region by updating the ogl related
* objects for use in rendering if {@link #isShapeDirty()}.
@@ -94,12 +105,28 @@ public abstract class GLRegion extends Region { protected abstract void clearImpl(final GL2ES2 gl);
+ protected static void printAndCount(final PrintStream out, final String name, final GLArrayData data, final int[] size, final int[] capacity) {
+ out.print(name+"[");
+ if( null != data ) {
+ data.printStats(out);
+ size[0] += data.getSizeInBytes();
+ capacity[0] += data.getCapacityInBytes();
+ out.print("]");
+ } else {
+ out.print("null]");
+ }
+ }
+
/**
* Clears all data, i.e. triangles, vertices etc.
+ *
+ * @param gl the current {@link GL2ES2} object
+ * @return this {@link GLRegion} for chaining.
*/
- public void clear(final GL2ES2 gl) {
+ public GLRegion clear(final GL2ES2 gl) {
clearImpl(gl);
clearImpl();
+ return this;
}
/**
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 88e972bdc..547a07fba 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -144,7 +144,7 @@ public class TextRegionUtil { GLRegion region = getCachedRegion(font, str); AABBox res; if(null == region) { - region = GLRegion.create(renderModes, null); + region = GLRegion.create(gl.getGLProfile(), renderModes, null); res = addStringToRegion(region, font, null, str, rgbaColor, tempT1, tempT2); addCachedRegion(gl, font, str, region); } else { @@ -185,7 +185,7 @@ public class TextRegionUtil { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } - final GLRegion region = GLRegion.create(renderModes, null); + final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); final AABBox res = addStringToRegion(region, font, null, str, rgbaColor); region.draw(gl, renderer, sampleCount); region.destroy(gl); @@ -193,8 +193,10 @@ public class TextRegionUtil { } /** - * Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of the given {@link GLRegion}, - * which will {@link GLRegion#clear(GL2ES2) cleared} beforehand. + * Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of the given {@link GLRegion}. + * <p> + * User might want to {@link GLRegion#clear(GL2ES2)} the region before calling this method. + * </p> * <p> * The shapes added to the GLRegion are in font em-size [0..1]. * </p> @@ -202,6 +204,8 @@ public class TextRegionUtil { * Origin of rendered text is 0/0 at bottom left. * </p> * @param gl the current GL state + * @param region + * @param renderer * @param font {@link Font} to be used * @param str text to be rendered * @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored. @@ -216,14 +220,13 @@ public class TextRegionUtil { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } - region.clear(gl); final AABBox res = addStringToRegion(region, font, null, str, rgbaColor); region.draw(gl, renderer, sampleCount); return res; } /** - * Clear all cached {@link GLRegions}. + * Clear all cached {@link GLRegions} and mapped values. */ public void clear(final GL2ES2 gl) { // fluchCache(gl) already called diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 798d77b8f..4d88479ea 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -27,9 +27,12 @@ */ package jogamp.graph.curve.opengl; +import java.io.PrintStream; import java.nio.FloatBuffer; import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLArrayData; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GL; import com.jogamp.opengl.GLUniformData; @@ -43,6 +46,7 @@ import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.opengl.util.GLArrayDataClient; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.Texture; @@ -134,15 +138,16 @@ public class VBORegion2PMSAAES2 extends GLRegion { } } - public VBORegion2PMSAAES2(final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit) { - super(renderModes, colorTexSeq); + public VBORegion2PMSAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit) { + super(glp, renderModes, colorTexSeq); rsLocal = new RenderState.ProgramLocal(); final int initialElementCount = 256; + // We leave GLArrayDataClient.DEFAULT_GROWTH_FACTOR intact for avg +19% size, but 15% less CPU overhead compared to 1.2 (19% total) // Pass 1: - indicesBuffer = GLArrayDataServer.createData(3, GL.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); @@ -173,7 +178,7 @@ public class VBORegion2PMSAAES2 extends GLRegion { // Pass 2: gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit); - indicesFbo = GLArrayDataServer.createData(3, GL.GL_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesFbo = GLArrayDataServer.createData(3, GL.GL_UNSIGNED_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3); indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3); indicesFbo.seal(true); @@ -191,6 +196,16 @@ public class VBORegion2PMSAAES2 extends GLRegion { } @Override + protected void growBufferSize(final int verticeCount, final int indexCount) { + indicesBuffer.growIfNeeded(indexCount); + gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); + } + } + + @Override protected final void clearImpl(final GL2ES2 gl) { if( null != indicesBuffer ) { indicesBuffer.clear(gl); @@ -208,6 +223,23 @@ public class VBORegion2PMSAAES2 extends GLRegion { } @Override + protected void printBufferStats(final PrintStream out) { + final int[] size= { 0 }, capacity= { 0 }; + out.println("VBORegion2PMSAAES2:"); + printAndCount(out, " indices ", indicesBuffer, size, capacity); + out.println(); + printAndCount(out, " vertices ", gca_VerticesAttr, size, capacity); + out.println(); + printAndCount(out, " params ", gca_CurveParamsAttr, size, capacity); + out.println(); + printAndCount(out, " color ", gca_ColorsAttr, size, capacity); + final float filled = (float)size[0]/(float)capacity[0]; + out.println(); + out.printf(" total [bytes %,d / %,d], filled %.1f%%, left %.1f%%]%n", + size[0], capacity[0], filled*100f, (1f-filled)*100f); + } + + @Override protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); @@ -231,7 +263,11 @@ public class VBORegion2PMSAAES2 extends GLRegion { @Override protected final void pushIndex(final int idx) { - indicesBuffer.puts((short)idx); + if( usesI32Idx() ) { + indicesBuffer.puti(idx); + } else { + indicesBuffer.puts((short)idx); + } } @Override diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index a5af67e0c..7e8d76127 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -27,9 +27,11 @@ */ package jogamp.graph.curve.opengl; +import java.io.PrintStream; import java.nio.FloatBuffer; import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GL; import com.jogamp.opengl.GLUniformData; @@ -47,6 +49,7 @@ import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.FBObject.TextureAttachment; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.AABBox; +import com.jogamp.opengl.util.GLArrayDataClient; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.Texture; @@ -171,24 +174,31 @@ public class VBORegion2PVBAAES2 extends GLRegion { } } - public VBORegion2PVBAAES2(final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit) { - super(renderModes, colorTexSeq); + public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit) { + super(glp, renderModes, colorTexSeq); rsLocal = new RenderState.ProgramLocal(); final int initialElementCount = 256; + // final float growthFactor = 1.2f; // avg +5% size but 15% more overhead (34% total) + final float growthFactor = GLArrayDataClient.DEFAULT_GROWTH_FACTOR; // avg +20% size, but 15% less CPU overhead compared to 1.2 (19% total) // Pass 1: - indicesBuffer = GLArrayDataServer.createData(3, GL.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer.setGrowthFactor(growthFactor); gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialElementCount, GL.GL_STATIC_DRAW); + false, initialElementCount, GL.GL_STATIC_DRAW); + gca_VerticesAttr.setGrowthFactor(growthFactor); gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialElementCount, GL.GL_STATIC_DRAW); + false, initialElementCount, GL.GL_STATIC_DRAW); + gca_CurveParamsAttr.setGrowthFactor(growthFactor); + if( hasColorChannel() ) { gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); + gca_ColorsAttr.setGrowthFactor(growthFactor); } else { gca_ColorsAttr = null; } @@ -210,7 +220,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { gcu_FboTexUnit = new GLUniformData(UniformNames.gcu_FboTexUnit, pass2TexUnit); gcu_FboTexSize = new GLUniformData(UniformNames.gcu_FboTexSize, 2, FloatBuffer.wrap(new float[2])); - indicesFbo = GLArrayDataServer.createData(3, GL.GL_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesFbo = GLArrayDataServer.createData(3, GL.GL_UNSIGNED_SHORT, 2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3); indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3); indicesFbo.seal(true); @@ -228,6 +238,16 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override + protected void growBufferSize(final int verticeCount, final int indexCount) { + indicesBuffer.growIfNeeded(indexCount); + gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); + } + } + + @Override protected final void clearImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Clear: " + this); @@ -249,6 +269,23 @@ public class VBORegion2PVBAAES2 extends GLRegion { } @Override + protected void printBufferStats(final PrintStream out) { + final int[] size= { 0 }, capacity= { 0 }; + out.println("VBORegion2PVBAAES2:"); + printAndCount(out, " indices ", indicesBuffer, size, capacity); + out.println(); + printAndCount(out, " vertices ", gca_VerticesAttr, size, capacity); + out.println(); + printAndCount(out, " params ", gca_CurveParamsAttr, size, capacity); + out.println(); + printAndCount(out, " color ", gca_ColorsAttr, size, capacity); + final float filled = (float)size[0]/(float)capacity[0]; + out.println(); + out.printf(" total [bytes %,d / %,d], filled %.1f%%, left %.1f%%]%n", + size[0], capacity[0], filled*100f, (1f-filled)*100f); + } + + @Override protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); @@ -272,7 +309,11 @@ public class VBORegion2PVBAAES2 extends GLRegion { @Override protected final void pushIndex(final int idx) { - indicesBuffer.puts((short)idx); + if( usesI32Idx() ) { + indicesBuffer.puti(idx); + } else { + indicesBuffer.puts((short)idx); + } } @Override diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 5b0d38929..73f9acb34 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -27,10 +27,12 @@ */ package jogamp.graph.curve.opengl; +import java.io.PrintStream; import java.nio.FloatBuffer; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import jogamp.graph.curve.opengl.shader.AttributeNames; @@ -58,13 +60,15 @@ public class VBORegionSPES2 extends GLRegion { private final GLUniformData gcu_ColorTexBBox; private ShaderProgram spPass1 = null; - public VBORegionSPES2(final int renderModes, final TextureSequence colorTexSeq) { - super(renderModes, colorTexSeq); + public VBORegionSPES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq) { + super(glp, renderModes, colorTexSeq); rsLocal = new RenderState.ProgramLocal(); final int initialElementCount = 256; - indicesBuffer = GLArrayDataServer.createData(3, GL.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + // We leave GLArrayDataClient.DEFAULT_GROWTH_FACTOR intact for avg +19% size, but 15% less CPU overhead compared to 1.2 (19% total) + + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); @@ -90,6 +94,16 @@ public class VBORegionSPES2 extends GLRegion { } @Override + protected void growBufferSize(final int verticeCount, final int indexCount) { + indicesBuffer.growIfNeeded(indexCount); + gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); + } + } + + @Override protected final void clearImpl(final GL2ES2 gl) { if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Clear: " + this); @@ -109,6 +123,23 @@ public class VBORegionSPES2 extends GLRegion { } @Override + protected void printBufferStats(final PrintStream out) { + final int[] size= { 0 }, capacity= { 0 }; + out.println("VBORegionSPES2:"); + printAndCount(out, " indices ", indicesBuffer, size, capacity); + out.println(); + printAndCount(out, " vertices ", gca_VerticesAttr, size, capacity); + out.println(); + printAndCount(out, " params ", gca_CurveParamsAttr, size, capacity); + out.println(); + printAndCount(out, " color ", gca_ColorsAttr, size, capacity); + final float filled = (float)size[0]/(float)capacity[0]; + out.println(); + out.printf(" total [bytes %,d / %,d], filled %.1f%%, left %.1f%%]%n", + size[0], capacity[0], filled*100f, (1f-filled)*100f); + } + + @Override protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { gca_VerticesAttr.putf(coords[0]); gca_VerticesAttr.putf(coords[1]); @@ -132,7 +163,11 @@ public class VBORegionSPES2 extends GLRegion { @Override protected final void pushIndex(final int idx) { - indicesBuffer.puts((short)idx); + if( usesI32Idx() ) { + indicesBuffer.puti(idx); + } else { + indicesBuffer.puts((short)idx); + } } @Override 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 a3733022f..add4b52dd 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -56,6 +56,7 @@ import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.font.FontSet; import com.jogamp.graph.geom.SVertex; import com.jogamp.graph.geom.plane.AffineTransform; +import com.jogamp.junit.util.JunitTracer; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.NEWTGLContext; @@ -84,6 +85,7 @@ public class TestTextRendererNEWT00 extends UITestCase { static boolean useMSAA = true; static int win_width = 1280; static int win_height = 720; + static boolean loop_inf = false; static Font font; static float fontSize = 24; // in pixel @@ -103,6 +105,7 @@ public class TestTextRendererNEWT00 extends UITestCase { } public static void main(final String args[]) throws IOException { + boolean wait = false; mainRun = true; for(int i=0; i<args.length; i++) { if(args[i].equals("-time")) { @@ -126,8 +129,15 @@ public class TestTextRendererNEWT00 extends UITestCase { } else if(args[i].equals("-fontSize")) { i++; fontSize = MiscUtils.atof(args[i], fontSize); + } else if(args[i].equals("-wait")) { + wait = true; + } else if(args[i].equals("-loop")) { + loop_inf = true; } } + if( wait ) { + JunitTracer.waitForKey("Start"); + } final String tstname = TestTextRendererNEWT00.class.getName(); org.junit.runner.JUnitCore.main(tstname); } @@ -165,64 +175,73 @@ public class TestTextRendererNEWT00 extends UITestCase { System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + 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); - // init - gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - renderer.init(gl, 0); - rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); - final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - - // reshape - gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); - - // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f); - renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f); - final int z0 = -1000; - - final int[] sampleCountIO = { sampleCount }; - // display - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - - final GLRegion region = GLRegion.create(renderModes, null); - final float dx = 0; - final float dy = drawable.getSurfaceHeight() - 3 * fontSize * font.getLineHeight(); - { - // all sizes in em - final float x_width = font.getAdvanceWidth( font.getGlyphID('X') ); - final AffineTransform t = new AffineTransform(); - - t.setToTranslation(3*x_width, 0f); - final AABBox tbox_1 = font.getGlyphBounds(text_1); - final AABBox rbox_1 = TextRegionUtil.addStringToRegion(region, font, t, text_1, fg_color); - System.err.println("Text_1: tbox "+tbox_1); - System.err.println("Text_1: rbox "+rbox_1); - - if( true ) { - t.setToTranslation(3*x_width, -1f*(rbox_1.getHeight()+font.getLineHeight())); - final AABBox tbox_2 = font.getGlyphBounds(text_2); - final AABBox rbox_2 = TextRegionUtil.addStringToRegion(region, font, t, text_2, fg_color); - System.err.println("Text_1: tbox "+tbox_2); - System.err.println("Text_1: rbox "+rbox_2); + do { + // init + final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); + System.err.println("GLRegion: for "+gl.getGLProfile()+" using int32_t indiced: "+region.usesI32Idx()); + + gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + renderer.init(gl, 0); + rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); + + // reshape + gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); + + // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f); + renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f); + final int z0 = -1000; + + final int[] sampleCountIO = { sampleCount }; + // display + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + region.clear(gl); + + final float dx = 0; + final float dy = drawable.getSurfaceHeight() - 3 * fontSize * font.getLineHeight(); + { + // all sizes in em + final float x_width = font.getAdvanceWidth( font.getGlyphID('X') ); + final AffineTransform t = new AffineTransform(); + + t.setToTranslation(3*x_width, 0f); + final AABBox tbox_1 = font.getGlyphBounds(text_1); + final AABBox rbox_1 = TextRegionUtil.addStringToRegion(region, font, t, text_1, fg_color); + System.err.println("Text_1: tbox "+tbox_1); + System.err.println("Text_1: rbox "+rbox_1); + + if( true ) { + t.setToTranslation(3*x_width, -1f*(rbox_1.getHeight()+font.getLineHeight())); + final AABBox tbox_2 = font.getGlyphBounds(text_2); + final AABBox rbox_2 = TextRegionUtil.addStringToRegion(region, font, t, text_2, fg_color); + System.err.println("Text_1: tbox "+tbox_2); + System.err.println("Text_1: rbox "+rbox_2); + } } - } - final PMVMatrix pmv = renderer.getMatrix(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(dx, dy, z0); - pmv.glScalef(fontSize, fontSize, 1f); - region.draw(gl, renderer, sampleCountIO); - gl.glFinish(); - printScreen(screenshot, renderModes, drawable, gl, false, sampleCount); - drawable.swapBuffers(); + final PMVMatrix pmv = renderer.getMatrix(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(dx, dy, z0); + pmv.glScalef(fontSize, fontSize, 1f); + region.draw(gl, renderer, sampleCountIO); + gl.glFinish(); + if( !loop_inf ) { + printScreen(screenshot, renderModes, drawable, gl, false, sampleCount); + } + drawable.swapBuffers(); + region.printBufferStats(System.err); + region.destroy(gl); + } while ( loop_inf ); sleep(); // dispose - region.destroy(gl);; screenshot.dispose(gl); renderer.destroy(gl); 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 63eb2be65..2a6c73a18 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -245,7 +245,7 @@ public class TestTextRendererNEWT10 extends UITestCase { renderModes = 0; sampleCount = 0; } - final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, renderModes, sampleCount); + final TextRendererGLEL textGLListener = new TextRendererGLEL(glp, rs, renderModes, sampleCount); System.err.println(textGLListener.getFontInfo()); window.addGLEventListener(textGLListener); @@ -294,13 +294,13 @@ public class TestTextRendererNEWT10 extends UITestCase { float fontSizeAnim, fontSizeDelta; float dpiV, ppmmV; - TextRendererGLEL(final RenderState rs, final int renderModes, final int sampleCount) { + TextRendererGLEL(final GLProfile glp, final RenderState rs, final int renderModes, final int sampleCount) { super(renderModes, new int[] { sampleCount }); setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); setRenderState(rs); - regionFPS = GLRegion.create(renderModes, null); - regionFPSAnim = GLRegion.create(renderModes, null); + regionFPS = GLRegion.create(glp, renderModes, null); + regionFPSAnim = GLRegion.create(glp, renderModes, null); if( null != fontURL ) { Font _font = null; try { @@ -418,7 +418,7 @@ public class TestTextRendererNEWT10 extends UITestCase { final String text1 = lfps+" / "+tfps+" fps, vsync "+gl.getSwapInterval()+", elapsed "+(t1-t0)/1000.0+ " s, fontSize "+fontSizeFixed+", msaa "+drawable.getChosenGLCapabilities().getNumSamples()+ ", "+modeS+"-samples "+vbaaSampleCount[0]; - renderString(drawable, font, pixelSize, text1, 0, 0, 0, 0, -1000, regionFPS); // no-cache + renderString(drawable, font, pixelSize, text1, 0, 0, 0, 0, -1000, regionFPS.clear(gl)); // no-cache } else { final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d", lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeFixed, @@ -431,9 +431,9 @@ public class TestTextRendererNEWT10 extends UITestCase { renderString(drawable, font, pixelSize, "I like JogAmp", 4, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "Hello World", 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, textX2, 0, 0, 0, -1000, true); - renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000, regionFPS); // no-cache + renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000, regionFPS.clear(gl)); // no-cache if( TextAnim ) { - renderString(drawable, font, pixelSizeAnim, text1, 0, 0, 0, -1000, regionFPSAnim); // no-cache + renderString(drawable, font, pixelSizeAnim, text1, 0, 0, 0, -1000, regionFPSAnim.clear(gl)); // no-cache } } } }; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java index 04604095f..a044ce9d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT20.java @@ -136,7 +136,7 @@ public class TestTextRendererNEWT20 extends UITestCase { System.err.println("Chosen: "+window.getChosenGLCapabilities()); final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, 4 /* sampleCount */, DEBUG, TRACE); + final TextGLListener textGLListener = new TextGLListener(glp, rs, Region.VBAA_RENDERING_BIT, 4 /* sampleCount */, DEBUG, TRACE); textGLListener.attachInputListenerTo(window); window.addGLEventListener(textGLListener); textGLListener.setHeadBox(2, true); @@ -200,7 +200,7 @@ public class TestTextRendererNEWT20 extends UITestCase { System.err.println("Chosen: "+window.getChosenGLCapabilities()); final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final TextGLListener textGLListener = new TextGLListener(rs, 0, 0 /* sampleCount */, DEBUG, TRACE); + final TextGLListener textGLListener = new TextGLListener(glp, rs, 0, 0 /* sampleCount */, DEBUG, TRACE); textGLListener.attachInputListenerTo(window); window.addGLEventListener(textGLListener); textGLListener.setHeadBox(2, true); @@ -247,7 +247,7 @@ public class TestTextRendererNEWT20 extends UITestCase { System.err.println("Chosen: "+window.getChosenGLCapabilities()); final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final TextGLListener textGLListener = new TextGLListener(rs, 0, 0 /* sampleCount */, DEBUG, TRACE); + final TextGLListener textGLListener = new TextGLListener(glp, rs, 0, 0 /* sampleCount */, DEBUG, TRACE); textGLListener.attachInputListenerTo(window); window.addGLEventListener(textGLListener); textGLListener.setHeadBox(2, true); @@ -283,8 +283,8 @@ public class TestTextRendererNEWT20 extends UITestCase { } private static class TextGLListener extends GPUTextRendererListenerBase01 { - public TextGLListener(final RenderState rs, final int type, final int sampleCount, final boolean debug, final boolean trace) { - super(rs, type, sampleCount, true, debug, trace); + public TextGLListener(final GLProfile glp, final RenderState rs, final int type, final int sampleCount, final boolean debug, final boolean trace) { + super(glp, rs, type, sampleCount, true, debug, trace); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java index 1059423f3..bc53bee2b 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener00.java @@ -31,6 +31,7 @@ package com.jogamp.opengl.test.junit.graph.demos; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.OutlineShape; @@ -55,7 +56,7 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { setMatrix(-20, 00, -50, 0f, sampleCount); } - private void createTestOutline(){ + private void createTestOutline(final GLProfile glp){ outlineShape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); outlineShape.addVertex(0.0f,-10.0f, true); outlineShape.addVertex(15.0f,-10.0f, true); @@ -90,7 +91,7 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { outlineShape.addVertex(offset+10.0f,0.0f, true); outlineShape.closeLastOutline(true); - region = GLRegion.create(getRenderModes(), null); + region = GLRegion.create(glp, getRenderModes(), null); region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null); } @@ -107,7 +108,7 @@ public class GPURegionGLListener00 extends GPURendererListenerBase01 { gl.glEnable(GL.GL_BLEND); rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); - createTestOutline(); + createTestOutline(gl.getGLProfile()); } @Override 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 b78826a6d..506c47f7d 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 @@ -272,7 +272,7 @@ public class GPURegionGLListener01 extends GPURendererListenerBase01 { createTestOutline01(); break; } - region = GLRegion.create(getRenderModes(), null); + region = GLRegion.create(gl.getGLProfile(), getRenderModes(), null); region.addOutlineShape(outlineShape, null, region.hasColorChannel() ? getRenderer().getRenderState().getColorStatic(new float[4]) : null); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java index 13c168ee7..188c27495 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionGLListener10.java @@ -34,6 +34,7 @@ import java.util.List; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.OutlineShape; @@ -55,7 +56,7 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { setMatrix(-20, 00, -50, 0f, sampleCount); } - private void createTestOutline(){ + private void createTestOutline(final GLProfile glp){ OutlineShape shape = new OutlineShape(getRenderer().getRenderState().getVertexFactory()); outlineShapes.add(shape); shape.addVertex(0.0f,-10.0f,true); @@ -92,7 +93,7 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { shape.addVertex(offset+10.0f,0.0f, true); shape.closeLastOutline(true); - region = GLRegion.create(getRenderModes(), null); + region = GLRegion.create(glp, getRenderModes(), null); region.addOutlineShapes(outlineShapes, null, null); } @@ -109,7 +110,7 @@ public class GPURegionGLListener10 extends GPURendererListenerBase01 { gl.glEnable(GL.GL_BLEND); rs.setColorStatic(0.0f, 0.0f, 0.0f, 1.0f); - createTestOutline(); + createTestOutline(gl.getGLProfile()); } @Override 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 5b7044fee..9c6402a68 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 @@ -31,7 +31,7 @@ package com.jogamp.opengl.test.junit.graph.demos; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; - +import com.jogamp.opengl.GLProfile; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.geom.SVertex; @@ -39,8 +39,8 @@ import com.jogamp.newt.opengl.GLWindow; public class GPUTextGLListener0A extends GPUTextRendererListenerBase01 { - public GPUTextGLListener0A(final RenderState rs, final int renderModes, final int sampleCount, final boolean blending, final boolean debug, final boolean trace) { - super(rs, renderModes, sampleCount, blending, debug, trace); + public GPUTextGLListener0A(final GLProfile glp, final RenderState rs, final int renderModes, final int sampleCount, final boolean blending, final boolean debug, final boolean trace) { + super(glp, rs, renderModes, sampleCount, blending, debug, trace); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java index ed7f7493f..0c22ac43a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextNewtDemo.java @@ -142,7 +142,7 @@ public class GPUTextNewtDemo { window.setTitle("GPU Text Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples); final RenderState rs = RenderState.createRenderState(SVertex.factory()); - final GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, rmode, sampleCount, true, DEBUG, TRACE); + final GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(glp, rs, rmode, sampleCount, true, DEBUG, TRACE); textGLListener.setFont(opt_font); textGLListener.setFontHeadSize(opt_fontSizeHead); // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32); 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 0e60ae160..8fa3744fd 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 @@ -34,6 +34,7 @@ import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAnimatorControl; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; @@ -142,16 +143,16 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB Window upstream_window = null; StringBuilder userString = new StringBuilder(textX1); boolean userInput = false; - public GPUTextRendererListenerBase01(final RenderState rs, final int renderModes, final int sampleCount, final boolean blending, final boolean debug, final boolean trace) { + public GPUTextRendererListenerBase01(final GLProfile glp, final RenderState rs, final int renderModes, final int sampleCount, final boolean blending, final boolean debug, final boolean trace) { // NOTE_ALPHA_BLENDING: We use alpha-blending 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.regionHead = GLRegion.create(renderModes, null); - this.regionBottom = GLRegion.create(renderModes, null); + this.regionFPS = GLRegion.create(glp, renderModes, null); + this.regionHead = GLRegion.create(glp, renderModes, null); + this.regionBottom = GLRegion.create(glp, renderModes, null); setFontSet(fontSet, FontSet.FAMILY_LIGHT, FontSet.STYLE_NONE); setMatrix(0, 0, 0, 0f, sampleCount); } @@ -338,7 +339,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB pmv.glScalef(sxy, sxy, 1.0f); } // No cache, keep region alive! - TextRegionUtil.drawString3D(gl, regionFPS, renderer, font, text, null, sampleCountFPS); + TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS); pmv.glPopMatrix(); } @@ -392,13 +393,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } if(!userInput) { if( bottomTextUseFrustum ) { - TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, text2, null, getSampleCount()); + TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, text2, null, getSampleCount()); } else { textRegionUtil.drawString3D(gl, renderer, font, text2, null, getSampleCount()); } } else { if( bottomTextUseFrustum ) { - TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, userString.toString(), null, getSampleCount()); + TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, userString.toString(), null, getSampleCount()); } else { textRegionUtil.drawString3D(gl, renderer, font, userString.toString(), null, getSampleCount()); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener02.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener02.java deleted file mode 100644 index 80225c92d..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener02.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jogamp.opengl.test.junit.graph.demos; - -import com.jogamp.graph.curve.Region; - -public class GPUUISceneGLListener02 extends GPUUISceneGLListener0A { - public GPUUISceneGLListener02() { - super(Region.VBAA_RENDERING_BIT); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener04.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener04.java deleted file mode 100644 index 461e2c114..000000000 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener04.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.jogamp.opengl.test.junit.graph.demos; - -public class GPUUISceneGLListener04 extends GPUUISceneGLListener0A { - public GPUUISceneGLListener04() { - super(GPUUISceneGLListener0A.DefaultNoAADPIThreshold /* noAADPIThreshold */); - } -} 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 22c9af424..e8c21efbe 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 @@ -128,17 +128,6 @@ public class GPUUISceneGLListener0A implements GLEventListener { "\n"+ "The quick brown fox jumps over the lazy dog\n"; - public GPUUISceneGLListener0A() { - this(0); - } - - /** - * @param noAADPIThreshold see {@link #DefaultNoAADPIThreshold} - */ - public GPUUISceneGLListener0A(final float noAADPIThreshold) { - this(null, noAADPIThreshold, false, false); - } - /** * @param renderModes */ diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java index 0eb0fbf22..1e9ae7a45 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneNewtDemo.java @@ -134,7 +134,7 @@ public class GPUUISceneNewtDemo { final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]); final GPUUISceneGLListener0A sceneGLListener = 0 < GraphAutoMode ? new GPUUISceneGLListener0A(fontfilename, GraphAutoMode, DEBUG, TRACE) : - new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); + new GPUUISceneGLListener0A(fontfilename, rmode, DEBUG, TRACE); window.addGLEventListener(sceneGLListener); sceneGLListener.attachInputListenerTo(window); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java index 0b372054e..a2bd5c0c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java @@ -329,7 +329,7 @@ public class UITypeDemo01 implements GLEventListener { pmv.glScalef(txt_scale, txt_scale, 1f); pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f); if( null != glyph.getShape() ) { - final GLRegion region = GLRegion.create(renderModes, null); + final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null); region.addOutlineShape(glyph.getShape(), null, region.hasColorChannel() ? fg_color : null); region.draw(gl, renderer, sampleCount); region.destroy(gl); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java index 30b5a6b90..226dfc1cd 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/TextureSeqButton.java @@ -28,7 +28,7 @@ package com.jogamp.opengl.test.junit.graph.demos.ui; import com.jogamp.opengl.GL2ES2; - +import com.jogamp.opengl.GLProfile; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -50,8 +50,8 @@ public class TextureSeqButton extends RoundButton { } @Override - protected GLRegion createGLRegion() { - return GLRegion.create(getRenderModes(), texSeq); + protected GLRegion createGLRegion(final GLProfile glp) { + return GLRegion.create(glp, getRenderModes(), texSeq); } public final TextureSequence getTextureSequence() { return this.texSeq; } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java index 3ee48504d..22eeec50f 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import com.jogamp.nativewindow.NativeWindowException; import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; @@ -264,8 +265,8 @@ public abstract class UIShape { getRegion(gl, renderer).draw(gl, renderer, sampleCount); } - protected GLRegion createGLRegion() { - return GLRegion.create(renderModes, null); + protected GLRegion createGLRegion(final GLProfile glp) { + return GLRegion.create(glp, renderModes, null); } /** @@ -278,7 +279,7 @@ public abstract class UIShape { if( isShapeDirty() || null == region ) { box.reset(); if( null == region ) { - region = createGLRegion(); + region = createGLRegion(gl.getGLProfile()); } else { region.clear(gl); } 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 66655dadd..c8ce8b1c2 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 @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLCapabilitiesImmutable; @@ -71,11 +72,11 @@ public abstract class GLReadBuffer00Base extends UITestCase { public int userCounter = 0; private final GLRegion regionFPS; - public TextRendererGLEL() { + public TextRendererGLEL(final GLProfile glp) { // 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(renderModes, null); + regionFPS = GLRegion.create(glp, renderModes, null); staticRGBAColor[0] = 0.9f; staticRGBAColor[1] = 0.9f; @@ -95,8 +96,9 @@ public abstract class GLReadBuffer00Base extends UITestCase { System.err.println("TextRendererGLEL.display: "+text); if( null != renderer ) { final float pixelSize = FontScale.toPixels(14f, dpiH); - drawable.getGL().glClearColor(1f, 1f, 1f, 0f); - renderString(drawable, font, pixelSize, text, 0 /* col */, 0 /* row */, 0, 0, -1, regionFPS); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glClearColor(1f, 1f, 1f, 0f); + renderString(drawable, font, pixelSize, text, 0 /* col */, 0 /* row */, 0, 0, -1, regionFPS.clear(gl)); } else { System.err.println(text); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java index 0953c9b47..0031b42be 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java @@ -76,10 +76,11 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00BaseAWT { final Frame frame = new Frame(); final Dimension d = new Dimension(320, 240); final GLCanvas glad = createGLCanvas(caps, d); - final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(caps.getGLProfile()); final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil, false) : null; try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setLocation(64, 64); frame.setLayout(new BorderLayout()); @@ -145,18 +146,21 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00BaseAWT { } try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size1); frame.validate(); } } ); try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size2); frame.validate(); } } ); try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size0); frame.validate(); @@ -175,6 +179,7 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00BaseAWT { } try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.dispose(); } } ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java index 95568704d..c6b6b5c7f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java @@ -75,10 +75,11 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00BaseAWT { final JFrame frame = new JFrame(); final Dimension d = new Dimension(320, 240); final GLJPanel glad = createGLJPanel(skipGLOrientationVerticalFlip, useSwingDoubleBuffer, caps, d); - final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(caps.getGLProfile()); final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil, skipGLOrientationVerticalFlip) : null; try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setLocation(64, 64); final JPanel panel = new JPanel(); @@ -146,18 +147,21 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00BaseAWT { } try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size1); frame.validate(); } } ); try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size2); frame.validate(); } } ); try { Thread.sleep(duration); } catch (final InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(size0); frame.validate(); @@ -176,6 +180,7 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00BaseAWT { } try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.dispose(); } } ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java index f558f698f..1ff6ced0d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java @@ -76,7 +76,7 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { } final GLReadBufferUtil glReadBufferUtil = new GLReadBufferUtil(false, false); final GLWindow glad= GLWindow.create(caps); - final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(caps.getGLProfile()); final SnapshotGLEL snapshotGLEL = doSnapshot ? new SnapshotGLEL(textRendererGLEL, glReadBufferUtil) : null; try { glad.setPosition(64, 64); 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 21cc6b7ef..673b71081 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 @@ -176,14 +176,14 @@ public class MovieCube implements GLEventListener { private final GLRegion regionFPS; private float pixelSize1, pixelSize2, underlineSize; - InfoTextRendererGLELBase(final int rmode, final boolean lowPerfDevice) { + InfoTextRendererGLELBase(final GLProfile glp, final int rmode, final boolean lowPerfDevice) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(rmode, MovieCube.this.textSampleCount); this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); if( lowPerfDevice ) { regionFPS = null; } else { - regionFPS = GLRegion.create(renderModes, null); + regionFPS = GLRegion.create(glp, renderModes, null); System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); } staticRGBAColor[0] = 0.1f; @@ -258,7 +258,7 @@ public class MovieCube implements GLEventListener { if( displayOSD && null != renderer ) { gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); if( null != regionFPS ) { - renderString(drawable, font, pixelSize1, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS); // no-cache + renderString(drawable, font, pixelSize1, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS.clear(gl.getGL2ES2())); // no-cache } else { renderString(drawable, font, pixelSize1, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, true); } @@ -400,7 +400,7 @@ public class MovieCube implements GLEventListener { if( showText ) { final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; final boolean lowPerfDevice = gl.isGLES(); - textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice); + textRendererGLEL = new InfoTextRendererGLELBase(gl.getGLProfile(), rmode, lowPerfDevice); drawable.addGLEventListener(textRendererGLEL); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java index af0aaa775..d9028822e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java @@ -58,6 +58,7 @@ import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.Quaternion; @@ -140,14 +141,14 @@ public class MovieSBSStereo implements StereoGLEventListener { private final float fontSize = 1f; // 0.01f; private final GLRegion regionFPS; - InfoTextRendererGLELBase(final int rmode, final boolean lowPerfDevice) { + InfoTextRendererGLELBase(final GLProfile glp, final int rmode, final boolean lowPerfDevice) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(rmode, textSampleCount); this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); if( lowPerfDevice ) { regionFPS = null; } else { - regionFPS = GLRegion.create(renderModes, null); + regionFPS = GLRegion.create(glp, renderModes, null); System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); } staticRGBAColor[0] = 0.9f; @@ -197,7 +198,8 @@ public class MovieSBSStereo implements StereoGLEventListener { // We share ClearColor w/ MovieSimple's init ! final float pixelSize = FontScale.toPixels(fontSize, dpiH); if( null != regionFPS ) { - renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS); // no-cache + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS.clear(gl)); // no-cache } else { renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, true); } @@ -545,7 +547,7 @@ public class MovieSBSStereo implements StereoGLEventListener { final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; final boolean lowPerfDevice = gl.isGLES(); if( enableTextRendererGLEL ) { - textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice); + textRendererGLEL = new InfoTextRendererGLELBase(gl.getGLProfile(), rmode, lowPerfDevice); textRendererGLEL.init(drawable); } else { textRendererGLEL = null; 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 4ba3372eb..5e7ace02b 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 @@ -143,14 +143,14 @@ public class MovieSimple implements GLEventListener { private final float fontSize = 10f; private final GLRegion regionFPS; - InfoTextRendererGLELBase(final int rmode, final boolean lowPerfDevice) { + InfoTextRendererGLELBase(final GLProfile glp, final int rmode, final boolean lowPerfDevice) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(rmode, textSampleCount); this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); if( lowPerfDevice ) { regionFPS = null; } else { - regionFPS = GLRegion.create(renderModes, null); + regionFPS = GLRegion.create(glp, renderModes, null); System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); } staticRGBAColor[0] = 0.9f; @@ -200,7 +200,8 @@ public class MovieSimple implements GLEventListener { // We share ClearColor w/ MovieSimple's init ! final float pixelSize = FontScale.toPixels(fontSize, dpiH); if( null != regionFPS ) { - renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS); // no-cache + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS.clear(gl)); // no-cache } else { renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, true); } @@ -618,7 +619,7 @@ public class MovieSimple implements GLEventListener { } final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; final boolean lowPerfDevice = gl.isGLES(); - textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice); + textRendererGLEL = new InfoTextRendererGLELBase(gl.getGLProfile(), rmode, lowPerfDevice); drawable.addGLEventListener(textRendererGLEL); } |