uploadVertexData method
void
uploadVertexData(})
Implementation
void uploadVertexData(
ByteData vertices,
int vertexCount,
ByteData? indices, {
gpu.IndexType indexType = gpu.IndexType.int16,
}) {
gpu.DeviceBuffer deviceBuffer = gpu.gpuContext.createDeviceBuffer(
gpu.StorageMode.hostVisible,
indices == null
? vertices.lengthInBytes
: vertices.lengthInBytes + indices.lengthInBytes,
);
deviceBuffer.overwrite(vertices, destinationOffsetInBytes: 0);
setVertices(
gpu.BufferView(
deviceBuffer,
offsetInBytes: 0,
lengthInBytes: vertices.lengthInBytes,
),
vertexCount,
);
if (indices != null) {
deviceBuffer.overwrite(
indices,
destinationOffsetInBytes: vertices.lengthInBytes,
);
setIndices(
gpu.BufferView(
deviceBuffer,
offsetInBytes: vertices.lengthInBytes,
lengthInBytes: indices.lengthInBytes,
),
indexType,
);
}
}