9

i have an iOS openGL app which uses the kEAGLDrawablePropertyRetainedBacking property to draw the current frame on top of the previous frame. it's a cheap way of getting effects like motion trails.

it works great on all devices (including iPhone w/ retina) and all device simulators, but on the actual iPad 3 device, the previous frame is vertically squished to 75% of its previous size.

for example, if i were to draw a 100 x 100 square at the bottom of the screen each frame, then in frame 0 i have one square, in frame 2 there's an echo that's 100 x 75 and offset towards the top of the screen, in frame three there's an additional echo that's 100 x 56 (56 ~= 75 * 0.75) and is more offset towards the top, and so-on. what should happen is that all the echoes remain in place.

i've verified the behavior on two devices, so i don't think it's a just a broken iPad.

any ideas ?

tia, orion

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
orion elenzil
  • 4,484
  • 3
  • 37
  • 49
  • just realized that 1536 = 2048*0.75, which suggests to me that somewhere, some system is using the image width for both width and height. – orion elenzil Mar 17 '12 at 21:19
  • 4
    i've been able to repro this with apple's example openGL app from xcode 4.0.1, and it's clearly a bug in the device. filed w/ apple as bug # 11069618. – orion elenzil Mar 17 '12 at 22:56
  • I can confirm this bug (which only appears on actual Retina iPad hardware), and have filed another bug report on it with a sample project that illustrates the issue. – Brad Larson Mar 18 '12 at 16:45
  • Ugh. It looks like this bug is impacting Layers for iPad. I'm investigating a workaround... I'll keep y'all posted. – Ben Gotow Mar 30 '12 at 21:14
  • 1
    I was able to work around it by rendering to a texture myself, which is really a more robust solution in the long run. the only tricky part is allocating the texture to be the appropriate power-of-two dimensions and then rendering to a sub-portion of it. for what it's worth, apple has confirmed the bug and says it's under investigation as bug # 11070429. – orion elenzil Mar 31 '12 at 01:21
  • Thanks orion—Layers uses this technique to redraw only the affected portion of the screen when you're creating a new brush stroke and I'd really rather not redraw the whole canvas—but it looks like that may be the only short-term solution if it's a legit bug. – Ben Gotow Mar 31 '12 at 01:24
  • I'm seeing similar issues trying to upgrade iBeams and gravilocity to use the retina display. I render to a pair of OpenGL fbos and then flip between them. The code that worked fine for the 4/4s only gets me 25% of the frame. – Gedalia Apr 03 '12 at 02:45
  • @orionelenzil You do not need power of two textures if you call `glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);` and `glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);` before your call to `glTexImage2D`. This should make your code simpler and more efficient. – rasmus Jun 21 '12 at 12:39

2 Answers2

3

I was seeing this bug. I don’t know anything about OpenGL, so I couldn’t really dig into solving it with textures, as has been suggested, but in my case I was able to switch to a very fast implementation of Quartz 2D drawing based on a tutorial from http://blog.effectiveui.com/?p=8105, plus how to make it work on Retina from https://stackoverflow.com/a/10870188/255489. It actually ended up being much faster than the code I had borrowed from Apple’s GLPaint sample code.

Community
  • 1
  • 1
Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
1

This was a confirmed bug with retained backing and the Retina iPad in iOS 5.x. It has since been fixed in iOS 6.0 and higher.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571