After an orientation change, calling glClear(GL_COLOR_BUFFER_BIT)
isn't enough to clear the GL display (drawing is cached somewhere?) How can I clear this cache?
You're drawing too an offscreen image. That image only becomes available for CoreAnimation compositing when you call -presentRenderbuffer
.
After an orientation change, glReadPixel()
can no longer access pixels drawn before the orientation change. How can I get access to where this is stored?
I assume you're using the RetainedBacking
option. Without that option, you can never read the contents of a previous frame, even outside of rotation. When you call -presentRenderbuffer
, the contents of the offscreen image are shipped off to CA for compositing, and a new image takes its place. The contents of the new image are undefined.
Assuming you are using something derived from the EAGLView sample code and that you are using RetainedBacking
, when the rotation occurs, your framebuffer is resized by deallocating and reallocating. Any of the existing contents will be lost when this occurs.
You can either:
1) save the contents yourself across the transition by calling ReadPixels
2) never reallocate the framebuffer, and instead rotate the UIView (or CALayer) using the transform property. Doing so can cause quite a performance hit during compositing, but you'll get the rotation you're looking for without having to resize your framebuffer.