Class GLArrayDataWrapper
- java.lang.Object
-
- com.jogamp.opengl.util.GLArrayDataWrapper
-
- All Implemented Interfaces:
GLArrayData
- Direct Known Subclasses:
GLArrayDataClient
public class GLArrayDataWrapper extends Object implements GLArrayData
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG
-
Constructor Summary
Constructors Constructor Description GLArrayDataWrapper(GLArrayDataWrapper src)Copy Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassociate(Object obj, boolean enable)Implementation and type dependent object association.intbytePosition()Returns the bytes position.static GLArrayDataWrappercreateFixed(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 GLArrayDataWrappercreateFixed(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 GLArrayDataWrappercreateGLSL(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.static GLArrayDataWrappercreateGLSL(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.voiddestroy(GL gl)intelemPosition()Returns the element position.StringelemStatsToString()Returns a string with detailed buffer element stats, i.e.StringfillStatsToString()Returns a string with detailed buffer fill stats.BuffergetBuffer()The Buffer holding the data, may be null if a GPU buffer without client bound dataClass<?>getBufferClass()static Class<?>getBufferClass(int dataType)intgetByteCapacity()Return the capacity in bytes.intgetByteCount()Returns the byte position (written elements) if notGLArrayData.sealed()or the byte limit (available to read) afterGLArrayData.sealed()(flip).intgetBytesPerComp()The component's size in bytesintgetCompsPerElem()The number of components per elementintgetCompType()The component's GL data type, ie.intgetElemCapacity()Return the element capacity.intgetElemCount()Returns the element position (written elements) if notGLArrayData.sealed()or the element limit (available to read) afterGLArrayData.sealed()(flip).intgetIndex()The index of the predefined array index, see list below, or -1 in case of a shader attribute array.intgetLocation()Returns the shader attribute location for this name, -1 if not yet determinedStringgetName()The name of the reflecting shader array attribute.booleangetNormalized()True, if GL shall normalize fixed point data while converting them into float.intgetStride()intgetVBOName()The VBO name or 0 if not a VBOlonggetVBOOffset()The VBO buffer offset or 0 if not a VBOintgetVBOTarget()The VBO target or 0 if not a VBOintgetVBOUsage()The VBO usage or 0 if not a VBObooleanisVBO()Determines whether the data is server side (VBO) and enabled, or a client side array (false).booleanisVertexAttribute()Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointerintremainingBytes()The current number of remaining bytes.intremainingElems()The current number of remaining elements.booleansealed()Returns true if data has beensealed(flipped to read), otherwise false (writing mode).intsetLocation(int v)Sets the given location of the shader attributeintsetLocation(GL2ES2 gl, int program)Retrieves the location of the shader attribute from the linked shader program.intsetLocation(GL2ES2 gl, int program, int location)Binds the location of the shader attribute to the given location for the unlinked shader program.voidsetName(String newName)Set a new name for this array.voidsetVBOEnabled(boolean vboEnabled)Enable or disable use of VBO.voidsetVBOName(int vboName)Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.voidsetVBOTarget(int vboTarget)voidsetVBOUsage(int vboUsage)StringtoString()booleanvalidate(GLProfile glp, boolean throwException)Validates this instance's parameter.
-
-
-
Constructor Detail
-
GLArrayDataWrapper
public GLArrayDataWrapper(GLArrayDataWrapper src)
Copy ConstructorBuffer is
sliced, i.e. sharing content but using own state.All other values are simply copied.
-
-
Method Detail
-
createFixed
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
Create a VBO, using a predefined fixed function array index, wrapping the given data.This buffer is always
sealed().- Parameters:
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_DRAWorGL.GL_DYNAMIC_DRAWvboTarget-GL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER- Returns:
- the new create instance
- Throws:
GLException
-
createFixed
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
Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.This buffer is always
sealed().- Parameters:
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_DRAWorGL.GL_DYNAMIC_DRAWvboTarget-GL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER- Returns:
- the new create instance
- Throws:
GLException
-
createGLSL
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
Create a VBO, using a custom GLSL array attribute name, wrapping the given data.This buffer is always
sealed().- Parameters:
name- The custom name for the GL attribute, maybe null if gpuBufferTarget isGL.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_DRAWorGL.GL_DYNAMIC_DRAWvboTarget-GL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER- Returns:
- the new create instance
- Throws:
GLException
-
createGLSL
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
Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.This buffer is always
sealed().- Parameters:
name- The custom name for the GL attribute, maybe null if gpuBufferTarget isGL.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_DRAWorGL.GL_DYNAMIC_DRAWvboTarget-GL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER- Returns:
- the new create instance
- Throws:
GLException
-
validate
public final boolean validate(GLProfile glp, boolean throwException)
Validates this instance's parameter. Called automatically byGLArrayDataClientandGLArrayDataServer.GLArrayDataWrapperdoes not validate it's instance by itself.- Parameters:
glp- the GLProfile to usethrowException- whether to throw an exception if this instance has invalid parameter or not- Returns:
- true if this instance has invalid parameter, otherwise false
-
associate
public void associate(Object obj, boolean enable)
Description copied from interface:GLArrayDataImplementation and type dependent object association.One currently known use case is to associate a
ShaderStateto 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 viashaderState.ownAttribute(GLArrayData, boolean).- Specified by:
associatein interfaceGLArrayData- Parameters:
obj- implementation and type dependent associationenable- pass true to enable the association and false to disable it.
-
isVertexAttribute
public final boolean isVertexAttribute()
Description copied from interface:GLArrayDataReturns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointer- Specified by:
isVertexAttributein interfaceGLArrayData
-
getIndex
public final int getIndex()
Description copied from interface:GLArrayDataThe index of the predefined array index, see list below, or -1 in case of a shader attribute array.- Specified by:
getIndexin interfaceGLArrayData- See Also:
GLPointerFunc.GL_VERTEX_ARRAY,GLPointerFunc.GL_NORMAL_ARRAY,GLPointerFunc.GL_COLOR_ARRAY,GLPointerFunc.GL_TEXTURE_COORD_ARRAY
-
getLocation
public final int getLocation()
Description copied from interface:GLArrayDataReturns the shader attribute location for this name, -1 if not yet determined- Specified by:
getLocationin interfaceGLArrayData
-
setLocation
public final int setLocation(int v)
Description copied from interface:GLArrayDataSets the given location of the shader attribute- Specified by:
setLocationin interfaceGLArrayData- Returns:
- the given location
- See Also:
ShaderState.vertexAttribPointer(GL2ES2, GLArrayData)
-
setLocation
public final int setLocation(GL2ES2 gl, int program)
Description copied from interface:GLArrayDataRetrieves the location of the shader attribute from the linked shader program.No validation is performed within the implementation.
- Specified by:
setLocationin interfaceGLArrayData- Returns:
- ≥0 denotes a valid attribute location as found and used in the given shader program. <0 denotes an invalid location, i.e. not found or used in the given shader program.
-
setLocation
public final int setLocation(GL2ES2 gl, int program, int location)
Description copied from interface:GLArrayDataBinds the location of the shader attribute to the given location for the unlinked shader program.No validation is performed within the implementation.
- Specified by:
setLocationin interfaceGLArrayData- Returns:
- the given location
-
getName
public final String getName()
Description copied from interface:GLArrayDataThe name of the reflecting shader array attribute.- Specified by:
getNamein interfaceGLArrayData
-
getVBOOffset
public final long getVBOOffset()
Description copied from interface:GLArrayDataThe VBO buffer offset or 0 if not a VBO- Specified by:
getVBOOffsetin interfaceGLArrayData
-
getVBOName
public final int getVBOName()
Description copied from interface:GLArrayDataThe VBO name or 0 if not a VBO- Specified by:
getVBONamein interfaceGLArrayData
-
isVBO
public final boolean isVBO()
Description copied from interface:GLArrayDataDetermines whether the data is server side (VBO) and enabled, or a client side array (false).- Specified by:
isVBOin interfaceGLArrayData
-
getVBOUsage
public final int getVBOUsage()
Description copied from interface:GLArrayDataThe VBO usage or 0 if not a VBO- Specified by:
getVBOUsagein interfaceGLArrayData- Returns:
- 0 if not a GPU buffer, otherwise
GL2ES2.GL_STREAM_DRAW,GL.GL_STATIC_DRAWorGL.GL_DYNAMIC_DRAW
-
getVBOTarget
public final int getVBOTarget()
Description copied from interface:GLArrayDataThe VBO target or 0 if not a VBO- Specified by:
getVBOTargetin interfaceGLArrayData- Returns:
- 0 if not a GPU buffer, otherwise
GL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER
-
getBuffer
public Buffer getBuffer()
Description copied from interface:GLArrayDataThe Buffer holding the data, may be null if a GPU buffer without client bound data- Specified by:
getBufferin interfaceGLArrayData
-
getCompsPerElem
public final int getCompsPerElem()
Description copied from interface:GLArrayDataThe number of components per element- Specified by:
getCompsPerElemin interfaceGLArrayData
-
getCompType
public final int getCompType()
Description copied from interface:GLArrayDataThe component's GL data type, ie. GL_FLOAT- Specified by:
getCompTypein interfaceGLArrayData
-
getBytesPerComp
public final int getBytesPerComp()
Description copied from interface:GLArrayDataThe component's size in bytes- Specified by:
getBytesPerCompin interfaceGLArrayData
-
sealed
public final boolean sealed()
Description copied from interface:GLArrayDataReturns true if data has beensealed(flipped to read), otherwise false (writing mode).- Specified by:
sealedin interfaceGLArrayData- See Also:
GLArrayDataEditable.seal(boolean),GLArrayDataEditable.seal(GL, boolean)
-
getElemCount
public final int getElemCount()
Description copied from interface:GLArrayDataReturns the element position (written elements) if notGLArrayData.sealed()or the element limit (available to read) afterGLArrayData.sealed()(flip).On element consist out of
GLArrayData.getCompsPerElem()components.- Specified by:
getElemCountin interfaceGLArrayData- See Also:
GLArrayData.sealed(),GLArrayData.getByteCount(),GLArrayData.elemPosition(),GLArrayData.remainingElems(),GLArrayData.getElemCapacity()
-
elemPosition
public final int elemPosition()
Description copied from interface:GLArrayDataReturns the element position.On element consist out of
GLArrayData.getCompsPerElem()components.- Specified by:
elemPositionin interfaceGLArrayData- See Also:
GLArrayData.bytePosition(),GLArrayData.getElemCount(),GLArrayData.remainingElems(),GLArrayData.getElemCapacity()
-
remainingElems
public int remainingElems()
Description copied from interface:GLArrayDataThe current number of remaining elements.On element consist out of
Returns the number of elements between the current position and the limit, i.e. remaining elements to write in this buffer.GLArrayData.getCompsPerElem()components.- Specified by:
remainingElemsin interfaceGLArrayData- See Also:
GLArrayData.remainingBytes(),GLArrayData.getElemCount(),GLArrayData.elemPosition(),GLArrayData.getElemCapacity()
-
getElemCapacity
public int getElemCapacity()
Description copied from interface:GLArrayDataReturn the element capacity.On element consist out of
GLArrayData.getCompsPerElem()components.- Specified by:
getElemCapacityin interfaceGLArrayData- See Also:
GLArrayData.getByteCapacity(),GLArrayData.getElemCount(),GLArrayData.elemPosition(),GLArrayData.remainingElems()
-
getByteCount
public final int getByteCount()
Description copied from interface:GLArrayDataReturns the byte position (written elements) if notGLArrayData.sealed()or the byte limit (available to read) afterGLArrayData.sealed()(flip).- Specified by:
getByteCountin interfaceGLArrayData- See Also:
GLArrayData.sealed(),GLArrayData.getElemCount(),GLArrayData.bytePosition(),GLArrayData.remainingBytes(),GLArrayData.getByteCapacity()
-
bytePosition
public final int bytePosition()
Description copied from interface:GLArrayDataReturns the bytes position.- Specified by:
bytePositionin interfaceGLArrayData- See Also:
GLArrayData.elemPosition(),GLArrayData.getByteCount(),GLArrayData.remainingElems(),GLArrayData.getElemCapacity()
-
remainingBytes
public int remainingBytes()
Description copied from interface:GLArrayDataThe current number of remaining bytes.Returns the number of bytes between the current position and the limit, i.e. remaining bytes to write in this buffer.
- Specified by:
remainingBytesin interfaceGLArrayData- See Also:
GLArrayData.remainingElems(),GLArrayData.getByteCount(),GLArrayData.bytePosition(),GLArrayData.getByteCapacity()
-
getByteCapacity
public int getByteCapacity()
Description copied from interface:GLArrayDataReturn the capacity in bytes.- Specified by:
getByteCapacityin interfaceGLArrayData- See Also:
GLArrayData.getElemCapacity(),GLArrayData.getByteCount(),GLArrayData.bytePosition(),GLArrayData.remainingBytes()
-
fillStatsToString
public String fillStatsToString()
Description copied from interface:GLArrayDataReturns a string with detailed buffer fill stats.- Specified by:
fillStatsToStringin interfaceGLArrayData
-
elemStatsToString
public String elemStatsToString()
Description copied from interface:GLArrayDataReturns a string with detailed buffer element stats, i.e. sealed, count, position, remaining, limit and capacity.- Specified by:
elemStatsToStringin interfaceGLArrayData
-
getNormalized
public final boolean getNormalized()
Description copied from interface:GLArrayDataTrue, if GL shall normalize fixed point data while converting them into float.Default behavior (of the fixed function pipeline) is
truefor fixed point data type andfalsefor floating point data types.- Specified by:
getNormalizedin interfaceGLArrayData
-
getStride
public final int getStride()
- Specified by:
getStridein interfaceGLArrayData- Returns:
- the byte offset between consecutive components
-
getBufferClass
public final Class<?> getBufferClass()
-
destroy
public void destroy(GL gl)
- Specified by:
destroyin interfaceGLArrayData
-
toString
public String toString()
- Specified by:
toStringin interfaceGLArrayData- Overrides:
toStringin classObject
-
getBufferClass
public static final Class<?> getBufferClass(int dataType)
-
setName
public void setName(String newName)
Description copied from interface:GLArrayDataSet a new name for this array.This clears the location, i.e. sets it to -1.
- Specified by:
setNamein interfaceGLArrayData- See Also:
GLArrayData.setLocation(int),GLArrayData.setLocation(GL2ES2, int)
-
setVBOEnabled
public void setVBOEnabled(boolean vboEnabled)
Enable or disable use of VBO. Only possible if a VBO buffer name is defined.- See Also:
setVBOName(int)
-
setVBOName
public void setVBOName(int vboName)
Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.- See Also:
setVBOEnabled(boolean)
-
setVBOUsage
public void setVBOUsage(int vboUsage)
- Parameters:
vboUsage-GL2ES2.GL_STREAM_DRAW,GL.GL_STATIC_DRAWorGL.GL_DYNAMIC_DRAW
-
setVBOTarget
public void setVBOTarget(int vboTarget)
- Parameters:
vboTarget- eitherGL.GL_ARRAY_BUFFERorGL.GL_ELEMENT_ARRAY_BUFFER
-
-