com.neovisionaries.android.opengl
Class Attribute

java.lang.Object
  extended by com.neovisionaries.android.opengl.Attribute

public class Attribute
extends Object

OpenGL ES vertex attribute.

 // E X A M P L E   1

 // Create an Attribute instance of the vertex array at
 // the index '0'.
 Attribute attr = new Attribute(0);

 // Set a constant value (1.0f, 0.0f, 0.0f, 1.0f).
 // As a side effect, the vertex array for the index '0'
 // is disabled by glDisableVertexAttribArray() because
 // otherwise the data set here will not take effect.
 attr.set(1.0f, 0.0f, 0.0f, 1.0f);

 // Get a shader program instance from somewhere.
 Program program = ...;

 // Feed data to the attribute variable 'a_color'.
 program.setAttribute("a_color", attr);
 
 // E X A M P L E   2

 // Prepare position data in the form of (x0, y0, z0),
 // (x1, y1, z1), (x2, y2, z2), ...
 FloatBuffer positions = ...;

 // Get a shader program instance from somewhere.
 Program program = ...;

 // Get an Attribute instance for an attribute variable
 // named 'a_position'.
 Attribute attr = program.getAttribute("a_position");

 // Feed data to the attribute variable. As side effects,
 // the vertex array for the index of the attribute is enabled
 // by glEnableVertexAttribArray() and the vertex array buffer
 // is unbound by calling glBindBuffer(GL_ARRAY_BUFFER, 0)
 // because otherwise the data set here will not take effect.
 attr.setArray3(positions);
 
 // E X A M P L E   3

 // Prepare position data in the form of (x0, y0, z0),
 // (x1, y1, z1), (x2, y2, z2), ...
 FloatBuffer positions = ...;

 // Store the position data to the vertex array buffer.
 ArrayBuffer ab = new ArrayBuffer();
 ab.setData(positions);

 // Get an Attribute instance from somewhere.
 Attribute attr = ...;

 // Make the Attribute instance use the vertex array buffer.
 // As side effects, the vertex array for the index of the
 // attribute is enabled by glEnableVertexAttribArray() and
 // the vertex array buffer is bound by calling ab.bind()
 // which is equivalent to glBindBuffer(GL_ARRAY_BUFFER, ab.getId()).
 // 
 // Note that the method call below will throw UnsupportedOperationException
 // in Android 2.2 (API Level 8) because android.opengl.GLES20
 // class does not have glVertexAttribPointer() method whose
 // last argument is 'int offset' although it should have.
 attr.setArray3(ab);
 

Author:
Takahiko Kawasaki

Constructor Summary
Attribute(int index)
          A constructor with a vertex attribute index.
 
