3

I've run into some problems getting a UIView with a large CAEAGLLayer to display properly. If the frame is above a certain size (apparently 768 in either dimension with a contentScaleFactor of 2.0), it redraws with a distorted image of previous versions of the buffer.

It's pretty easy to reproduce in Apple's GLPaint example. PaintingView.m has a hardcoded contentScaleFactor of 1.0, but if you change it to 2.0:

self.contentScaleFactor = 2.0;

and run it on a Retina iPad (not the simulator), you get something like this when you draw:

https://i.stack.imgur.com/FuJT8.jpg

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982

1 Answers1

5

This appears to be a bug with setting kEAGLDrawablePropertyRetainedBacking to YES on the Retina iPads, as reported by Orion in this question. Setting that to NO using

    eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];

removes the glitched drawing, but GLPaint relies on the retained backing for its brushes, so it won't work quite right if you do so.

I've filed a bug report on this (rdar://11070429), with the modified GLPaint as a test application for this behavior.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • Thanks Brad, i'm creating a painting app based on GLPaint, am i to understand that i can not support drawing for iPad3 retina display? (BTW - GPUImage is amazing, tnx!) – Yogev Shelly Jun 30 '12 at 15:10
  • @YogevShelly - There are ways of doing this, but you'll need to modify GLPaint to use a different drawing process (rendering to texture, for example). GLPaint really is a terrible example to start from if you're not familiar with OpenGL ES, so you're almost better off writing your own drawing application from scratch. – Brad Larson Jun 30 '12 at 15:13
  • Setting kEAGLDrawablePropertyRetainedBacking to NO results in an animated Ant-Trail effect. so for now i should just forget about CAEAGLLayer and look into other openGL painting methods? (i'm not experienced in openGL) – Yogev Shelly Jun 30 '12 at 16:21
  • @BradLarson is quickly becoming the John Skeet of the iOS world – JoeCortopassi Jul 06 '12 at 18:04
  • Hi guys, is this still an issue in iOS 6? – Luke Mar 19 '13 at 22:49