aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java41
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java15
2 files changed, 43 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 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