summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java209
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java128
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java107
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java120
-rw-r--r--src/jogl/classes/jogamp/opengl/FPSCounterImpl.java51
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java14
8 files changed, 346 insertions, 292 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index b7a244f81..89693bb66 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl;
import java.io.PrintStream;
import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
@@ -51,13 +53,15 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class VBORegion2PMSAAES2 extends GLRegion {
+public final class VBORegion2PMSAAES2 extends GLRegion {
private static final boolean DEBUG_FBO_1 = false;
private static final boolean DEBUG_FBO_2 = false;
private final RenderState.ProgramLocal rsLocal;
// Pass-1:
+ private int curVerticesCap = 0;
+ private int curIndicesCap = 0;
private GLArrayDataServer gca_VerticesAttr;
private GLArrayDataServer gca_CurveParamsAttr;
private GLArrayDataServer gca_ColorsAttr;
@@ -84,58 +88,6 @@ public class VBORegion2PMSAAES2 extends GLRegion {
final int[] maxTexSize = new int[] { -1 } ;
- /**
- * <p>
- * Since multiple {@link Region}s may share one
- * {@link ShaderProgram}, the uniform data must always be updated.
- * </p>
- *
- * @param gl
- * @param renderer
- * @param renderModes
- * @param pass1
- * @param quality
- * @param sampleCount
- */
- public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
- final RenderState rs = renderer.getRenderState();
- final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq);
- final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
- final boolean updateLocLocal;
- if( pass1 ) {
- updateLocLocal = !sp.equals(spPass1);
- spPass1 = sp;
- if( DEBUG ) {
- System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
- }
- if( updateLocLocal ) {
- rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true);
- rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true);
- if( null != gca_ColorsAttr ) {
- rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
- }
- }
- rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true);
- rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
- if( null != gcu_ColorTexUnit ) {
- rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
- rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
- }
- } else {
- updateLocLocal = !sp.equals(spPass2);
- spPass2 = sp;
- if( DEBUG ) {
- System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
- }
- if( updateLocLocal ) {
- rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true);
- rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true);
- }
- rsLocal.update(gl, rs, updateLocLocal, renderModes, false, true);
- rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
- }
- }
-
public VBORegion2PMSAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit,
final int initialVerticesCount, final int initialIndicesCount)
{
@@ -146,20 +98,8 @@ public class VBORegion2PMSAAES2 extends GLRegion {
// 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, glIdxType(), initialIndicesCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
-
- gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
-
- gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
+ initBuffer(initialVerticesCount, initialIndicesCount);
- if( hasColorChannel() ) {
- gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
- } else {
- gca_ColorsAttr = null;
- }
if( hasColorTexture() ) {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
colorTexBBox = new float[4];
@@ -194,13 +134,54 @@ public class VBORegion2PMSAAES2 extends GLRegion {
false, 4, GL.GL_STATIC_DRAW);
}
+ private void initBuffer(final int verticeCount, final int indexCount) {
+ indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
+ indicesBuffer.setGrowthFactor(growthFactor);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+
+ gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_VerticesAttr.setGrowthFactor(growthFactor);
+ gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_CurveParamsAttr.setGrowthFactor(growthFactor);
+ if( hasColorChannel() ) {
+ gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_ColorsAttr.setGrowthFactor(growthFactor);
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
+ }
+
@Override
- public void growBufferSize(final int verticeCount, final int indexCount) {
- indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem());
- 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());
+ public void growBuffer(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) {
+ indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem());
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) {
+ gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem());
+ gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem());
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem());
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
+ }
+ }
+
+ @Override
+ public void setBufferCapacity(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesCount ) {
+ indicesBuffer.reserve(indicesCount);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < verticesCount ) {
+ gca_VerticesAttr.reserve(verticesCount);
+ gca_CurveParamsAttr.reserve(verticesCount);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.reserve(verticesCount);
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
}
}
@@ -240,15 +221,11 @@ public class VBORegion2PMSAAES2 extends GLRegion {
@Override
protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) {
- // NIO array[3] is much slows than group/single
- // gca_VerticesAttr.putf(coords, 0, 3);
- // gca_CurveParamsAttr.putf(texParams, 0, 3);
- gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]);
- gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
- // gca_ColorsAttr.putf(rgba, 0, 4);
- gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -258,18 +235,18 @@ public class VBORegion2PMSAAES2 extends GLRegion {
@Override
protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3,
final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) {
- gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]);
- gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]);
- gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]);
- gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]);
- gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]);
- gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3];
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -288,9 +265,9 @@ public class VBORegion2PMSAAES2 extends GLRegion {
@Override
protected final void pushIndices(final int idx1, final int idx2, final int idx3) {
if( usesI32Idx() ) {
- indicesBuffer.put3i(idx1, idx2, idx3);
+ put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3);
} else {
- indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3);
+ put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3);
}
}
@@ -342,6 +319,58 @@ public class VBORegion2PMSAAES2 extends GLRegion {
// the buffers were disabled, since due to real/fbo switching and other vbo usage
}
+ /**
+ * <p>
+ * Since multiple {@link Region}s may share one
+ * {@link ShaderProgram}, the uniform data must always be updated.
+ * </p>
+ *
+ * @param gl
+ * @param renderer
+ * @param renderModes
+ * @param pass1
+ * @param quality
+ * @param sampleCount
+ */
+ public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) {
+ final RenderState rs = renderer.getRenderState();
+ final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq);
+ final ShaderProgram sp = renderer.getRenderState().getShaderProgram();
+ final boolean updateLocLocal;
+ if( pass1 ) {
+ updateLocLocal = !sp.equals(spPass1);
+ spPass1 = sp;
+ if( DEBUG ) {
+ System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ }
+ if( updateLocLocal ) {
+ rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true);
+ rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true);
+ if( null != gca_ColorsAttr ) {
+ rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true);
+ }
+ }
+ rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true);
+ if( null != gcu_ColorTexUnit ) {
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true);
+ rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true);
+ }
+ } else {
+ updateLocLocal = !sp.equals(spPass2);
+ spPass2 = sp;
+ if( DEBUG ) {
+ System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal);
+ }
+ if( updateLocLocal ) {
+ rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true);
+ rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true);
+ }
+ rsLocal.update(gl, rs, updateLocLocal, renderModes, false, true);
+ rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit
+ }
+ }
+
private final AABBox drawWinBox = new AABBox();
private final int[] drawView = new int[] { 0, 0, 0, 0 };
private final float[] drawVec4Tmp0 = new float[4];
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 2998f3fe1..9567bab10 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl;
import java.io.PrintStream;
import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
@@ -56,7 +58,7 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class VBORegion2PVBAAES2 extends GLRegion {
+public final class VBORegion2PVBAAES2 extends GLRegion {
private static final boolean DEBUG_FBO_1 = false;
private static final boolean DEBUG_FBO_2 = false;
@@ -93,6 +95,8 @@ public class VBORegion2PVBAAES2 extends GLRegion {
private final RenderState.ProgramLocal rsLocal;
// Pass-1:
+ private int curVerticesCap = 0;
+ private int curIndicesCap = 0;
private GLArrayDataServer gca_VerticesAttr;
private GLArrayDataServer gca_CurveParamsAttr;
private GLArrayDataServer gca_ColorsAttr;
@@ -174,9 +178,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
}
}
- // private static final float growthFactor = 1.2f; // avg +5% size but 15% more overhead (34% total)
- private static final float growthFactor = GLArrayDataClient.DEFAULT_GROWTH_FACTOR; // avg +20% size, but 15% less CPU overhead compared to 1.2 (19% total)
-
public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit,
final int initialVerticesCount, final int initialIndicesCount)
{
@@ -185,7 +186,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
rsLocal = new RenderState.ProgramLocal();
// Pass 1:
- growBufferSize(initialVerticesCount, initialIndicesCount);
+ initBuffer(initialVerticesCount, initialIndicesCount);
if( hasColorTexture() ) {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
@@ -222,37 +223,58 @@ public class VBORegion2PVBAAES2 extends GLRegion {
false, 4, GL.GL_STATIC_DRAW);
}
+ private void initBuffer(final int verticeCount, final int indexCount) {
+ indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
+ indicesBuffer.setGrowthFactor(growthFactor);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+
+ gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_VerticesAttr.setGrowthFactor(growthFactor);
+ gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_CurveParamsAttr.setGrowthFactor(growthFactor);
+ if( hasColorChannel() ) {
+ gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_ColorsAttr.setGrowthFactor(growthFactor);
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
+ }
+
@Override
- public void growBufferSize(final int verticeCount, final int indexCount) {
- if(null == indicesBuffer ) {
- indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- indicesBuffer.setGrowthFactor(growthFactor);
- } else {
- indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem());
- }
- if( null == gca_VerticesAttr ) {
- gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
- false, verticeCount, GL.GL_STATIC_DRAW);
- gca_VerticesAttr.setGrowthFactor(growthFactor);
- } else {
- gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem());
- }
- if( null == gca_CurveParamsAttr ) {
- gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
- false, verticeCount, GL.GL_STATIC_DRAW);
- gca_CurveParamsAttr.setGrowthFactor(growthFactor);
- } else {
- gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem());
+ public void growBuffer(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) {
+ // System.err.printf("XXX Buffer grow - Indices: %d < ( %d = %d + %d ); Status: %s%n",
+ // curIndicesCap, indicesBuffer.elemPosition() + indicesCount, indicesBuffer.elemPosition(), indicesCount, indicesBuffer.elemStatsToString());
+ indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem());
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) {
+ // System.err.printf("XXX Buffer grow - Verices: %d < ( %d = %d + %d ); Status: %s%n",
+ // curVerticesCap, gca_VerticesAttr.elemPosition() + verticesCount, gca_VerticesAttr.elemPosition(), verticesCount, gca_VerticesAttr.elemStatsToString());
+ gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem());
+ gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem());
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem());
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
}
+ }
- if( null == gca_ColorsAttr ) {
- if( hasColorChannel() ) {
- gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
- false, verticeCount, GL.GL_STATIC_DRAW);
- gca_ColorsAttr.setGrowthFactor(growthFactor);
+ @Override
+ public void setBufferCapacity(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesCount ) {
+ indicesBuffer.reserve(indicesCount);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < verticesCount ) {
+ gca_VerticesAttr.reserve(verticesCount);
+ gca_CurveParamsAttr.reserve(verticesCount);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.reserve(verticesCount);
}
- } else {
- gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem());
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
}
}
@@ -299,12 +321,15 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// NIO array[3] is much slows than group/single
// gca_VerticesAttr.putf(coords, 0, 3);
// gca_CurveParamsAttr.putf(texParams, 0, 3);
- gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]);
- gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]);
+ // gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]);
+ // gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
// gca_ColorsAttr.putf(rgba, 0, 4);
- gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]);
+ // gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -314,18 +339,27 @@ public class VBORegion2PVBAAES2 extends GLRegion {
@Override
protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3,
final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) {
- gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]);
- gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]);
- gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]);
- gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]);
- gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]);
- gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]);
+ // gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]);
+ // gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]);
+ // gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]);
+ // gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]);
+ // gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]);
+ // gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3];
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
+ // gca_ColorsAttr.put4f(r, g, b, a);
+ // gca_ColorsAttr.put4f(r, g, b, a);
+ // gca_ColorsAttr.put4f(r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -344,9 +378,11 @@ public class VBORegion2PVBAAES2 extends GLRegion {
@Override
protected final void pushIndices(final int idx1, final int idx2, final int idx3) {
if( usesI32Idx() ) {
- indicesBuffer.put3i(idx1, idx2, idx3);
+ // indicesBuffer.put3i(idx1, idx2, idx3);
+ put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3);
} else {
- indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3);
+ // indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3);
+ put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3);
}
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 5a4c0c731..adf3e4bc2 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl;
import java.io.PrintStream;
import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
@@ -48,9 +50,11 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class VBORegionSPES2 extends GLRegion {
+public final class VBORegionSPES2 extends GLRegion {
private final RenderState.ProgramLocal rsLocal;
+ private int curVerticesCap = 0;
+ private int curIndicesCap = 0;
private GLArrayDataServer gca_VerticesAttr = null;
private GLArrayDataServer gca_CurveParamsAttr = null;
private GLArrayDataServer gca_ColorsAttr;
@@ -67,22 +71,8 @@ public class VBORegionSPES2 extends GLRegion {
rsLocal = new RenderState.ProgramLocal();
- // We leave GLArrayDataClient.DEFAULT_GROWTH_FACTOR intact for avg +19% size, but 15% less CPU overhead compared to 1.2 (19% total)
+ initBuffer(initialVerticesCount, initialIndicesCount);
- indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialIndicesCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
-
- gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
-
- gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
-
- if( hasColorChannel() ) {
- gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
- false, initialVerticesCount, GL.GL_STATIC_DRAW);
- } else {
- gca_ColorsAttr = null;
- }
if( hasColorTexture() ) {
gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit());
colorTexBBox = new float[4];
@@ -94,13 +84,54 @@ public class VBORegionSPES2 extends GLRegion {
}
}
+ private void initBuffer(final int verticeCount, final int indexCount) {
+ indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
+ indicesBuffer.setGrowthFactor(growthFactor);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+
+ gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_VerticesAttr.setGrowthFactor(growthFactor);
+ gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_CurveParamsAttr.setGrowthFactor(growthFactor);
+ if( hasColorChannel() ) {
+ gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT,
+ false, verticeCount, GL.GL_STATIC_DRAW);
+ gca_ColorsAttr.setGrowthFactor(growthFactor);
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
+ }
+
@Override
- public void growBufferSize(final int verticeCount, final int indexCount) {
- indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem());
- 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());
+ public void growBuffer(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) {
+ indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem());
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) {
+ gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem());
+ gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem());
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem());
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
+ }
+ }
+
+ @Override
+ public void setBufferCapacity(final int verticesCount, final int indicesCount) {
+ if( curIndicesCap < indicesCount ) {
+ indicesBuffer.reserve(indicesCount);
+ curIndicesCap = indicesBuffer.getElemCapacity();
+ }
+ if( curVerticesCap < verticesCount ) {
+ gca_VerticesAttr.reserve(verticesCount);
+ gca_CurveParamsAttr.reserve(verticesCount);
+ if( null != gca_ColorsAttr ) {
+ gca_ColorsAttr.reserve(verticesCount);
+ }
+ curVerticesCap = gca_VerticesAttr.getElemCapacity();
}
}
@@ -142,15 +173,11 @@ public class VBORegionSPES2 extends GLRegion {
@Override
protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) {
- // NIO array[3] is much slows than group/single
- // gca_VerticesAttr.putf(coords, 0, 3);
- // gca_CurveParamsAttr.putf(texParams, 0, 3);
- gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]);
- gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
- // gca_ColorsAttr.putf(rgba, 0, 4);
- gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -160,18 +187,18 @@ public class VBORegionSPES2 extends GLRegion {
@Override
protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3,
final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) {
- gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]);
- gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]);
- gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]);
- gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]);
- gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]);
- gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]);
+ put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]);
+ put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]);
if( null != gca_ColorsAttr ) {
if( null != rgba ) {
final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3];
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
- gca_ColorsAttr.put4f(r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
+ put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a);
} else {
throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode");
}
@@ -190,9 +217,9 @@ public class VBORegionSPES2 extends GLRegion {
@Override
protected final void pushIndices(final int idx1, final int idx2, final int idx3) {
if( usesI32Idx() ) {
- indicesBuffer.put3i(idx1, idx2, idx3);
+ put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3);
} else {
- indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3);
+ put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3);
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index ebc3eeacc..12128f5ad 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -42,14 +42,7 @@ import jogamp.graph.font.typecast.ot.table.KernTable;
import jogamp.graph.font.typecast.ot.table.KerningPair;
import jogamp.graph.font.typecast.ot.table.PostTable;
-import java.io.PrintStream;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.concurrent.TimeUnit;
-
-import com.jogamp.common.os.Clock;
import com.jogamp.common.util.IntObjectHashMap;
-import com.jogamp.common.util.PerfCounterCtrl;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
@@ -293,17 +286,22 @@ class TypecastFont implements Font {
@Override
public AABBox getGlyphBounds(final CharSequence string) {
- return getGlyphBoundsFU(string).scale2(1.0f/metrics.getUnitsPerEM(), new float[3]);
+ return getGlyphBounds(string, new AffineTransform(), new AffineTransform());
+ }
+ @Override
+ public AABBox getGlyphBounds(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2) {
+ return getGlyphBoundsFU(string, tmp1, tmp2).scale2(1.0f/metrics.getUnitsPerEM(), new float[3]);
}
@Override
public AABBox getGlyphBoundsFU(final CharSequence string) {
+ return getGlyphBoundsFU(string, new AffineTransform(), new AffineTransform());
+ }
+ @Override
+ public AABBox getGlyphBoundsFU(final CharSequence string, final AffineTransform temp1, final AffineTransform temp2) {
if (null == string || 0 == string.length() ) {
return new AABBox();
}
- final AffineTransform temp1 = new AffineTransform();
- final AffineTransform temp2 = new AffineTransform();
-
final AABBox res = new AABBox();
final int charCount = string.length();
@@ -367,68 +365,6 @@ class TypecastFont implements Font {
return processString(visitor, transform, string, new AffineTransform(), new AffineTransform());
}
- static class Perf {
- Instant t0 = null;
- // all td_ values are in [ns]
- long td_visitor = 0;
- long td_total = 0;
- long count = 0;
-
- public void print(final PrintStream out) {
- out.printf("TypecastFont.process(): count %,3d, total %,5d [ms], per-add %,4.2f [ns]%n", count, TimeUnit.NANOSECONDS.toMillis(td_total),
- ((double)td_total/(double)count));
- out.printf(" visitor %,5d [ms], per-add %,4.2f [ns]%n", TimeUnit.NANOSECONDS.toMillis(td_visitor),
- ((double)td_visitor/(double)count));
- }
-
- public void clear() {
- t0 = null;
- td_visitor = 0;
- td_total = 0;
- count = 0;
- }
- }
- private Perf perf = null;
-
- private final PerfCounterCtrl perfCounterCtrl = new PerfCounterCtrl() {
- @Override
- public void enable(final boolean enable) {
- if( enable ) {
- if( null != perf ) {
- perf.clear();
- } else {
- perf = new Perf();
- }
- } else {
- perf = null;
- }
- }
-
- @Override
- public void clear() {
- if( null != perf ) {
- perf.clear();
- }
- }
-
- @Override
- public Duration getTotalDuration() {
- if( null != perf ) {
- return Duration.ofNanos(perf.td_total);
- } else {
- return Duration.ZERO;
- }
- }
-
- @Override
- public void print(final PrintStream out) {
- if( null != perf ) {
- perf.print(out);
- }
- } };
- @Override
- public PerfCounterCtrl perfCounter() { return perfCounterCtrl; }
-
@Override
public AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform,
final CharSequence string,
@@ -436,10 +372,6 @@ class TypecastFont implements Font {
if (null == string || 0 == string.length() ) {
return new AABBox();
}
- if( null != perf ) {
- ++perf.count;
- perf.t0 = Clock.getMonotonicTime();
- }
final AABBox res = new AABBox();
final int charCount = string.length();
@@ -479,26 +411,33 @@ class TypecastFont implements Font {
}
temp1.translate(advanceTotal, y, temp2);
res.resize(temp1.transform(glyphShape.getBounds(), temp_box));
- if( null != perf ) {
- final Instant t1 = Clock.getMonotonicTime();
- visitor.visit(glyphShape, temp1);
- final Instant t2 = Clock.getMonotonicTime();
- perf.td_visitor += Duration.between(t1, t2).toNanos();
- } else {
- visitor.visit(glyphShape, temp1);
- }
+ visitor.visit(glyphShape, temp1);
advanceTotal += glyph.getAdvance();
left_glyph = glyph;
}
}
- if( null != perf ) {
- final Instant tX = Clock.getMonotonicTime();
- perf.td_total += Duration.between(perf.t0, tX).toNanos();
- }
return res;
}
@Override
+ public void processString(final OutlineShape.Visitor2 visitor, final CharSequence string) {
+ if (null == string || 0 == string.length() ) {
+ return;
+ }
+ final int charCount = string.length();
+
+ for(int i=0; i< charCount; i++) {
+ final char character = string.charAt(i);
+ if( '\n' != character ) {
+ final OutlineShape glyphShape = getGlyph(getGlyphID(character)).getShape();
+ if( null != glyphShape ) { // also covers 'space' and all non-contour symbols
+ visitor.visit(glyphShape);
+ }
+ }
+ }
+ }
+
+ @Override
final public int getNumGlyphs() {
return font.getNumGlyphs();
}
@@ -517,8 +456,7 @@ class TypecastFont implements Font {
public final boolean equals(final Object o) {
if( this == o ) { return true; }
if( o instanceof TypecastFont ) {
- final TypecastFont of = (TypecastFont)o;
- return of.font.getName(Font.NAME_UNIQUNAME).equals(font.getName(Font.NAME_UNIQUNAME));
+ return ((TypecastFont)o).font.getName(Font.NAME_UNIQUNAME).equals(font.getName(Font.NAME_UNIQUNAME));
}
return false;
}
diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
index 7f8f262e9..61d6d965b 100644
--- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
+++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
@@ -30,16 +30,26 @@ package jogamp.opengl;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
+import com.jogamp.common.os.Clock;
import com.jogamp.opengl.FPSCounter;
/**
* Default implementation of FPSCounter to be used for FPSCounter implementing renderer.
*/
public class FPSCounterImpl implements FPSCounter {
- private int fpsUpdateFramesInterval;
private PrintStream fpsOutputStream ;
- private long fpsStartTime, fpsLastUpdateTime, fpsLastPeriod, fpsTotalDuration;
+
+ // counter in [ns]
+ private long fpsStartTimeNS, fpsLastUpdateTimeNS;
+
+ // counter in [ms]
+ private long fpsLastPeriodMS, fpsTotalDurationMS;
+
+ // counter in events
+ private int fpsUpdateFramesInterval;
private int fpsTotalFrames;
+
+ // counter in fps
private float fpsLast, fpsTotal;
/** Creates a disabled instance */
@@ -52,25 +62,24 @@ public class FPSCounterImpl implements FPSCounter {
* update interval is reached.<br>
*
* Shall be called by actual FPSCounter implementing renderer, after display a new frame.
- *
*/
public final synchronized void tickFPS() {
fpsTotalFrames++;
if(fpsUpdateFramesInterval>0 && fpsTotalFrames%fpsUpdateFramesInterval == 0) {
- final long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
- fpsLastPeriod = now - fpsLastUpdateTime;
- fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0
- fpsLast = ( fpsUpdateFramesInterval * 1000f ) / ( fpsLastPeriod ) ;
+ final long now = Clock.currentNanos();
+ fpsLastPeriodMS = TimeUnit.NANOSECONDS.toMillis(now - fpsLastUpdateTimeNS);
+ fpsLastPeriodMS = Math.max(fpsLastPeriodMS, 1); // div 0
+ fpsLast = ( fpsUpdateFramesInterval * 1000f ) / ( fpsLastPeriodMS ) ;
- fpsTotalDuration = now - fpsStartTime;
- fpsTotalDuration = Math.max(fpsTotalDuration, 1); // div 0
- fpsTotal= ( fpsTotalFrames * 1000f ) / ( fpsTotalDuration ) ;
+ fpsTotalDurationMS = TimeUnit.NANOSECONDS.toMillis(now - fpsStartTimeNS);
+ fpsTotalDurationMS = Math.max(fpsTotalDurationMS, 1); // div 0
+ fpsTotal= ( fpsTotalFrames * 1000f ) / ( fpsTotalDurationMS ) ;
if(null != fpsOutputStream) {
fpsOutputStream.println(toString());
}
- fpsLastUpdateTime = now;
+ fpsLastUpdateTimeNS = now;
}
}
@@ -82,8 +91,8 @@ public class FPSCounterImpl implements FPSCounter {
fpsLastS = fpsLastS.substring(0, fpsLastS.indexOf('.') + 2);
String fpsTotalS = String.valueOf(fpsTotal);
fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2);
- sb.append(fpsTotalDuration/1000 +" s: "+ fpsUpdateFramesInterval+" f / "+ fpsLastPeriod+" ms, " + fpsLastS+" fps, "+ fpsLastPeriod/fpsUpdateFramesInterval+" ms/f; "+
- "total: "+ fpsTotalFrames+" f, "+ fpsTotalS+ " fps, "+ fpsTotalDuration/fpsTotalFrames+" ms/f");
+ sb.append(fpsTotalDurationMS/1000 +" s: "+ fpsUpdateFramesInterval+" f / "+ fpsLastPeriodMS+" ms, " + fpsLastS+" fps, "+ fpsLastPeriodMS/fpsUpdateFramesInterval+" ms/f; "+
+ "total: "+ fpsTotalFrames+" f, "+ fpsTotalS+ " fps, "+ fpsTotalDurationMS/fpsTotalFrames+" ms/f");
return sb;
}
@@ -101,12 +110,12 @@ public class FPSCounterImpl implements FPSCounter {
@Override
public final synchronized void resetFPSCounter() {
- fpsStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); // overwrite startTime to real init one
- fpsLastUpdateTime = fpsStartTime;
- fpsLastPeriod = 0;
+ fpsStartTimeNS = Clock.currentNanos();
+ fpsLastUpdateTimeNS = fpsStartTimeNS;
+ fpsLastPeriodMS = 0;
fpsTotalFrames = 0;
fpsLast = 0f; fpsTotal = 0f;
- fpsLastPeriod = 0; fpsTotalDuration=0;
+ fpsLastPeriodMS = 0; fpsTotalDurationMS=0;
}
@Override
@@ -116,17 +125,17 @@ public class FPSCounterImpl implements FPSCounter {
@Override
public final synchronized long getFPSStartTime() {
- return fpsStartTime;
+ return TimeUnit.NANOSECONDS.toMillis(fpsStartTimeNS);
}
@Override
public final synchronized long getLastFPSUpdateTime() {
- return fpsLastUpdateTime;
+ return TimeUnit.NANOSECONDS.toMillis(fpsLastUpdateTimeNS);
}
@Override
public final synchronized long getLastFPSPeriod() {
- return fpsLastPeriod;
+ return fpsLastPeriodMS;
}
@Override
@@ -141,7 +150,7 @@ public class FPSCounterImpl implements FPSCounter {
@Override
public final synchronized long getTotalFPSDuration() {
- return fpsTotalDuration;
+ return fpsTotalDurationMS;
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index d97e0e201..7964416fe 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -50,6 +50,7 @@ import java.util.Map;
import java.util.Set;
import com.jogamp.common.ExceptionUtils;
+import com.jogamp.common.os.Clock;
import com.jogamp.common.os.DynamicLookupHelper;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.Bitfield;
@@ -1200,7 +1201,7 @@ public abstract class GLContextImpl extends GLContext {
if (DEBUG) {
System.err.println(getThreadName() + ": createContextARB-MapGLVersions START (GLDesktop "+hasOpenGLDesktopSupport+", GLES "+hasOpenGLESSupport+", minorVersion "+hasMinorVersionSupport+") on "+device);
}
- final long t0 = ( DEBUG ) ? System.nanoTime() : 0;
+ final long t0 = ( DEBUG ) ? Clock.currentNanos() : 0;
boolean success = false;
// Following GLProfile.GL_PROFILE_LIST_ALL order of profile detection { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }
boolean hasGL4bc = false;
@@ -1350,7 +1351,7 @@ public abstract class GLContextImpl extends GLContext {
GLContext.setAvailableGLVersionsSet(device, true);
}
if(DEBUG) {
- final long t1 = System.nanoTime();
+ final long t1 = Clock.currentNanos();
System.err.println(getThreadName() + ": createContextARB-MapGLVersions END (success "+success+") on "+device+", profileAliasing: "+PROFILE_ALIASING+", total "+(t1-t0)/1e6 +"ms");
if( success ) {
System.err.println(GLContext.dumpAvailableGLVersions(null).toString());
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
index 6c497c9e3..558fa88f2 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
@@ -93,7 +93,7 @@ public class GLSLArrayHandler extends GLVBOArrayHandler {
if(!ad.isVBOWritten()) {
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
if(null!=buffer) {
- glsl.glBufferData(ad.getVBOTarget(), ad.getSizeInBytes(), buffer, ad.getVBOUsage());
+ glsl.glBufferData(ad.getVBOTarget(), ad.getByteCount(), buffer, ad.getVBOUsage());
}
ad.setVBOWritten(true);
st.vertexAttribPointer(glsl, ad);
@@ -144,7 +144,7 @@ public class GLSLArrayHandler extends GLVBOArrayHandler {
if(!ad.isVBOWritten()) {
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
if(null!=buffer) {
- glsl.glBufferData(ad.getVBOTarget(), ad.getSizeInBytes(), buffer, ad.getVBOUsage());
+ glsl.glBufferData(ad.getVBOTarget(), ad.getByteCount(), buffer, ad.getVBOUsage());
}
ad.setVBOWritten(true);
glsl.glVertexAttribPointer(ad);
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
index 740289fa6..8c74ba090 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
@@ -32,6 +32,7 @@ import jogamp.nativewindow.x11.XVisualInfo;
import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.VisualIDHolder;
+import com.jogamp.nativewindow.VisualIDHolder.VIDType;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLProfile;
@@ -92,6 +93,19 @@ public class X11GLCapabilities extends GLCapabilities {
}
@Override
+ final public boolean isVisualIDSupported(final VIDType type) {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ case X11_XVISUAL:
+ case X11_FBCONFIG:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
public StringBuilder toString(StringBuilder sink) {
if(null == sink) {
sink = new StringBuilder();