With every Implementation of Metal based ImageView I'm facing the same problem
let targetTexture = currentDrawable?.texture else{ return }
Value of type 'MTLDrawable' has no member 'texture'
Seems like apple has changed some metal api
here is the full function I'm tryong to use:
func renderImage()
{
guard let
image = image,
let targetTexture = currentDrawable?.texture else{return}
let commandBuffer = commandQueue.makeCommandBuffer()
let bounds = CGRect(origin: CGPoint.zero, size: drawableSize)
let originX = image.extent.origin.x
let originY = image.extent.origin.y
let scaleX = drawableSize.width / image.extent.width
let scaleY = drawableSize.height / image.extent.height
let scale = min(scaleX, scaleY)
let scaledImage = image
.applying(CGAffineTransform(translationX: -originX, y: -originY))
.applying(CGAffineTransform(scaleX: scale, y: scale))
ciContext.render(scaledImage,
to: targetTexture,
commandBuffer: commandBuffer,
bounds: bounds,
colorSpace: colorSpace)
commandBuffer.present(currentDrawable!)
commandBuffer.commit()
}
currentDrawable
variable. According to the error, it's of typeMTLDrawable
which does not, in fact, have atexture
property. I imagine you were thinking ofCAMetalDrawable
, which does. – Ken ThomasesMTKView
? – Ken Thomases