Method Summary
 int getIndex()
          Get the index of this vertex attribute.
 Attribute set(float x)
          Set a constant value to this vertex attribute by glVertexAttrib1f().
 Attribute set(float[] values)
          Set a constant value to this vertex attribute.
 Attribute set(FloatBuffer values)
          Set a constant value to this vertex attribute.
 Attribute set(float x, float y)
          Set a constant value to this vertex attribute by glVertexAttrib2f().
 Attribute set(float x, float y, float z)
          Set a constant value to this vertex attribute by glVertexAttrib3f().
 Attribute set(float x, float y, float z, float w)
          Set a constant value to this vertex attribute by glVertexAttrib4f().
 Attribute set1(float[] values)
          This method is an alias of set1(values, 0).
 Attribute set1(float[] values, int offset)
          Set a constant value to this vertex attribute by glVertexAttrib1fv().
 Attribute set1(FloatBuffer values)
          Set a constant value to this vertex attribute by glVertexAttrib1fv().
 Attribute set2(float[] values)
          This method is an alias of set2(values, 0).
 Attribute set2(float[] values, int offset)
          Set a constant value to this vertex attribute by glVertexAttrib2fv().
 Attribute set2(FloatBuffer values)
          Set a constant value to this vertex attribute by glVertexAttrib2fv().
 Attribute set3(float[] values)
          This method is an alias of set3(values, 0).
 Attribute set3(float[] values, int offset)
          Set a constant value to this vertex attribute by glVertexAttrib3fv().
 Attribute set3(FloatBuffer values)
          Set a constant value to this vertex attribute by glVertexAttrib3fv().
 Attribute set4(float[] values)
          This method is an alias of set4(values, 0).
 Attribute set4(float[] values, int offset)
          Set a constant value to this vertex attribute by glVertexAttrib4fv().
 Attribute set4(FloatBuffer values)
          Set a constant value to this vertex attribute by glVertexAttrib4fv().
 Attribute setArray(ArrayBuffer values, AttrDataSize size)
          This method is an alias of setArray(values, size, null, false, 0, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, AttrDataType type)
          This method is an alias of setArray(values, size, type, false, 0, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, size, type, normalized, 0, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, size, type, normalized, stride, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride, int offset)
          Set a vertex array to this vertex attribute by glVertexAttribPointer().
 Attribute setArray(ArrayBuffer values, AttrDataSize size, boolean normalized)
          This method is an alias of setArray(values, size, null, normalized, 0, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, boolean normalized, int stride)
          This method is an alias of setArray(values, size, null, normalized, stride, 0).
 Attribute setArray(ArrayBuffer values, AttrDataSize size, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, size, null, normalized, stride, 0).
 Attribute setArray(Buffer values, AttrDataSize size, AttrDataType type)
          This method is an alias of setArray(values, size, type, false, 0).
 Attribute setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, size, type, normalized, 0).
 Attribute setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)
          Set a vertex array to this vertex attribute by glVertexAttribPointer().
 Attribute setArray(FloatBuffer values, AttrDataSize size)
          This method is an alias of setArray(values, size, AttrDataType.FLOAT, false, 0).
 Attribute setArray(FloatBuffer values, AttrDataSize size, int stride)
          This method is an alias of setArray(values, size, AttrDataType.FLOAT, false, stride).
 Attribute setArray1(ArrayBuffer values)
          This method is an alias of setArray(values, AttrDataSize.ONE, null, false, 0, 0).
 Attribute setArray1(ArrayBuffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, false, 0, 0).
 Attribute setArray1(ArrayBuffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, 0, 0).
 Attribute setArray1(ArrayBuffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride, 0).
 Attribute setArray1(ArrayBuffer values, AttrDataType type, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride, offset).
 Attribute setArray1(ArrayBuffer values, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, 0, 0).
 Attribute setArray1(ArrayBuffer values, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, stride, 0).
 Attribute setArray1(ArrayBuffer values, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, stride, offset).
 Attribute setArray1(Buffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, false, 0).
 Attribute setArray1(Buffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, 0).
 Attribute setArray1(Buffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride).
 Attribute setArray1(FloatBuffer values)
          This method is an alias of setArray(values, AttrDataSize.ONE, AttrDataType.FLOAT, false, 0).
 Attribute setArray1(FloatBuffer values, int stride)
          This method is an alias of setArray(values, AttrDataSize.ONE, AttrDataType.FLOAT, false, stride).
 Attribute setArray2(ArrayBuffer values)
          This method is an alias of setArray(values, AttrDataSize.TWO, null, false, 0, 0).
 Attribute setArray2(ArrayBuffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, false, 0, 0).
 Attribute setArray2(ArrayBuffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, 0, 0).
 Attribute setArray2(ArrayBuffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride, 0).
 Attribute setArray2(ArrayBuffer values, AttrDataType type, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride, offset).
 Attribute setArray2(ArrayBuffer values, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, 0, 0).
 Attribute setArray2(ArrayBuffer values, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, stride, 0).
 Attribute setArray2(ArrayBuffer values, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, stride, offset).
 Attribute setArray2(Buffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, false, 0).
 Attribute setArray2(Buffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, 0).
 Attribute setArray2(Buffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride).
 Attribute setArray2(FloatBuffer values)
          This method is an alias of setArray(values, AttrDataSize.TWO, AttrDataType.FLOAT, false, 0).
 Attribute setArray2(FloatBuffer values, int stride)
          This method is an alias of setArray(values, AttrDataSize.TWO, AttrDataType.FLOAT, false, stride).
 Attribute setArray3(ArrayBuffer values)
          This method is an alias of setArray(values, AttrDataSize.THREE, null, false, 0, 0).
 Attribute setArray3(ArrayBuffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, false, 0, 0).
 Attribute setArray3(ArrayBuffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, 0, 0).
 Attribute setArray3(ArrayBuffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride, 0).
 Attribute setArray3(ArrayBuffer values, AttrDataType type, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride, offset).
 Attribute setArray3(ArrayBuffer values, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, 0, 0).
 Attribute setArray3(ArrayBuffer values, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, stride, 0).
 Attribute setArray3(ArrayBuffer values, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, stride, offset).
 Attribute setArray3(Buffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, false, 0).
 Attribute setArray3(Buffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, 0).
 Attribute setArray3(Buffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride).
 Attribute setArray3(FloatBuffer values)
          This method is an alias of setArray(values, AttrDataSize.THREE, AttrDataType.FLOAT, false, 0).
 Attribute setArray3(FloatBuffer values, int stride)
          This method is an alias of setArray(values, AttrDataSize.THREE, AttrDataType.FLOAT, false, stride).
 Attribute setArray4(ArrayBuffer values)
          This method is an alias of setArray(values, AttrDataSize.FOUR, null, false, 0, 0).
 Attribute setArray4(ArrayBuffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, false, 0, 0).
 Attribute setArray4(ArrayBuffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, 0, 0).
 Attribute setArray4(ArrayBuffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride, 0).
 Attribute setArray4(ArrayBuffer values, AttrDataType type, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride, offset).
 Attribute setArray4(ArrayBuffer values, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, 0, 0).
 Attribute setArray4(ArrayBuffer values, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, stride, 0).
 Attribute setArray4(ArrayBuffer values, boolean normalized, int stride, int offset)
          This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, stride, offset).
 Attribute setArray4(Buffer values, AttrDataType type)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, false, 0).
 Attribute setArray4(Buffer values, AttrDataType type, boolean normalized)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, 0).
 Attribute setArray4(Buffer values, AttrDataType type, boolean normalized, int stride)
          This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride).
 Attribute setArray4(FloatBuffer values)
          This method is an alias of setArray(values, AttrDataSize.FOUR, AttrDataType.FLOAT, false, 0).
 Attribute setArray4(FloatBuffer values, int stride)
          This method is an alias of setArray(values, AttrDataSize.FOUR, AttrDataType.FLOAT, false, stride).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(int index)
