Slide 71
Slide 71 text
Loading Texture Data from a UIImage
let textureDescriptor = MTLTextureDescriptor.texture2DDescriptorWithPixelFormat(.RGBA8Unorm,
width: Int(width),
height: Int(height),
mipmapped: true)
let texture = device.newTextureWithDescriptor(textureDescriptor)
let region = MTLRegionMake2D(0, 0, Int(width), Int(height))
texture.replaceRegion(region,
mipmapLevel: 0,
withBytes: rawData,
bytesPerRow: Int(bytesPerRow))