rivt
June 12, 2016, 12:50am
2
Hello, thanks for this amazing tutorial it’s really helpful to start learning about metal
Also I need a little help for this question :
How to draw multiple triangles instead of one ?
How to draw a point ?
Thank you
I got the error Use of unresolved identifier ‘drawable’. I noticed in the swift 2.2 version above the line “let drawable = metalLayer.nextDrawable()!” is there but above its not written…
Hi,
I tried to convert this to Xcode 8 and Swit 3, some of the functions will be converted automatically and some issues I found by myself, but the following Code is impossible to fix for me:
if let renderEncoder = renderEncoderOpt {
renderEncoder.setRenderPipelineState(pipelineState)
renderEncoder.setVertexBuffer(vertexBuffer, offset: 0, atIndex: 0)
renderEncoder.drawPrimitives(.Triangle, vertexStart: 0, vertexCount: 3, instanceCount: 1)
renderEncoder.endEncoding()
}
The compiler always reports me:
Initializer for conditional binding must have Optional type, not ‘MTLRenderCommandEncoder’
It complains about the line if let renderEncoder = renderEncoderOpt { . Can someone help me to fix this issue?
Thanks in advance.
Try this… Swift 3 doesn’t return an Optional like it used to…
let renderEncoderOpt = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor)
renderEncoderOpt.setRenderPipelineState(pipelineState)
renderEncoderOpt.setVertexBuffer(vertexBuffer, offset: 0, at: 0)
renderEncoderOpt.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 3, instanceCount: 1)
renderEncoderOpt.endEncoding()