summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLArrayData.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java131
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java17
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java140
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java154
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java20
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java20
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/util/GLVBOArrayHandler.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java2
10 files changed, 274 insertions, 250 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLArrayData.java b/src/jogl/classes/com/jogamp/opengl/GLArrayData.java
index ea2dfb0f3..972b10d4e 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLArrayData.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLArrayData.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl;
+import java.io.PrintStream;
import java.nio.Buffer;
import com.jogamp.opengl.fixedfunc.GLPointerFunc;
@@ -159,26 +160,26 @@ public interface GLArrayData {
/**
* The number of components per element
*/
- public int getComponentCount();
+ public int getCompsPerElem();
/**
* The component's GL data type, ie. GL_FLOAT
*/
- public int getComponentType();
+ public int getCompType();
/**
* The component's size in bytes
*/
- public int getComponentSizeInBytes();
+ public int getBytesPerComp();
/**
* The current number of used elements.
* <p>
- * On element consist out of {@link #getComponentCount()} components.
+ * On element consist out of {@link #getCompsPerElem()} components.
* </p>
* In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
*/
- public int getElementCount();
+ public int getElemCount();
/**
* The currently used size in bytes.<br>
@@ -187,6 +188,13 @@ public interface GLArrayData {
public int getSizeInBytes();
/**
+ * The current capacity in bytes.
+ */
+ public int getCapacityInBytes();
+
+ public void printStats(final PrintStream out);
+
+ /**
* True, if GL shall normalize fixed point data while converting
* them into float.
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 542da4bf1..e790194ca 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -48,6 +48,8 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayDataEditable {
+ /** Default growth factor using the golden ratio 1.618 */
+ public static final float DEFAULT_GROWTH_FACTOR = 1.618f;
/**
* Create a client side buffer object, using a predefined fixed function array index
@@ -72,10 +74,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
public static GLArrayDataClient createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int initialElementCount)
throws GLException
{
- final GLArrayDataClient adc = new GLArrayDataClient();
- final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(null, index, comps, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, 0, 0, false);
- return adc;
+ return new GLArrayDataClient(null, index, comps, dataType, normalized, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLFixedArrayHandler.class, 0, 0, 0, 0, false);
}
/**
@@ -103,10 +103,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
final Buffer buffer)
throws GLException
{
- final GLArrayDataClient adc = new GLArrayDataClient();
- final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(null, index, comps, dataType, normalized, stride, buffer, comps*comps, 0 /* mappedElementCount */, false, glArrayHandler, 0, 0, 0, 0, false);
- return adc;
+ return new GLArrayDataClient(null, index, comps, dataType, normalized, stride, buffer, comps*comps, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLFixedArrayHandler.class, 0, 0, 0, 0, false);
}
/**
@@ -122,10 +120,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
final int dataType, final boolean normalized, final int initialElementCount)
throws GLException
{
- final GLArrayDataClient adc = new GLArrayDataClient();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
- adc.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, 0, 0, true);
- return adc;
+ return new GLArrayDataClient(name, -1, comps, dataType, normalized, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ true, GLSLArrayHandler.class, 0, 0, 0, 0, true);
}
/**
@@ -142,10 +138,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
final int dataType, final boolean normalized, final int stride, final Buffer buffer)
throws GLException
{
- final GLArrayDataClient adc = new GLArrayDataClient();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
- adc.init(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, 0, 0, true);
- return adc;
+ return new GLArrayDataClient(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ true, GLSLArrayHandler.class, 0, 0, 0, 0, true);
}
@Override
@@ -183,14 +177,14 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
@Override
public void destroy(final GL gl) {
- reset(gl);
+ clear(gl);
super.destroy(gl);
}
@Override
- public void reset(final GL gl) {
- enableBuffer(gl, false);
- reset();
+ public void clear(final GL gl) {
+ seal(gl, false);
+ clear();
}
@Override
@@ -232,7 +226,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
//
@Override
- public void reset() {
+ public void clear() {
if( buffer != null ) {
buffer.clear();
}
@@ -334,7 +328,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
", usesShaderState "+(null!=shaderState)+
", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
- ", elements "+getElementCount()+
+ ", elements "+getElemCount()+
", components "+componentsPerElement+
", stride "+strideB+"b "+strideL+"c"+
", mappedElementCount "+mappedElementCount+
@@ -349,20 +343,27 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
// non public matters
- protected final boolean growBufferIfNecessary(final int spareComponents) {
+ private final boolean growBufferIfNecessary(final int spareComponents) {
if( buffer==null || buffer.remaining()<spareComponents ) {
if( 0 != mappedElementCount ) {
throw new GLException("Mapped buffer can't grow. Insufficient storage size: Needed "+spareComponents+" components, "+
"mappedElementCount "+mappedElementCount+
", has mapped buffer "+buffer+"; "+this);
}
- growBuffer(Math.max(initialElementCount, (spareComponents+componentsPerElement-1)/componentsPerElement));
+ final int required_elems = ( spareComponents + componentsPerElement - 1 ) / componentsPerElement;
+ if( null == buffer ) {
+ growBuffer( Math.max( initialElementCount, required_elems ) );
+ } else {
+ final int add_comps = (int)( buffer.capacity() * ( growthFactor - 1.0f ) + 0.5f );
+ final int add_elems = ( add_comps + componentsPerElement - 1 ) / componentsPerElement;
+ growBuffer( Math.max( add_elems, required_elems ) );
+ }
return true;
}
return false;
}
- protected final void growBuffer(int additionalElements) {
+ private final void growBuffer(int additionalElements) {
if(!alive || sealed) {
throw new GLException("Invalid state: "+this);
}
@@ -424,20 +425,32 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
}
- protected void init(final String name, final int index, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer data,
- final int initialElementCount, final int mappedElementCount, final boolean isVertexAttribute,
- final GLArrayHandler handler, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL)
+ protected GLArrayDataClient(final String name, final int index, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer data,
+ final int initialElementCount, final float growthFactor,
+ final int mappedElementCount, final boolean isVertexAttribute,
+ final Class<? extends GLArrayHandler> handlerClass,
+ final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL)
throws GLException
{
- super.init(name, index, comps, dataType, normalized, stride, data, mappedElementCount,
- isVertexAttribute, vboName, vboOffset, vboUsage, vboTarget);
+ super(name, index, comps, dataType, normalized, stride, data, mappedElementCount,
+ isVertexAttribute, vboName, vboOffset, vboUsage, vboTarget);
if( 0<mappedElementCount && 0<initialElementCount ) { // null!=buffer case validated in super.init(..)
throw new IllegalArgumentException("mappedElementCount:="+mappedElementCount+" specified, but passing non zero initialElementSize");
}
+
+ // immutable types
this.initialElementCount = initialElementCount;
- this.glArrayHandler = handler;
+ this.growthFactor = growthFactor;
+ try {
+ final Constructor<? extends GLArrayHandler> ctor = handlerClass.getConstructor(GLArrayDataEditable.class);
+ this.glArrayHandler = ctor.newInstance(this);
+ } catch (final Exception e) {
+ throw new RuntimeException("Could not ctor "+handlerClass.getName()+"("+this.getClass().getName()+")", e);
+ }
this.usesGLSL = usesGLSL;
+
+ // mutable types
this.sealed=false;
this.bufferEnabled=false;
this.enableBufferAlways=false;
@@ -448,8 +461,6 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
}
- private boolean isValidated = false;
-
protected void init_vbo(final GL gl) {
if(!isValidated ) {
isValidated = true;
@@ -457,8 +468,6 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
}
- protected GLArrayDataClient() { }
-
/**
* Copy Constructor
* <p>
@@ -470,11 +479,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
*/
public GLArrayDataClient(final GLArrayDataClient src) {
super(src);
- this.isValidated = src.isValidated;
- this.sealed = src.sealed;
- this.bufferEnabled = src.bufferEnabled;
- this.bufferWritten = src.bufferWritten;
- this.enableBufferAlways = src.enableBufferAlways;
+
+ // immutable types
this.initialElementCount = src.initialElementCount;
if( null != src.glArrayHandler ) {
final Class<? extends GLArrayHandler> clazz = src.glArrayHandler.getClass();
@@ -488,18 +494,55 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
this.glArrayHandler = null;
}
this.usesGLSL = src.usesGLSL;
+
+ // mutable types
+ this.growthFactor = src.growthFactor;
+ this.isValidated = src.isValidated;
+ this.sealed = src.sealed;
+ this.bufferEnabled = src.bufferEnabled;
+ this.bufferWritten = src.bufferWritten;
+ this.enableBufferAlways = src.enableBufferAlways;
this.shaderState = src.shaderState;
}
+ /**
+ * Returns this buffer's growth factor.
+ * <p>
+ * Default is {@link #DEFAULT_GROWTH_FACTOR}, i.e. the golden ratio 1.618.
+ * </p>
+ * @see #setGrowthFactor(float)
+ * @see #DEFAULT_GROWTH_FACTOR
+ */
+ public float getGrowthFactor() { return growthFactor; }
+
+ /**
+ * Sets a new growth factor for this buffer.
+ * <p>
+ * Default is {@link #DEFAULT_GROWTH_FACTOR}, i.e. the golden ratio 1.618.
+ * </p>
+ * @param v new growth factor, which must be >= 1.1, i.e. 10%
+ * @throws IllegalArgumentException if growth factor is < 1.1
+ * @see #getGrowthFactor()
+ * @see #DEFAULT_GROWTH_FACTOR
+ */
+ public void setGrowthFactor(final float v) {
+ if( v < 1.1f ) {
+ throw new IllegalArgumentException("New growth factor must be > 1.1 but is "+v);
+ }
+ growthFactor = v;
+ }
+
+ protected final int initialElementCount;
+ protected final GLArrayHandler glArrayHandler;
+ protected final boolean usesGLSL;
+
+ protected float growthFactor;
+ private boolean isValidated = false;
protected boolean sealed;
protected boolean bufferEnabled;
protected boolean bufferWritten;
protected boolean enableBufferAlways;
- protected int initialElementCount;
-
- protected GLArrayHandler glArrayHandler;
- protected boolean usesGLSL;
protected ShaderState shaderState;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
index 7524fe1d1..50bcf7c5b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
@@ -34,7 +34,16 @@ public interface GLArrayDataEditable extends GLArrayData {
@Override
public void destroy(GL gl);
- public void reset(GL gl);
+ /**
+ * Clears this buffer.
+ * <p>
+ * Implementation must call {@link #seal(GL, boolean) seal(gl, false)} and {@link #clear()},
+ * i.e. turns-off the GL buffer and then clearing it.
+ * </p>
+ * @see #seal(GL, boolean)
+ * @see #clear()
+ */
+ public void clear(GL gl);
/**
* Convenience method calling {@link #seal(boolean)} and {@link #enableBuffer(GL, boolean)}.
@@ -105,7 +114,11 @@ public interface GLArrayDataEditable extends GLArrayData {
// Data modification ..
//
- public void reset();
+ /**
+ * Clears this buffer and resets states accordingly.
+ * @see #clear(GL)
+ */
+ public void clear();
/**
* <p>If <i>seal</i> is true, it
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 6b7c31d13..9c803d36e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -85,11 +85,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final Buffer buffer, final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(null, index, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
- return ads;
+ return new GLArrayDataServer(null, index, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLFixedArrayHandler.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
}
/**
@@ -117,11 +114,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(null, index, compsPerElement, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
- return ads;
+ return new GLArrayDataServer(null, index, compsPerElement, dataType, normalized, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLFixedArrayHandler.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
}
/**
@@ -138,11 +132,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount,
- 0 /* mappedElementCount */, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
- return ads;
+ return new GLArrayDataServer(name, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount,
+ DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */, true, GLSLArrayHandler.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
}
/**
@@ -159,10 +150,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int dataType, final boolean normalized, final int mappedElementCount, final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */,
- mappedElementCount, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
+ final GLArrayDataServer ads = new GLArrayDataServer(name, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */,
+ DEFAULT_GROWTH_FACTOR, mappedElementCount, true, GLSLArrayHandler.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
ads.seal(true);
return ads;
}
@@ -183,11 +172,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, true,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
- return ads;
+ return new GLArrayDataServer(name, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ true, GLSLArrayHandler.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
}
/**
@@ -207,11 +193,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final Buffer buffer, final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
- ads.init(null, -1, compsPerElement, dataType, false, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, vboTarget, false);
- return ads;
+ return new GLArrayDataServer(null, -1, compsPerElement, dataType, false, stride, buffer, buffer.limit(), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLDataArrayHandler.class, 0, 0, vboUsage, vboTarget, false);
}
/**
@@ -229,11 +212,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
- ads.init(null, -1, compsPerElement, dataType, false, 0, null, initialElementCount, 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, vboTarget, false);
- return ads;
+ return new GLArrayDataServer(null, -1, compsPerElement, dataType, false, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLDataArrayHandler.class, 0, 0, vboUsage, vboTarget, false);
}
/**
@@ -253,11 +233,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
- ads.init(null, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, mappedElementCount, false,
- glArrayHandler, 0, 0, vboUsage, vboTarget, false);
- return ads;
+ return new GLArrayDataServer(null, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, DEFAULT_GROWTH_FACTOR, mappedElementCount,
+ false, GLDataArrayHandler.class, 0, 0, vboUsage, vboTarget, false);
}
/**
@@ -275,11 +252,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, initialElementCount, 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
- return ads;
+ return new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
}
/**
@@ -297,10 +271,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, mappedElementCount, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
+ final GLArrayDataServer ads = new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, false, 0, null, 0 /* initialElementCount */, DEFAULT_GROWTH_FACTOR, mappedElementCount,
+ false, GLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
ads.seal(true);
return ads;
}
@@ -321,11 +293,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
- return ads;
+ return new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
}
/**
@@ -343,28 +312,28 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
*/
public GLArrayData addFixedSubArray(final int index, final int comps, final int vboTarget) {
- if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
- final int iOffC = interleavedOffset / getComponentSizeInBytes();
- throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
+ if(interleavedOffset >= getCompsPerElem() * getBytesPerComp()) {
+ final int iOffC = interleavedOffset / getBytesPerComp();
+ throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getCompsPerElem()+")");
}
if(usesGLSL) {
throw new GLException("buffer uses GLSL");
}
- final int subStrideB = ( 0 == getStride() ) ? getComponentCount() * getComponentSizeInBytes() : getStride();
+ final int subStrideB = ( 0 == getStride() ) ? getCompsPerElem() * getBytesPerComp() : getStride();
final GLArrayDataWrapper ad;
if( 0 < mappedElementCount ) {
ad = GLArrayDataWrapper.createFixed(
- index, comps, getComponentType(),
+ index, comps, getCompType(),
getNormalized(), subStrideB, mappedElementCount,
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
} else {
ad = GLArrayDataWrapper.createFixed(
- index, comps, getComponentType(),
+ index, comps, getCompType(),
getNormalized(), subStrideB, getBuffer(),
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
}
ad.setVBOEnabled(isVBO());
- interleavedOffset += comps * getComponentSizeInBytes();
+ interleavedOffset += comps * getBytesPerComp();
if(GL.GL_ARRAY_BUFFER == vboTarget) {
glArrayHandler.addSubHandler(new GLFixedArrayHandlerFlat(ad));
}
@@ -386,11 +355,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount, 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
- return ads;
+ return new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, initialElementCount, DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLSLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
}
/**
@@ -407,10 +373,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
public static GLArrayDataServer createGLSLInterleavedMapped(final int compsPerElement, final int dataType, final boolean normalized, final int mappedElementCount, final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */, mappedElementCount, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
+ final GLArrayDataServer ads = new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, 0, null, 0 /* initialElementCount */, DEFAULT_GROWTH_FACTOR, mappedElementCount,
+ false, GLSLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
ads.seal(true);
return ads;
}
@@ -431,11 +395,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final int vboUsage)
throws GLException
{
- final GLArrayDataServer ads = new GLArrayDataServer();
- final GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), 0 /* mappedElementCount */, false,
- glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
- return ads;
+ return new GLArrayDataServer(GLPointerFuncUtil.mgl_InterleaveArray, -1, compsPerElement, dataType, normalized, stride, buffer, buffer.limit(), DEFAULT_GROWTH_FACTOR, 0 /* mappedElementCount */,
+ false, GLSLArrayHandlerInterleaved.class, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
}
/**
@@ -452,28 +413,28 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
*/
public GLArrayData addGLSLSubArray(final String name, final int comps, final int vboTarget) {
- if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
- final int iOffC = interleavedOffset / getComponentSizeInBytes();
- throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
+ if(interleavedOffset >= getCompsPerElem() * getBytesPerComp()) {
+ final int iOffC = interleavedOffset / getBytesPerComp();
+ throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getCompsPerElem()+")");
}
if(!usesGLSL) {
throw new GLException("buffer uses fixed function");
}
- final int subStrideB = ( 0 == getStride() ) ? getComponentCount() * getComponentSizeInBytes() : getStride();
+ final int subStrideB = ( 0 == getStride() ) ? getCompsPerElem() * getBytesPerComp() : getStride();
final GLArrayDataWrapper ad;
if( 0 < mappedElementCount ) {
ad = GLArrayDataWrapper.createGLSL(
- name, comps, getComponentType(),
+ name, comps, getCompType(),
getNormalized(), subStrideB, mappedElementCount,
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
} else {
ad = GLArrayDataWrapper.createGLSL(
- name, comps, getComponentType(),
+ name, comps, getCompType(),
getNormalized(), subStrideB, getBuffer(),
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
}
ad.setVBOEnabled(isVBO());
- interleavedOffset += comps * getComponentSizeInBytes();
+ interleavedOffset += comps * getBytesPerComp();
if(GL.GL_ARRAY_BUFFER == vboTarget) {
glArrayHandler.addSubHandler(new GLSLArrayHandlerFlat(ad));
}
@@ -597,7 +558,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
", usesShaderState "+(null!=shaderState)+
", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
- ", elements "+getElementCount()+
+ ", elements "+getElemCount()+
", components "+componentsPerElement+
", stride "+strideB+"b "+strideL+"c"+
", initialElementCount "+initialElementCount+
@@ -620,15 +581,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
// non public matters ..
//
- @Override
- protected void init(final String name, final int index, final int comps, final int dataType, final boolean normalized,
- final int stride, final Buffer data, final int initialElementCount, final int mappedElementCount,
- final boolean isVertexAttribute,
- final GLArrayHandler glArrayHandler, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL)
+ protected GLArrayDataServer(final String name, final int index, final int comps, final int dataType, final boolean normalized,
+ final int stride, final Buffer data, final int initialElementCount, final float growthFactor,
+ final int mappedElementCount, final boolean isVertexAttribute,
+ final Class<? extends GLArrayHandler> handlerClass, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget, final boolean usesGLSL)
throws GLException
{
- super.init(name, index, comps, dataType, normalized, stride, data, initialElementCount, mappedElementCount, isVertexAttribute,
- glArrayHandler, vboName, vboOffset, vboUsage, vboTarget, usesGLSL);
+ super(name, index, comps, dataType, normalized, stride, data, initialElementCount, growthFactor, mappedElementCount,
+ isVertexAttribute, handlerClass, vboName, vboOffset, vboUsage, vboTarget, usesGLSL);
vboEnabled=true;
}
@@ -646,8 +606,6 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
}
- protected GLArrayDataServer() { }
-
/**
* Copy Constructor
* <p>
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
index 3f759c6d8..ae19d788f 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
@@ -28,6 +28,7 @@
package com.jogamp.opengl.util;
+import java.io.PrintStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
@@ -35,7 +36,6 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import com.jogamp.opengl.GL;
-import com.jogamp.opengl.GL2ES1;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLArrayData;
import com.jogamp.opengl.GLException;
@@ -70,10 +70,8 @@ public class GLArrayDataWrapper implements GLArrayData {
final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataWrapper adc = new GLArrayDataWrapper();
- adc.init(null, index, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
- false, vboName, vboOffset, vboUsage, vboTarget);
- return adc;
+ return new GLArrayDataWrapper(null, index, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
+ false, vboName, vboOffset, vboUsage, vboTarget);
}
/**
@@ -97,10 +95,8 @@ public class GLArrayDataWrapper implements GLArrayData {
final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataWrapper adc = new GLArrayDataWrapper();
- adc.init(null, index, comps, dataType, normalized, stride, null, mappedElementCount,
- false, vboName, vboOffset, vboUsage, vboTarget);
- return adc;
+ return new GLArrayDataWrapper(null, index, comps, dataType, normalized, stride, null, mappedElementCount,
+ false, vboName, vboOffset, vboUsage, vboTarget);
}
/**
@@ -123,10 +119,8 @@ public class GLArrayDataWrapper implements GLArrayData {
final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataWrapper adc = new GLArrayDataWrapper();
- adc.init(name, -1, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
- true, vboName, vboOffset, vboUsage, vboTarget);
- return adc;
+ return new GLArrayDataWrapper(name, -1, comps, dataType, normalized, stride, buffer, 0 /* mappedElementCount */,
+ true, vboName, vboOffset, vboUsage, vboTarget);
}
/**
@@ -149,10 +143,8 @@ public class GLArrayDataWrapper implements GLArrayData {
final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
throws GLException
{
- final GLArrayDataWrapper adc = new GLArrayDataWrapper();
- adc.init(name, -1, comps, dataType, normalized, stride, null, mappedElementCount,
- true, vboName, vboOffset, vboUsage, vboTarget);
- return adc;
+ return new GLArrayDataWrapper(name, -1, comps, dataType, normalized, stride, null, mappedElementCount,
+ true, vboName, vboOffset, vboUsage, vboTarget);
}
/**
@@ -176,7 +168,7 @@ public class GLArrayDataWrapper implements GLArrayData {
}
return false;
}
- return glp.isValidArrayDataType(getIndex(), getComponentCount(), getComponentType(), isVertexAttribute(), throwException);
+ return glp.isValidArrayDataType(getIndex(), getCompsPerElem(), getCompType(), isVertexAttribute(), throwException);
}
@Override
@@ -235,21 +227,21 @@ public class GLArrayDataWrapper implements GLArrayData {
public Buffer getBuffer() { return buffer; }
@Override
- public final int getComponentCount() { return componentsPerElement; }
+ public final int getCompsPerElem() { return componentsPerElement; }
@Override
- public final int getComponentType() { return componentType; }
+ public final int getCompType() { return componentType; }
@Override
- public final int getComponentSizeInBytes() { return componentByteSize; }
+ public final int getBytesPerComp() { return bytesPerComponent; }
@Override
- public final int getElementCount() {
+ public final int getElemCount() {
if( 0 != mappedElementCount ) {
return mappedElementCount;
} else if( null != buffer ) {
final int remainingComponents = ( 0 == buffer.position() ) ? buffer.limit() : buffer.position();
- return ( remainingComponents * componentByteSize ) / strideB ;
+ return ( remainingComponents * bytesPerComponent ) / strideB ;
} else {
return 0;
}
@@ -258,15 +250,29 @@ public class GLArrayDataWrapper implements GLArrayData {
@Override
public final int getSizeInBytes() {
if( 0 != mappedElementCount ) {
- return mappedElementCount * componentsPerElement * componentByteSize ;
+ return mappedElementCount * componentsPerElement * bytesPerComponent ;
} else if( null != buffer ) {
- return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ;
+ return ( buffer.position()==0 ) ? ( buffer.limit() * bytesPerComponent ) : ( buffer.position() * bytesPerComponent ) ;
} else {
return 0;
}
}
@Override
+ public int getCapacityInBytes() {
+ if( null != buffer ) {
+ return buffer.capacity() * bytesPerComponent;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public void printStats(final PrintStream out) {
+ out.printf("elements %,d, bytes %,d / %,d", getElemCount(), getSizeInBytes(), getCapacityInBytes());
+ }
+
+ @Override
public final boolean getNormalized() { return normalized; }
@Override
@@ -291,7 +297,7 @@ public class GLArrayDataWrapper implements GLArrayData {
", isVertexAttribute "+isVertexAttribute+
", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
- ", elements "+getElementCount()+
+ ", elements "+getElemCount()+
", components "+componentsPerElement+
", stride "+strideB+"b "+strideL+"c"+
", mappedElementCount "+mappedElementCount+
@@ -364,17 +370,14 @@ public class GLArrayDataWrapper implements GLArrayData {
this.vboTarget = vboTarget;
}
- protected void init(final String name, final int index, final int componentsPerElement, final int componentType,
- final boolean normalized, final int stride, final Buffer data, final int mappedElementCount,
- final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
+ protected GLArrayDataWrapper(final String name, final int index, final int componentsPerElement, final int componentType,
+ final boolean normalized, final int stride, final Buffer data, final int mappedElementCount,
+ final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)
throws GLException
{
if( 0<mappedElementCount && null != data ) {
throw new IllegalArgumentException("mappedElementCount:="+mappedElementCount+" specified, but passing non null buffer");
}
- this.isVertexAttribute = isVertexAttribute;
- this.index = index;
- this.location = -1;
// We can't have any dependence on the FixedFuncUtil class here for build bootstrapping reasons
if( GL.GL_ELEMENT_ARRAY_BUFFER == vboTarget ) {
@@ -389,15 +392,11 @@ public class GLArrayDataWrapper implements GLArrayData {
throw new GLException("Invalid GPUBuffer target: 0x"+Integer.toHexString(vboTarget));
}
+ // immutable types
this.componentType = componentType;
componentClazz = getBufferClass(componentType);
- if( GLBuffers.isGLTypeFixedPoint(componentType) ) {
- this.normalized = normalized;
- } else {
- this.normalized = false;
- }
- componentByteSize = GLBuffers.sizeOfGLType(componentType);
- if(0 > componentByteSize) {
+ bytesPerComponent = GLBuffers.sizeOfGLType(componentType);
+ if(0 > bytesPerComponent) {
throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this);
}
if(0 >= componentsPerElement) {
@@ -405,19 +404,30 @@ public class GLArrayDataWrapper implements GLArrayData {
}
this.componentsPerElement = componentsPerElement;
- if(0<stride && stride<componentsPerElement*componentByteSize) {
- throw new GLException("stride ("+stride+") lower than component bytes, "+componentsPerElement+" * "+componentByteSize);
+ if(0<stride && stride<componentsPerElement*bytesPerComponent) {
+ throw new GLException("stride ("+stride+") lower than component bytes, "+componentsPerElement+" * "+bytesPerComponent);
}
- if(0<stride && stride%componentByteSize!=0) {
- throw new GLException("stride ("+stride+") not a multiple of bpc "+componentByteSize);
+ if(0<stride && stride%bytesPerComponent!=0) {
+ throw new GLException("stride ("+stride+") not a multiple of bpc "+bytesPerComponent);
+ }
+ this.strideB=(0==stride)?componentsPerElement*bytesPerComponent:stride;
+ this.strideL=strideB/bytesPerComponent;
+
+ if( GLBuffers.isGLTypeFixedPoint(componentType) ) {
+ this.normalized = normalized;
+ } else {
+ this.normalized = false;
}
- this.buffer = data;
this.mappedElementCount = mappedElementCount;
- this.strideB=(0==stride)?componentsPerElement*componentByteSize:stride;
- this.strideL=strideB/componentByteSize;
+ this.isVertexAttribute = isVertexAttribute;
+
+ // mutable types
+ this.index = index;
+ this.location = -1;
+ this.buffer = data;
this.vboName= vboName;
- this.vboEnabled= 0 != vboName ;
this.vboOffset=vboOffset;
+ this.vboEnabled= 0 != vboName ;
switch(vboUsage) {
case 0: // nop
@@ -441,8 +451,6 @@ public class GLArrayDataWrapper implements GLArrayData {
this.alive=true;
}
- protected GLArrayDataWrapper() { }
-
/**
* Copy Constructor
* <p>
@@ -453,17 +461,22 @@ public class GLArrayDataWrapper implements GLArrayData {
* </p>
*/
public GLArrayDataWrapper(final GLArrayDataWrapper src) {
- this.alive = src.alive;
- this.index = src.index;
- this.location = src.location;
- this.name = src.name;
- this.componentsPerElement = src.componentsPerElement;
+ // immutable types
this.componentType = src.componentType;
this.componentClazz = src.componentClazz;
- this.componentByteSize = src.componentByteSize;
- this.normalized = src.normalized;
+ this.bytesPerComponent = src.bytesPerComponent;
+ this.componentsPerElement = src.componentsPerElement;
this.strideB = src.strideB;
this.strideL = src.strideL;
+ this.normalized = src.normalized;
+ this.mappedElementCount = src.mappedElementCount;
+ this.isVertexAttribute = src.isVertexAttribute;
+
+ // mutable types
+ this.alive = src.alive;
+ this.index = src.index;
+ this.location = src.location;
+ this.name = src.name;
if( null != src.buffer ) {
if( src.buffer.position() == 0 ) {
this.buffer = Buffers.slice(src.buffer);
@@ -473,33 +486,32 @@ public class GLArrayDataWrapper implements GLArrayData {
} else {
this.buffer = null;
}
- this.mappedElementCount = src.mappedElementCount;
- this.isVertexAttribute = src.isVertexAttribute;
- this.vboOffset = src.vboOffset;
this.vboName = src.vboName;
+ this.vboOffset = src.vboOffset;
this.vboEnabled = src.vboEnabled;
this.vboUsage = src.vboUsage;
this.vboTarget = src.vboTarget;
}
+ protected final int componentType;
+ protected final Class<?> componentClazz;
+ protected final int bytesPerComponent;
+ protected final int componentsPerElement;
+ /** stride in bytes; strideB >= componentsPerElement * componentByteSize */
+ protected final int strideB;
+ /** stride in logical components */
+ protected final int strideL;
+ protected final boolean normalized;
+ protected final int mappedElementCount;
+ protected final boolean isVertexAttribute;
+
protected boolean alive;
protected int index;
protected int location;
protected String name;
- protected int componentsPerElement;
- protected int componentType;
- protected Class<?> componentClazz;
- protected int componentByteSize;
- protected boolean normalized;
- /** stride in bytes; strideB >= componentsPerElement * componentByteSize */
- protected int strideB;
- /** stride in logical components */
- protected int strideL;
protected Buffer buffer;
- protected int mappedElementCount;
- protected boolean isVertexAttribute;
- protected long vboOffset;
protected int vboName;
+ protected long vboOffset;
protected boolean vboEnabled;
protected int vboUsage;
protected int vboTarget;
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index 3010fa5ff..798d77b8f 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -193,20 +193,16 @@ public class VBORegion2PMSAAES2 extends GLRegion {
@Override
protected final void clearImpl(final GL2ES2 gl) {
if( null != indicesBuffer ) {
- indicesBuffer.seal(gl, false);
- indicesBuffer.rewind();
+ indicesBuffer.clear(gl);
}
if( null != gca_VerticesAttr ) {
- gca_VerticesAttr.seal(gl, false);
- gca_VerticesAttr.rewind();
+ gca_VerticesAttr.clear(gl);
}
if( null != gca_CurveParamsAttr ) {
- gca_CurveParamsAttr.seal(gl, false);
- gca_CurveParamsAttr.rewind();
+ gca_CurveParamsAttr.clear(gl);
}
if( null != gca_ColorsAttr ) {
- gca_ColorsAttr.seal(gl, false);
- gca_ColorsAttr.rewind();
+ gca_ColorsAttr.clear(gl);
}
fboDirty = true;
}
@@ -297,7 +293,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
@Override
protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
- if( 0 >= indicesBuffer.getElementCount() ) {
+ if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegion2PMSAAES2.drawImpl: Empty%n");
}
@@ -432,7 +428,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gca_FboTexCoordsAttr.enableBuffer(gl, true);
indicesFbo.bindBuffer(gl, true); // keeps VBO binding
- gl.glDrawElements(GL.GL_TRIANGLES, indicesFbo.getElementCount() * indicesFbo.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesFbo.getElemCount() * indicesFbo.getCompsPerElem(), GL.GL_UNSIGNED_SHORT, 0);
indicesFbo.bindBuffer(gl, false);
gca_FboTexCoordsAttr.enableBuffer(gl, false);
@@ -529,10 +525,10 @@ public class VBORegion2PMSAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
tex.disable(gl); // nop on core
} else {
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
}
indicesBuffer.bindBuffer(gl, false);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 092cc55c1..a5af67e0c 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -234,20 +234,16 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// Thread.dumpStack();
}
if( null != indicesBuffer ) {
- indicesBuffer.seal(gl, false);
- indicesBuffer.rewind();
+ indicesBuffer.clear(gl);;
}
if( null != gca_VerticesAttr ) {
- gca_VerticesAttr.seal(gl, false);
- gca_VerticesAttr.rewind();
+ gca_VerticesAttr.clear(gl);
}
if( null != gca_CurveParamsAttr ) {
- gca_CurveParamsAttr.seal(gl, false);
- gca_CurveParamsAttr.rewind();
+ gca_CurveParamsAttr.clear(gl);
}
if( null != gca_ColorsAttr ) {
- gca_ColorsAttr.seal(gl, false);
- gca_ColorsAttr.rewind();
+ gca_ColorsAttr.clear(gl);;
}
fboDirty = true;
}
@@ -337,7 +333,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
@Override
protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
- if( 0 >= indicesBuffer.getElementCount() ) {
+ if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegion2PVBAAES2.drawImpl: Empty%n");
}
@@ -545,7 +541,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gca_FboTexCoordsAttr.enableBuffer(gl, true);
indicesFbo.bindBuffer(gl, true); // keeps VBO binding
- gl.glDrawElements(GL.GL_TRIANGLES, indicesFbo.getElementCount() * indicesFbo.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesFbo.getElemCount() * indicesFbo.getCompsPerElem(), GL.GL_UNSIGNED_SHORT, 0);
indicesFbo.bindBuffer(gl, false);
gca_FboTexCoordsAttr.enableBuffer(gl, false);
@@ -640,10 +636,10 @@ public class VBORegion2PVBAAES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
tex.disable(gl); // nop on core
} else {
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
}
indicesBuffer.bindBuffer(gl, false);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index a8e74aed5..5b0d38929 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -95,20 +95,16 @@ public class VBORegionSPES2 extends GLRegion {
System.err.println("VBORegionSPES2 Clear: " + this);
}
if( null != indicesBuffer ) {
- indicesBuffer.seal(gl, false);
- indicesBuffer.rewind();
+ indicesBuffer.clear(gl);
}
if( null != gca_VerticesAttr ) {
- gca_VerticesAttr.seal(gl, false);
- gca_VerticesAttr.rewind();
+ gca_VerticesAttr.clear(gl);
}
if( null != gca_CurveParamsAttr ) {
- gca_CurveParamsAttr.seal(gl, false);
- gca_CurveParamsAttr.rewind();
+ gca_CurveParamsAttr.clear(gl);
}
if( null != gca_ColorsAttr ) {
- gca_ColorsAttr.seal(gl, false);
- gca_ColorsAttr.rewind();
+ gca_ColorsAttr.clear(gl);
}
}
@@ -218,7 +214,7 @@ public class VBORegionSPES2 extends GLRegion {
final int renderModes = getRenderModes();
useShaderProgram(gl, renderer, renderModes, getQuality());
- if( 0 >= indicesBuffer.getElementCount() ) {
+ if( 0 >= indicesBuffer.getElemCount() ) {
if(DEBUG_INSTANCE) {
System.err.printf("VBORegionSPES2.drawImpl: Empty%n");
}
@@ -244,10 +240,12 @@ public class VBORegionSPES2 extends GLRegion {
gcu_ColorTexUnit.setData(colorTexSeq.getTextureUnit());
gl.glUniform(gcu_ColorTexUnit); // Always update, since program maybe used by multiple regions
gl.glUniform(gcu_ColorTexBBox); // Always update, since program maybe used by multiple regions
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
+ // gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), gl_idx_type, 0);
tex.disable(gl); // nop on core
} else {
- gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), GL.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
+ // gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElementCount() * indicesBuffer.getComponentCount(), gl_idx_type, 0);
}
indicesBuffer.bindBuffer(gl, false);
diff --git a/src/jogl/classes/jogamp/opengl/util/GLVBOArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLVBOArrayHandler.java
index a9424282e..1eed318bf 100644
--- a/src/jogl/classes/jogamp/opengl/util/GLVBOArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/GLVBOArrayHandler.java
@@ -57,7 +57,7 @@ public abstract class GLVBOArrayHandler implements GLArrayHandler {
if(!ad.isVBOWritten()) {
final Buffer buffer = ad.getBuffer();
if(null!=buffer) {
- gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
+ gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getBytesPerComp(), buffer, ad.getVBOUsage());
}
ad.setVBOWritten(true);
}
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
index 0b8a15557..9cd8c863f 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
@@ -433,7 +433,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
@Override
public void glNormalPointer(final GLArrayData array) {
- if(array.getComponentCount()!=3) {
+ if(array.getCompsPerElem()!=3) {
throw new GLException("Only 3 components per normal allowed");
}
if(array.isVBO()) {