public class GLArrayDataWrapper extends Object implements GLArrayData
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
Constructor and Description |
---|
GLArrayDataWrapper(GLArrayDataWrapper src)
Copy Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
associate(Object obj,
boolean enable)
Implementation and type dependent object association.
|
static GLArrayDataWrapper |
createFixed(int index,
int comps,
int dataType,
boolean normalized,
int stride,
Buffer buffer,
int vboName,
long vboOffset,
int vboUsage,
int vboTarget)
Create a VBO, using a predefined fixed function array index, wrapping the given data.
|
static GLArrayDataWrapper |
createFixed(int index,
int comps,
int dataType,
boolean normalized,
int stride,
int mappedElementCount,
int vboName,
long vboOffset,
int vboUsage,
int vboTarget)
Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.
|
static GLArrayDataWrapper |
createGLSL(String name,
int comps,
int dataType,
boolean normalized,
int stride,
Buffer buffer,
int vboName,
long vboOffset,
int vboUsage,
int vboTarget)
Create a VBO, using a custom GLSL array attribute name, wrapping the given data.
|
static GLArrayDataWrapper |
createGLSL(String name,
int comps,
int dataType,
boolean normalized,
int stride,
int mappedElementCount,
int vboName,
long vboOffset,
int vboUsage,
int vboTarget)
Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.
|
void |
destroy(GL gl) |
Buffer |
getBuffer()
The Buffer holding the data, may be null if a GPU buffer without client bound data
|
Class<?> |
getBufferClass() |
static Class<?> |
getBufferClass(int dataType) |
int |
getComponentCount()
The number of components per element
|
int |
getComponentSizeInBytes()
The component's size in bytes
|
int |
getComponentType()
The component's GL data type, ie.
|
int |
getElementCount()
The current number of used elements.
|
int |
getIndex()
The index of the predefined array index, see list below,
or -1 in case of a shader attribute array.
|
int |
getLocation()
Returns the shader attribute location for this name,
-1 if not yet determined
|
String |
getName()
The name of the reflecting shader array attribute.
|
boolean |
getNormalized()
True, if GL shall normalize fixed point data while converting
them into float.
|
int |
getSizeInBytes()
The currently used size in bytes.
In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position. |
int |
getStride() |
int |
getVBOName()
The VBO name or 0 if not a VBO
|
long |
getVBOOffset()
The VBO buffer offset or 0 if not a VBO
|
int |
getVBOTarget()
The VBO target or 0 if not a VBO
|
int |
getVBOUsage()
The VBO usage or 0 if not a VBO
|
boolean |
isVBO()
Determines whether the data is server side (VBO) and enabled,
or a client side array (false).
|
boolean |
isVertexAttribute()
Returns true if this data set is intended for a GLSL vertex shader attribute,
otherwise false, ie intended for fixed function vertex pointer
|
int |
setLocation(GL2ES2 gl,
int program)
Retrieves the location of the shader attribute from the linked shader program.
|
int |
setLocation(GL2ES2 gl,
int program,
int location)
Binds the location of the shader attribute to the given location for the unlinked shader program.
|
int |
setLocation(int v)
Sets the given location of the shader attribute
|
void |
setName(String newName)
Set a new name for this array.
|
void |
setVBOEnabled(boolean vboEnabled)
Enable or disable use of VBO.
|
void |
setVBOName(int vboName)
Set the VBO buffer name, if valid (!= 0) enable use of VBO,
otherwise (==0) disable VBO usage.
|
void |
setVBOTarget(int vboTarget) |
void |
setVBOUsage(int vboUsage) |
String |
toString() |
boolean |
validate(GLProfile glp,
boolean throwException)
Validates this instance's parameter.
|
public GLArrayDataWrapper(GLArrayDataWrapper src)
Buffer is sliced
, i.e. sharing content but using own state.
All other values are simply copied.
public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException
index
- The GL array indexcomps
- The array component numberdataType
- The array index GL data typenormalized
- Whether the data shall be normalizedstride
- buffer
- the user define datavboName
- vboOffset
- vboUsage
- GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
vboTarget
- GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
GLException
public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException
index
- The GL array indexcomps
- The array component numberdataType
- The array index GL data typenormalized
- Whether the data shall be normalizedstride
- mappedElementCount
- vboName
- vboOffset
- vboUsage
- GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
vboTarget
- GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
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) throws GLException
name
- The custom name for the GL attribute, maybe null if gpuBufferTarget is GL.GL_ELEMENT_ARRAY_BUFFER
comps
- The array component numberdataType
- The array index GL data typenormalized
- Whether the data shall be normalizedstride
- buffer
- the user define datavboName
- vboOffset
- vboUsage
- GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
vboTarget
- GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
GLException
public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException
name
- The custom name for the GL attribute, maybe null if gpuBufferTarget is GL.GL_ELEMENT_ARRAY_BUFFER
comps
- The array component numberdataType
- The array index GL data typenormalized
- Whether the data shall be normalizedstride
- mappedElementCount
- vboName
- vboOffset
- vboUsage
- GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
vboTarget
- GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
GLException
public final boolean validate(GLProfile glp, boolean throwException)
GLArrayDataClient
and GLArrayDataServer
.
GLArrayDataWrapper
does not validate it's instance by itself.glp
- the GLProfile to usethrowException
- whether to throw an exception if this instance has invalid parameter or notpublic void associate(Object obj, boolean enable)
GLArrayData
One currently known use case is to associate a ShaderState
to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's
data persistence, location and state change.
This is implicitly done via shaderState.ownAttribute(GLArrayData, boolean)
.
associate
in interface GLArrayData
obj
- implementation and type dependent associationenable
- pass true to enable the association and false to disable it.public final boolean isVertexAttribute()
GLArrayData
isVertexAttribute
in interface GLArrayData
public final int getIndex()
GLArrayData
getIndex
in interface GLArrayData
GLPointerFunc.GL_VERTEX_ARRAY
,
GLPointerFunc.GL_NORMAL_ARRAY
,
GLPointerFunc.GL_COLOR_ARRAY
,
GLPointerFunc.GL_TEXTURE_COORD_ARRAY
public final int getLocation()
GLArrayData
getLocation
in interface GLArrayData
public final int setLocation(int v)
GLArrayData
setLocation
in interface GLArrayData
ShaderState.vertexAttribPointer(GL2ES2, GLArrayData)
public final int setLocation(GL2ES2 gl, int program)
GLArrayData
No validation is performed within the implementation.
setLocation
in interface GLArrayData
public final int setLocation(GL2ES2 gl, int program, int location)
GLArrayData
No validation is performed within the implementation.
setLocation
in interface GLArrayData
public final String getName()
GLArrayData
getName
in interface GLArrayData
public final long getVBOOffset()
GLArrayData
getVBOOffset
in interface GLArrayData
public final int getVBOName()
GLArrayData
getVBOName
in interface GLArrayData
public final boolean isVBO()
GLArrayData
isVBO
in interface GLArrayData
public final int getVBOUsage()
GLArrayData
getVBOUsage
in interface GLArrayData
GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
public final int getVBOTarget()
GLArrayData
getVBOTarget
in interface GLArrayData
GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
public Buffer getBuffer()
GLArrayData
getBuffer
in interface GLArrayData
public final int getComponentCount()
GLArrayData
getComponentCount
in interface GLArrayData
public final int getComponentType()
GLArrayData
getComponentType
in interface GLArrayData
public final int getComponentSizeInBytes()
GLArrayData
getComponentSizeInBytes
in interface GLArrayData
public final int getElementCount()
GLArrayData
On element consist out of GLArrayData.getComponentCount()
components.
getElementCount
in interface GLArrayData
public final int getSizeInBytes()
GLArrayData
getSizeInBytes
in interface GLArrayData
public final boolean getNormalized()
GLArrayData
Default behavior (of the fixed function pipeline) is true
for fixed point data type and false
for floating point data types.
getNormalized
in interface GLArrayData
public final int getStride()
getStride
in interface GLArrayData
public final Class<?> getBufferClass()
public void destroy(GL gl)
destroy
in interface GLArrayData
public String toString()
toString
in interface GLArrayData
toString
in class Object
public static final Class<?> getBufferClass(int dataType)
public void setName(String newName)
GLArrayData
This clears the location, i.e. sets it to -1.
setName
in interface GLArrayData
GLArrayData.setLocation(int)
,
GLArrayData.setLocation(GL2ES2, int)
public void setVBOEnabled(boolean vboEnabled)
setVBOName(int)
public void setVBOName(int vboName)
setVBOEnabled(boolean)
public void setVBOUsage(int vboUsage)
vboUsage
- GL2ES2.GL_STREAM_DRAW
, GL.GL_STATIC_DRAW
or GL.GL_DYNAMIC_DRAW
public void setVBOTarget(int vboTarget)
vboTarget
- either GL.GL_ARRAY_BUFFER
or GL.GL_ELEMENT_ARRAY_BUFFER
Copyright 2010 JogAmp Community.