Halfway the tutorial in the draw function you’re wrapping the indexBuffer in a guard statement. But why didn’t you do this with the vertexBuffer as well?
Thanks for the help!
@bababoega - Because it’s an error not to.
commandEncoder.setVertexBuffer(vertexBuffer,
offset: 0, at: 0)
setVertexBuffer(_:offset:at:)
allows an optional in the buffer.
commandEncoder.drawIndexedPrimitives(type: .triangle,
indexCount: indices.count,
indexType: .uint16,
indexBuffer: indexBuffer,
indexBufferOffset: 0)
drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:)
does not allow the indexBuffer
parameter to be an optional.
The guard
statement unwraps the optional.