Skip to content

Instantly share code, notes, and snippets.

@patskovn
Created March 3, 2024 20:22
Show Gist options
  • Save patskovn/adb4b55b3893829ca715f0877c6391a2 to your computer and use it in GitHub Desktop.
Save patskovn/adb4b55b3893829ca715f0877c6391a2 to your computer and use it in GitHub Desktop.
var sceneConstants: SceneConstants = ...
public func draw(in view: MTKView) {
guard let drawable = view.currentDrawable else { return }
...
let deltaTime = 1 / Float(view.preferredFramesPerSecond)
sceneConstants.t += deltaTime
commandEncoder.setVertexBytes(&sceneConstants,
length: MemoryLayout<SceneConstants>.stride,
index: 2)
...
commandEncoder.endEncoding()
commandBuffer.present(drawable)
commandBuffer.commit()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment