Class BufferObject

java.lang.Object
com.jme3.util.NativeObject
com.jme3.shader.BufferObject
All Implemented Interfaces:
Cloneable

public class BufferObject extends NativeObject
The base implementation of BO.
  • Constructor Details

  • Method Details

    • getVarTypeByValue

      protected static VarType getVarTypeByValue(Object value)
    • declareField

      public void declareField(String name, VarType varType)
      Declares a filed in this BO.
      Parameters:
      name - the field's name.
      varType - the field's type.
    • getBufferType

      public BufferObject.BufferType getBufferType()
      Gets the buffer's type.
      Returns:
      the buffer's type.
    • setBufferType

      public void setBufferType(BufferObject.BufferType bufferType)
      Sets the buffer's type.
      Parameters:
      bufferType - the buffer's type.
    • setFieldValue

      public void setFieldValue(String name, Object value)
      Sets the value to the filed by the field's name.
      Parameters:
      name - the field's name.
      value - the value.
    • getFieldValue

      public <T> T getFieldValue(String name)
      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 class NativeObject
    • computeData

      public ByteBuffer computeData(int maxSize)
      Computes the current binary data of this BO.
      Parameters:
      maxSize - the max data size.
      Returns:
      the current binary data of this BO.
    • estimateSize

      protected int estimateSize(BufferObjectField field)
      Estimates size of the field.
      Parameters:
      field - the field.
      Returns:
      the estimated size.
    • estimateArray

      protected int estimateArray(Object value, int multiplier)
      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

      protected void writeField(BufferObjectField field, ByteBuffer data)
      Writes the field to the data buffer.
      Parameters:
      field - the field.
      data - the data buffer.
    • writeMat3Array

      protected void writeMat3Array(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • writeMat4Array

      protected void writeMat4Array(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • writeVec4Array

      protected void writeVec4Array(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • writeVec3Array

      protected void writeVec3Array(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • writeVec2Array

      protected void writeVec2Array(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, float[] value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, int[] value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • writeVec4

      protected void writeVec4(ByteBuffer data, Object value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, Vector3f value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, float x, float y, float z)
      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

      protected void write(ByteBuffer data, float x, float y, float z, float w)
      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

      protected void write(ByteBuffer data, Vector2f value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, Matrix3f value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • write

      protected void write(ByteBuffer data, Matrix4f value)
      Writes the value to the data buffer.
      Parameters:
      data - the data buffer.
      value - the value.
    • deleteObject

      public void deleteObject(Object rendererObject)
      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 class NativeObject
      Parameters:
      rendererObject - The renderer to be used to delete the object
    • createDestructableClone

      public NativeObject 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 class NativeObject
      Returns:
      a new instance
    • deleteNativeBuffers

      protected void deleteNativeBuffers()
      Description copied from class: NativeObject
      Deletes any associated native 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 protected
      Overrides:
      deleteNativeBuffers in class NativeObject
    • 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 class NativeObject
      Returns:
      unique ID for this NativeObject.