@ExperimentalCustomMeshApi
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 MeshBuffer.

static final @NonNull MeshBuffer
@MainThread
create(
    @NonNull Session session,
    @NonNull VertexLayout vertexLayout,
    @NonNull List<@NonNull ByteBufferRegion> vertexData,
    @NonNull ByteBufferRegion indexData
)

Creates a new MeshBuffer.

final @NonNull VertexLayout

The VertexLayout describing the structure of the vertex data.

Public methods

close

Added in 1.0.0-alpha15
@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

Added in 1.0.0-alpha15
@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 ByteBuffer can be released or modified without affecting the MeshBuffer.

@NonNull ByteBufferRegion indexData

The index data region. The data is copied and the original data in the ByteBuffer can be released or modified without affecting the MeshBuffer.

Returns
@NonNull MeshBuffer

A new MeshBuffer.

Throws
IllegalArgumentException

if vertexData does not contain a buffer for each buffer index used in the layout, or if any of the ByteBufferRegions are empty.

getVertexLayout

Added in 1.0.0-alpha15
public final @NonNull VertexLayout getVertexLayout()

The VertexLayout describing the structure of the vertex data.