public class BufferObject extends NativeObject
Modifier and Type | Class and Description |
---|---|
static class |
BufferObject.BufferType |
static class |
BufferObject.Layout |
handleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded
Constructor and Description |
---|
BufferObject() |
BufferObject(BufferObject.BufferType bufferType) |
BufferObject(BufferObject.Layout layout) |
BufferObject(int binding) |
BufferObject(int binding,
BufferObject.BufferType bufferType) |
BufferObject(int binding,
BufferObject.Layout layout) |
BufferObject(int binding,
BufferObject.Layout layout,
BufferObject.BufferType bufferType) |
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
computeData(int maxSize)
Computes the current binary data of this BO.
|
NativeObject |
createDestructableClone()
Creates a shallow clone of this GL Object.
|
void |
declareField(java.lang.String name,
VarType varType)
Declares a filed in this BO.
|
protected void |
deleteNativeBuffers()
Deletes any associated native
buffers . |
void |
deleteObject(java.lang.Object rendererObject)
Deletes the GL object from the GPU when it is no longer used.
|
protected int |
estimate(float[] values)
Estimates bytes count to present the values on GPU.
|
protected int |
estimate(int[] values)
Estimates bytes count to present the values on GPU.
|
protected int |
estimateArray(java.lang.Object value,
int multiplier)
Estimates bytes count to present the value on GPU.
|
protected int |
estimateSize(BufferObjectField field)
Estimates size of the field.
|
int |
getBinding()
Get the binding number.
|
BufferObject.BufferType |
getBufferType()
Gets the buffer's type.
|
<T> T |
getFieldValue(java.lang.String name)
Gets the current value of the field by the name.
|
long |
getUniqueId()
Returns a unique ID for this NativeObject.
|
protected static VarType |
getVarTypeByValue(java.lang.Object value) |
void |
resetObject()
Called when the GL context is restarted to reset all IDs.
|
void |
setBufferType(BufferObject.BufferType bufferType)
Sets the buffer's type.
|
void |
setFieldValue(java.lang.String name,
java.lang.Object value)
Sets the value to the filed by the field's name.
|
protected void |
write(java.nio.ByteBuffer data,
float[] value)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
float x,
float y,
float z)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
float x,
float y,
float z,
float w)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
int[] value)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
Matrix3f value)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
Matrix4f value)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
Vector2f value)
Writes the value to the data buffer.
|
protected void |
write(java.nio.ByteBuffer data,
Vector3f value)
Writes the value to the data buffer.
|
protected void |
writeField(BufferObjectField field,
java.nio.ByteBuffer data)
Writes the field to the data buffer.
|
protected void |
writeMat3Array(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
protected void |
writeMat4Array(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
protected void |
writeVec2Array(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
protected void |
writeVec3Array(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
protected void |
writeVec4(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
protected void |
writeVec4Array(java.nio.ByteBuffer data,
java.lang.Object value)
Writes the value to the data buffer.
|
clearUpdateNeeded, clone, dispose, getId, isUpdateNeeded, setId, setUpdateNeeded, toString
public BufferObject(int binding, BufferObject.Layout layout, BufferObject.BufferType bufferType)
public BufferObject(int binding, BufferObject.Layout layout)
public BufferObject(int binding, BufferObject.BufferType bufferType)
public BufferObject(BufferObject.BufferType bufferType)
public BufferObject(BufferObject.Layout layout)
public BufferObject(int binding)
public BufferObject()
protected static VarType getVarTypeByValue(java.lang.Object value)
public void declareField(java.lang.String name, VarType varType)
name
- the field's name.varType
- the field's type.public BufferObject.BufferType getBufferType()
public void setBufferType(BufferObject.BufferType bufferType)
bufferType
- the buffer's type.public void setFieldValue(java.lang.String name, java.lang.Object value)
name
- the field's name.value
- the value.public <T> T getFieldValue(java.lang.String name)
T
- the value's type.name
- the field name.public int getBinding()
public void resetObject()
NativeObject
resetObject
in class NativeObject
public java.nio.ByteBuffer computeData(int maxSize)
maxSize
- the max data size.protected int estimateSize(BufferObjectField field)
field
- the field.protected int estimateArray(java.lang.Object value, int multiplier)
value
- the value.multiplier
- the multiplier.protected int estimate(float[] values)
values
- the values.protected int estimate(int[] values)
values
- the values.protected void writeField(BufferObjectField field, java.nio.ByteBuffer data)
field
- the field.data
- the data buffer.protected void writeMat3Array(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void writeMat4Array(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void writeVec4Array(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void writeVec3Array(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void writeVec2Array(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, float[] value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, int[] value)
data
- the data buffer.value
- the value.protected void writeVec4(java.nio.ByteBuffer data, java.lang.Object value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, Vector3f value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, float x, float y, float z)
data
- the data buffer.x
- the x value.y
- the y value.z
- the z value.protected void write(java.nio.ByteBuffer data, float x, float y, float z, float w)
data
- the data buffer.x
- the x value.y
- the y value.z
- the z value.w
- the w value.protected void write(java.nio.ByteBuffer data, Vector2f value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, Matrix3f value)
data
- the data buffer.value
- the value.protected void write(java.nio.ByteBuffer data, Matrix4f value)
data
- the data buffer.value
- the value.public void deleteObject(java.lang.Object rendererObject)
NativeObject
deleteObject
in class NativeObject
rendererObject
- The renderer to be used to delete the objectpublic NativeObject createDestructableClone()
NativeObject
createDestructableClone
in class NativeObject
protected void deleteNativeBuffers()
NativeObject
buffers
.
This is necessary because it is unlikely that native buffers
will be garbage collected naturally (due to how GC works), therefore
the collection must be handled manually.
Only implementations that manage native buffers need to override
this method. Note that the behavior that occurs when a
deleted native buffer is used is not defined, therefore this
method is protecteddeleteNativeBuffers
in class NativeObject
public long getUniqueId()
NativeObject
getUniqueId
in class NativeObject