Top Fields Constructors Methods
com.jogamp.opengl.util

public Class GLArrayDataWrapper

extends Object
implements GLArrayData
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.GLArrayData
Known Direct Subclasses
com.jogamp.opengl.util.GLArrayDataClient
Imports
java.nio.Buffer, .ByteBuffer, .FloatBuffer, .IntBuffer, .ShortBuffer, com.jogamp.opengl.GL, .GL2ES1, .GL2ES2, .GLArrayData, .GLException, .GLProfile, com.jogamp.opengl.fixedfunc.GLPointerFuncUtil, com.jogamp.common.nio.Buffers, jogamp.opengl.Debug

Field Summary

Modifier and TypeField and Description
protected boolean
protected Buffer
protected int
protected Class<?>
protected int
protected int
public static final boolean
protected int
protected boolean
protected int
protected int
protected String
protected boolean
protected int
strideB

stride in bytes; strideB >= componentsPerElement * componentByteSize

protected int
strideL

stride in logical components

protected boolean
protected int
protected long
protected int
protected int

Constructor Summary

AccessConstructor and Description
protected
public
GLArrayDataWrapper(final GLArrayDataWrapper src)

Copy Constructor

Buffer is sliced, i.e. sharing content but using own state.

Method Summary

Modifier and TypeMethod and Description
public void
associate(final Object
implementation and type dependent association
obj
,
final boolean
pass true to enable the association and false to disable it.
enable
)

Implements com.jogamp.opengl.GLArrayData.associate.

Implementation and type dependent object association.
public static GLArrayDataWrapper

Returns:

the new create instance
createFixed
(final int
The GL array index
index
,
final int
The array component number
comps
,
final int
The array index GL data type
dataType
,
final boolean
Whether the data shall be normalized
normalized
,
final int stride, final Buffer
the user define data
buffer
,
final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)

Create a VBO, using a predefined fixed function array index, wrapping the given data.

public static GLArrayDataWrapper

Returns:

the new create instance
createFixed
(final int
The GL array index
index
,
final int
The array component number
comps
,
final int
The array index GL data type
dataType
,
final boolean
Whether the data shall be normalized
normalized
,
final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)

Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.

public static GLArrayDataWrapper

Returns:

the new create instance
createGLSL
(final String
The custom name for the GL attribute, maybe null if gpuBufferTarget is GL#GL_ELEMENT_ARRAY_BUFFER
name
,
final int
The array component number
comps
,
final int
The array index GL data type
dataType
,
final boolean
Whether the data shall be normalized
normalized
,
final int stride, final Buffer
the user define data
buffer
,
final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)

Create a VBO, using a custom GLSL array attribute name, wrapping the given data.

public static GLArrayDataWrapper

Returns:

the new create instance
createGLSL
(final String
The custom name for the GL attribute, maybe null if gpuBufferTarget is GL#GL_ELEMENT_ARRAY_BUFFER
name
,
final int
The array component number
comps
,
final int
The array index GL data type
dataType
,
final boolean
Whether the data shall be normalized
normalized
,
final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)

Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.

public void
public Buffer
getBuffer()

Implements com.jogamp.opengl.GLArrayData.getBuffer.

The Buffer holding the data, may be null if a GPU buffer without client bound data
public final Class<?>
public static final Class<?>
getBufferClass(final int dataType)

public final int
getComponentCount()

Implements com.jogamp.opengl.GLArrayData.getComponentCount.

The number of components per element
public final int
public final int
getComponentType()

Implements com.jogamp.opengl.GLArrayData.getComponentType.

The component's GL data type, ie.
public final int
getElementCount()

Implements com.jogamp.opengl.GLArrayData.getElementCount.

The current number of used elements.
public final int
getIndex()

Implements com.jogamp.opengl.GLArrayData.getIndex.

The index of the predefined array index, see list below, or -1 in case of a shader attribute array.
public final int
getLocation()

Implements com.jogamp.opengl.GLArrayData.getLocation.

Returns the shader attribute location for this name, -1 if not yet determined
public final String
getName()

Implements com.jogamp.opengl.GLArrayData.getName.

The name of the reflecting shader array attribute.
public final boolean
getNormalized()

Implements com.jogamp.opengl.GLArrayData.getNormalized.

True, if GL shall normalize fixed point data while converting them into float.
public final int
getSizeInBytes()

Implements com.jogamp.opengl.GLArrayData.getSizeInBytes.

The currently used size in bytes.
public final int
public final int
getVBOName()

