Class GLArrayDataClient
- java.lang.Object
-
- com.jogamp.opengl.util.GLArrayDataWrapper
-
- com.jogamp.opengl.util.GLArrayDataClient
-
- All Implemented Interfaces:
GLArrayData,GLArrayDataEditable
- Direct Known Subclasses:
GLArrayDataServer
public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayDataEditable
-
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_GROWTH_FACTORDefault growth factor using the golden ratio 1.618-
Fields inherited from class com.jogamp.opengl.util.GLArrayDataWrapper
DEBUG
-
-
Constructor Summary
Constructors Constructor Description GLArrayDataClient(GLArrayDataClient 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.booleanbindBuffer(GL gl, boolean bind)ifbindis true and the data usesVBO, the latter will be bound and data written to the GPU if required.voidclear()Clears this buffer and resets states accordingly.voidclear(GL gl)Clears this buffer and resets states accordingly.intcompsToElemCount(int componentCount)Returning element-count from given componentCount, rounding up to componentsPerElement.static GLArrayDataClientcreateFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount)Create a client side buffer object, using a predefined fixed function array index and starting with a new created Buffer object with initialElementCount size On profiles GL2 and ES1 the fixed function pipeline behavior is as expected.static GLArrayDataClientcreateFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer)Create a client side buffer object, using a predefined fixed function array index and starting with a given Buffer object incl it's stride On profiles GL2 and ES1 the fixed function pipeline behavior is as expected.static GLArrayDataClientcreateGLSL(String name, int comps, int dataType, boolean normalized, int initialElementCount)Create a client side buffer object, using a custom GLSL array attribute name and starting with a new created Buffer object with initialElementCount sizestatic GLArrayDataClientcreateGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer)Create a client side buffer object, using a custom GLSL array attribute name and starting with a given Buffer object incl it's stridevoiddestroy(GL gl)voidenableBuffer(GL gl, boolean enable)Enables the buffer ifenableistrue, and transfers the data if required.booleanenabled()floatgetGrowthFactor()Returns this buffer's growth factor.booleangrowIfNeeded(int spareComponents)Increase the capacity of the buffer if necessary to add given spareComponents components.booleanisVBOWritten()Is the buffer written to the VBO ?voidpadding(int doneInByteSize)voidput(Buffer v)Generic buffer relative put method.voidput3b(byte v1, byte v2, byte v3)voidput3f(float v1, float v2, float v3)voidput3i(int v1, int v2, int v3)voidput3s(short v1, short v2, short v3)voidput4b(byte v1, byte v2, byte v3, byte v4)voidput4f(float v1, float v2, float v3, float v4)voidput4i(int v1, int v2, int v3, int v4)voidput4s(short v1, short v2, short v3, short v4)voidputb(byte v)voidputb(byte[] src, int offset, int length)voidputf(float v)voidputf(float[] src, int offset, int length)voidputi(int v)voidputi(int[] src, int offset, int length)voidputs(short v)voidputs(short[] src, int offset, int length)voidputx(int v)booleanreserve(int elementCount)Increase the capacity of the buffer to given elementCount element size, i.e.voidrewind()Rewinds this buffer.voidseal(boolean seal)If seal is true, it disables write operations to the buffer.voidseal(GL gl, boolean seal)Convenience method callingGLArrayDataEditable.seal(boolean)andGLArrayDataEditable.enableBuffer(GL, boolean).voidsetEnableAlways(boolean always)Affects the behavior of 'enableBuffer'.voidsetGrowthFactor(float v)Sets a new growth factor for this buffer.voidsetVBOWritten(boolean written)Marks the buffer written to the VBOStringtoString()-
Methods inherited from class com.jogamp.opengl.util.GLArrayDataWrapper
bytePosition, createFixed, createFixed, createGLSL, createGLSL, elemPosition, elemStatsToString, fillStatsToString, getBuffer, getBufferClass, getBufferClass, getByteCapacity, getByteCount, getBytesPerComp, getCompsPerElem, getCompType, getElemCapacity, getElemCount, getIndex, getLocation, getName, getNormalized, getStride, getVBOName, getVBOOffset, getVBOTarget, getVBOUsage, isVBO, isVertexAttribute, remainingBytes, remainingElems, sealed, setLocation, setLocation, setLocation, setName, setVBOEnabled, setVBOName, setVBOTarget, setVBOUsage, validate
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.opengl.GLArrayData
bytePosition, elemPosition, elemStatsToString, fillStatsToString, getBuffer, getByteCapacity, getByteCount, getBytesPerComp, getCompsPerElem, getCompType, getElemCapacity, getElemCount, getIndex, getLocation, getName, getNormalized, getStride, getVBOName, getVBOOffset, getVBOTarget, getVBOUsage, isVBO, isVertexAttribute, remainingBytes, remainingElems, sealed, setLocation, setLocation, setLocation, setName
-
-
-
-
Field Detail
-
DEFAULT_GROWTH_FACTOR
public static final float DEFAULT_GROWTH_FACTOR
Default growth factor using the golden ratio 1.618- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GLArrayDataClient
public GLArrayDataClient(GLArrayDataClient src)
Copy ConstructorBuffer is
sliced, i.e. sharing content but using own state.All other values are simply copied.
-
-
Method Detail
-
createFixed
public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException
Create a client side buffer object, using a predefined fixed function array index and starting with a new created Buffer object with initialElementCount size On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. On profile ES2 the fixed function emulation will transform these calls to EnableVertexAttribArray and VertexAttribPointer calls, and a predefined vertex attribute variable name will be chosen. The default name mapping will be used, seeGLPointerFuncUtil.getPredefinedArrayIndexName(int).- Parameters:
index- The GL array indexcomps- The array component numberdataType- The array index GL data typenormalized- Whether the data shall be normalizedinitialElementCount-- Throws:
GLException- See Also:
com.jogamp.opengl.GLContext#getPredefinedArrayIndexName(int)
-
createFixed
public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer) throws GLException
Create a client side buffer object, using a predefined fixed function array index and starting with a given Buffer object incl it's stride On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. On profile ES2 the fixed function emulation will transform these calls to EnableVertexAttribArray and VertexAttribPointer calls, and a predefined vertex attribute variable name will be chosen. The default name mapping will be used, seeGLPointerFuncUtil.getPredefinedArrayIndexName(int).- 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 data- Throws:
GLException- See Also:
com.jogamp.opengl.GLContext#getPredefinedArrayIndexName(int)
-
createGLSL
public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException
Create a client side buffer object, using a custom GLSL array attribute name and starting with a new created Buffer object with initialElementCount size- Parameters:
name- The custom name for the GL attribute.comps- The array component numberdataType- The array index GL data typenormalized- Whether the data shall be normalizedinitialElementCount-- Throws:
GLException
-
createGLSL
public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer) throws GLException
Create a client side buffer object, using a custom GLSL array attribute name and starting with a given Buffer object incl it's stride- Parameters:
name- The custom name for the GL attribute.comps- The array component numberdataType- The array index GL data typenormalized- Whether the data shall be normalizedstride-buffer- the user define data- Throws:
GLException
-
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- Overrides:
associatein classGLArrayDataWrapper- Parameters:
obj- implementation and type dependent associationenable- pass true to enable the association and false to disable it.
-
isVBOWritten
public final boolean isVBOWritten()
Description copied from interface:GLArrayDataEditableIs the buffer written to the VBO ?- Specified by:
isVBOWrittenin interfaceGLArrayDataEditable
-
enabled
public final boolean enabled()
- Specified by:
enabledin interfaceGLArrayDataEditable
-
setVBOWritten
public final void setVBOWritten(boolean written)
Description copied from interface:GLArrayDataEditableMarks the buffer written to the VBO- Specified by:
setVBOWrittenin interfaceGLArrayDataEditable
-
destroy
public void destroy(GL gl)
- Specified by:
destroyin interfaceGLArrayData- Specified by:
destroyin interfaceGLArrayDataEditable- Overrides:
destroyin classGLArrayDataWrapper
-
clear
public void clear(GL gl)
Description copied from interface:GLArrayDataEditableClears this buffer and resets states accordingly.Implementation calls
seal(gl, false)andGLArrayDataEditable.clear(), i.e. turns-off the GL buffer and then clearing it.The position is set to zero, the limit is set to the capacity, and the mark is discarded.
Invoke this method before using a sequence of get or put operations to fill this buffer.
This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
- Specified by:
clearin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.seal(GL, boolean),GLArrayDataEditable.clear()
-
seal
public void seal(GL gl, boolean seal)
Description copied from interface:GLArrayDataEditableConvenience method callingGLArrayDataEditable.seal(boolean)andGLArrayDataEditable.enableBuffer(GL, boolean).- Specified by:
sealin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.seal(boolean),GLArrayDataEditable.enableBuffer(GL, boolean)
-
enableBuffer
public void enableBuffer(GL gl, boolean enable)
Description copied from interface:GLArrayDataEditableEnables the buffer ifenableistrue, and transfers the data if required. In caseVBO is used, it is bound accordingly for the data transfer and association, i.e. it issuedGLArrayDataEditable.bindBuffer(GL, boolean). The VBO buffer is unbound when the method returns.Disables the buffer if
enableisfalse.The action will only be executed, if the internal enable state differs, or 'setEnableAlways' was called with 'true'.
It is up to the user to enable/disable the array properly, ie in case of multiple data sets for the same vertex attribute (VA). Meaning in such case usage of one set while expecting another one to be used for the same VA implies decorating each usage with enable/disable.
- Specified by:
enableBufferin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.setEnableAlways(boolean)
-
bindBuffer
public boolean bindBuffer(GL gl, boolean bind)
Description copied from interface:GLArrayDataEditableifbindis true and the data usesVBO, the latter will be bound and data written to the GPU if required.If
bindis false and the data usesVBO, the latter will be unbound.This method is exposed to allow data VBO arrays, i.e.
GL.GL_ELEMENT_ARRAY_BUFFER, to be bounded and written while keeping the VBO bound. The latter is in contrast toGLArrayDataEditable.enableBuffer(GL, boolean), which leaves the VBO unbound, since it's not required for vertex attributes or pointers.- Specified by:
bindBufferin interfaceGLArrayDataEditable- Parameters:
gl- current GL objectbind- true if VBO shall be bound and data written, otherwise clear VBO binding.- Returns:
- true if data uses VBO and action was performed, otherwise false
-
setEnableAlways
public void setEnableAlways(boolean always)
Description copied from interface:GLArrayDataEditableAffects the behavior of 'enableBuffer'. The default is 'false' This is useful when you mix up GLArrayData usage with conventional GL array calls or in case of a buggy GL VBO implementation.- Specified by:
setEnableAlwaysin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.enableBuffer(GL, boolean)
-
clear
public void clear()
Description copied from interface:GLArrayDataEditableClears this buffer and resets states accordingly.The position is set to zero, the limit is set to the capacity, and the mark is discarded.
Invoke this method before using a sequence of get or put operations to fill this buffer.
This method does not actually erase the data in the buffer and will most often be used when erasing the underlying memory is suitable.
- Specified by:
clearin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.clear(GL)
-
seal
public void seal(boolean seal)
Description copied from interface:GLArrayDataEditableIf seal is true, it disables write operations to the buffer. Calls flip, ie limit:=position and position:=0.
If seal is false, it enable write operations continuing at the buffer position, where you left off at seal(true), ie position:=limit and limit:=capacity.
- Specified by:
sealin interfaceGLArrayDataEditable- See Also:
GLArrayDataEditable.seal(boolean),GLArrayData.sealed()
-
rewind
public void rewind()
Description copied from interface:GLArrayDataEditableRewinds this buffer. The position is set to zero and the mark is discarded.Invoke this method before a sequence of put or get operations.
- Specified by:
rewindin interfaceGLArrayDataEditable
-
padding
public void padding(int doneInByteSize)
- Specified by:
paddingin interfaceGLArrayDataEditable
-
put
public void put(Buffer v)
Generic buffer relative put method. This class buffer Class must match the arguments buffer class. The arguments remaining elements must be a multiple of this arrays element stride.- Specified by:
putin interfaceGLArrayDataEditable
-
putb
public void putb(byte v)
- Specified by:
putbin interfaceGLArrayDataEditable
-
put3b
public void put3b(byte v1, byte v2, byte v3)- Specified by:
put3bin interfaceGLArrayDataEditable
-
put4b
public void put4b(byte v1, byte v2, byte v3, byte v4)- Specified by:
put4bin interfaceGLArrayDataEditable
-
putb
public void putb(byte[] src, int offset, int length)- Specified by:
putbin interfaceGLArrayDataEditable
-
puts
public void puts(short v)
- Specified by:
putsin interfaceGLArrayDataEditable
-
put3s
public void put3s(short v1, short v2, short v3)- Specified by:
put3sin interfaceGLArrayDataEditable
-
put4s
public void put4s(short v1, short v2, short v3, short v4)- Specified by:
put4sin interfaceGLArrayDataEditable
-
puts
public void puts(short[] src, int offset, int length)- Specified by:
putsin interfaceGLArrayDataEditable
-
puti
public void puti(int v)
- Specified by:
putiin interfaceGLArrayDataEditable
-
put3i
public void put3i(int v1, int v2, int v3)- Specified by:
put3iin interfaceGLArrayDataEditable
-
put4i
public void put4i(int v1, int v2, int v3, int v4)- Specified by:
put4iin interfaceGLArrayDataEditable
-
puti
public void puti(int[] src, int offset, int length)- Specified by:
putiin interfaceGLArrayDataEditable
-
putx
public void putx(int v)
- Specified by:
putxin interfaceGLArrayDataEditable
-
putf
public void putf(float v)
- Specified by:
putfin interfaceGLArrayDataEditable
-
put3f
public void put3f(float v1, float v2, float v3)- Specified by:
put3fin interfaceGLArrayDataEditable
-
put4f
public void put4f(float v1, float v2, float v3, float v4)- Specified by:
put4fin interfaceGLArrayDataEditable
-
putf
public void putf(float[] src, int offset, int length)- Specified by:
putfin interfaceGLArrayDataEditable
-
toString
public String toString()
- Specified by:
toStringin interfaceGLArrayData- Overrides:
toStringin classGLArrayDataWrapper
-
compsToElemCount
public int compsToElemCount(int componentCount)
Returning element-count from given componentCount, rounding up to componentsPerElement.
-
growIfNeeded
public final boolean growIfNeeded(int spareComponents)
Increase the capacity of the buffer if necessary to add given spareComponents components.Buffer will not change if remaining free slots, capacity less position, satisfy spareComponents components.
- Parameters:
spareComponents- number of components to add if necessary.- Returns:
- true if buffer size has changed, i.e. grown. Otherwise false.
-
reserve
public final boolean reserve(int elementCount)
Increase the capacity of the buffer to given elementCount element size, i.e. elementCount * componentsPerElement components.Buffer will not change if given elementCount is lower or equal current capacity.
- Parameters:
elementCount- number of elements to hold.- Returns:
- true if buffer size has changed, i.e. grown. Otherwise false.
-
getGrowthFactor
public float getGrowthFactor()
Returns this buffer's growth factor.Default is
DEFAULT_GROWTH_FACTOR, i.e. the golden ratio 1.618.- See Also:
setGrowthFactor(float),DEFAULT_GROWTH_FACTOR
-
setGrowthFactor
public void setGrowthFactor(float v)
Sets a new growth factor for this buffer.Default is
DEFAULT_GROWTH_FACTOR, i.e. the golden ratio 1.618.- Parameters:
v- new growth factor, which will be clipped to a minimum of 1, i.e. 0% minimum growth.- See Also:
getGrowthFactor(),DEFAULT_GROWTH_FACTOR
-
-