aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-11 11:00:17 +0200
committerSven Gothel <[email protected]>2012-04-11 11:00:17 +0200
commit41b75429e3801f8bf8d5eea679487ccc49ce2584 (patch)
tree75c9fe65506bc137320648796eed8bcf20c8f3a9 /src/jogl/classes/com/jogamp/opengl/util
parent173b7820b3e7dfb44aab055e7427f296a864feb3 (diff)
GLArrayData: Fix 'growBuffer()' / clarify 'initialSize' -> 'initialElementCount'
- growBuffer() was using '(osize+additional) * components' -> 'osize + (additional * components )' - added jogl.debug.GLArrayData - notifying growBuffer()
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java51
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java50
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java26
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java68
4 files changed, 104 insertions, 91 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index a61fe0d27..134dd9677 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -23,7 +23,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
/**
* Create a client side buffer object, using a predefined fixed function array index
- * and starting with a new created Buffer object with initialSize size
+ * and starting with a new created Buffer object with initialElementCount size
*
* On profiles GL2 and ES1 the fixed function pipeline behavior is as expected.
* On profile ES2 the fixed function emulation will transform these calls to
@@ -37,16 +37,16 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialSize)
+ public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0, 0, 0, false);
+ adc.init(null, index, comps, dataType, normalized, 0, null, initialElementCount, false, glArrayHandler, 0, 0, 0, 0, false);
return adc;
}
@@ -83,20 +83,20 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
/**
* Create a client side buffer object, using a custom GLSL array attribute name
- * and starting with a new created Buffer object with initialSize size
+ * and starting with a new created Buffer object with initialElementCount size
* @param name The custom name for the GL attribute.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
*/
public static GLArrayDataClient createGLSL(String name, int comps,
- int dataType, boolean normalized, int initialSize)
+ int dataType, boolean normalized, int initialElementCount)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
- adc.init(name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler, 0, 0, 0, 0, true);
+ adc.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount, true, glArrayHandler, 0, 0, 0, 0, true);
return adc;
}
@@ -274,12 +274,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
", index "+index+
", location "+location+
", isVertexAttribute "+isVertexAttribute+
- ", dataType "+componentType+
+ ", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
", elements "+getElementCount()+
", components "+components+
", stride "+strideB+"b "+strideL+"c"+
- ", initialSize "+initialSize+
+ ", initialElementCount "+initialElementCount+
", sealed "+sealed+
", bufferEnabled "+bufferEnabled+
", bufferWritten "+bufferWritten+
@@ -292,44 +292,46 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
protected final boolean growBufferIfNecessary(int spare) {
if(buffer==null || buffer.remaining()<spare) {
- growBuffer(Math.max(initialSize, spare));
+ growBuffer(Math.max(initialElementCount, spare));
return true;
}
return false;
}
- protected final void growBuffer(int additional) {
+ protected final void growBuffer(int additionalElements) {
if(!alive || sealed) {
throw new GLException("Invalid state: "+this);
}
// add the stride delta
- additional += (additional/components)*(strideL-components);
+ additionalElements += (additionalElements/components)*(strideL-components);
- int osize = (buffer!=null)?buffer.capacity():0;
+ final int osize = (buffer!=null) ? buffer.capacity() : 0;
+ final int nsize = osize + ( additionalElements * components );
+
if(componentClazz==ByteBuffer.class) {
- ByteBuffer newBBuffer = Buffers.newDirectByteBuffer( (osize+additional) * components );
+ ByteBuffer newBBuffer = Buffers.newDirectByteBuffer( nsize );
if(buffer!=null) {
buffer.flip();
newBBuffer.put((ByteBuffer)buffer);
}
buffer = newBBuffer;
} else if(componentClazz==ShortBuffer.class) {
- ShortBuffer newSBuffer = Buffers.newDirectShortBuffer( (osize+additional) * components );
+ ShortBuffer newSBuffer = Buffers.newDirectShortBuffer( nsize );
if(buffer!=null) {
buffer.flip();
newSBuffer.put((ShortBuffer)buffer);
}
buffer = newSBuffer;
} else if(componentClazz==IntBuffer.class) {
- IntBuffer newIBuffer = Buffers.newDirectIntBuffer( (osize+additional) * components );
+ IntBuffer newIBuffer = Buffers.newDirectIntBuffer( nsize );
if(buffer!=null) {
buffer.flip();
newIBuffer.put((IntBuffer)buffer);
}
buffer = newIBuffer;
} else if(componentClazz==FloatBuffer.class) {
- FloatBuffer newFBuffer = Buffers.newDirectFloatBuffer( (osize+additional) * components );
+ FloatBuffer newFBuffer = Buffers.newDirectFloatBuffer( nsize );
if(buffer!=null) {
buffer.flip();
newFBuffer.put((FloatBuffer)buffer);
@@ -338,6 +340,9 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
} else {
throw new GLException("Given Buffer Class not supported: "+componentClazz+":\n\t"+this);
}
+ if(DEBUG) {
+ System.err.println("*** Grow: comps: "+components+", "+(osize/components)+"/"+osize+" -> "+(nsize/components)+"/"+nsize+", "+this);
+ }
}
protected final void checkSeal(boolean test) throws GLException {
@@ -354,22 +359,22 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data,
- int initialSize, boolean isVertexAttribute, GLArrayHandler handler,
+ int initialElementCount, boolean isVertexAttribute, GLArrayHandler handler,
int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL)
throws GLException
{
super.init(name, index, comps, dataType, normalized, stride, data, isVertexAttribute,
vboName, vboOffset, vboUsage, vboTarget);
- this.initialSize = initialSize;
+ this.initialElementCount = initialElementCount;
this.glArrayHandler = handler;
this.usesGLSL = usesGLSL;
this.sealed=false;
this.bufferEnabled=false;
this.enableBufferAlways=false;
this.bufferWritten=false;
- if(null==buffer && initialSize>0) {
- growBuffer(initialSize);
+ if(null==buffer && initialElementCount>0) {
+ growBuffer(initialElementCount);
}
}
@@ -389,7 +394,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
protected boolean bufferWritten;
protected boolean enableBufferAlways;
- protected int initialSize;
+ protected int initialElementCount;
protected GLArrayHandler glArrayHandler;
protected boolean usesGLSL;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 77cf71bc0..c9dd98751 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -60,7 +60,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
/**
* Create a VBO, using a predefined fixed function array index
- * and starting with a new created Buffer object with initialSize size
+ * and starting with a new created Buffer object with initialElementCount size
*
* On profiles GL2 and ES1 the fixed function pipeline behavior is as expected.
* On profile ES2 the fixed function emulation will transform these calls to
@@ -74,39 +74,39 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialSize,
+ public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount,
int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
+ ads.init(null, index, comps, dataType, normalized, 0, null, initialElementCount, false, glArrayHandler,
0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
return ads;
}
/**
* Create a VBO, using a custom GLSL array attribute name
- * and starting with a new created Buffer object with initialSize size
+ * and starting with a new created Buffer object with initialElementCount size
* @param name The custom name for the GL attribute
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
public static GLArrayDataServer createGLSL(String name, int comps,
- int dataType, boolean normalized, int initialSize, int vboUsage)
+ int dataType, boolean normalized, int initialElementCount, int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, comps, dataType, normalized, 0, null, initialSize,
+ ads.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount,
true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
return ads;
}
@@ -133,7 +133,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
return ads;
}
-
+
/**
* Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}.
*
@@ -165,17 +165,17 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @param comps The array component number
* @param dataType The array index GL data type
- * @param initialSize
+ * @param initialElementCount
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
* @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, ..
*/
- public static GLArrayDataServer createData(int comps, int dataType, int initialSize,
+ public static GLArrayDataServer createData(int comps, int dataType, int initialElementCount,
int vboUsage, int vboTarget)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLDataArrayHandler(ads);
- ads.init(null, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
+ ads.init(null, -1, comps, dataType, false, 0, null, initialElementCount, false, glArrayHandler,
0, 0, vboUsage, vboTarget, false);
return ads;
}
@@ -183,22 +183,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
/**
* Create a VBO for fixed function interleaved array data
- * starting with a new created Buffer object with initialSize size.
+ * starting with a new created Buffer object with initialElementCount size.
* <p>User needs to <i>configure</i> the interleaved segments via {@link #addFixedSubArray(int, int, int)}.</p>
*
* @param comps The total number of all interleaved components.
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
- public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialSize,
+ public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialElementCount,
int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
+ ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialElementCount, false, glArrayHandler,
0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false);
return ads;
}
@@ -239,22 +239,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
/**
* Create a VBO for GLSL interleaved array data
- * starting with a new created Buffer object with initialSize size.
+ * starting with a new created Buffer object with initialElementCount size.
* <p>User needs to <i>configure</i> the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.</p>
*
* @param comps The total number of all interleaved components.
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
- * @param initialSize
+ * @param initialElementCount
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
*/
- public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialSize,
+ public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialElementCount,
int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads);
- ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
+ ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialElementCount, false, glArrayHandler,
0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true);
return ads;
}
@@ -283,7 +283,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
final GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
name, comps, getComponentType(),
getNormalized(), getStride(), getBuffer(),
- getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
+ getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
ad.setVBOEnabled(isVBO());
interleavedOffset += comps * getComponentSizeInBytes();
if(GL.GL_ARRAY_BUFFER == vboTarget) {
@@ -332,12 +332,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
", index "+index+
", location "+location+
", isVertexAttribute "+isVertexAttribute+
- ", dataType "+componentType+
+ ", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
", elements "+getElementCount()+
", components "+components+
", stride "+strideB+"b "+strideL+"c"+
- ", initialSize "+initialSize+
+ ", initialElementCount "+initialElementCount+
", vboEnabled "+vboEnabled+
", vboName "+vboName+
", vboUsage 0x"+Integer.toHexString(vboUsage)+
@@ -356,12 +356,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
//
protected void init(String name, int index, int comps, int dataType, boolean normalized,
- int stride, Buffer data, int initialSize, boolean isVertexAttribute,
+ int stride, Buffer data, int initialElementCount, boolean isVertexAttribute,
GLArrayHandler glArrayHandler,
int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL)
throws GLException
{
- super.init(name, index, comps, dataType, normalized, stride, data, initialSize, isVertexAttribute, glArrayHandler,
+ super.init(name, index, comps, dataType, normalized, stride, data, initialElementCount, isVertexAttribute, glArrayHandler,
vboName, vboOffset, vboUsage, vboTarget, usesGLSL);
vboEnabled=true;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
index a80900998..bade0a3ae 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
@@ -1,14 +1,24 @@
package com.jogamp.opengl.util;
-import javax.media.opengl.*;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLArrayData;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
-import jogamp.opengl.util.glsl.fixedfunc.*;
-
-import java.nio.*;
+import jogamp.opengl.Debug;
public class GLArrayDataWrapper implements GLArrayData {
+ public static final boolean DEBUG = Debug.debug("GLArrayData");
/**
* Create a VBO, using a predefined fixed function array index, wrapping the given data.
@@ -28,8 +38,7 @@ public class GLArrayDataWrapper implements GLArrayData {
* @throws GLException
*/
public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride,
- Buffer buffer, int vboName,
- long vboOffset, int vboUsage, int vboTarget)
+ Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget)
throws GLException
{
GLArrayDataWrapper adc = new GLArrayDataWrapper();
@@ -55,8 +64,7 @@ public class GLArrayDataWrapper implements GLArrayData {
* @throws GLException
*/
public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride,
- Buffer buffer, int vboName,
- long vboOffset, int vboUsage, int vboTarget)
+ Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget)
throws GLException
{
GLArrayDataWrapper adc = new GLArrayDataWrapper();
@@ -149,7 +157,7 @@ public class GLArrayDataWrapper implements GLArrayData {
", index "+index+
", location "+location+
", isVertexAttribute "+isVertexAttribute+
- ", dataType "+componentType+
+ ", dataType 0x"+Integer.toHexString(componentType)+
", bufferClazz "+componentClazz+
", elements "+getElementCount()+
", components "+components+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index 681cf7c36..44026fdac 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -6,6 +6,7 @@ import com.jogamp.opengl.util.glsl.ShaderState;
import javax.media.opengl.*;
import javax.media.opengl.fixedfunc.*;
+
import java.nio.*;
import java.util.Iterator;
import java.util.ArrayList;
@@ -22,12 +23,12 @@ public class ImmModeSink {
/**
* Uses a GL2ES1, or ES2 fixed function emulation immediate mode sink
*/
- public static ImmModeSink createFixed(GL gl, int glBufferUsage, int initialSize,
+ public static ImmModeSink createFixed(GL gl, int glBufferUsage, int initialElementCount,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType) {
- return new ImmModeSink(gl, glBufferUsage, initialSize,
+ return new ImmModeSink(gl, glBufferUsage, initialElementCount,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, false);
}
@@ -40,12 +41,12 @@ public class ImmModeSink {
* @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean)
* @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState()
*/
- public static ImmModeSink createGLSL(GL gl, int glBufferUsage, int initialSize,
+ public static ImmModeSink createGLSL(GL gl, int glBufferUsage, int initialElementCount,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType) {
- return new ImmModeSink(gl, glBufferUsage, initialSize,
+ return new ImmModeSink(gl, glBufferUsage, initialElementCount,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true);
}
@@ -71,9 +72,9 @@ public class ImmModeSink {
public String toString() {
StringBuffer sb = new StringBuffer("ImmModeSink[");
sb.append(",\n\tVBO list: "+vboSetList.size()+" [");
- for(Iterator i=vboSetList.iterator(); i.hasNext() ; ) {
+ for(Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; ) {
sb.append("\n\t");
- sb.append( (VBOSet)i.next() );
+ sb.append( i.next() );
}
if(vboSetList.size()>0) {
sb.append("\n\t],\nVBO current: NOP]");
@@ -91,8 +92,8 @@ public class ImmModeSink {
e.printStackTrace();
}
int n=0;
- for(Iterator i=vboSetList.iterator(); i.hasNext() ; n++) {
- ((VBOSet)i.next()).draw(gl, null, disableBufferAfterDraw, n);
+ for(Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; n++) {
+ i.next().draw(gl, null, disableBufferAfterDraw, n);
}
}
@@ -102,8 +103,8 @@ public class ImmModeSink {
e.printStackTrace();
}
int n=0;
- for(Iterator i=vboSetList.iterator(); i.hasNext() ; n++) {
- ((VBOSet)i.next()).draw(gl, indices, disableBufferAfterDraw, n);
+ for(Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; n++) {
+ i.next().draw(gl, indices, disableBufferAfterDraw, n);
}
}
@@ -255,7 +256,7 @@ public class ImmModeSink {
vboSet.glTexCoord3b(x,y,z);
}
- protected ImmModeSink(GL gl, int glBufferUsage, int initialSize,
+ protected ImmModeSink(GL gl, int glBufferUsage, int initialElementCount,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
@@ -263,31 +264,31 @@ public class ImmModeSink {
if(useGLSL && !gl.hasGLSL()) {
throw new GLException("ImmModeSink GLSL usage not supported: "+gl);
}
- vboSet = new VBOSet(gl, glBufferUsage, initialSize,
+ vboSet = new VBOSet(gl, glBufferUsage, initialElementCount,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL);
- this.vboSetList = new ArrayList();
+ this.vboSetList = new ArrayList<VBOSet>();
}
private void destroyList(GL gl) {
- for(Iterator i=vboSetList.iterator(); i.hasNext() ; ) {
- ((VBOSet)i.next()).destroy(gl);
+ for(Iterator<VBOSet> i=vboSetList.iterator(); i.hasNext() ; ) {
+ i.next().destroy(gl);
}
vboSetList.clear();
}
private VBOSet vboSet;
- private ArrayList vboSetList;
+ private ArrayList<VBOSet> vboSetList;
private static boolean vboUsage = true;
protected static class VBOSet {
- protected VBOSet (GL gl, int glBufferUsage, int initialSize,
+ protected VBOSet (GL gl, int glBufferUsage, int initialElementCount,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType, boolean useGLSL) {
this.gl=gl;
this.glBufferUsage=glBufferUsage;
- this.initialSize=initialSize;
+ this.initialElementCount=initialElementCount;
this.vDataType=vDataType;
this.vComps=vComps;
this.cDataType=cDataType;
@@ -298,7 +299,7 @@ public class ImmModeSink {
this.tComps=tComps;
this.useGLSL=useGLSL;
- allocateBuffer(initialSize);
+ allocateBuffer(initialElementCount);
rewind();
this.sealed=false;
@@ -310,7 +311,7 @@ public class ImmModeSink {
}
protected final VBOSet regenerate() {
- return new VBOSet(gl, glBufferUsage, initialSize,
+ return new VBOSet(gl, glBufferUsage, initialElementCount,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL);
}
@@ -341,7 +342,7 @@ public class ImmModeSink {
if(null==indices) {
glf.glDrawArrays(mode, 0, count);
} else {
- Class clazz = indices.getClass();
+ Class<?> clazz = indices.getClass();
int type=-1;
if(ReflectionUtil.instanceOf(clazz, ByteBuffer.class.getName())) {
type = GL.GL_UNSIGNED_BYTE;
@@ -713,35 +714,35 @@ public class ImmModeSink {
}
if(vComps>0) {
- glf.glEnableClientState(glf.GL_VERTEX_ARRAY);
+ glf.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
glf.glVertexPointer(vArrayData);
}
if(cComps>0) {
- glf.glEnableClientState(glf.GL_COLOR_ARRAY);
+ glf.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
glf.glColorPointer(cArrayData);
}
if(nComps>0) {
- glf.glEnableClientState(glf.GL_NORMAL_ARRAY);
+ glf.glEnableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
glf.glNormalPointer(nArrayData);
}
if(tComps>0) {
- glf.glEnableClientState(glf.GL_TEXTURE_COORD_ARRAY);
+ glf.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
glf.glTexCoordPointer(tArrayData);
}
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
} else {
if(vComps>0) {
- glf.glDisableClientState(glf.GL_VERTEX_ARRAY);
+ glf.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
}
if(cComps>0) {
- glf.glDisableClientState(glf.GL_COLOR_ARRAY);
+ glf.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
}
if(nComps>0) {
- glf.glDisableClientState(glf.GL_NORMAL_ARRAY);
+ glf.glDisableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
}
if(tComps>0) {
- glf.glDisableClientState(glf.GL_TEXTURE_COORD_ARRAY);
+ glf.glDisableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
}
}
}
@@ -810,13 +811,13 @@ public class ImmModeSink {
// non public matters
- protected void allocateBuffer(int elements) {
+ protected void allocateBuffer(int elementCount) {
int vWidth = vComps * GLBuffers.sizeOfGLType(vDataType);
int cWidth = cComps * GLBuffers.sizeOfGLType(cDataType);
int nWidth = nComps * GLBuffers.sizeOfGLType(nDataType);
int tWidth = tComps * GLBuffers.sizeOfGLType(tDataType);
- count = elements;
+ count = elementCount;
bSize = count * ( vWidth + cWidth + nWidth + tWidth ) ;
buffer = GLBuffers.newDirectByteBuffer(bSize);
@@ -890,7 +891,7 @@ public class ImmModeSink {
protected final boolean growBufferIfNecessary(int type, int spare) {
if(buffer==null || count < spare) {
- growBuffer(type, initialSize);
+ growBuffer(type, initialElementCount);
return true;
}
return false;
@@ -901,7 +902,6 @@ public class ImmModeSink {
// save olde values ..
Buffer _vertexArray=vertexArray, _colorArray=colorArray, _normalArray=normalArray, _textCoordArray=textCoordArray;
- ByteBuffer _buffer = buffer;
allocateBuffer(count+additional);
@@ -951,7 +951,7 @@ public class ImmModeSink {
}
protected int mode, modeOrig;
- protected int glBufferUsage, initialSize;
+ protected int glBufferUsage, initialElementCount;
protected ByteBuffer buffer;
protected int bSize, count, vboName;