Implements com.jogamp.opengl.GLArrayData.getVBOName.

The VBO name or 0 if not a VBO
public final long
getVBOOffset()

Implements com.jogamp.opengl.GLArrayData.getVBOOffset.

The VBO buffer offset or 0 if not a VBO
public final int
getVBOTarget()

Implements com.jogamp.opengl.GLArrayData.getVBOTarget.

The VBO target or 0 if not a VBO
public final int
getVBOUsage()

Implements com.jogamp.opengl.GLArrayData.getVBOUsage.

The VBO usage or 0 if not a VBO
protected void
init(final String name, final int index, final int componentsPerElement, final int componentType, final boolean normalized, final int stride, final Buffer data, final int mappedElementCount, final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget)

public final boolean
isVBO()

Implements com.jogamp.opengl.GLArrayData.isVBO.

Determines whether the data is server side (VBO) and enabled, or a client side array (false).
public final boolean
isVertexAttribute()

Implements com.jogamp.opengl.GLArrayData.isVertexAttribute.

Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointer
public final int
setLocation(final int v)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Sets the given location of the shader attribute
public final int
setLocation(final GL2ES2 gl, final int program)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Retrieves the location of the shader attribute from the linked shader program.
public final int
setLocation(final GL2ES2 gl, final int program, final int location)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Binds the location of the shader attribute to the given location for the unlinked shader program.
public void
setName(final String newName)

Implements com.jogamp.opengl.GLArrayData.setName.

Set a new name for this array.
public void
setVBOEnabled(final boolean vboEnabled)

Enable or disable use of VBO.

public void
setVBOName(final int vboName)

Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.

public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Implements com.jogamp.opengl.GLArrayData.toString.

Returns a string representation of the object.
public final boolean

Returns:

true if this instance has invalid parameter, otherwise false
validate
(final GLProfile
the GLProfile to use
glp
,
final boolean
whether to throw an exception if this instance has invalid parameter or not
throwException
)

Validates this instance's parameter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aliveback to summary
protected boolean alive
bufferback to summary
protected Buffer buffer
componentByteSizeback to summary
protected int componentByteSize
componentClazzback to summary
protected Class<?> componentClazz
componentsPerElementback to summary
protected int componentsPerElement
componentTypeback to summary
protected int componentType
DEBUGback to summary
public static final boolean DEBUG
indexback to summary
protected int index
isVertexAttributeback to summary
protected boolean isVertexAttribute
locationback to summary
protected int location
mappedElementCountback to summary
protected int mappedElementCount
nameback to summary
protected String name
normalizedback to summary
protected boolean normalized
strideBback to summary
protected int strideB

stride in bytes; strideB >= componentsPerElement * componentByteSize

strideLback to summary
protected int strideL

stride in logical components

vboEnabledback to summary
protected boolean vboEnabled
vboNameback to summary
protected int vboName
vboOffsetback to summary
protected long vboOffset
vboTargetback to summary
protected int vboTarget
vboUsageback to summary
protected int vboUsage

Constructor Detail

GLArrayDataWrapperback to summary
protected GLArrayDataWrapper()
GLArrayDataWrapperback to summary
public GLArrayDataWrapper(final GLArrayDataWrapper src)

Copy Constructor

Buffer is sliced, i.e. sharing content but using own state.

All other values are simply copied.

Method Detail

associateback to summary
public void associate(final Object obj, final boolean enable)

Implements com.jogamp.opengl.GLArrayData.associate.

Doc from com.jogamp.opengl.GLArrayData.associate.

Implementation and type dependent object association.

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).

Parameters
obj:Object

implementation and type dependent association

enable:boolean

pass true to enable the association and false to disable it.

Annotations
@Override
createFixedback to summary
public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException

Create a VBO, using a predefined fixed function array index, wrapping the given data.

Parameters
index:int

The GL array index

comps:int

The array component number

dataType:int

The array index GL data type

normalized:boolean

Whether the data shall be normalized

buffer:Buffer

the user define data

vboUsage:int

GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

vboTarget:int

GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

Returns:GLArrayDataWrapper

the new create instance

