Class VertexBuffer


  • public class VertexBuffer
    extends java.lang.Object
    Holds a set of buffers that define the geometry of a Renderable.

    The geometry of the Renderable itself is defined by a set of vertex attributes such as position, color, normals, tangents, etc...

    There is no need to have a 1-to-1 mapping between attributes and buffer. A buffer can hold the data of several attributes -- attributes are then referred as being "interleaved".

    The buffers themselves are GPU resources, therefore mutating their data can be relatively slow. For this reason, it is best to separate the constant data from the dynamic data into multiple buffers.

    It is possible, and even encouraged, to use a single vertex buffer for several Renderables.

    See Also:
    IndexBuffer, RenderableManager
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getNativeObject()  
      int getVertexCount()
      Returns the vertex count.
      void setBufferAt​(Engine engine, int bufferIndex, java.nio.Buffer buffer)
      Asynchronously copy-initializes the specified buffer from the given buffer data.
      void setBufferAt​(Engine engine, int bufferIndex, java.nio.Buffer buffer, int destOffsetInBytes, int count)
      Asynchronously copy-initializes a region of the specified buffer from the given buffer data.
      void setBufferAt​(Engine engine, int bufferIndex, java.nio.Buffer buffer, int destOffsetInBytes, int count, java.lang.Object handler, java.lang.Runnable callback)
      Asynchronously copy-initializes a region of the specified buffer from the given buffer data.
      void setBufferObjectAt​(Engine engine, int bufferIndex, BufferObject bufferObject)
      Swaps in the given buffer object.
      • Methods inherited from class java.lang.Object

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

      • getVertexCount

        @IntRange(from=0L)
        public int getVertexCount()
        Returns the vertex count.
        Returns:
        number of vertices in this vertex buffer set
      • setBufferAt

        public void setBufferAt​(@NonNull
                                Engine engine,
                                int bufferIndex,
                                @NonNull
                                java.nio.Buffer buffer)
        Asynchronously copy-initializes the specified buffer from the given buffer data.
        Parameters:
        engine - reference to the Engine to associate this VertexBuffer with
        bufferIndex - index of the buffer to initialize. Must be between 0 and bufferCount() - 1.
        buffer - a CPU-side Buffer representing the data used to initialize the VertexBuffer at index bufferIndex. buffer should contain raw, untyped data that will be copied as-is into the buffer.
      • setBufferAt

        public void setBufferAt​(@NonNull
                                Engine engine,
                                int bufferIndex,
                                @NonNull
                                java.nio.Buffer buffer,
                                @IntRange(from=0L)
                                int destOffsetInBytes,
                                @IntRange(from=0L)
                                int count)
        Asynchronously copy-initializes a region of the specified buffer from the given buffer data.
        Parameters:
        engine - reference to the Engine to associate this VertexBuffer with
        bufferIndex - index of the buffer to initialize. Must be between 0 and bufferCount() - 1.
        buffer - a CPU-side Buffer representing the data used to initialize the VertexBuffer at index bufferIndex. buffer should contain raw, untyped data that will be copied as-is into the buffer.
        destOffsetInBytes - offset in bytes into the buffer at index bufferIndex of this vertex buffer set.
      • setBufferAt

        public void setBufferAt​(@NonNull
                                Engine engine,
                                int bufferIndex,
                                @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 the specified buffer from the given buffer data.
        Parameters:
        engine - reference to the Engine to associate this VertexBuffer with
        bufferIndex - index of the buffer to initialize. Must be between 0 and bufferCount() - 1.
        buffer - a CPU-side Buffer representing the data used to initialize the VertexBuffer at index bufferIndex. buffer should contain raw, untyped data that will be copied as-is into the buffer.
        destOffsetInBytes - offset in bytes into the buffer at index bufferIndex of this vertex buffer set.
        handler - an Executor. On Android this can also be a Handler.
        callback - a callback executed by handler when buffer is no longer needed.
      • setBufferObjectAt

        public void setBufferObjectAt​(@NonNull
                                      Engine engine,
                                      int bufferIndex,
                                      @NonNull
                                      BufferObject bufferObject)
        Swaps in the given buffer object. To use this, you must first call enableBufferObjects() on the Builder.
        Parameters:
        engine - Reference to the filament::Engine to associate this VertexBuffer with.
        bufferIndex - Index of the buffer to initialize. Must be between 0 and Builder::bufferCount() - 1.
        bufferObject - The handle to the GPU data that will be used in this buffer slot.
      • getNativeObject

        public long getNativeObject()