fromFormats static method

VertexBufferLayout fromFormats(
  1. List<WGPUVertexFormat> formats, {
  2. WGPUVertexStepMode stepMode = WGPUVertexStepMode.WGPUVertexStepMode_Vertex,
  3. int startShaderLocation = 0,
})

Implementation

static VertexBufferLayout fromFormats(
  List<WGPUVertexFormat> formats, {
  WGPUVertexStepMode stepMode = WGPUVertexStepMode.WGPUVertexStepMode_Vertex,
  int startShaderLocation = 0,
}) {
  final List<VertexAttribute> attrs = [];
  int currentOffset = 0;

  for (int i = 0; i < formats.length; i++) {
    final format = formats[i];
    attrs.add(VertexAttribute(
      format: format,
      offset: currentOffset,
      shaderLocation: startShaderLocation + i,
    ));
    currentOffset += _getSizeInBytes(format);
  }

  return VertexBufferLayout(
    arrayStride: currentOffset, // Total size is the stride
    stepMode: stepMode,
    attributes: attrs,
  );
}