A constructor with a vertex attribute index.

Parameters:
index - A vertex attribute index.
Method Detail

getIndex

public int getIndex()
Get the index of this vertex attribute.

Returns:
The index of this vertex attribute.

set

public Attribute set(float x)
Set a constant value to this vertex attribute by glVertexAttrib1f(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
x -
Returns:
This Attribute object.
See Also:
glVertexAttrib1f, glDisableVertexAttribArray

set

public Attribute set(float x,
                     float y)
Set a constant value to this vertex attribute by glVertexAttrib2f(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
x -
y -
Returns:
This Attribute object.
See Also:
glVertexAttrib2f, glDisableVertexAttribArray

set

public Attribute set(float x,
                     float y,
                     float z)
Set a constant value to this vertex attribute by glVertexAttrib3f(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
x -
y -
z -
Returns:
This Attribute object.
See Also:
glVertexAttrib3f, glDisableVertexAttribArray

set

public Attribute set(float x,
                     float y,
                     float z,
                     float w)
Set a constant value to this vertex attribute by glVertexAttrib4f(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
x -
y -
z -
w -
Returns:
This Attribute object.
See Also:
glVertexAttrib4f, glDisableVertexAttribArray

set1

public Attribute set1(float[] values,
                      int offset)
Set a constant value to this vertex attribute by glVertexAttrib1fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
offset -
Returns:
This Attribute object.
See Also:
glVertexAttrib1fv, glDisableVertexAttribArray

set1

public Attribute set1(float[] values)
This method is an alias of set1(values, 0).

Parameters:
values -
Returns:
This Attribute object.
See Also:
set1(float[], int)

set1

public Attribute set1(FloatBuffer values)
Set a constant value to this vertex attribute by glVertexAttrib1fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
Returns:
This Attribute object.
See Also:
glVertexAttrib1fv, glDisableVertexAttribArray

set2

public Attribute set2(float[] values,
                      int offset)
Set a constant value to this vertex attribute by glVertexAttrib2fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
offset -
Returns:
This Attribute object.
See Also:
glVertexAttrib2fv, glDisableVertexAttribArray

set2

public Attribute set2(float[] values)
This method is an alias of set2(values, 0).

Parameters:
values -
Returns:
This Attribute object.
See Also:
set2(float[], int)

set2

public Attribute set2(FloatBuffer values)
Set a constant value to this vertex attribute by glVertexAttrib2fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
Returns:
This Attribute object.
See Also:
glVertexAttrib2fv, glDisableVertexAttribArray

set3

public Attribute set3(float[] values,
                      int offset)
Set a constant value to this vertex attribute by glVertexAttrib3fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
offset -
Returns:
This Attribute object.
See Also:
glVertexAttrib3fv, glDisableVertexAttribArray

set3

public Attribute set3(float[] values)
This method is an alias of set3(values, 0).

Parameters:
values -
Returns:
This Attribute object.
See Also:
set3(float[], int)

set3

public Attribute set3(FloatBuffer values)
Set a constant value to this vertex attribute by glVertexAttrib3fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
Returns:
This Attribute object.
See Also:
glVertexAttrib3fv, glDisableVertexAttribArray

set4

public Attribute set4(float[] values,
                      int offset)
Set a constant value to this vertex attribute by glVertexAttrib4fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
offset -
Returns:
This Attribute object.
See Also:
glVertexAttrib4fv, glDisableVertexAttribArray

set4

public Attribute set4(float[] values)
This method is an alias of set4(values, 0).

Parameters:
values -
Returns:
This Attribute object.
See Also:
set4(float[], int)

set4

public Attribute set4(FloatBuffer values)
Set a constant value to this vertex attribute by glVertexAttrib4fv(). As a side effect, the vertex array is disabled by glDisableVertexAttribArray().

Parameters:
values -
Returns:
This Attribute object.
See Also:
glVertexAttrib4fv, glDisableVertexAttribArray

set

public Attribute set(float[] values)
Set a constant value to this vertex attribute. This method calls another setter method depending on the size of the given values. The following table shows pairs of size and method.

values.length Method to call
1 set1(values)
2 set2(values)
3 set3(values)
4 set4(values)

Parameters:
values -
Returns:
This Attribute object.
Throws:
IllegalArgumentException - The argument is null, or its length is none of the ones listed in the above table.

set

public Attribute set(FloatBuffer values)
Set a constant value to this vertex attribute. This method calls another setter method depending on the number of the remaining elements in the given values. The following table shows pairs of number and method.

values.remaining() Method to call
1 set1(values)
2 set2(values)
3 set3(values)
4 set4(values)

Parameters:
values -
Returns:
This Attribute object.
Throws:
IllegalArgumentException - The argument is null, or its length is none of the ones listed in the above table.

setArray

public Attribute setArray(Buffer values,
                          AttrDataSize size,
                          AttrDataType type,
                          boolean normalized,
                          int stride)
Set a vertex array to this vertex attribute by glVertexAttribPointer(). Below are important side effects that are necessary to make the given 'value' take effect.
  1. The vertex array buffer is unbound by calling glBindBuffer(GL_ARRAY_BUFFER, 0).
  2. The vertex array for the index of this vertex attribute is enabled by glEnableVertexAttribArray().

Parameters:
values - Data to set to this vertex attribute.
size - The number of elements per one set of data. From ONE to FOUR.
type - The type of the data. Possible values are BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, FLOAT and FIXED. Null can be given only when 'values' is an instance of FloatBuffer, and in the case, AttrDataType.FLOAT is used.
normalized - True to normalize data when they are used. This parameter does not take any effect if 'type' is AttrDataType.FLOAT.
stride - The number of elements between the start of one data set and the start of the next data set. Note that the unit is not 'bytes'. The size (in bytes) that is passed to the underlying glVertexAttribPointer() implementation is calculated in this method based on the actual type of the given 'values'. For example, if the actual type of 'values' is FloatBuffer, (stride * 4) is passed to glVertexAttribPointer().
Returns:
This Attribute object.
Throws:
IllegalArgumentException - 'values', 'size', or 'type' is null. Or 'stride' is less than 0. Note that, however, if 'values' is an instance of FloatBuffer, 'type' can be null.
See Also:
glVertexAttribPointer, glEnableVertexAttribArray, glBindBuffer

setArray

public Attribute setArray(Buffer values,
                          AttrDataSize size,
                          AttrDataType type,
                          boolean normalized)
This method is an alias of setArray(values, size, type, normalized, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray

public Attribute setArray(Buffer values,
                          AttrDataSize size,
                          AttrDataType type)
This method is an alias of setArray(values, size, type, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray1

public Attribute setArray1(Buffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray1

public Attribute setArray1(Buffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray1

public Attribute setArray1(Buffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.ONE, type, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray2

public Attribute setArray2(Buffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray2

public Attribute setArray2(Buffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray2

public Attribute setArray2(Buffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.TWO, type, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray3

public Attribute setArray3(Buffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray3

public Attribute setArray3(Buffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray3

public Attribute setArray3(Buffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.THREE, type, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray4

public Attribute setArray4(Buffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray4

public Attribute setArray4(Buffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray4

public Attribute setArray4(Buffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray

public Attribute setArray(FloatBuffer values,
                          AttrDataSize size,
                          int stride)
This method is an alias of setArray(values, size, AttrDataType.FLOAT, false, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray

public Attribute setArray(FloatBuffer values,
                          AttrDataSize size)
This method is an alias of setArray(values, size, AttrDataType.FLOAT, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray1

public Attribute setArray1(FloatBuffer values,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.ONE, AttrDataType.FLOAT, false, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray1

public Attribute setArray1(FloatBuffer values)
This method is an alias of setArray(values, AttrDataSize.ONE, AttrDataType.FLOAT, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray2

public Attribute setArray2(FloatBuffer values,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.TWO, AttrDataType.FLOAT, false, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray2

public Attribute setArray2(FloatBuffer values)
This method is an alias of setArray(values, AttrDataSize.TWO, AttrDataType.FLOAT, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray3

public Attribute setArray3(FloatBuffer values,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.THREE, AttrDataType.FLOAT, false, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray3

public Attribute setArray3(FloatBuffer values)
This method is an alias of setArray(values, AttrDataSize.THREE, AttrDataType.FLOAT, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray4

public Attribute setArray4(FloatBuffer values,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.FOUR, AttrDataType.FLOAT, false, stride).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray4

public Attribute setArray4(FloatBuffer values)
This method is an alias of setArray(values, AttrDataSize.FOUR, AttrDataType.FLOAT, false, 0).

Returns:
This Attribute object.
See Also:
setArray(Buffer values, AttrDataSize size, AttrDataType type, boolean normalized, int stride)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          AttrDataType type,
                          boolean normalized,
                          int stride,
                          int offset)
Set a vertex array to this vertex attribute by glVertexAttribPointer(). Below are important side effects that are necessary to make the given 'value' take effect.
  1. The vertex array buffer is bound by calling bind() method of the given 'values'. This has the same effect as glBindBuffer(GL_ARRAY_BUFFER, values.VertexBuffer.getId()).
  2. The vertex array for the index of this vertex attribute is enabled by glEnableVertexAttribArray().

Important Note: This method will throw an UnsupportedOperationException in Android 2.2 (API Level 8). It is because android.opengl.GLES20 class does not have glVertexAttribPointer() method whose last parameter is 'int offset' although it should have.

Parameters:
values - Data to set to this vertex attribute.
size - The number of elements per one set of data. From ONE to FOUR.
type - The type of the data. Possible values are BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, FLOAT and FIXED. Null can be given only when data held by 'values' is a float array, and in the case, AttrDataType.FLOAT is used.
normalized - True to normalize data when they are used. This parameter does not take any effect if 'type' is AttrDataType.FLOAT.
stride - The number of elements between the start of one data set and the start of the next data set. Note that the unit is not 'bytes'. The size (in bytes) that is passed to the underlying glVertexAttribPointer() implementation is calculated in this method based on the actual type of the data that has been set to 'values' in advance by setData() method of 'values'. For example, if a FloatBuffer instance has been set by calling values.setData(data), in advance, (stride * 4) is passed to glVertexAttribPointer() in the implementation of this setArray method. To private necessary information for this caluculation, VertexBuffer class remembers the class type of the given data every time setData() method is called.
offset - Data offset in 'values'.
Returns:
This Attribute object.
Throws:
IllegalArgumentException - 'values', 'size', or 'type' is null. Or 'stride' is less than 0. Note that, however, if data held by 'values' is a float array, 'type' can be null.
See Also:
glVertexAttribPointer, glEnableVertexAttribArray, glBindBuffer

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          boolean normalized,
                          int stride,
                          int offset)
This method is an alias of setArray(values, size, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
size -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          AttrDataType type,
                          boolean normalized,
                          int stride)
This method is an alias of setArray(values, size, type, normalized, stride, 0).

Parameters:
values -
size -
type -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          boolean normalized,
                          int stride)
This method is an alias of setArray(values, size, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
size -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          AttrDataType type,
                          boolean normalized)
This method is an alias of setArray(values, size, type, normalized, 0, 0).

Parameters:
values -
size -
type -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          boolean normalized)
This method is an alias of setArray(values, size, null, normalized, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
size -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size,
                          AttrDataType type)
This method is an alias of setArray(values, size, type, false, 0, 0).

Parameters:
values -
size -
type -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray

public Attribute setArray(ArrayBuffer values,
                          AttrDataSize size)
This method is an alias of setArray(values, size, null, false, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
size -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride, offset).

Parameters:
values -
type -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, stride, offset).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, stride, 0).

Parameters:
values -
type -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.ONE, type, normalized, 0, 0).

Parameters:
values -
type -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.ONE, null, normalized, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.ONE, type, false, 0, 0).

Parameters:
values -
type -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray1

public Attribute setArray1(ArrayBuffer values)
This method is an alias of setArray(values, AttrDataSize.ONE, null, false, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride, offset).

Parameters:
values -
type -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, stride, offset).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, stride, 0).

Parameters:
values -
type -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.TWO, type, normalized, 0, 0).

Parameters:
values -
type -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.TWO, null, normalized, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.TWO, type, false, 0, 0).

Parameters:
values -
type -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray2

public Attribute setArray2(ArrayBuffer values)
This method is an alias of setArray(values, AttrDataSize.TWO, null, false, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride, offset).

Parameters:
values -
type -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, stride, offset).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, stride, 0).

Parameters:
values -
type -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.THREE, type, normalized, 0, 0).

Parameters:
values -
type -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.THREE, null, normalized, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.THREE, type, false, 0, 0).

Parameters:
values -
type -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray3

public Attribute setArray3(ArrayBuffer values)
This method is an alias of setArray(values, AttrDataSize.THREE, null, false, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride, offset).

Parameters:
values -
type -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           boolean normalized,
                           int stride,
                           int offset)
This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, stride, offset).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
offset -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, stride, 0).

Parameters:
values -
type -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           boolean normalized,
                           int stride)
This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, stride, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
stride -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           AttrDataType type,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, normalized, 0, 0).

Parameters:
values -
type -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           boolean normalized)
This method is an alias of setArray(values, AttrDataSize.FOUR, null, normalized, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
normalized -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values,
                           AttrDataType type)
This method is an alias of setArray(values, AttrDataSize.FOUR, type, false, 0, 0).

Parameters:
values -
type -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)

setArray4

public Attribute setArray4(ArrayBuffer values)
This method is an alias of setArray(values, AttrDataSize.FOUR, null, false, 0, 0).

Note that data held by 'values' must be a float array. If not, other method variants having AttrDataType as an argument must be used.

Parameters:
values -
Returns:
This Attribute object.
See Also:
setArray(ArrayBuffer, AttrDataSize, AttrDataType, boolean, int, int)