@ExperimentalCustomMeshApi
class MeshBuffer : 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 companion functions

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

Creates a new MeshBuffer.

Public functions

open Unit

Closes the given MeshBuffer.

Public properties

VertexLayout

The VertexLayout describing the structure of the vertex data.

Public companion functions

create

Added in 1.0.0-alpha15
@MainThread
fun create(
    session: Session,
    vertexLayout: VertexLayout,
    vertexData: List<ByteBufferRegion>,
    indexData: ByteBufferRegion
): MeshBuffer

Creates a new MeshBuffer.

Parameters
session: Session

The session to use for creating the MeshBuffer.

vertexLayout: VertexLayout

The layout of the vertices in the vertex buffer(s).

vertexData: List<ByteBufferRegion>

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.

indexData: ByteBufferRegion

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
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.

Public functions

close

Added in 1.0.0-alpha15
@MainThread
open fun close(): Unit

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.

Public properties

vertexLayout

Added in 1.0.0-alpha15
val vertexLayoutVertexLayout

The VertexLayout describing the structure of the vertex data.