MeshBuffer
public final class MeshBuffer implements AutoCloseable
A container holding raw vertex and index data for custom meshes.
A MeshBuffer represents a compilation of one or more vertex buffers and an index buffer in the underlying rendering engine. The vertex buffers contain the vertex data according to the provided VertexLayout, and the index buffer contains the indices of the vertices that form the primitives of the mesh.
The raw buffer data is provided during the creation of the MeshBuffer and is immediately copied into the rendering engine's memory. As a result, the MeshBuffer does not retain references to the original ByteBuffer objects, which can be modified or released by the application after creation.
Summary
Public methods |
|
|---|---|
void |
Closes the given |
static final @NonNull MeshBuffer |
@MainThreadCreates a new |
final @NonNull VertexLayout |
The |
Public methods
close
@MainThread
public void close()
Closes the given MeshBuffer.
The MeshBuffer can be explicitly closed at anytime or garbage collected. An exception will be thrown if the MeshBuffer is used after being closed.
| Throws | |
|---|---|
IllegalStateException |
if the resource has already been closed. |
create
@MainThread
public static final @NonNull MeshBuffer create(
@NonNull Session session,
@NonNull VertexLayout vertexLayout,
@NonNull List<@NonNull ByteBufferRegion> vertexData,
@NonNull ByteBufferRegion indexData
)
Creates a new MeshBuffer.
| Parameters | |
|---|---|
@NonNull Session session |
The session to use for creating the MeshBuffer. |
@NonNull VertexLayout vertexLayout |
The layout of the vertices in the vertex buffer(s). |
@NonNull List<@NonNull ByteBufferRegion> vertexData |
The vertex data regions, one for each buffer index used in the layout. The data is copied and the original data in the |
@NonNull ByteBufferRegion indexData |
The index data region. The indices must be 32-bit unsigned values. The data is copied and the original data in the |
| Returns | |
|---|---|
@NonNull MeshBuffer |
A new |
| Throws | |
|---|---|
IllegalArgumentException |
if |
getVertexLayout
public final @NonNull VertexLayout getVertexLayout()
The VertexLayout describing the structure of the vertex data.