createFixedback to summary
public static GLArrayDataWrapper createFixed(final int index, final int comps, final int dataType, final boolean normalized, final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException

Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.

Parameters
index:int

The GL array index

comps:int

The array component number

dataType:int

The array index GL data type

normalized:boolean

Whether the data shall be normalized

vboUsage:int

GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

vboTarget:int

GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

Returns:GLArrayDataWrapper

the new create instance

createGLSLback to summary
public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, final Buffer buffer, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException

Create a VBO, using a custom GLSL array attribute name, wrapping the given data.

Parameters
name:String

The custom name for the GL attribute, maybe null if gpuBufferTarget is GL#GL_ELEMENT_ARRAY_BUFFER

comps:int

The array component number

dataType:int

The array index GL data type

normalized:boolean

Whether the data shall be normalized

buffer:Buffer

the user define data

vboUsage:int

GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

vboTarget:int

GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

Returns:GLArrayDataWrapper

the new create instance

createGLSLback to summary
public static GLArrayDataWrapper createGLSL(final String name, final int comps, final int dataType, final boolean normalized, final int stride, final int mappedElementCount, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException

Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.

Parameters
name:String

The custom name for the GL attribute, maybe null if gpuBufferTarget is GL#GL_ELEMENT_ARRAY_BUFFER

comps:int

The array component number

dataType:int

The array index GL data type

normalized:boolean

Whether the data shall be normalized

vboUsage:int

GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

vboTarget:int

GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

Returns:GLArrayDataWrapper

the new create instance

destroyback to summary
public void destroy(final GL gl)

Implements com.jogamp.opengl.GLArrayData.destroy.

Annotations
@Override
getBufferback to summary
public Buffer getBuffer()

Implements com.jogamp.opengl.GLArrayData.getBuffer.

Doc from com.jogamp.opengl.GLArrayData.getBuffer.

The Buffer holding the data, may be null if a GPU buffer without client bound data

Annotations
@Override
getBufferClassback to summary
public final Class<?> getBufferClass()
getBufferClassback to summary
public static final Class<?> getBufferClass(final int dataType)
getComponentCountback to summary
public final int getComponentCount()

Implements com.jogamp.opengl.GLArrayData.getComponentCount.

Doc from com.jogamp.opengl.GLArrayData.getComponentCount.

The number of components per element

Annotations
@Override
getComponentSizeInBytesback to summary
public final int getComponentSizeInBytes()

Implements com.jogamp.opengl.GLArrayData.getComponentSizeInBytes.

Doc from com.jogamp.opengl.GLArrayData.getComponentSizeInBytes.

The component's size in bytes

Annotations
@Override
getComponentTypeback to summary
public final int getComponentType()

Implements com.jogamp.opengl.GLArrayData.getComponentType.

Doc from com.jogamp.opengl.GLArrayData.getComponentType.

The component's GL data type, ie. GL_FLOAT

Annotations
@Override
getElementCountback to summary
public final int getElementCount()

Implements com.jogamp.opengl.GLArrayData.getElementCount.

Doc from com.jogamp.opengl.GLArrayData.getElementCount.

The current number of used elements.

On element consist out of getComponentCount() components.

In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
Annotations
@Override
getIndexback to summary
public final int getIndex()

Implements com.jogamp.opengl.GLArrayData.getIndex.

Doc from com.jogamp.opengl.GLArrayData.getIndex.

The index of the predefined array index, see list below, or -1 in case of a shader attribute array.

Annotations
@Override
getLocationback to summary
public final int getLocation()

Implements com.jogamp.opengl.GLArrayData.getLocation.

Doc from com.jogamp.opengl.GLArrayData.getLocation.

Returns the shader attribute location for this name, -1 if not yet determined

Annotations
@Override
getNameback to summary
public final String getName()

Implements com.jogamp.opengl.GLArrayData.getName.

Doc from com.jogamp.opengl.GLArrayData.getName.

The name of the reflecting shader array attribute.

Annotations
@Override
getNormalizedback to summary
public final boolean getNormalized()

Implements com.jogamp.opengl.GLArrayData.getNormalized.

Doc from com.jogamp.opengl.GLArrayData.getNormalized.

True, if GL shall normalize fixed point data while converting them into float.

Default behavior (of the fixed function pipeline) is true for fixed point data type and false for floating point data types.

Annotations
@Override
getSizeInBytesback to summary
public final int getSizeInBytes()

Implements com.jogamp.opengl.GLArrayData.getSizeInBytes.

Doc from com.jogamp.opengl.GLArrayData.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.

Annotations
@Override
getStrideback to summary
public final int getStride()

Implements com.jogamp.opengl.GLArrayData.getStride.

Returns:int

Doc from com.jogamp.opengl.GLArrayData.getStride.

the byte offset between consecutive components

Annotations
@Override
getVBONameback to summary
public final int getVBOName()

Implements com.jogamp.opengl.GLArrayData.getVBOName.

Doc from com.jogamp.opengl.GLArrayData.getVBOName.

The VBO name or 0 if not a VBO

Annotations
@Override
getVBOOffsetback to summary
public final long getVBOOffset()

Implements com.jogamp.opengl.GLArrayData.getVBOOffset.

Doc from com.jogamp.opengl.GLArrayData.getVBOOffset.

The VBO buffer offset or 0 if not a VBO

Annotations
@Override
getVBOTargetback to summary
public final int getVBOTarget()

Implements com.jogamp.opengl.GLArrayData.getVBOTarget.

Doc from com.jogamp.opengl.GLArrayData.getVBOTarget.

The VBO target or 0 if not a VBO

Returns:int

0 if not a GPU buffer, otherwise GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

Annotations
@Override
getVBOUsageback to summary
public final int getVBOUsage()

Implements com.jogamp.opengl.GLArrayData.getVBOUsage.

Doc from com.jogamp.opengl.GLArrayData.getVBOUsage.

The VBO usage or 0 if not a VBO

Returns:int

0 if not a GPU buffer, otherwise GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

Annotations
@Override
initback to summary
protected void init(final String name, final int index, final int componentsPerElement, final int componentType, final boolean normalized, final int stride, final Buffer data, final int mappedElementCount, final boolean isVertexAttribute, final int vboName, final long vboOffset, final int vboUsage, final int vboTarget) throws GLException
isVBOback to summary
public final boolean isVBO()

Implements com.jogamp.opengl.GLArrayData.isVBO.

Doc from com.jogamp.opengl.GLArrayData.isVBO.

Determines whether the data is server side (VBO) and enabled, or a client side array (false).

Annotations
@Override
isVertexAttributeback to summary
public final boolean isVertexAttribute()

Implements com.jogamp.opengl.GLArrayData.isVertexAttribute.

Doc from com.jogamp.opengl.GLArrayData.isVertexAttribute.

Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointer

Annotations
@Override
setLocationback to summary
public final int setLocation(final int v)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Doc from com.jogamp.opengl.GLArrayData.setLocation.

Sets the given location of the shader attribute

Returns:int

the given location

Annotations
@Override
setLocationback to summary
public final int setLocation(final GL2ES2 gl, final int program)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Doc from com.jogamp.opengl.GLArrayData.setLocation.

Retrieves the location of the shader attribute from the linked shader program.

No validation is performed within the implementation.

Returns:int

≥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.

Annotations
@Override
setLocationback to summary
public final int setLocation(final GL2ES2 gl, final int program, final int location)

Implements com.jogamp.opengl.GLArrayData.setLocation.

Doc from com.jogamp.opengl.GLArrayData.setLocation.

Binds the location of the shader attribute to the given location for the unlinked shader program.

No validation is performed within the implementation.

Returns:int

the given location

Annotations
@Override
setNameback to summary
public void setName(final String newName)

Implements com.jogamp.opengl.GLArrayData.setName.

Doc from com.jogamp.opengl.GLArrayData.setName.

Set a new name for this array.

This clears the location, i.e. sets it to -1.

Annotations
@Override
setVBOEnabledback to summary
public void setVBOEnabled(final boolean vboEnabled)

Enable or disable use of VBO. Only possible if a VBO buffer name is defined.

See Also
setVBOName(int)
setVBONameback to summary
public void setVBOName(final int vboName)

Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.

See Also
setVBOEnabled(boolean)
setVBOTargetback to summary
public void setVBOTarget(final int vboTarget)
Parameters
vboTarget:int

either GL#GL_ARRAY_BUFFER or GL#GL_ELEMENT_ARRAY_BUFFER

setVBOUsageback to summary
public void setVBOUsage(final int vboUsage)
Parameters
vboUsage:int

GL2ES2#GL_STREAM_DRAW, GL#GL_STATIC_DRAW or GL#GL_DYNAMIC_DRAW

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements com.jogamp.opengl.GLArrayData.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
validateback to summary
public final boolean validate(final GLProfile glp, final boolean throwException)

Validates this instance's parameter. Called automatically by GLArrayDataClient and GLArrayDataServer. GLArrayDataWrapper does not validate it's instance by itself.

Parameters
glp:GLProfile

the GLProfile to use

throwException:boolean

whether to throw an exception if this instance has invalid parameter or not

Returns:boolean

true if this instance has invalid parameter, otherwise false