summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-07 17:56:08 +0100
committerSven Gothel <[email protected]>2023-03-07 17:56:08 +0100
commit90a95e6f689b479f3c3ae3caf4e30447030c7682 (patch)
treee230c2efb8d9e0b79b51610be2d3661c51f34128 /src/jogl/classes/com/jogamp/opengl/util
parent8fbb5bb2f4312b52c24375db3055198a18d66319 (diff)
GLArrayData: Promote sealed() from GLArrayDataEditable, to correctly being used for getElemCount() instead of 0==position, ... (API change)
API Change - sealed() moved up from GLArrayDataEditable -> GLArrayData - GLArrayDataWrapper is sealed by default - getSizeInBytes() -> getByteCount() - Semantics of getElemCount() and getByteCount() - Correctly use sealed() to switch from position to limit - instead of 0==position Aligned method names: - getElemCount() - elemPosition() - remainingElems() - getElemCapacity() to corresponding byte counts: - getByteCount() - bytePosition() - remainingBytes() - getByteCapacity()
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java72
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java37
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java193
4 files changed, 195 insertions, 110 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 792d2c474..e5f9e5336 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -161,9 +161,6 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
public final boolean isVBOWritten() { return bufferWritten; }
@Override
- public final boolean sealed() { return sealed; }
-
- @Override
public final boolean enabled() { return bufferEnabled; }
//
@@ -172,7 +169,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
@Override
public final void setVBOWritten(final boolean written) {
- bufferWritten = ( 0 == mappedElementCount ) ? written : true;
+ bufferWritten = ( 0 == mappedElemCount ) ? written : true;
}
@Override
@@ -232,7 +229,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
sealed = false;
bufferEnabled = false;
- bufferWritten = ( 0 == mappedElementCount ) ? false : true;
+ bufferWritten = ( 0 == mappedElemCount ) ? false : true;
}
@Override
@@ -240,7 +237,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
{
if( sealed == seal ) return;
sealed = seal;
- bufferWritten = ( 0 == mappedElementCount ) ? false : true;
+ bufferWritten = ( 0 == mappedElemCount ) ? false : true;
if( seal ) {
if ( null != buffer ) {
buffer.flip();
@@ -407,17 +404,16 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
return "GLArrayDataClient["+name+
", index "+index+
", location "+location+
- ", isVertexAttribute "+isVertexAttribute+
+ ", isVertexAttribute "+isVertexAttr+
", usesGLSL "+usesGLSL+
", usesShaderState "+(null!=shaderState)+
- ", dataType 0x"+Integer.toHexString(componentType)+
- ", bufferClazz "+componentClazz+
- ", elements "+getElemCount()+
- ", compsPerElem "+componentsPerElement+
+ ", dataType 0x"+Integer.toHexString(compType)+
+ ", bufferClazz "+compClazz+
+ ", compsPerElem "+compsPerElement+
", stride "+strideB+"b "+strideL+"c"+
- ", mappedElementCount "+mappedElementCount+
- ", initialElementCount "+initialElementCount+
- ", sealed "+sealed+
+ ", initElemCount "+initElemCount+
+ ", mappedElemCount "+mappedElemCount+
+ ", "+elemStatsToString()+
", bufferEnabled "+bufferEnabled+
", bufferWritten "+bufferWritten+
", buffer "+buffer+
@@ -429,7 +425,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* Returning element-count from given componentCount, rounding up to componentsPerElement.
*/
public int compsToElemCount(final int componentCount) {
- return ( componentCount + componentsPerElement - 1 ) / componentsPerElement;
+ return ( componentCount + compsPerElement - 1 ) / compsPerElement;
}
/**
@@ -441,15 +437,31 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* @return true if buffer size has changed, i.e. grown. Otherwise false.
*/
public final boolean growIfNeeded(final int spareComponents) {
+ if( buffer.remaining() < spareComponents ) {
+ if( 0 != mappedElemCount ) {
+ throw new GLException("Mapped buffer can't grow. Insufficient storage size: Needed "+spareComponents+" components, "+
+ "mappedElementCount "+mappedElemCount+
+ ", has mapped buffer "+buffer+"; "+this);
+ }
+ final int has_comps = buffer.capacity();
+ final int required_elems = compsToElemCount(has_comps + spareComponents);
+ final int new_elems = compsToElemCount( (int)( has_comps * growthFactor + 0.5f ) );
+ final int elementCount = Math.max( new_elems, required_elems );
+ return reserve( elementCount );
+ }
+ return false;
+ }
+
+ public final boolean growIfNeeded0(final int spareComponents) {
if( buffer==null || buffer.remaining()<spareComponents ) {
- if( 0 != mappedElementCount ) {
+ if( 0 != mappedElemCount ) {
throw new GLException("Mapped buffer can't grow. Insufficient storage size: Needed "+spareComponents+" components, "+
- "mappedElementCount "+mappedElementCount+
+ "mappedElementCount "+mappedElemCount+
", has mapped buffer "+buffer+"; "+this);
}
if( null == buffer ) {
final int required_elems = compsToElemCount(spareComponents);
- return reserve( Math.max( initialElementCount, required_elems ) );
+ return reserve( Math.max( initElemCount, required_elems ) );
} else {
final int has_comps = buffer.capacity();
final int required_elems = compsToElemCount(has_comps + spareComponents);
@@ -479,37 +491,37 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
// add the stride delta
- elementCount += (elementCount/componentsPerElement)*(strideL-componentsPerElement);
+ elementCount += (elementCount/compsPerElement)*(strideL-compsPerElement);
final int osize = (buffer!=null) ? buffer.capacity() : 0;
- final int nsize = elementCount * componentsPerElement;
+ final int nsize = elementCount * compsPerElement;
if( nsize <= osize ) {
return false;
}
final Buffer oldBuffer = buffer;
- if(componentClazz==ByteBuffer.class) {
+ if(compClazz==ByteBuffer.class) {
final ByteBuffer newBBuffer = Buffers.newDirectByteBuffer( nsize );
if(oldBuffer!=null) {
oldBuffer.flip();
newBBuffer.put((ByteBuffer)oldBuffer);
}
buffer = newBBuffer;
- } else if(componentClazz==ShortBuffer.class) {
+ } else if(compClazz==ShortBuffer.class) {
final ShortBuffer newSBuffer = Buffers.newDirectShortBuffer( nsize );
if(oldBuffer!=null) {
oldBuffer.flip();
newSBuffer.put((ShortBuffer)oldBuffer);
}
buffer = newSBuffer;
- } else if(componentClazz==IntBuffer.class) {
+ } else if(compClazz==IntBuffer.class) {
final IntBuffer newIBuffer = Buffers.newDirectIntBuffer( nsize );
if(oldBuffer!=null) {
oldBuffer.flip();
newIBuffer.put((IntBuffer)oldBuffer);
}
buffer = newIBuffer;
- } else if(componentClazz==FloatBuffer.class) {
+ } else if(compClazz==FloatBuffer.class) {
final FloatBuffer newFBuffer = Buffers.newDirectFloatBuffer( nsize );
if(oldBuffer!=null) {
oldBuffer.flip();
@@ -517,10 +529,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
buffer = newFBuffer;
} else {
- throw new GLException("Given Buffer Class not supported: "+componentClazz+":\n\t"+this);
+ throw new GLException("Given Buffer Class not supported: "+compClazz+":\n\t"+this);
}
if(DEBUG) {
- System.err.println("*** Size: Reserve: comps: "+componentsPerElement+", "+(osize/componentsPerElement)+"/"+osize+" -> "+(nsize/componentsPerElement)+"/"+nsize+
+ System.err.println("*** Size: Reserve: comps: "+compsPerElement+", "+(osize/compsPerElement)+"/"+osize+" -> "+(nsize/compsPerElement)+"/"+nsize+
"; "+oldBuffer+" -> "+buffer+"; "+this);
}
return true;
@@ -556,7 +568,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
// immutable types
- this.initialElementCount = initialElementCount;
+ this.initElemCount = initialElementCount;
this.growthFactor = growthFactor;
try {
final Constructor<? extends GLArrayHandler> ctor = handlerClass.getConstructor(GLArrayDataEditable.class);
@@ -597,7 +609,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
super(src);
// immutable types
- this.initialElementCount = src.initialElementCount;
+ this.initElemCount = src.initElemCount;
if( null != src.glArrayHandler ) {
final Class<? extends GLArrayHandler> clazz = src.glArrayHandler.getClass();
try {
@@ -614,7 +626,6 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
// 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;
@@ -644,13 +655,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
growthFactor = Math.max(1f, v);
}
- protected final int initialElementCount;
+ protected final int initElemCount;
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;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
index 9430f585f..fad217c05 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java
@@ -40,8 +40,6 @@ import java.nio.*;
*/
public interface GLArrayDataEditable extends GLArrayData {
- public boolean sealed();
-
public boolean enabled();
/**
@@ -176,6 +174,7 @@ public interface GLArrayDataEditable extends GLArrayData {
* ie position:=limit and limit:=capacity.</p>
*
* @see #seal(boolean)
+ * @see #sealed()
*/
public void seal(boolean seal);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 9fd35c74f..e530ad627 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -321,10 +321,10 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
final int subStrideB = ( 0 == getStride() ) ? getCompsPerElem() * getBytesPerComp() : getStride();
final GLArrayDataWrapper ad;
- if( 0 < mappedElementCount ) {
+ if( 0 < mappedElemCount ) {
ad = GLArrayDataWrapper.createFixed(
index, comps, getCompType(),
- getNormalized(), subStrideB, mappedElementCount,
+ getNormalized(), subStrideB, mappedElemCount,
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
} else {
ad = GLArrayDataWrapper.createFixed(
@@ -422,10 +422,10 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
final int subStrideB = ( 0 == getStride() ) ? getCompsPerElem() * getBytesPerComp() : getStride();
final GLArrayDataWrapper ad;
- if( 0 < mappedElementCount ) {
+ if( 0 < mappedElemCount ) {
ad = GLArrayDataWrapper.createGLSL(
name, comps, getCompType(),
- getNormalized(), subStrideB, mappedElementCount,
+ getNormalized(), subStrideB, mappedElemCount,
getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
} else {
ad = GLArrayDataWrapper.createGLSL(
@@ -495,7 +495,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
checkSeal(true);
bindBuffer(gl, true);
- gl.glBufferData(getVBOTarget(), getSizeInBytes(), null, getVBOUsage());
+ gl.glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
final GLBufferStorage storage = gl.mapBuffer(getVBOTarget(), access);
setMappedBuffer(storage);
bindBuffer(gl, false);
@@ -512,7 +512,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
checkSeal(true);
bindBuffer(gl, true);
- gl.glBufferData(getVBOTarget(), getSizeInBytes(), null, getVBOUsage());
+ gl.glBufferData(getVBOTarget(), getByteCount(), null, getVBOUsage());
final GLBufferStorage storage = gl.mapBufferRange(getVBOTarget(), offset, length, access);
setMappedBuffer(storage);
bindBuffer(gl, false);
@@ -523,16 +523,16 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
private final void setMappedBuffer(final GLBufferStorage storage) {
mappedStorage = storage;
final ByteBuffer bb = storage.getMappedBuffer();
- if(componentClazz==ByteBuffer.class) {
+ if(compClazz==ByteBuffer.class) {
buffer = bb;
- } else if(componentClazz==ShortBuffer.class) {
+ } else if(compClazz==ShortBuffer.class) {
buffer = bb.asShortBuffer();
- } else if(componentClazz==IntBuffer.class) {
+ } else if(compClazz==IntBuffer.class) {
buffer = bb.asIntBuffer();
- } else if(componentClazz==FloatBuffer.class) {
+ } else if(compClazz==FloatBuffer.class) {
buffer = bb.asFloatBuffer();
} else {
- throw new GLException("Given Buffer Class not supported: "+componentClazz+":\n\t"+this);
+ throw new GLException("Given Buffer Class not supported: "+compClazz+":\n\t"+this);
}
}
@@ -553,23 +553,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
return "GLArrayDataServer["+name+
", index "+index+
", location "+location+
- ", isVertexAttribute "+isVertexAttribute+
+ ", isVertexAttribute "+isVertexAttr+
", usesGLSL "+usesGLSL+
", usesShaderState "+(null!=shaderState)+
- ", dataType 0x"+Integer.toHexString(componentType)+
- ", bufferClazz "+componentClazz+
- ", elements "+getElemCount()+
- ", components "+componentsPerElement+
+ ", dataType 0x"+Integer.toHexString(compType)+
+ ", bufferClazz "+compClazz+
+ ", compsPerElem "+compsPerElement+
", stride "+strideB+"b "+strideL+"c"+
- ", initialElementCount "+initialElementCount+
- ", mappedElementCount "+mappedElementCount+
+ ", initElemCount "+initElemCount+
+ ", mappedElemCount "+mappedElemCount+
+ ", "+elemStatsToString()+
", mappedStorage "+mappedStorage+
", vboEnabled "+vboEnabled+
", vboName "+vboName+
", vboUsage 0x"+Integer.toHexString(vboUsage)+
", vboTarget 0x"+Integer.toHexString(vboTarget)+
", vboOffset "+vboOffset+
- ", sealed "+sealed+
", bufferEnabled "+bufferEnabled+
", bufferWritten "+bufferWritten+
", buffer "+buffer+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
index 699a0be0d..21d375dbc 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.util;
-import java.io.PrintStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
@@ -51,7 +50,9 @@ public class GLArrayDataWrapper implements GLArrayData {
/**
* Create a VBO, using a predefined fixed function array index, wrapping the given data.
- *
+ * <p>
+ * This buffer is always {@link #sealed()}.
+ * </p>
* @param index The GL array index
* @param comps The array component number
* @param dataType The array index GL data type
@@ -76,7 +77,9 @@ public class GLArrayDataWrapper implements GLArrayData {
/**
* Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.
- *
+ * <p>
+ * This buffer is always {@link #sealed()}.
+ * </p>
* @param index The GL array index
* @param comps The array component number
* @param dataType The array index GL data type
@@ -101,7 +104,9 @@ public class GLArrayDataWrapper implements GLArrayData {
/**
* Create a VBO, using a custom GLSL array attribute name, wrapping the given data.
- *
+ * <p>
+ * This buffer is always {@link #sealed()}.
+ * </p>
* @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
* @param comps The array component number
* @param dataType The array index GL data type
@@ -125,7 +130,9 @@ public class GLArrayDataWrapper implements GLArrayData {
/**
* Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.
- *
+ * <p>
+ * This buffer is always {@link #sealed()}.
+ * </p>
* @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
* @param comps The array component number
* @param dataType The array index GL data type
@@ -183,7 +190,7 @@ public class GLArrayDataWrapper implements GLArrayData {
//
@Override
- public final boolean isVertexAttribute() { return isVertexAttribute; }
+ public final boolean isVertexAttribute() { return isVertexAttr; }
@Override
public final int getIndex() { return index; }
@@ -229,53 +236,119 @@ public class GLArrayDataWrapper implements GLArrayData {
public Buffer getBuffer() { return buffer; }
@Override
- public final int getCompsPerElem() { return componentsPerElement; }
+ public final int getCompsPerElem() { return compsPerElement; }
@Override
- public final int getCompType() { return componentType; }
+ public final int getCompType() { return compType; }
@Override
- public final int getBytesPerComp() { return bytesPerComponent; }
+ public final int getBytesPerComp() { return bytesPerComp; }
+
+ @Override
+ public final boolean sealed() { return sealed; }
@Override
public final int getElemCount() {
- if( 0 != mappedElementCount ) {
- return mappedElementCount;
+ if( 0 != mappedElemCount ) {
+ return mappedElemCount;
+ } else if( null != buffer ) {
+ if( sealed ) {
+ return ( buffer.limit() * bytesPerComp ) / strideB ;
+ } else {
+ return ( buffer.position() * bytesPerComp ) / strideB ;
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public final int elemPosition() {
+ if( 0 != mappedElemCount ) {
+ return mappedElemCount;
+ } else if( null != buffer ) {
+ return ( buffer.position() * bytesPerComp ) / strideB ;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public int remainingElems() {
+ if( null != buffer ) {
+ return ( buffer.remaining() * bytesPerComp ) / strideB ;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public int getElemCapacity() {
+ if( null != buffer ) {
+ return ( buffer.capacity() * bytesPerComp ) / strideB ;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public final int getByteCount() {
+ if( 0 != mappedElemCount ) {
+ return mappedElemCount * compsPerElement * bytesPerComp ;
} else if( null != buffer ) {
- final int remainingComponents = ( 0 == buffer.position() ) ? buffer.limit() : buffer.position();
- return ( remainingComponents * bytesPerComponent ) / strideB ;
+ if( sealed ) {
+ return buffer.limit() * bytesPerComp ;
+ } else {
+ return buffer.position() * bytesPerComp ;
+ }
} else {
return 0;
}
}
@Override
- public final int getSizeInBytes() {
- if( 0 != mappedElementCount ) {
- return mappedElementCount * componentsPerElement * bytesPerComponent ;
+ public final int bytePosition() {
+ if( 0 != mappedElemCount ) {
+ return mappedElemCount * compsPerElement * bytesPerComp ;
} else if( null != buffer ) {
- return ( buffer.position()==0 ) ? ( buffer.limit() * bytesPerComponent ) : ( buffer.position() * bytesPerComponent ) ;
+ return buffer.position() * bytesPerComp;
} else {
return 0;
}
}
@Override
- public int getCapacityInBytes() {
+ public int remainingBytes() {
+ if( null != buffer ) {
+ return buffer.remaining() * bytesPerComp;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public int getByteCapacity() {
if( null != buffer ) {
- return buffer.capacity() * bytesPerComponent;
+ return buffer.capacity() * bytesPerComp;
} else {
return 0;
}
}
@Override
- public void printStats(final PrintStream out) {
- final int sz_bytes = getSizeInBytes();
- final int cap_bytes = getCapacityInBytes();
- final float filled = (float)sz_bytes/(float)cap_bytes;
- out.printf("elements %,d / %,d, bytes %,d / %,d, filled %.1f%%, left %.1f%%",
- getElemCount(), cap_bytes / (componentsPerElement * bytesPerComponent), sz_bytes, cap_bytes, filled*100f, (1f-filled)*100f);
+ public String fillStatsToString() {
+ final int cnt_bytes = getByteCount();
+ final int cap_bytes = getByteCapacity();
+ final float filled = (float)cnt_bytes/(float)cap_bytes;
+ return String.format("elements %,d cnt / %,d cap, bytes %,d cnt / %,d cap, filled %.1f%%, left %.1f%%",
+ getElemCount(), getElemCapacity(), cnt_bytes, cap_bytes, filled*100f, (1f-filled)*100f);
+ }
+
+ @Override
+ public String elemStatsToString() {
+ final int elem_limit = null != buffer ? ( buffer.limit() * bytesPerComp ) / strideB : 0;
+ return String.format("sealed %b, elements %,d cnt, [%,d pos .. %,d rem .. %,d lim .. %,d cap]",
+ sealed(), getElemCount(), elemPosition(), remainingElems(), elem_limit, getElemCapacity());
}
@Override
@@ -284,7 +357,7 @@ public class GLArrayDataWrapper implements GLArrayData {
@Override
public final int getStride() { return strideB; }
- public final Class<?> getBufferClass() { return componentClazz; }
+ public final Class<?> getBufferClass() { return compClazz; }
@Override
public void destroy(final GL gl) {
@@ -300,13 +373,13 @@ public class GLArrayDataWrapper implements GLArrayData {
return "GLArrayDataWrapper["+name+
", index "+index+
", location "+location+
- ", isVertexAttribute "+isVertexAttribute+
- ", dataType 0x"+Integer.toHexString(componentType)+
- ", bufferClazz "+componentClazz+
- ", elements "+getElemCount()+
- ", components "+componentsPerElement+
+ ", isVertexAttribute "+isVertexAttr+
+ ", dataType 0x"+Integer.toHexString(compType)+
+ ", bufferClazz "+compClazz+
+ ", compsPerElem "+compsPerElement+
", stride "+strideB+"b "+strideL+"c"+
- ", mappedElementCount "+mappedElementCount+
+ ", mappedElemCount "+mappedElemCount+
+ ", "+elemStatsToString()+
", buffer "+buffer+
", vboEnabled "+vboEnabled+
", vboName "+vboName+
@@ -399,33 +472,33 @@ public class GLArrayDataWrapper implements GLArrayData {
}
// immutable types
- this.componentType = componentType;
- componentClazz = getBufferClass(componentType);
- bytesPerComponent = GLBuffers.sizeOfGLType(componentType);
- if(0 > bytesPerComponent) {
+ this.compType = componentType;
+ compClazz = getBufferClass(componentType);
+ bytesPerComp = GLBuffers.sizeOfGLType(componentType);
+ if(0 > bytesPerComp) {
throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this);
}
if(0 >= componentsPerElement) {
throw new GLException("Invalid number of components: " + componentsPerElement);
}
- this.componentsPerElement = componentsPerElement;
+ this.compsPerElement = componentsPerElement;
- if(0<stride && stride<componentsPerElement*bytesPerComponent) {
- throw new GLException("stride ("+stride+") lower than component bytes, "+componentsPerElement+" * "+bytesPerComponent);
+ if(0<stride && stride<componentsPerElement*bytesPerComp) {
+ throw new GLException("stride ("+stride+") lower than component bytes, "+componentsPerElement+" * "+bytesPerComp);
}
- if(0<stride && stride%bytesPerComponent!=0) {
- throw new GLException("stride ("+stride+") not a multiple of bpc "+bytesPerComponent);
+ if(0<stride && stride%bytesPerComp!=0) {
+ throw new GLException("stride ("+stride+") not a multiple of bpc "+bytesPerComp);
}
- this.strideB=(0==stride)?componentsPerElement*bytesPerComponent:stride;
- this.strideL=strideB/bytesPerComponent;
+ this.strideB=(0==stride)?componentsPerElement*bytesPerComp:stride;
+ this.strideL=strideB/bytesPerComp;
if( GLBuffers.isGLTypeFixedPoint(componentType) ) {
this.normalized = normalized;
} else {
this.normalized = false;
}
- this.mappedElementCount = mappedElementCount;
- this.isVertexAttribute = isVertexAttribute;
+ this.mappedElemCount = mappedElementCount;
+ this.isVertexAttr = isVertexAttribute;
// mutable types
this.index = index;
@@ -455,6 +528,7 @@ public class GLArrayDataWrapper implements GLArrayData {
this.vboUsage=vboUsage;
this.vboTarget=vboTarget;
this.alive=true;
+ this.sealed = true;
}
/**
@@ -468,15 +542,15 @@ public class GLArrayDataWrapper implements GLArrayData {
*/
public GLArrayDataWrapper(final GLArrayDataWrapper src) {
// immutable types
- this.componentType = src.componentType;
- this.componentClazz = src.componentClazz;
- this.bytesPerComponent = src.bytesPerComponent;
- this.componentsPerElement = src.componentsPerElement;
+ this.compType = src.compType;
+ this.compClazz = src.compClazz;
+ this.bytesPerComp = src.bytesPerComp;
+ this.compsPerElement = src.compsPerElement;
this.strideB = src.strideB;
this.strideL = src.strideL;
this.normalized = src.normalized;
- this.mappedElementCount = src.mappedElementCount;
- this.isVertexAttribute = src.isVertexAttribute;
+ this.mappedElemCount = src.mappedElemCount;
+ this.isVertexAttr = src.isVertexAttr;
// mutable types
this.alive = src.alive;
@@ -497,20 +571,22 @@ public class GLArrayDataWrapper implements GLArrayData {
this.vboEnabled = src.vboEnabled;
this.vboUsage = src.vboUsage;
this.vboTarget = src.vboTarget;
+ this.sealed = src.sealed;
}
- 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 compType;
+ protected final Class<?> compClazz;
+ protected final int bytesPerComp;
+ protected final int compsPerElement;
+ /** stride in bytes; strideB >= compsPerElement * bytesPerComp */
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 final int mappedElemCount;
+ protected final boolean isVertexAttr;
+ // mutable types
protected boolean alive;
protected int index;
protected int location;
@@ -521,5 +597,6 @@ public class GLArrayDataWrapper implements GLArrayData {
protected boolean vboEnabled;
protected int vboUsage;
protected int vboTarget;
+ protected boolean sealed;
}