Package com.jme3.shader
Class BufferObject
java.lang.Object
com.jme3.util.NativeObject
com.jme3.shader.BufferObject
- All Implemented Interfaces:
Cloneable
The base implementation of BO.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
Fields inherited from class com.jme3.util.NativeObject
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 Summary
ConstructorDescriptionBufferObject
(int binding) BufferObject
(int binding, BufferObject.BufferType bufferType) BufferObject
(int binding, BufferObject.Layout layout) BufferObject
(int binding, BufferObject.Layout layout, BufferObject.BufferType bufferType) BufferObject
(BufferObject.BufferType bufferType) BufferObject
(BufferObject.Layout layout) -
Method Summary
Modifier and TypeMethodDescriptioncomputeData
(int maxSize) Computes the current binary data of this BO.Creates a shallow clone of this GL Object.void
declareField
(String name, VarType varType) Declares a filed in this BO.protected void
Deletes any associated nativebuffers
.void
deleteObject
(Object rendererObject) Deletes the GL object from the GPU when it is no longer used.protected int
estimate
(float[] values) Estimates byte count to present the values on the GPU.protected int
estimate
(int[] values) Estimates byte count to present the values on the GPU.protected int
estimateArray
(Object value, int multiplier) Estimates byte count to present the value on the GPU.protected int
estimateSize
(BufferObjectField field) Estimates size of the field.int
Get the binding number.Gets the buffer's type.<T> T
getFieldValue
(String name) Gets the current value of the field by the name.long
Returns a unique ID for this NativeObject.protected static VarType
getVarTypeByValue
(Object value) void
Called when the GL context is restarted to reset all IDs.void
setBufferType
(BufferObject.BufferType bufferType) Sets the buffer's type.void
setFieldValue
(String name, Object value) Sets the value to the filed by the field's name.protected void
write
(ByteBuffer data, float[] value) Writes the value to the data buffer.protected void
write
(ByteBuffer data, float x, float y, float z) Writes the value to the data buffer.protected void
write
(ByteBuffer data, float x, float y, float z, float w) Writes the value to the data buffer.protected void
write
(ByteBuffer data, int[] value) Writes the value to the data buffer.protected void
write
(ByteBuffer data, Matrix3f value) Writes the value to the data buffer.protected void
write
(ByteBuffer data, Matrix4f value) Writes the value to the data buffer.protected void
write
(ByteBuffer data, Vector2f value) Writes the value to the data buffer.protected void
write
(ByteBuffer data, Vector3f value) Writes the value to the data buffer.protected void
writeField
(BufferObjectField field, ByteBuffer data) Writes the field to the data buffer.protected void
writeMat3Array
(ByteBuffer data, Object value) Writes the value to the data buffer.protected void
writeMat4Array
(ByteBuffer data, Object value) Writes the value to the data buffer.protected void
writeVec2Array
(ByteBuffer data, Object value) Writes the value to the data buffer.protected void
writeVec3Array
(ByteBuffer data, Object value) Writes the value to the data buffer.protected void
writeVec4
(ByteBuffer data, Object value) Writes the value to the data buffer.protected void
writeVec4Array
(ByteBuffer data, Object value) Writes the value to the data buffer.Methods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, clone, dispose, getId, getWeakRef, isUpdateNeeded, setId, setUpdateNeeded, toString
-
Constructor Details
-
BufferObject
-
BufferObject
-
BufferObject
-
BufferObject
-
BufferObject
-
BufferObject
public BufferObject(int binding) -
BufferObject
public BufferObject()
-
-
Method Details
-
getVarTypeByValue
-
declareField
Declares a filed in this BO.- Parameters:
name
- the field's name.varType
- the field's type.
-
getBufferType
Gets the buffer's type.- Returns:
- the buffer's type.
-
setBufferType
Sets the buffer's type.- Parameters:
bufferType
- the buffer's type.
-
setFieldValue
Sets the value to the filed by the field's name.- Parameters:
name
- the field's name.value
- the value.
-
getFieldValue
Gets the current value of the field by the name.- Type Parameters:
T
- the value's type.- Parameters:
name
- the field name.- Returns:
- the current value.
-
getBinding
public int getBinding()Get the binding number.- Returns:
- the binding number.
-
resetObject
public void resetObject()Description copied from class:NativeObject
Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.- Specified by:
resetObject
in classNativeObject
-
computeData
Computes the current binary data of this BO.- Parameters:
maxSize
- the max data size.- Returns:
- the current binary data of this BO.
-
estimateSize
Estimates size of the field.- Parameters:
field
- the field.- Returns:
- the estimated size.
-
estimateArray
Estimates byte count to present the value on the GPU.- Parameters:
value
- the value.multiplier
- the multiplier.- Returns:
- the estimated byte count.
-
estimate
protected int estimate(float[] values) Estimates byte count to present the values on the GPU.- Parameters:
values
- the values.- Returns:
- the estimated byte count.
-
estimate
protected int estimate(int[] values) Estimates byte count to present the values on the GPU.- Parameters:
values
- the values.- Returns:
- the estimated byte count.
-
writeField
Writes the field to the data buffer.- Parameters:
field
- the field.data
- the data buffer.
-
writeMat3Array
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
writeMat4Array
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
writeVec4Array
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
writeVec3Array
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
writeVec2Array
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
writeVec4
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.x
- the x value.y
- the y value.z
- the z value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.x
- the x value.y
- the y value.z
- the z value.w
- the w value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
write
Writes the value to the data buffer.- Parameters:
data
- the data buffer.value
- the value.
-
deleteObject
Description copied from class:NativeObject
Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObject
in classNativeObject
- Parameters:
rendererObject
- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObject
Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClone
in classNativeObject
- Returns:
- a new instance
-
deleteNativeBuffers
protected void deleteNativeBuffers()Description copied from class:NativeObject
Deletes any associated nativebuffers
. 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 protected- Overrides:
deleteNativeBuffers
in classNativeObject
-
getUniqueId
public long getUniqueId()Description copied from class:NativeObject
Returns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueId
in classNativeObject
- Returns:
- unique ID for this NativeObject.
-