Skip to content

Instantly share code, notes, and snippets.

@rmirabelli
Last active March 9, 2018 20:39
Show Gist options
  • Save rmirabelli/2a5b8b9bda2d6bfa8e5bcd9fe09a1690 to your computer and use it in GitHub Desktop.
Save rmirabelli/2a5b8b9bda2d6bfa8e5bcd9fe09a1690 to your computer and use it in GitHub Desktop.
Creating buffers
// STEP 2: create data & buffer for data source
let vertexData: [Float] = [
0.0,1.0,0.0,
-1.0,-1.0,0.0,
1.0,-1.0,0.0
]
let dataSize = vertexData.count * MemoryLayout.stride(ofValue: vertexData[0]) // use stride instead of size, as this properly reflects memory usage.
let vertexArray = device?.makeBuffer(bytes: vertexData, length: dataSize, options: [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment