Package com.google.android.filament
Class VertexBuffer
- java.lang.Object
-
- com.google.android.filament.VertexBuffer
-
public class VertexBuffer extends java.lang.ObjectHolds a set of buffers that define the geometry of aRenderable.The geometry of the
Renderableitself 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVertexBuffer.AttributeTypestatic classVertexBuffer.Builderstatic classVertexBuffer.VertexAttribute
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetNativeObject()intgetVertexCount()Returns the vertex count.voidsetBufferAt(Engine engine, int bufferIndex, java.nio.Buffer buffer)Asynchronously copy-initializes the specified buffer from the given buffer data.voidsetBufferAt(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.voidsetBufferAt(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.voidsetBufferObjectAt(Engine engine, int bufferIndex, BufferObject bufferObject)Swaps in the given buffer object.
-
-
-
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 theEngineto associate thisVertexBufferwithbufferIndex- index of the buffer to initialize. Must be between 0 and bufferCount() - 1.buffer- a CPU-sideBufferrepresenting the data used to initialize theVertexBufferat indexbufferIndex.buffershould 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 theEngineto associate thisVertexBufferwithbufferIndex- index of the buffer to initialize. Must be between 0 and bufferCount() - 1.buffer- a CPU-sideBufferrepresenting the data used to initialize theVertexBufferat indexbufferIndex.buffershould contain raw, untyped data that will be copied as-is into the buffer.destOffsetInBytes- offset in bytes into the buffer at indexbufferIndexof 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 theEngineto associate thisVertexBufferwithbufferIndex- index of the buffer to initialize. Must be between 0 and bufferCount() - 1.buffer- a CPU-sideBufferrepresenting the data used to initialize theVertexBufferat indexbufferIndex.buffershould contain raw, untyped data that will be copied as-is into the buffer.destOffsetInBytes- offset in bytes into the buffer at indexbufferIndexof this vertex buffer set.handler- anExecutor. On Android this can also be aHandler.callback- a callback executed byhandlerwhenbufferis 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()
-
-