glReadPixel stopped working with iOS6 Beta [duplicate]
Asked Answered
J

2

4

Possible Duplicate:
Why is glReadPixels() failing in this code in iOS 6.0?

I currently have an App in Appstore that uses the Cocos2D framework. For collision detection I am using glReadPixels. The screen only has white and black pixels and detecting a black pixel means collision. Everything works fine up to iOS 5.1.1 but in iOS6 Beta (all of them) glReadPixels stopped working. Now the RGB values returned by glReadPixels are always 0,0,0.

Does anyone have an idea what went wrong or how to fix that?

Your help is much appreciated!

Junie answered 23/8, 2012 at 13:35 Comment(3)
Wait for the next beta build or the GM.Gilbert
Ask this on the apple private lists and you will probably get an answer. Anyone who gave you an answer would be violating their non-disclosure contract with Apple.Consequence
Why are SO users so obsessed with enforcing Apple's NDAs? Let Apple worry about it...Amygdaline
J
5

Thanks for the apple private list suggestion - that's where I found the solution to that problem.

In the Cocos2D Class "EAGLView.m" I was setting the "preserveBackbuffer" variable to "YES" at the init method. It now works again also in iOS 6 Beta.

Junie answered 23/8, 2012 at 22:50 Comment(0)
T
7

Changing this on EAGLView.m runs for me!

- (id)initWithCoder:(NSCoder*)coder {

   self = [super initWithCoder:coder];
   if (self) {
        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;

        eaglLayer.opaque = TRUE;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:YES],
                                        kEAGLDrawablePropertyRetainedBacking,
                                        kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
                                        nil];
        // YES
        self.contentScaleFactor = [UIScreen mainScreen].scale;
    }

    return self;
}
Taconite answered 14/10, 2012 at 23:51 Comment(2)
I ran into the same issue with iOS 6.0 full release. Setting retained backing to true fixed itBaugh
I had the issue of glReadPixels not working in Unity3d (iOS) and I fixed it by setting the retained backing property (as seen in the answer) to true in GlesHelper.mm. Thanks, this was holding me up until I found this answer.Butterfield
J
5

Thanks for the apple private list suggestion - that's where I found the solution to that problem.

In the Cocos2D Class "EAGLView.m" I was setting the "preserveBackbuffer" variable to "YES" at the init method. It now works again also in iOS 6 Beta.

Junie answered 23/8, 2012 at 22:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.