aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-22 17:26:13 +0200
committerSven Gothel <[email protected]>2011-08-22 17:26:13 +0200
commit55dae6968075cd082f7a9b8060f0912669e7aa78 (patch)
tree44165f00d9db6195e9beda55bfc5ab7fa96a191a /src/jogl/classes/com/jogamp/opengl/util
parent16e5b7e6c14497b932f58ed38fc03c48656fdb09 (diff)
API Change GLArrayDataWrapper/GLArrayDataServer: Add vboTarget to wrapper cstr and add interleaved seg.
vboTarget is required in case of interleaved segments to allow eg. interleaved indices.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java71
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java8
3 files changed, 68 insertions, 23 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 38207cd2d..8b254a9c9 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -37,9 +37,6 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}.
*
* @param index The GL array index
- * @param name The optional custom name for the GL array index, maybe null.
- * If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
- * This name might be used as the shader attribute name.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
@@ -97,7 +94,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* and starting with a new created Buffer object with initialSize size
*
* @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
- * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ * @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
@@ -121,7 +118,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* and starting with a given Buffer object incl it's stride
*
* @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
- * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is
+ * @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
@@ -188,6 +185,19 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
+ /**
+ * Create a VBO for interleaved array data
+ * starting with a new created Buffer object with initialSize size.
+ * <p>User needs to <i>configure</i> the interleaved segments via {@link #addFixedSubArray(int, int, int)}
+ * for fixed function arrays or via {@link #addGLSLSubArray(ShaderState, String, int, int)} for GLSL
+ * attributes.</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 vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
+ */
public static GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize,
int vboUsage)
throws GLException
@@ -201,7 +211,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
int interleavedOffset = 0;
- public GLArrayData addFixedSubArray(int index, int comps) {
+ /**
+ * Configure a segment of this interleaved array (see {@link #createInterleaved(int, int, boolean, int, int)})
+ * for fixed function usage.
+ * <p>
+ * This method may be called several times as long the sum of interleaved components does not
+ * exceed the total number of components of the created interleaved array.</p>
+ * <p>
+ * The memory of the the interleaved array is being used.</p>
+ * <p>
+ * Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, .. </p>
+ *
+ * @param index The GL array index, maybe -1 if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ * @param comps This interleaved array segment's component number
+ * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ */
+ public GLArrayData addFixedSubArray(int index, int comps, int vboTarget) {
if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
final int iOffC = interleavedOffset / getComponentSizeInBytes();
throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
@@ -209,15 +234,33 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed(
index, comps, getComponentType(),
getNormalized(), getStride(), getBuffer(),
- getVBOName(), interleavedOffset, getVBOUsage());
+ getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
ad.setVBOEnabled(isVBO());
interleavedOffset += comps * getComponentSizeInBytes();
- GLArrayHandler handler = new GLFixedArrayHandlerFlat(ad);
- glArrayHandler.addSubHandler(handler);
+ if(GL.GL_ARRAY_BUFFER == vboTarget) {
+ GLArrayHandler handler = new GLFixedArrayHandlerFlat(ad);
+ glArrayHandler.addSubHandler(handler);
+ }
return ad;
}
- public GLArrayData addGLSLSubArray(ShaderState st, String name, int comps) {
+ /**
+ * Configure a segment of this interleaved array (see {@link #createInterleaved(int, int, boolean, int, int)})
+ * for GLSL usage.
+ * <p>
+ * This method may be called several times as long the sum of interleaved components does not
+ * exceed the total number of components of the created interleaved array.</p>
+ * <p>
+ * The memory of the the interleaved array is being used.</p>
+ * <p>
+ * Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, .. </p>
+ *
+ * @param st The ShaderState managing the state of the used shader program, vertex attributes and uniforms
+ * @param name The custom name for the GL attribute, maybe null if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ * @param comps This interleaved array segment's component number
+ * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ */
+ public GLArrayData addGLSLSubArray(ShaderState st, String name, int comps, int vboTarget) {
if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
final int iOffC = interleavedOffset / getComponentSizeInBytes();
throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
@@ -225,11 +268,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
name, comps, getComponentType(),
getNormalized(), getStride(), getBuffer(),
- getVBOName(), interleavedOffset, getVBOUsage());
+ getVBOName(), interleavedOffset, getVBOUsage(), vboTarget);
ad.setVBOEnabled(isVBO());
interleavedOffset += comps * getComponentSizeInBytes();
- GLArrayHandler handler = new GLSLArrayHandlerFlat(st, ad);
- glArrayHandler.addSubHandler(handler);
+ if(GL.GL_ARRAY_BUFFER == vboTarget) {
+ GLArrayHandler handler = new GLSLArrayHandlerFlat(st, ad);
+ glArrayHandler.addSubHandler(handler);
+ }
return ad;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
index da841afca..3cfb56bf4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
@@ -22,19 +22,19 @@ public class GLArrayDataWrapper implements GLArrayData {
* @param vboName
* @param vboOffset
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
- *
+ * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
* @return the new create instance
*
* @throws GLException
*/
public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride,
Buffer buffer, int vboName,
- long vboOffset, int vboUsage)
+ long vboOffset, int vboUsage, int vboTarget)
throws GLException
{
GLArrayDataWrapper adc = new GLArrayDataWrapper();
adc.init(null, index, comps, dataType, normalized, stride, buffer, false,
- vboName, vboOffset, vboUsage, GL.GL_ARRAY_BUFFER);
+ vboName, vboOffset, vboUsage, vboTarget);
return adc;
}
@@ -50,18 +50,18 @@ public class GLArrayDataWrapper implements GLArrayData {
* @param vboName
* @param vboOffset
* @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
- *
+ * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
* @return the new create instance
* @throws GLException
*/
public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride,
Buffer buffer, int vboName,
- long vboOffset, int vboUsage)
+ long vboOffset, int vboUsage, int vboTarget)
throws GLException
{
GLArrayDataWrapper adc = new GLArrayDataWrapper();
adc.init(name, -1, comps, dataType, normalized, stride, buffer, true,
- vboName, vboOffset, vboUsage, GL.GL_ARRAY_BUFFER);
+ vboName, vboOffset, vboUsage, vboTarget);
return adc;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
index 96f4cef92..681cf7c36 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java
@@ -863,25 +863,25 @@ public class ImmModeSink {
if(vComps>0) {
vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, vDataType, false, 0,
- vertexArray, 0, vOffset, GL.GL_STATIC_DRAW);
+ vertexArray, 0, vOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
} else {
vArrayData = null;
}
if(cComps>0) {
cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, cDataType, false, 0,
- colorArray, 0, cOffset, GL.GL_STATIC_DRAW);
+ colorArray, 0, cOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
} else {
cArrayData = null;
}
if(nComps>0) {
nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, nDataType, false, 0,
- normalArray, 0, nOffset, GL.GL_STATIC_DRAW);
+ normalArray, 0, nOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
} else {
nArrayData = null;
}
if(tComps>0) {
tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, tDataType, false, 0,
- textCoordArray, 0, tOffset, GL.GL_STATIC_DRAW);
+ textCoordArray, 0, tOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
} else {
tArrayData = null;
}