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_DRAWvboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERGLExceptionpublic 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_DRAWvboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERGLExceptionpublic 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_BUFFERcomps - 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_DRAWvboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERGLExceptionpublic 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_BUFFERcomps - 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_DRAWvboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERGLExceptionpublic 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 GLArrayDataobj - implementation and type dependent associationenable - pass true to enable the association and false to disable it.public final boolean isVertexAttribute()
GLArrayDataisVertexAttribute in interface GLArrayDatapublic final int getIndex()
GLArrayDatagetIndex in interface GLArrayDataGLPointerFunc.GL_VERTEX_ARRAY,
GLPointerFunc.GL_NORMAL_ARRAY,
GLPointerFunc.GL_COLOR_ARRAY,
GLPointerFunc.GL_TEXTURE_COORD_ARRAYpublic final int getLocation()
GLArrayDatagetLocation in interface GLArrayDatapublic final int setLocation(int v)
GLArrayDatasetLocation in interface GLArrayDataShaderState.vertexAttribPointer(GL2ES2, GLArrayData)public final int setLocation(GL2ES2 gl, int program)
GLArrayDataNo validation is performed within the implementation.
setLocation in interface GLArrayDatapublic final int setLocation(GL2ES2 gl, int program, int location)
GLArrayDataNo validation is performed within the implementation.
setLocation in interface GLArrayDatapublic final String getName()
GLArrayDatagetName in interface GLArrayDatapublic final long getVBOOffset()
GLArrayDatagetVBOOffset in interface GLArrayDatapublic final int getVBOName()
GLArrayDatagetVBOName in interface GLArrayDatapublic final boolean isVBO()
GLArrayDataisVBO in interface GLArrayDatapublic final int getVBOUsage()
GLArrayDatagetVBOUsage in interface GLArrayDataGL2ES2.GL_STREAM_DRAW, GL.GL_STATIC_DRAW or GL.GL_DYNAMIC_DRAWpublic final int getVBOTarget()
GLArrayDatagetVBOTarget in interface GLArrayDataGL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERpublic Buffer getBuffer()
GLArrayDatagetBuffer in interface GLArrayDatapublic final int getComponentCount()
GLArrayDatagetComponentCount in interface GLArrayDatapublic final int getComponentType()
GLArrayDatagetComponentType in interface GLArrayDatapublic final int getComponentSizeInBytes()
GLArrayDatagetComponentSizeInBytes in interface GLArrayDatapublic final int getElementCount()
GLArrayData
On element consist out of GLArrayData.getComponentCount() components.
getElementCount in interface GLArrayDatapublic final int getSizeInBytes()
GLArrayDatagetSizeInBytes in interface GLArrayDatapublic 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 GLArrayDatapublic final int getStride()
getStride in interface GLArrayDatapublic final Class<?> getBufferClass()
public void destroy(GL gl)
destroy in interface GLArrayDatapublic String toString()
toString in interface GLArrayDatatoString in class Objectpublic static final Class<?> getBufferClass(int dataType)
public void setName(String newName)
GLArrayDataThis clears the location, i.e. sets it to -1.
setName in interface GLArrayDataGLArrayData.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_DRAWpublic void setVBOTarget(int vboTarget)
vboTarget - either GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFERCopyright 2010 JogAmp Community.