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);
if (deviceBuffer == null) {
throw Exception('Failed to allocate geometry buffer');
}
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);
}
}