Why Is Glreadpixels() Failing in This Code in iOS 6.0

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

CAEAGLLayer *eaglLayer = (CAEAGLLayer *) self.layer;
eaglLayer.drawableProperties = @{
kEAGLDrawablePropertyRetainedBacking: [NSNumber numberWithBool:YES],
kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8
};

set

kEAGLDrawablePropertyRetainedBacking = YES

(I do not know why this tip is going well..///)

glReadPixel stopped working with iOS6 Beta

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.

glReadPixels gives a black image only on iOS 7 device

As posted in the comments I managed to use your code and it worked. However, I defined your BACKING_TYPE_LAYERBACKED which generates the render buffer from the view.

The other pipeline that creates the FBO did not work though. The issue in your FBO pipeline is calling [self.context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil]. Remove this line and you should be fine.

Cocos2D 2.0 screenshots on iOS 6

I am not sure what the GitHub version does but this code will take a screenshot and I just tested it on iOS 6 and it works fine.

+(UIImage*) screenshotWithStartNode:(CCNode*)startNode
{
[CCDirector sharedDirector].nextDeltaTimeZero = YES;

CGSize winSize = [CCDirector sharedDirector].winSize;
CCRenderTexture* rtx =
[CCRenderTexture renderTextureWithWidth:winSize.width
height:winSize.height];
[rtx begin];
[startNode visit];
[rtx end];

return [rtx getUIImage];
}

You can call it like this

CCScene *scene = [[CCDirector sharedDirector] runningScene];
CCNode *n = [scene.children objectAtIndex:0];
UIImage *img = [AppController screenshotWithStartNode:n];


Related Topics



Leave a reply



Submit