Class BufferObject

java.lang.Object
com.jme3.util.NativeObject
com.jme3.shader.bufferobject.BufferObject
All Implemented Interfaces:
Savable, Cloneable
Direct Known Subclasses:
StructStd140BufferObject

public class BufferObject extends NativeObject implements Savable
A generic memory buffer that can be divided in logical regions
  • Field Details

  • Constructor Details

    • BufferObject

      public BufferObject()
    • BufferObject

      protected BufferObject(int id)
  • Method Details

    • setUpdateNeeded

      public final void setUpdateNeeded()
      Internal use only. Indicates that the object has changed and its state needs to be updated. Mark all the regions as dirty.
      Overrides:
      setUpdateNeeded in class NativeObject
    • setUpdateNeeded

      public void setUpdateNeeded(boolean dirtyAll)
      Indicates that the object has changed and its state needs to be updated.
      Parameters:
      dirtyAll - mark all regions for update
    • getBinding

      public int getBinding()
      Get binding point
      Returns:
      the binding point
    • initializeEmpty

      public void initializeEmpty(int length)
      Initialize an empty buffer object of the given length
      Parameters:
      length - expected length of the buffer object
    • setData

      public void setData(ByteBuffer data)
      Transfer remaining bytes of passed buffer to the internal buffer of this buffer object
      Parameters:
      data - ByteBuffer containing the data to pass
    • getData

      public ByteBuffer getData()
      Rewind and return buffer data
      Returns:
    • getDirtyRegions

      public DirtyRegionsIterator getDirtyRegions()
      Get dirty regions
      Returns:
      Helper object to iterate through dirty regions
    • unsetRegions

      public void unsetRegions()
      Reset layour definition
    • setRegions

      public void setRegions(List<BufferRegion> lr)
      Add a region at the end of the layout
      Parameters:
      lr -
    • getRegion

      public BufferRegion getRegion(int i)
      Return all the regions of this layout
      Returns:
      ordered list of regions
    • markAllRegionsDirty

      public void markAllRegionsDirty()
      Mark all regions as dirty
    • 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
    • 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
    • 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
    • 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.
    • setBinding

      public void setBinding(int binding)
      Set binding point
      Parameters:
      binding - binding point
    • getWeakRef

      public WeakReference<BufferObject> getWeakRef()
      Description copied from class: NativeObject
      Acquire a weak reference to this NativeObject.
      Overrides:
      getWeakRef in class NativeObject
      Returns:
      a weak reference (possibly a pre-existing one)
    • getAccessHint

      public BufferObject.AccessHint getAccessHint()
    • setAccessHint

      public void setAccessHint(BufferObject.AccessHint accessHint)
      Set AccessHint to hint the renderer on how to access this data.
      Parameters:
      natureHint -
    • getNatureHint

      public BufferObject.NatureHint getNatureHint()
    • setNatureHint

      public void setNatureHint(BufferObject.NatureHint natureHint)
      Set NatureHint to hint the renderer on how to use this data.
      Parameters:
      natureHint -
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • clone

      public BufferObject clone()
      Description copied from class: NativeObject
      This should create a deep clone. For a shallow clone, use createDestructableClone().
      Overrides:
      clone in class NativeObject
    • toString

      public String toString()
      Overrides:
      toString in class NativeObject
    • getName

      public String getName()
      Get name of the buffer object
      Returns:
      the name of this buffer object, can be null
    • setName

      public void setName(String name)
      Set name for debugging purposes
      Parameters:
      name - the name of this buffer object