Reputation: 93
In objective-C, I was able to render the EAGLContext to UIImage using glReadPixels to read the pixel data from the framebuffer, creating a CGImage using the pixel data, and then retrieving a UIImage from the context.
I am trying a new method in Swift, but it is returning an empty image. I would like to create a GLKView from the EAGLContext, and then use 'snapshot' to get the UIImage. The “myEaglContext” passed into the GLKView constructor has data on it.
let glkView = GLKView(frame: CGRect(x: 0,y: 0,width: self.frame.size.width,height: self.frame.size.height),context: myEaglContext)
glkView.bindDrawable()
glkView.display()
let image : UIImage = glkView.snapshot
Does anyone know why this approach is not working?
Upvotes: 0
Views: 360