Class BufferObject


  • public class BufferObject
    extends java.lang.Object
    A generic GPU buffer containing data. Usage of this BufferObject is optional. For simple use cases it is not necessary. It is useful only when you need to share data between multiple VertexBuffer instances. It also allows you to efficiently swap-out the buffers in VertexBuffer. NOTE: For now this is only used for vertex data, but in the future we may use it for other things (e.g. compute).
    See Also:
    VertexBuffer
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BufferObject.Builder  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getByteCount()
      Returns the size of this BufferObject in elements.
      long getNativeObject()  
      void setBuffer​(Engine engine, java.nio.Buffer buffer)
      Asynchronously copy-initializes this BufferObject from the data provided.
      void setBuffer​(Engine engine, java.nio.Buffer buffer, int destOffsetInBytes, int count)
      Asynchronously copy-initializes a region of this BufferObject from the data provided.
      void setBuffer​(Engine engine, java.nio.Buffer buffer, int destOffsetInBytes, int count, java.lang.Object handler, java.lang.Runnable callback)
      Asynchronously copy-initializes a region of this BufferObject from the data provided.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getByteCount

        @IntRange(from=0L)
        public int getByteCount()
        Returns the size of this BufferObject in elements.
        Returns:
        the number of bytes the BufferObject holds
      • setBuffer

        public void setBuffer​(@NonNull
                              Engine engine,
                              @NonNull
                              java.nio.Buffer buffer)
        Asynchronously copy-initializes this BufferObject from the data provided.
        Parameters:
        engine - reference to the Engine to associate this BufferObject with
        buffer - a CPU-side Buffer with the data used to initialize the BufferObject.
      • setBuffer

        public void setBuffer​(@NonNull
                              Engine engine,
                              @NonNull
                              java.nio.Buffer buffer,
                              @IntRange(from=0L)
                              int destOffsetInBytes,
                              @IntRange(from=0L)
                              int count)
        Asynchronously copy-initializes a region of this BufferObject from the data provided.
        Parameters:
        engine - reference to the Engine to associate this BufferObject with
        buffer - a CPU-side Buffer with the data used to initialize the BufferObject.
        destOffsetInBytes - offset in bytes into the BufferObject
        count - number of bytes to consume, defaults to buffer.remaining()
      • setBuffer

        public void setBuffer​(@NonNull
                              Engine engine,
                              @NonNull
                              java.nio.Buffer buffer,
                              @IntRange(from=0L)
                              int destOffsetInBytes,
                              @IntRange(from=0L)
                              int count,
                              @Nullable
                              java.lang.Object handler,
                              @Nullable
                              java.lang.Runnable callback)
        Asynchronously copy-initializes a region of this BufferObject from the data provided.
        Parameters:
        engine - reference to the Engine to associate this BufferObject with
        buffer - a CPU-side Buffer with the data used to initialize the BufferObject.
        destOffsetInBytes - offset in bytes into the BufferObject
        count - number of bytes to consume, defaults to buffer.remaining()
        handler - an Executor. On Android this can also be a Handler.
        callback - a callback executed by handler when buffer is no longer needed.
      • getNativeObject

        public long getNativeObject()