Best way to flip a CAEAGLLayer for presentation in OpenGL ES 2
Open GL ES coordinates are flipped on the y axis compared to iOS. Saving the data out via glreadpixels (to a video) gives me the proper transformation, but displaying in a UIView has the y axis flipped. What is the best way to flip it back for presentation?
I'm seeing three ways so far:
1) Render twice in opengl, sending the non-flipped version to glreadpixels, and a flipped version to the CAEAGLLayer (presentRenderbuffer).
2) Flip the pixels in opengl so it displays properly; once I've read them via glreadpixels, shift the bits then save that to file.
3) Flip the pixels in opengl so it displays proper开发者_JAVA百科ly; apply some type of transform on the video itself (causing it to flip at the time of playback).
I'm not sure any of these are the right path. Looking for the most performant path.
Just apply a transform to the UIView to flip it. For example:
view.transform = CGAffineTransformMakeScale(1.0, -1.0);
Looks like the best way is by using flipped vertices in opengl.
精彩评论