         }
     }
 
-    func image(mipLevel: Int) -> UIImage {
+    func image(mipLevel: Int = 0) -> UIImage {
         let p = bytesForMipLevel(mipLevel: mipLevel)
         let q = Int(powf(2, Float(mipLevel)))
         let mipmapedWidth = max(width / q, 1)

            bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
        )
        return UIImage(cgImage: (context?.makeImage())!)
    }

    func image() -> UIImage {
        return image(mipLevel: 0)
    }

    func bytes() -> UnsafeMutableRawPointer {

import CoreGraphics

// see http://www.raywenderlich.com/93997/ios-8-metal-tutorial-swift-part-3-adding-texture

func alphaState(alphaInfo: CGImageAlphaInfo) -> Bool {
    switch alphaInfo {
    case .none:               return false
    case .first:              return true
    case .last:               return true
    case .noneSkipFirst:      return false
    case .noneSkipLast:       return false
    case .alphaOnly:          return true
    case .premultipliedFirst: return true
    case .premultipliedLast:  return true
    }
}

class MetalTexture {
    var texture: MTLTexture!
