iphoneuikituiviewopengl-eseaglview

How to get UIImage from EAGLView?


I am trying to get a UIImage from what is displayed in my EAGLView. Any suggestions on how to do this?


Solution

  • EDIT: as demianturner notes below, you no longer need to render the layer, you can (and should) now use the higher-level [UIView drawViewHierarchyInRect:]. Other than that; this should work the same.

    An EAGLView is just a kind of view, and its underlying CAEAGLLayer is just a kind of layer. That means, that the standard approach for converting a view/layer into a UIImage will work. (The fact that the linked question is UIWebview doesn't matter; that's just yet another kind of view.)